Vowpal Wabbit
Static Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
Program Class Reference

Static Public Member Functions

static void Main (string[] args)
 

Static Private Member Functions

static Process StartGitRevParse ()
 

Private Attributes

const string VersionFilePath = @"..\version.txt"
 

Detailed Description

Definition at line 6 of file make_config_h.cs.

Member Function Documentation

◆ Main()

static void Program.Main ( string []  args)
inlinestatic

Definition at line 35 of file make_config_h.cs.

References StartGitRevParse(), and VW.version().

36  {
37  using (Process p = StartGitRevParse())
38  try
39  {
40  string[] lines = File.ReadAllLines("..\\version.txt");
41 
42  if(lines.Length < 1)
43  {
44  throw new Exception("version.txt first line should contain the version number.");
45  }
46 
47  string version = lines[0].Trim();
48 
49  string gitCommit = String.Empty;
50 
51  if (p != null)
52  {
53  gitCommit = p.StandardOutput.ReadToEnd().Trim();
54 
55  // Needed?
56  p.WaitForExit();
57  }
58 
59  string config = "#define PACKAGE_VERSION \"" + version + "\"\n"
60  + "#define COMMIT_VERSION \"" + gitCommit + "\"\n";
61 
62  if (!File.Exists("config.h") ||
63  string.CompareOrdinal(File.ReadAllText("config.h"), config) != 0)
64  {
65  File.WriteAllText("config.h", config);
66  }
67  }
68  catch (Exception e)
69  {
70  Console.Error.WriteLine(e.ToString());
71  Environment.Exit(1);
72  }
73  }
const version_struct version(PACKAGE_VERSION)
static Process StartGitRevParse()

◆ StartGitRevParse()

static Process Program.StartGitRevParse ( )
inlinestaticprivate

Definition at line 10 of file make_config_h.cs.

Referenced by Main().

11  {
12  Process gitProcess = new Process();
13 
14  try
15  {
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; // Should we use ShellExec()?
20  gitProcess.StartInfo.CreateNoWindow = true;
21 
22  gitProcess.StartInfo.RedirectStandardOutput = true;
23 
24  gitProcess.Start();
25 
26  }
27  catch (Win32Exception)
28  {
29  gitProcess = null;
30  }
31 
32  return gitProcess;
33  }
const string VersionFilePath
Definition: make_config_h.cs:8

Member Data Documentation

◆ VersionFilePath

const string Program.VersionFilePath = @"..\version.txt"
private

Definition at line 8 of file make_config_h.cs.


The documentation for this class was generated from the following file: