px_mkfw: add git commit hash to .px4 file

This commit is contained in:
Beat Küng 2019-08-14 14:20:53 +02:00 committed by Daniel Agar
parent 9e055e9b21
commit 5cadb0aab1
1 changed files with 7 additions and 2 deletions

View File

@ -57,7 +57,8 @@ def mkdesc():
proto['version'] = "" proto['version'] = ""
proto['summary'] = "" proto['summary'] = ""
proto['description'] = "" proto['description'] = ""
proto['git_identity'] = "" proto['git_identity'] = "" # git tag
proto['git_hash'] = "" # git commit hash
proto['build_time'] = 0 proto['build_time'] = 0
proto['image'] = bytes() proto['image'] = bytes()
proto['image_size'] = 0 proto['image_size'] = 0
@ -98,10 +99,14 @@ if args.summary != None:
if args.description != None: if args.description != None:
desc['description'] = str(args.description) desc['description'] = str(args.description)
if args.git_identity != None: if args.git_identity != None:
cmd = " ".join(["git", "--git-dir", args.git_identity + "/.git", "describe", "--always", "--tags"]) cmd = "git --git-dir '{:}/.git' describe --always --tags".format(args.git_identity)
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout
desc['git_identity'] = str(p.read().strip()) desc['git_identity'] = str(p.read().strip())
p.close() p.close()
cmd = "git --git-dir '{:}/.git' rev-parse --verify HEAD".format(args.git_identity)
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout
desc['git_hash'] = str(p.read().strip())
p.close()
if args.parameter_xml != None: if args.parameter_xml != None:
f = open(args.parameter_xml, "rb") f = open(args.parameter_xml, "rb")
bytes = f.read() bytes = f.read()