diff --git a/Tools/ardupilotwaf/boards.py b/Tools/ardupilotwaf/boards.py index b3382ee88370c..b80f760f0ccf0 100644 --- a/Tools/ardupilotwaf/boards.py +++ b/Tools/ardupilotwaf/boards.py @@ -553,7 +553,9 @@ def pre_build(self, bld): self.embed_ROMFS_files(bld) def build(self, bld): + git_hash_ext = bld.git_head_hash(short=True, hash_abbrev=16) bld.ap_version_append_str('GIT_VERSION', bld.git_head_hash(short=True)) + bld.ap_version_append_str('GIT_VERSION_EXTENDED', git_hash_ext) bld.ap_version_append_int('GIT_VERSION_INT', int("0x" + bld.git_head_hash(short=True), base=16)) bld.ap_version_append_str('AP_BUILD_ROOT', bld.srcnode.abspath()) import time diff --git a/Tools/ardupilotwaf/git_submodule.py b/Tools/ardupilotwaf/git_submodule.py index e2c727e05bb97..05edf06ae065a 100644 --- a/Tools/ardupilotwaf/git_submodule.py +++ b/Tools/ardupilotwaf/git_submodule.py @@ -156,19 +156,19 @@ def _post_fun(bld): def git_submodule_post_fun(bld): bld.add_post_fun(_post_fun) -def _git_head_hash(ctx, path, short=False): +def _git_head_hash(ctx, path, short=False, hash_abbrev=8): cmd = [ctx.env.get_flat('GIT'), 'rev-parse'] if short: - cmd.append('--short=8') + cmd.append(f'--short={hash_abbrev}') cmd.append('HEAD') out = ctx.cmd_and_log(cmd, quiet=Context.BOTH, cwd=path) return out.strip() @conf -def git_submodule_head_hash(self, name, short=False): +def git_submodule_head_hash(self, name, short=False, hash_abbrev=8): module_node = self.srcnode.make_node(os.path.join('modules', name)) - return _git_head_hash(self, module_node.abspath(), short=short) + return _git_head_hash(self, module_node.abspath(), short=short, hash_abbrev=hash_abbrev) @conf -def git_head_hash(self, short=False): - return _git_head_hash(self, self.srcnode.abspath(), short=short) +def git_head_hash(self, short=False, hash_abbrev=8): + return _git_head_hash(self, self.srcnode.abspath(), short=short, hash_abbrev=hash_abbrev)