Skip to content

Commit 5e8df0c

Browse files
authored
Revision script fixes (#453)
- suppresses the error messages that are currently printed on the output at every run. - adds a command to the hxx output that looks like this: #define REVISION_GIT_HASH "b60e1f7:-d-u" This is suitable for being included into the SNIP version string.
1 parent 9e47246 commit 5e8df0c

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

bin/revision.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@
9393
outputcxx += ' "' + gcc + '",\n'
9494
outputhxx += '"' + gcc + '\\n"\n'
9595

96+
main_git_hash = None
97+
9698
for x in inputs :
9799
print x
98100
# go into the root of the repo
@@ -121,17 +123,19 @@
121123
outputcxx += ':' + os.path.split(os.path.abspath(x))[1]
122124
outputhxx += '"' + git_hash + ':' + os.path.split(os.path.abspath(x))[1]
123125

126+
hashopts = ""
127+
124128
if dirty or untracked :
125-
outputcxx += ':'
126-
outputhxx += ':'
129+
hashopts += ':'
127130
if dirty :
128-
outputcxx += '-d'
129-
outputhxx += '-d'
131+
hashopts += '-d'
130132
if untracked :
131-
outputcxx += '-u'
132-
outputhxx += '-u'
133-
outputcxx += '",\n'
134-
outputhxx += '\\n"\n'
133+
hashopts += '-u'
134+
outputcxx += hashopts + '",\n'
135+
outputhxx += hashopts + '\\n"\n'
136+
137+
if main_git_hash is None:
138+
main_git_hash = git_hash + hashopts
135139

136140
outputcxx += ' nullptr\n'
137141
outputcxx += '};\n'
@@ -142,6 +146,9 @@
142146
outputhxx += '));\n'
143147
outputhxx += 'CDI_GROUP_END();\n'
144148

149+
if main_git_hash is not None:
150+
outputhxx += '\n#define REVISION_GIT_HASH "' + main_git_hash + '"\n'
151+
145152
os.chdir(orig_dir)
146153

147154
# generate the *.cxxout style content
@@ -165,14 +172,18 @@
165172
"-I", """Thu, """, "-I", """Fri, """,
166173
"-I", """Sat, """,
167174
options.output + 'Try.hxxout',
168-
options.output + '.hxxout'], stdout=f_null)
175+
options.output + '.hxxout'],
176+
stdout=f_null, stderr=f_null)
169177
diffcxx = subprocess.call(['diff',
170178
"-I", """Sun, """, "-I", """Mon, """,
171179
"-I", """Tue, """, "-I", """Wed, """,
172180
"-I", """Thu, """, "-I", """Fri, """,
173181
"-I", """Sat, """,
174182
options.output + 'Try.cxxout',
175-
options.output + '.cxxout'], stdout=f_null)
183+
options.output + '.cxxout'],
184+
stdout=f_null, stderr=f_null)
185+
# disable this because we are not actually writing a cxx file above.
186+
diffcxx = 0
176187

177188
if diffhxx != 0 :
178189
os.system('rm -f ' + options.output + '.hxxout')

0 commit comments

Comments
 (0)