mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
makefile: generate multiple versions of UAVOs
This will allow a single GCS to have access to multiple sets of UAVO libraries.
This commit is contained in:
parent
6da6274543
commit
f7467cbb47
126
Makefile
126
Makefile
@ -554,18 +554,28 @@ uavobjects_clean:
|
||||
#
|
||||
################################
|
||||
|
||||
|
||||
# Build the output directory for the Android GCS build
|
||||
ANDROIDGCS_OUT_DIR := $(BUILD_DIR)/androidgcs
|
||||
$(ANDROIDGCS_OUT_DIR):
|
||||
$(V1) mkdir -p $@
|
||||
|
||||
# Build the asset directory for the android assets
|
||||
ANDROIDGCS_ASSETS_DIR := $(ANDROIDGCS_OUT_DIR)/assets
|
||||
$(ANDROIDGCS_ASSETS_DIR)/uavos:
|
||||
$(V1) mkdir -p $@
|
||||
|
||||
ifeq ($(V), 1)
|
||||
ANDROID_VERBOSE := -verbose
|
||||
ANT_VERBOSE := -verbose
|
||||
else
|
||||
ANDROID_VERBOSE :=
|
||||
ANT_VERBOSE :=
|
||||
endif
|
||||
.PHONY: androidgcs
|
||||
androidgcs: uavobjects_java
|
||||
androidgcs: uavo-collections_java
|
||||
$(V1) mkdir -p $(ANDROIDGCS_OUT_DIR)
|
||||
$(V1) $(ANDROID) update project --target 'Google Inc.:Google APIs:16' --name androidgcs --path ./androidgcs
|
||||
$(V1) ant -f ./androidgcs/build.xml \
|
||||
$(ANDROID_VERBOSE) \
|
||||
$(ANT_VERBOSE) \
|
||||
-Dout.dir="../$(call toprel, $(ANDROIDGCS_OUT_DIR)/bin)" \
|
||||
-Dgen.absolute.dir="$(ANDROIDGCS_OUT_DIR)/gen" \
|
||||
debug
|
||||
@ -575,6 +585,114 @@ androidgcs_clean:
|
||||
$(V0) @echo " CLEAN $@"
|
||||
$(V1) [ ! -d "$(ANDROIDGCS_OUT_DIR)" ] || $(RM) -r "$(ANDROIDGCS_OUT_DIR)"
|
||||
|
||||
# We want to take snapshots of the UAVOs at each point that they change
|
||||
# to allow the GCS to be compatible with as many versions as possible.
|
||||
#
|
||||
# Find the git hashes of each commit that changes uavobjects with:
|
||||
# git log --format=%h -- shared/uavobjectdefinition/ | head -n 2
|
||||
UAVO_GIT_VERSIONS := 684620d 43f85d9
|
||||
|
||||
# All versions includes a pseudo collection called "working" which represents
|
||||
# the UAVOs in the source tree
|
||||
UAVO_ALL_VERSIONS := $(UAVO_GIT_VERSIONS) srctree
|
||||
|
||||
# This is where the UAVO collections are stored
|
||||
UAVO_COLLECTION_DIR := $(BUILD_DIR)/uavo-collections
|
||||
|
||||
# $(1) git hash of a UAVO snapshot
|
||||
define UAVO_COLLECTION_GIT_TEMPLATE
|
||||
|
||||
# Make the output directory that will contain all of the synthetics for the
|
||||
# uavo collection referenced by the git hash $(1)
|
||||
$$(UAVO_COLLECTION_DIR)/$(1):
|
||||
$$(V1) mkdir -p $$(UAVO_COLLECTION_DIR)/$(1)
|
||||
|
||||
# Extract the snapshot of shared/uavobjectdefinition from git hash $(1)
|
||||
$$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml.tar: | $$(UAVO_COLLECTION_DIR)/$(1)
|
||||
$$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml.tar:
|
||||
$$(V0) @echo " UAVOTAR $(1)"
|
||||
$$(V1) git archive $(1) -o $$@ -- shared/uavobjectdefinition/
|
||||
|
||||
# Extract the uavo xml files from our snapshot
|
||||
$$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml: $$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml.tar
|
||||
$$(V0) @echo " UAVOUNTAR $(1)"
|
||||
$$(V1) rm -rf $$@
|
||||
$$(V1) mkdir -p $$@
|
||||
$$(V1) tar -C $$@ -xf $$< || rm -rf $$@
|
||||
endef
|
||||
|
||||
# Map the current working directory into the set of UAVO collections
|
||||
$(UAVO_COLLECTION_DIR)/srctree:
|
||||
$(V1) mkdir -p $@
|
||||
|
||||
$(UAVO_COLLECTION_DIR)/srctree/uavo-xml: | $(UAVO_COLLECTION_DIR)/srctree
|
||||
$(UAVO_COLLECTION_DIR)/srctree/uavo-xml: $(UAVOBJ_XML_DIR)
|
||||
$(V1) ln -sf $(ROOT_DIR) $(UAVO_COLLECTION_DIR)/srctree/uavo-xml
|
||||
|
||||
# $(1) git hash (or symbolic name) of a UAVO snapshot
|
||||
define UAVO_COLLECTION_BUILD_TEMPLATE
|
||||
|
||||
# This leaves us with a (broken) symlink that points to the full sha1sum of the collection
|
||||
$$(UAVO_COLLECTION_DIR)/$(1)/uavohash: $$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml
|
||||
# Compute the sha1 hash for this UAVO collection
|
||||
$$(V1) python $$(ROOT_DIR)/make/scripts/version-info.py \
|
||||
--path=$$(ROOT_DIR) \
|
||||
--uavodir=$$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml/shared/uavobjectdefinition \
|
||||
--format='$$$${UAVOSHA1TXT}' | xargs -n1 -I{} ln -sf {} $$(UAVO_COLLECTION_DIR)/$(1)/uavohash
|
||||
|
||||
# Create the target of the symlink (ie. a directory named by the actual UAVO hash)
|
||||
$$(V0) @echo " UAVOHASH $(1) ->" $$$$(readlink $$(UAVO_COLLECTION_DIR)/$(1)/uavohash)
|
||||
$$(V1) mkdir -p $$(UAVO_COLLECTION_DIR)/$(1)/$$$$(readlink $$(UAVO_COLLECTION_DIR)/$(1)/uavohash)
|
||||
|
||||
# Generate the java uavobjects for this UAVO collection
|
||||
$$(UAVO_COLLECTION_DIR)/$(1)/uavohash/java-build/java: $$(UAVO_COLLECTION_DIR)/$(1)/uavohash
|
||||
$$(V0) @echo " UAVOJAVA $(1) " $$$$(readlink $$(UAVO_COLLECTION_DIR)/$(1)/uavohash)
|
||||
$$(V1) mkdir -p $$@
|
||||
$$(V1) ( \
|
||||
cd $$(UAVO_COLLECTION_DIR)/$(1)/uavohash/java-build && \
|
||||
$$(UAVOBJGENERATOR) -java $$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml/shared/uavobjectdefinition $$(ROOT_DIR) ; \
|
||||
)
|
||||
|
||||
# Build a jar file for this UAVO collection
|
||||
$$(UAVO_COLLECTION_DIR)/$(1)/uavohash/java-build/uavobjects.jar: | $$(ANDROIDGCS_ASSETS_DIR)/uavos
|
||||
$$(UAVO_COLLECTION_DIR)/$(1)/uavohash/java-build/uavobjects.jar: $$(UAVO_COLLECTION_DIR)/$(1)/uavohash/java-build/java
|
||||
$$(V0) @echo " UAVOJAR $(1) " $$$$(readlink $$(UAVO_COLLECTION_DIR)/$(1)/uavohash)
|
||||
$$(V1) ( \
|
||||
HASH=$$$$(readlink $$(UAVO_COLLECTION_DIR)/$(1)/uavohash) && \
|
||||
cd $$(UAVO_COLLECTION_DIR)/$(1)/uavohash/java-build && \
|
||||
javac java/*.java \
|
||||
$$(ROOT_DIR)/androidgcs/src/org/openpilot/uavtalk/UAVDataObject.java \
|
||||
$$(ROOT_DIR)/androidgcs/src/org/openpilot/uavtalk/UAVObject*.java \
|
||||
$$(ROOT_DIR)/androidgcs/src/org/openpilot/uavtalk/UAVMetaObject.java \
|
||||
-d . && \
|
||||
find ./org/openpilot/uavtalk/uavobjects -type f -name '*.class' > classlist.txt && \
|
||||
jar cf tmp_uavobjects.jar @classlist.txt && \
|
||||
$$(ANDROID_SDK_DIR)/platform-tools/dx \
|
||||
--dex \
|
||||
--output $$(ANDROIDGCS_ASSETS_DIR)/uavos/$$$${HASH}.jar \
|
||||
tmp_uavobjects.jar && \
|
||||
ln -sf $$(ANDROIDGCS_ASSETS_DIR)/uavos/$$$${HASH}.jar uavobjects.jar \
|
||||
)
|
||||
|
||||
endef
|
||||
|
||||
# One of these for each element of UAVO_GIT_VERSIONS so we can extract the UAVOs from git
|
||||
$(foreach githash, $(UAVO_GIT_VERSIONS), $(eval $(call UAVO_COLLECTION_GIT_TEMPLATE,$(githash))))
|
||||
|
||||
# One of these for each UAVO_ALL_VERSIONS which includes the ones in the srctree
|
||||
$(foreach githash, $(UAVO_ALL_VERSIONS), $(eval $(call UAVO_COLLECTION_BUILD_TEMPLATE,$(githash))))
|
||||
|
||||
.PHONY: uavo-collections_java
|
||||
uavo-collections_java: $(foreach githash, $(UAVO_ALL_VERSIONS), $(UAVO_COLLECTION_DIR)/$(githash)/uavohash/java-build/uavobjects.jar)
|
||||
|
||||
.PHONY: uavo-collections
|
||||
uavo-collections: uavo-collections_java
|
||||
|
||||
.PHONY: uavo-collections_clean
|
||||
uavo-collections_clean:
|
||||
$(V0) @echo " CLEAN $(UAVO_COLLECTION_DIR)"
|
||||
$(V1) [ ! -d "$(UAVO_COLLECTION_DIR)" ] || $(RM) -r $(UAVO_COLLECTION_DIR)
|
||||
|
||||
##############################
|
||||
#
|
||||
# Flight related components
|
||||
|
Loading…
x
Reference in New Issue
Block a user