From 99b916e179ec027b1a73d66d7c8bd085e233404f Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Thu, 2 Apr 2020 22:37:34 -0400 Subject: [PATCH] [build] Share multi-app code --- build/helpers.mk | 19 +++++++++++++++++++ build/platform.simulator.android.mak | 4 +++- build/platform.simulator.ios.mak | 4 ++-- build/platform.simulator.macos.mak | 2 +- ion/src/simulator/android/Makefile | 12 ------------ 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/build/helpers.mk b/build/helpers.mk index f0b68cf28..b397ea96a 100644 --- a/build/helpers.mk +++ b/build/helpers.mk @@ -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 diff --git a/build/platform.simulator.android.mak b/build/platform.simulator.android.mak index 46601bfea..d8f8f2199 100644 --- a/build/platform.simulator.android.mak +++ b/build/platform.simulator.android.mak @@ -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 diff --git a/build/platform.simulator.ios.mak b/build/platform.simulator.ios.mak index 3db1988be..b53ad508a 100644 --- a/build/platform.simulator.ios.mak +++ b/build/platform.simulator.ios.mak @@ -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 diff --git a/build/platform.simulator.macos.mak b/build/platform.simulator.macos.mak index 09c9f1cea..5f2c492e5 100644 --- a/build/platform.simulator.macos.mak +++ b/build/platform.simulator.macos.mak @@ -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 diff --git a/ion/src/simulator/android/Makefile b/ion/src/simulator/android/Makefile index a0417ebd9..c3f31d5f1 100644 --- a/ion/src/simulator/android/Makefile +++ b/ion/src/simulator/android/Makefile @@ -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)))