3 using System.ComponentModel;
12 Process gitProcess =
new Process();
16 gitProcess.StartInfo.FileName =
"git";
17 gitProcess.StartInfo.Arguments =
"rev-parse --short HEAD";
18 gitProcess.StartInfo.WorkingDirectory = Path.GetDirectoryName(VersionFilePath);
19 gitProcess.StartInfo.UseShellExecute =
false;
20 gitProcess.StartInfo.CreateNoWindow =
true;
22 gitProcess.StartInfo.RedirectStandardOutput =
true;
27 catch (Win32Exception)
35 public static void Main(
string[] args)
40 string[] lines = File.ReadAllLines(
"..\\version.txt");
44 throw new Exception(
"version.txt first line should contain the version number.");
47 string version = lines[0].Trim();
49 string gitCommit = String.Empty;
53 gitCommit = p.StandardOutput.ReadToEnd().Trim();
59 string config =
"#define PACKAGE_VERSION \"" + version +
"\"\n" 60 +
"#define COMMIT_VERSION \"" + gitCommit +
"\"\n";
62 if (!File.Exists(
"config.h") ||
63 string.CompareOrdinal(File.ReadAllText(
"config.h"), config) != 0)
65 File.WriteAllText(
"config.h", config);
70 Console.Error.WriteLine(e.ToString());
const version_struct version(PACKAGE_VERSION)
const string VersionFilePath
static Process StartGitRevParse()
static void Main(string[] args)