waf: fixed --build-dates option

and remove build_time from apj when --build-dates not used to avoid
changing apj file
This commit is contained in:
Andrew Tridgell 2019-09-22 20:37:36 +10:00
parent 0da70fdc38
commit 3538bd62c3
2 changed files with 5 additions and 2 deletions

View File

@ -268,7 +268,7 @@ class Board:
cfg.srcnode.find_dir('modules/uavcan/libuavcan/include').abspath() cfg.srcnode.find_dir('modules/uavcan/libuavcan/include').abspath()
] ]
if cfg.env.build_dates: if cfg.options.build_dates:
env.build_dates = True env.build_dates = True
# We always want to use PRI format macros # We always want to use PRI format macros

View File

@ -103,13 +103,16 @@ class generate_apj(Task.Task):
"magic": "APJFWv1", "magic": "APJFWv1",
"description": "Firmware for a %s board" % self.env.APJ_BOARD_TYPE, "description": "Firmware for a %s board" % self.env.APJ_BOARD_TYPE,
"image": base64.b64encode(zlib.compress(img,9)).decode('utf-8'), "image": base64.b64encode(zlib.compress(img,9)).decode('utf-8'),
"build_time": int(time.time()),
"summary": self.env.BOARD, "summary": self.env.BOARD,
"version": "0.1", "version": "0.1",
"image_size": len(img), "image_size": len(img),
"git_identity": self.generator.bld.git_head_hash(short=True), "git_identity": self.generator.bld.git_head_hash(short=True),
"board_revision": 0 "board_revision": 0
} }
if self.env.build_dates:
# we omit build_time when we don't have build_dates so that apj
# file is idential for same git hash and compiler
d["build_time"] = int(time.time())
apj_file = self.outputs[0].abspath() apj_file = self.outputs[0].abspath()
f = open(apj_file, "w") f = open(apj_file, "w")
f.write(json.dumps(d, indent=4)) f.write(json.dumps(d, indent=4))