From c97903f3bef2ba547dd329adb4ef473f32e6e9f4 Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Wed, 25 Sep 2019 16:12:27 +0200 Subject: [PATCH] [build] Clean the targets --- Makefile | 30 ++---------------------------- build/targets.blackbox.mak | 4 ++-- build/targets.device.mak | 4 ++-- build/targets.device.n0110.mak | 2 +- build/targets.mak | 28 ++++++++++++++++++++++++++++ 5 files changed, 35 insertions(+), 33 deletions(-) create mode 100644 build/targets.mak diff --git a/Makefile b/Makefile index 12dba43d0..8a2150e44 100644 --- a/Makefile +++ b/Makefile @@ -30,14 +30,6 @@ $(addprefix $$(BUILD_DIR)/,$(strip $(2))): $(strip $(3)) | $$$$(@D)/. $(Q) $(4) endef -# Define rules for targets -# Those can be built directly with make executable.extension as a shortcut. - -define rules_for_targets -.PHONY: $(1)$(2) -$(1)$(2): $$(BUILD_DIR)/$(1)$(2) -endef - .PHONY: info info: @echo "========= Building Flags =========" @@ -147,31 +139,13 @@ all_objs = $(call object_for,$(all_src)) # but allows correct yet optimal incremental builds. -include $(all_objs:.o=.d) -executables = epsilon epsilon.on-boarding epsilon.on-boarding.update epsilon.on-boarding.beta test - -extensions = .$(EXE) - -#define platform generic targets -all_epsilon_common_src = $(ion_src) $(liba_src) $(kandinsky_src) $(epsilon_src) $(app_src) $(escher_src) $(libaxx_src) $(poincare_src) $(python_src) $(ion_device_dfu_relocated_src) -all_epsilon_default_src = $(all_epsilon_common_src) $(apps_launch_default_src) $(apps_prompt_none_src) - -$(BUILD_DIR)/epsilon.$(EXE): $(call object_for,$(all_epsilon_default_src)) -$(BUILD_DIR)/epsilon.on-boarding.$(EXE): $(call object_for,$(all_epsilon_common_src) $(apps_launch_on_boarding_src) $(apps_prompt_none_src)) -$(BUILD_DIR)/epsilon.on-boarding.update.$(EXE): $(call object_for,$(all_epsilon_common_src) $(apps_launch_on_boarding_src) $(apps_prompt_update_src)) -$(BUILD_DIR)/epsilon.on-boarding.beta.$(EXE): $(call object_for,$(all_epsilon_common_src) $(apps_launch_on_boarding_src) $(apps_prompt_beta_src)) - -$(BUILD_DIR)/test.$(EXE): $(BUILD_DIR)/quiz/src/tests_symbols.o $(call object_for,$(ion_src) $(liba_src) $(kandinsky_src) $(escher_src) $(libaxx_src) $(poincare_src) $(python_src) $(ion_device_dfu_relocated_src) $(tests_src) $(runner_src) $(app_calculation_test_src) $(app_probability_test_src) $(app_regression_test_src) $(app_sequence_test_src) $(app_shared_test_src) $(app_statistics_test_src) $(app_solver_test_src)) - -# Load platform-specific targets -# We include them before the standard ones to give them precedence. --include build/targets.$(PLATFORM).mak +# Define main and shortcut targets +include build/targets.mak # Fill in the default recipe DEFAULT ?= $(BUILD_DIR)/epsilon.$(EXE) default: $(DEFAULT) -$(foreach extension,$(extensions),$(foreach executable,$(executables),$(eval $(call rules_for_targets,$(executable),$(extension))))) - # Load standard build rules include build/rules.mk diff --git a/build/targets.blackbox.mak b/build/targets.blackbox.mak index 512a4d937..5e1077e07 100644 --- a/build/targets.blackbox.mak +++ b/build/targets.blackbox.mak @@ -1,7 +1,7 @@ # Compare -executables += libepsilon_first libepsilon_second -extensions += .o +HANDY_TARGETS += libepsilon_first libepsilon_second +HANDY_TARGETS_EXTENSIONS += o $(eval $(call rules_for_targets,compare,)) diff --git a/build/targets.device.mak b/build/targets.device.mak index ba57a1d0a..4c30db642 100644 --- a/build/targets.device.mak +++ b/build/targets.device.mak @@ -1,7 +1,7 @@ include build/targets.device.$(MODEL).mak -executables += flasher.light flasher.verbose bench.ram bench.flash -extensions += .dfu .hex .bin +HANDY_TARGETS += flasher.light flasher.verbose bench.ram bench.flash +HANDY_TARGETS_EXTENSIONS += dfu hex bin $(eval $(call rule_for, \ DFUSE, %.dfu, %.$$(EXE), \ diff --git a/build/targets.device.n0110.mak b/build/targets.device.n0110.mak index 084e1b1ec..437d613d8 100644 --- a/build/targets.device.n0110.mak +++ b/build/targets.device.n0110.mak @@ -1,4 +1,4 @@ -executables += test.external_flash.write test.external_flash.read +HANDY_TARGETS += test.external_flash.write test.external_flash.read $(BUILD_DIR)/test.external_flash.%.$(EXE): LDSCRIPT = ion/test/device/n0110/external_flash_tests.ld test_external_flash_src = $(ion_src) $(liba_src) $(libaxx_src) $(kandinsky_src) $(poincare_src) $(ion_device_dfu_relogated_src) $(runner_src) diff --git a/build/targets.mak b/build/targets.mak new file mode 100644 index 000000000..ff4efa650 --- /dev/null +++ b/build/targets.mak @@ -0,0 +1,28 @@ +# Define standard Epsilon targets +all_epsilon_common_src = $(ion_src) $(liba_src) $(kandinsky_src) $(epsilon_src) $(app_src) $(escher_src) $(libaxx_src) $(poincare_src) $(python_src) $(ion_device_dfu_relocated_src) +all_epsilon_default_src = $(all_epsilon_common_src) $(apps_launch_default_src) $(apps_prompt_none_src) + +$(BUILD_DIR)/epsilon.$(EXE): $(call object_for,$(all_epsilon_default_src)) +$(BUILD_DIR)/epsilon.on-boarding.$(EXE): $(call object_for,$(all_epsilon_common_src) $(apps_launch_on_boarding_src) $(apps_prompt_none_src)) +$(BUILD_DIR)/epsilon.on-boarding.update.$(EXE): $(call object_for,$(all_epsilon_common_src) $(apps_launch_on_boarding_src) $(apps_prompt_update_src)) +$(BUILD_DIR)/epsilon.on-boarding.beta.$(EXE): $(call object_for,$(all_epsilon_common_src) $(apps_launch_on_boarding_src) $(apps_prompt_beta_src)) + +$(BUILD_DIR)/test.$(EXE): $(BUILD_DIR)/quiz/src/tests_symbols.o $(call object_for,$(ion_src) $(liba_src) $(kandinsky_src) $(escher_src) $(libaxx_src) $(poincare_src) $(python_src) $(ion_device_dfu_relocated_src) $(tests_src) $(runner_src) $(app_calculation_test_src) $(app_probability_test_src) $(app_regression_test_src) $(app_sequence_test_src) $(app_shared_test_src) $(app_statistics_test_src) $(app_solver_test_src)) + +# Define handy targets +# Those can be built easily by simply invoking "make target.ext". The named file +# will be built in $(BUILD_DIR). + +HANDY_TARGETS = epsilon epsilon.on-boarding epsilon.on-boarding.update epsilon.on-boarding.beta test +HANDY_TARGETS_EXTENSIONS = $(EXE) + +define handy_target_rule +.PHONY: $(1).$(2) +$(1).$(2): $$(BUILD_DIR)/$(1).$(2) +endef + +# Load platform-specific targets +# We include them before the standard ones to give them precedence. +-include build/targets.$(PLATFORM).mak + +$(foreach extension,$(HANDY_TARGETS_EXTENSIONS),$(foreach executable,$(HANDY_TARGETS),$(eval $(call handy_target_rule,$(executable),$(extension)))))