diff options
author | William A. Kennington III <wak@google.com> | 2017-04-14 16:31:37 -0700 |
---|---|---|
committer | Sachin Gupta <sgupta2m@in.ibm.com> | 2017-04-20 09:04:32 -0400 |
commit | 695eed7bf424f58899e2650ecfdadc5389bf35f5 (patch) | |
tree | 5ea919d84a811a0b4dff3b622c52635cab757bcf /src/build | |
parent | a68658eecc4878025e3d4cf2a44c3a8de8ea438d (diff) | |
download | talos-sbe-695eed7bf424f58899e2650ecfdadc5389bf35f5.tar.gz talos-sbe-695eed7bf424f58899e2650ecfdadc5389bf35f5.zip |
buildInfo: Ensure we have a COMMIT_ID
It's currently possible to build the current sbe without having git
installed and have the compiler complain about:
sbecmdgeneric.C:54:18: error: unable to find numeric literal operator
‘operator""x’
fwCommitId = SBE_COMMIT_ID;
This commmit makes it possible to specify a git COMMIT_ID, but fall back
to the old behavior of parsing the actual git data. It also makes sure
the process fails at this script instead of during compilation.
Signed-off-by: William A. Kennington III <wak@google.com>
Resolves #4
Resolves #4
Change-Id: I533d7914fe2f74a3540be87c6a5a2c2bb98ffc78
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/39468
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Sachin Gupta <sgupta2m@in.ibm.com>
Diffstat (limited to 'src/build')
-rwxr-xr-x | src/build/buildInfo.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/build/buildInfo.py b/src/build/buildInfo.py index d1149c70..6188ed9e 100755 --- a/src/build/buildInfo.py +++ b/src/build/buildInfo.py @@ -7,6 +7,7 @@ # OpenPOWER sbe Project # # Contributors Listed Below - COPYRIGHT 2016,2017 +# [+] Google Inc. # [+] International Business Machines Corp. # # @@ -36,13 +37,22 @@ def buildInfo(): #define SBE_BUILD_INFO_H \n\n" footer = "\n#endif // SBE_BUILD_INFO_H" - commitId = "0x" + os.popen("git rev-parse --short=8 HEAD").read().rstrip() + + if 'COMMIT_ID' in os.environ: + commitStr = os.environ['COMMIT_ID'][:8] + else: + commitStr = os.popen('git rev-parse --short=8 HEAD').read().rstrip() + try: + commitInt = int(commitStr, 16) + except: + print("Failed to get a valid COMMIT_ID") + sys.exit(1) f = open( buildInfoFileName, 'w') f.write(header) f.write("//Define SBE Commit ID \n") - f.write("#define SBE_COMMIT_ID " + commitId + "\n") + f.write("#define SBE_COMMIT_ID " + hex(commitInt) + "\n") f.write(footer) f.close() |