waf: add build option to include dates in binary

This commit is contained in:
Peter Barker 2019-06-13 20:30:21 +10:00 committed by Andrew Tridgell
parent 8f8851271a
commit 4f7905331a
2 changed files with 11 additions and 3 deletions

View File

@ -246,6 +246,9 @@ 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:
env.build_dates = True
# We always want to use PRI format macros # We always want to use PRI format macros
cfg.define('__STDC_FORMAT_MACROS', 1) cfg.define('__STDC_FORMAT_MACROS', 1)
@ -259,9 +262,10 @@ class Board:
bld.ap_version_append_str('GIT_VERSION', bld.git_head_hash(short=True)) bld.ap_version_append_str('GIT_VERSION', bld.git_head_hash(short=True))
import time import time
ltime = time.localtime() ltime = time.localtime()
bld.ap_version_append_int('BUILD_DATE_YEAR', ltime.tm_year) if bld.env.build_dates:
bld.ap_version_append_int('BUILD_DATE_MONTH', ltime.tm_mon) bld.ap_version_append_int('BUILD_DATE_YEAR', ltime.tm_year)
bld.ap_version_append_int('BUILD_DATE_DAY', ltime.tm_mday) bld.ap_version_append_int('BUILD_DATE_MONTH', ltime.tm_mon)
bld.ap_version_append_int('BUILD_DATE_DAY', ltime.tm_mday)
def embed_ROMFS_files(self, ctx): def embed_ROMFS_files(self, ctx):
'''embed some files using AP_ROMFS''' '''embed some files using AP_ROMFS'''

View File

@ -196,6 +196,10 @@ configuration in order to save typing.
default=False, default=False,
help="Enable SITL RGBLed") help="Enable SITL RGBLed")
g.add_option('--build-dates', action='store_true',
default=False,
help="Include build date in binaries. Appears in AUTOPILOT_VERSION.os_sw_version")
g.add_option('--sitl-flash-storage', g.add_option('--sitl-flash-storage',
action='store_true', action='store_true',
default=False, default=False,