mirror of https://github.com/ArduPilot/ardupilot
Build: add git hashes to .px4 files
This commit is contained in:
parent
fdcd5ca1a1
commit
5059fc620c
|
@ -0,0 +1,56 @@
|
|||
#!/usr/bin/env python
|
||||
'''
|
||||
Add git hashes to .px4 file for PX4/Pixhawk build
|
||||
Written by Jon Challinger January 2015
|
||||
'''
|
||||
|
||||
import json
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
parser.add_argument('input_file')
|
||||
parser.add_argument('output_file')
|
||||
|
||||
parser.add_argument('--ardupilot')
|
||||
parser.add_argument('--px4')
|
||||
parser.add_argument('--nuttx')
|
||||
parser.add_argument('--uavcan')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
f = open(args.input_file,'r')
|
||||
fw_json = json.load(f)
|
||||
f.close()
|
||||
|
||||
if args.ardupilot is not None:
|
||||
try:
|
||||
fw_json["ardupilot_git_hash"] = subprocess.check_output(["git", "--git-dir", os.path.join(args.ardupilot,".git"), "rev-parse", "HEAD"]).strip().decode('ascii')
|
||||
except:
|
||||
print("Failed to get apm hash")
|
||||
|
||||
if args.px4 is not None:
|
||||
try:
|
||||
fw_json["px4_git_hash"] = subprocess.check_output(["git", "--git-dir", os.path.join(args.px4,".git"), "rev-parse", "HEAD"]).strip().decode('ascii')
|
||||
except:
|
||||
print("Failed to get px4 hash")
|
||||
|
||||
if args.nuttx is not None:
|
||||
try:
|
||||
fw_json["nuttx_git_hash"] = subprocess.check_output(["git", "--git-dir", os.path.join(args.nuttx,".git"), "rev-parse", "HEAD"]).strip().decode('ascii')
|
||||
except:
|
||||
print("Failed to get nuttx hash")
|
||||
|
||||
if args.uavcan is not None:
|
||||
try:
|
||||
fw_json["uavcan_git_hash"] = subprocess.check_output(["git", "--git-dir", os.path.join(args.uavcan,".git"), "rev-parse", "HEAD"]).strip().decode('ascii')
|
||||
except:
|
||||
print("Failed to get uavcan hash")
|
||||
|
||||
f=open(args.output_file,'w')
|
||||
json.dump(fw_json,f,indent=4)
|
||||
f.truncate()
|
||||
f.close()
|
|
@ -53,6 +53,18 @@ export GIT_SUBMODULES_ARE_EVIL = 1
|
|||
PX4_MAKE = $(v) GIT_SUBMODULES_ARE_EVIL=1 make -C $(SKETCHBOOK) -f $(PX4_ROOT)/Makefile EXTRADEFINES="$(SKETCHFLAGS) $(WARNFLAGS) "'$(EXTRAFLAGS)' APM_MODULE_DIR=$(SKETCHBOOK) SKETCHBOOK=$(SKETCHBOOK) CCACHE=$(CCACHE) PX4_ROOT=$(PX4_ROOT) NUTTX_SRC=$(NUTTX_SRC) MAXOPTIMIZATION="-Os" UAVCAN_DIR=$(UAVCAN_DIR)
|
||||
PX4_MAKE_ARCHIVES = make -C $(PX4_ROOT) NUTTX_SRC=$(NUTTX_SRC) CCACHE=$(CCACHE) archives MAXOPTIMIZATION="-Os"
|
||||
|
||||
HASHADDER_FLAGS += --ardupilot "$(SKETCHBOOK)"
|
||||
|
||||
ifneq ($(wildcard $(PX4_ROOT)),)
|
||||
HASHADDER_FLAGS += --px4 "$(PX4_ROOT)"
|
||||
endif
|
||||
ifneq ($(wildcard $(NUTTX_SRC)/..),)
|
||||
HASHADDER_FLAGS += --nuttx "$(NUTTX_SRC)/.."
|
||||
endif
|
||||
ifneq ($(wildcard $(UAVCAN_DIR)),)
|
||||
HASHADDER_FLAGS += --uavcan "$(UAVCAN_DIR)"
|
||||
endif
|
||||
|
||||
.PHONY: module_mk
|
||||
module_mk:
|
||||
$(RULEHDR)
|
||||
|
@ -70,6 +82,7 @@ px4-v1: $(BUILDROOT)/make.flags $(PX4_ROOT)/Archives/px4fmu-v1.export $(SKETCHCP
|
|||
$(v) $(PX4_MAKE) px4fmu-v1_APM
|
||||
$(v) /bin/rm -f $(SKETCH)-v1.px4
|
||||
$(v) cp $(PX4_ROOT)/Images/px4fmu-v1_APM.px4 $(SKETCH)-v1.px4
|
||||
$(v) $(SKETCHBOOK)/Tools/scripts/add_git_hashes.py $(HASHADDER_FLAGS) "$(SKETCH)-v1.px4" "$(SKETCH)-v1.px4"
|
||||
$(v) echo "PX4 $(SKETCH) Firmware is in $(SKETCH)-v1.px4"
|
||||
|
||||
px4-v2: $(BUILDROOT)/make.flags $(PX4_ROOT)/Archives/px4fmu-v2.export $(SKETCHCPP) module_mk px4-io-v2
|
||||
|
@ -79,6 +92,7 @@ px4-v2: $(BUILDROOT)/make.flags $(PX4_ROOT)/Archives/px4fmu-v2.export $(SKETCHCP
|
|||
$(PX4_MAKE) px4fmu-v2_APM
|
||||
$(v) /bin/rm -f $(SKETCH)-v2.px4
|
||||
$(v) cp $(PX4_ROOT)/Images/px4fmu-v2_APM.px4 $(SKETCH)-v2.px4
|
||||
$(v) $(SKETCHBOOK)/Tools/scripts/add_git_hashes.py $(HASHADDER_FLAGS) "$(SKETCH)-v2.px4" "$(SKETCH)-v2.px4"
|
||||
$(v) echo "PX4 $(SKETCH) Firmware is in $(SKETCH)-v2.px4"
|
||||
|
||||
px4: px4-v1 px4-v2
|
||||
|
|
Loading…
Reference in New Issue