waf: use GIT_VERSION from env if available

This allows for reproducible builds to be produced
This commit is contained in:
Peter Barker 2022-01-16 13:18:21 +11:00 committed by Andrew Tridgell
parent 2fe709a59c
commit 43b4f86485

View File

@ -205,7 +205,7 @@ class set_app_descriptor(Task.Task):
desc_len = 16
crc1 = to_unsigned(crc32(bytearray(img[:offset])))
crc2 = to_unsigned(crc32(bytearray(img[offset+desc_len:])))
githash = to_unsigned(int('0x' + self.generator.bld.git_head_hash(short=True),16))
githash = to_unsigned(int('0x' + os.environ.get('GIT_VERSION', self.generator.bld.git_head_hash(short=True)),16))
desc = struct.pack('<IIII', crc1, crc2, len(img), githash)
img = img[:offset] + desc + img[offset+desc_len:]
Logs.info("Applying %s APP_DESCRIPTOR %08x%08x" % (self.env.APP_DESCRIPTOR, crc1, crc2))