-
Notifications
You must be signed in to change notification settings - Fork 55
/
pullgitinfo.py
executable file
·49 lines (33 loc) · 1 KB
/
pullgitinfo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/python
import os
import sys
# run the script from the remoll directory
presentcwd = os.getcwd()
os.chdir(presentcwd)
f = os.popen("git log -n 1 && git status -bs && echo \"\nGeant4 version\" `geant4-config --version` && echo \" ROOT version\" `root-config --version` && echo \" `cmake --version`\" && echo \"\nGenerated at `date`\"")
boringstring = "";
if( f != 0):
for line in f:
boringstring += line
else:
boringstring = "git information unavailable"
boringstring += "Source dir " + os.getcwd()
boringstring += "\nBuild dir " + presentcwd + "\n"
newheadertext = """#ifndef __GITINFO_HH
#define __GITINFO_HH
/*
Generated automatically by cmake process
*/
const char* gGitInfo = R\"gitinfo(
""" + boringstring + """
)gitinfo\";
#endif//__GITINFO_HH
"""
os.chdir(presentcwd)
outdir = "include/"
if not os.path.exists(outdir):
os.makedirs(outdir)
newheader = open( outdir + "/gitinfo.hh", "w")
newheader.write(newheadertext)
newheader.close()
print( "Repository information\n", boringstring)