[build] Share multi-app code

This commit is contained in:
Romain Goyet
2020-04-02 22:37:34 -04:00
committed by Ecco
parent f9b0843578
commit 99b916e179
5 changed files with 25 additions and 16 deletions

View File

@@ -34,3 +34,22 @@ endef
define object_for
$(call direct_object_for,$(call any_variant,$(1)))
endef
# Multi-arch helpers
ifdef ARCHS
ifndef ARCH
# This rule allow us to build any executable (%) for a specified ARCH ($1)
# We depend on a phony target to make sure this rule is always executed
.PHONY: force_remake
define rule_for_arch_executable
.PRECIOUS: $$(BUILD_DIR)/$(1)/%.$$(EXE)
$$(BUILD_DIR)/$(1)/%.$$(EXE): force_remake
$(Q) echo "MAKE ARCH=$(1)"
$(Q) $$(MAKE) ARCH=$(1) --silent $$*.$$(EXE)
endef
$(foreach ARCH,$(ARCHS),$(eval $(call rule_for_arch_executable,$(ARCH))))
endif
endif

View File

@@ -1,10 +1,12 @@
TOOLCHAIN = android
EXE = so
EPSILON_TELEMETRY ?= 1
ARCHS = armeabi-v7a arm64-v8a x86 x86_64
ifdef ARCH
EXE = so
BUILD_DIR := $(BUILD_DIR)/$(ARCH)
else
HANDY_TARGETS_EXTENSIONS = apk
endif

View File

@@ -1,4 +1,5 @@
TOOLCHAIN = apple
EXE = bin
APPLE_PLATFORM ?= ios
APPLE_PLATFORM_MIN_VERSION = 8.0
@@ -14,8 +15,7 @@ endif
BUILD_DIR := $(subst $(TARGET),$(APPLE_PLATFORM),$(BUILD_DIR))
ifdef ARCH
EXE = bin
BUILD_DIR := $(BUILD_DIR)/$(ARCH)
else
HANDY_TARGETS_EXTENSIONS = ipa
HANDY_TARGETS_EXTENSIONS = ipa app
endif

View File

@@ -1,4 +1,5 @@
TOOLCHAIN = apple
EXE = bin
APPLE_PLATFORM = macos
APPLE_PLATFORM_MIN_VERSION = 10.10
@@ -8,7 +9,6 @@ ARCHS = x86_64
EPSILON_SIMULATOR_HAS_LIBPNG = 1
ifdef ARCH
EXE = bin
BUILD_DIR := $(BUILD_DIR)/$(ARCH)
else
HANDY_TARGETS_EXTENSIONS = app

View File

@@ -36,17 +36,6 @@ $(BUILD_DIR)/app/res/%.xml: ion/src/simulator/android/src/res/%.xml | $$(@D)/.
$(call rule_label,COPY)
$(Q) cp $< $@
# This rule allow us to build any executable (%) for a specified ARCH ($1)
# We depend on a phony target to make sure this rule is always executed
.PHONY: force_remake
define rule_for_arch_executable
.PRECIOUS: $$(BUILD_DIR)/$(1)/%.so
$$(BUILD_DIR)/$(1)/%.so: force_remake
$(Q) echo "MAKE ARCH=$(1) $$*.so"
$(Q) $$(MAKE) ARCH=$(1) --silent $$*.so
endef
# We need to put the .so files somewhere Gradle can pick them up.
# We decided to use the location "app/libs/$EXECUTABLE/$ARCH/libepsilon.so"
# This way it's easy to import the shared object from Java code (it's always
@@ -61,7 +50,6 @@ $(call path_for_arch_jni_lib,$(1)): $$(BUILD_DIR)/$(1)/%.so | $$$$(@D)/.
$(Q) cp $$< $$@
endef
$(foreach ARCH,$(ARCHS),$(eval $(call rule_for_arch_executable,$(ARCH))))
$(foreach ARCH,$(ARCHS),$(eval $(call rule_for_arch_jni_lib,$(ARCH))))
apk_deps = $(foreach ARCH,$(ARCHS),$(call path_for_arch_jni_lib,$(ARCH)))