From 059c596a80dbc16a301f29ecfd138d8a0609b434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Thu, 11 Jul 2019 14:40:25 +0200 Subject: [PATCH] Makefiles: avoid building all sources for each target; introduce more modularity --- Makefile | 21 +++++++++++---------- apps/Makefile | 4 +--- apps/calculation/Makefile | 6 ++++-- apps/code/Makefile | 4 +++- apps/graph/Makefile | 4 +++- apps/hardware_test/Makefile | 4 +++- apps/home/Makefile | 4 +++- apps/on_boarding/Makefile | 4 +++- apps/probability/Makefile | 6 ++++-- apps/regression/Makefile | 8 +++++--- apps/sequence/Makefile | 6 ++++-- apps/settings/Makefile | 4 +++- apps/shared/Makefile | 4 +++- apps/solver/Makefile | 6 ++++-- apps/statistics/Makefile | 6 ++++-- apps/usb/Makefile | 4 +++- escher/Makefile | 4 ++-- ion/Makefile | 6 +++--- ion/src/blackbox/Makefile | 4 ++-- ion/src/blackbox/compare.cpp | 8 ++++---- ion/src/device/Makefile | 6 +++--- ion/src/emscripten/Makefile | 4 ++-- ion/src/sdl/Makefile | 4 ++-- ion/src/sdl/android/Makefile | 2 +- ion/src/sdl/external/Makefile | 2 +- ion/src/sdl/ios/Makefile | 6 +++--- ion/src/sdl/macos/Makefile | 2 +- ion/src/sdl/windows/Makefile | 4 ++-- ion/src/simulator/Makefile | 10 +++++----- kandinsky/Makefile | 6 +++--- liba/Makefile | 10 +++++----- liba/Makefile.bridge | 2 +- libaxx/Makefile | 6 +++--- poincare/Makefile | 14 +++++++------- python/Makefile | 2 -- quiz/Makefile | 2 +- scripts/targets.blackbox.mak | 14 ++++++++------ scripts/targets.device.mak | 23 +++++++++++++---------- scripts/targets.device.n0110.mak | 2 +- scripts/targets.emscripten.mak | 2 +- 40 files changed, 135 insertions(+), 105 deletions(-) diff --git a/Makefile b/Makefile index a64f1decd..7018a9133 100644 --- a/Makefile +++ b/Makefile @@ -48,9 +48,9 @@ $(BUILD_DIR)%/.: # To make objects dependent on their directory, we need a second expansion .SECONDEXPANSION: -# Each sub-Makefile can either add sources to the $(src) variable or define a -# new executable target. The $(src) variable lists the sources that will be -# built and linked to every executable being generated. +# Each sub-Makefile can either add sources to $(%_src) variables or define a +# new executable target. The $(%_src) variables list the sources that can be +# built and linked to executables being generated. ifeq ($(USE_LIBA),0) include liba/Makefile.bridge @@ -70,7 +70,7 @@ include scripts/struct_layout/Makefile include scripts/scenario/Makefile include quiz/Makefile # Quiz needs to be included at the end -all_src = src ion_device_dfu_relocated_src ion_device_dfu_xip flasher_src bench_src epsilon_src runner_src tests +all_src = app_src escher_src ion_src kandinsky_src liba_src libaxx_src poincare_src python_src ion_device_dfu_relocated_src ion_device_dfu_xip epsilon_src runner_src flasher_src bench_src tests_src all_objs = $(call object_for,$(all_src)) .SECONDARY: $(all_objs) @@ -83,14 +83,15 @@ all_objs = $(call object_for,$(all_src)) executables = epsilon epsilon.on-boarding epsilon.on-boarding.update epsilon.on-boarding.beta test #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,$(src) $(epsilon_src) $(ion_device_dfu_relocated_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)/epsilon.on-boarding.$(EXE): $(call object_for,$(src) $(epsilon_src) $(ion_device_dfu_relocated_src) $(apps_launch_on_boarding_src) $(apps_prompt_none_src)) -$(BUILD_DIR)/epsilon.on-boarding.update.$(EXE): $(call object_for,$(src) $(epsilon_src) $(ion_device_dfu_relocated_src) $(apps_launch_on_boarding_src) $(apps_prompt_update_src)) -$(BUILD_DIR)/epsilon.on-boarding.beta.$(EXE): $(call object_for,$(src) $(epsilon_src) $(ion_device_dfu_relocated_src) $(apps_launch_on_boarding_src) $(apps_prompt_beta_src)) - -$(BUILD_DIR)/test.$(EXE): $(BUILD_DIR)/quiz/src/tests_symbols.o $(call object_for,$(src) $(ion_device_dfu_relocated_src) $(tests) $(runner_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_src) $(app_probability_src) $(app_regression_src) $(app_sequence_src) $(app_shared_src) $(app_statistics_src) $(app_solver_src)) # Load platform-specific targets # We include them before the standard ones to give them precedence. diff --git a/apps/Makefile b/apps/Makefile index 5e83fe2d2..85bc4610f 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -95,9 +95,7 @@ epsilon_src += $(addprefix apps/, \ i18n.py \ ) -all_app_src = $(app_src) $(epsilon_src) $(apps_launch_on_boarding_src) $(apps_launch_default_src) $(apps_prompt_none_src) $(apps_container_prompt_update) $(apps_prompt_beta_src) +all_app_src = $(app_src) $(epsilon_src) $(apps_launch_on_boarding_src) $(apps_launch_default_src) $(apps_prompt_none_src) $(apps_container_prompt_update) $(apps_prompt_beta_src) $(tests_src) $(call object_for,$(all_app_src)): $(BUILD_DIR)/apps/i18n.h $(call object_for,$(all_app_src)): $(BUILD_DIR)/python/port/genhdr/qstrdefs.generated.h - -src += $(app_src) diff --git a/apps/calculation/Makefile b/apps/calculation/Makefile index c8960bb30..1b215fb04 100644 --- a/apps/calculation/Makefile +++ b/apps/calculation/Makefile @@ -1,7 +1,7 @@ apps += Calculation::App app_headers += apps/calculation/app.h -app_src += $(addprefix apps/calculation/,\ +app_calculation_src = $(addprefix apps/calculation/,\ app.cpp \ calculation.cpp \ calculation_store.cpp \ @@ -13,6 +13,8 @@ app_src += $(addprefix apps/calculation/,\ selectable_table_view.cpp \ ) +app_src += $(app_calculation_src) + i18n_files += $(addprefix apps/calculation/,\ base.de.i18n\ base.en.i18n\ @@ -21,7 +23,7 @@ i18n_files += $(addprefix apps/calculation/,\ base.pt.i18n\ ) -tests += $(addprefix apps/calculation/test/,\ +tests_src += $(addprefix apps/calculation/test/,\ calculation_store.cpp\ ) diff --git a/apps/code/Makefile b/apps/code/Makefile index 891aa24d2..f05354dff 100644 --- a/apps/code/Makefile +++ b/apps/code/Makefile @@ -1,7 +1,7 @@ apps += Code::App app_headers += apps/code/app.h -app_src += $(addprefix apps/code/,\ +app_code_src = $(addprefix apps/code/,\ app.cpp \ console_controller.cpp \ console_edit_cell.cpp \ @@ -23,6 +23,8 @@ app_src += $(addprefix apps/code/,\ variable_box_controller.cpp \ ) +app_src += $(app_code_src) + i18n_files += $(addprefix apps/code/,\ base.de.i18n\ base.en.i18n\ diff --git a/apps/graph/Makefile b/apps/graph/Makefile index b3b7ef5b0..71fd982ac 100644 --- a/apps/graph/Makefile +++ b/apps/graph/Makefile @@ -1,7 +1,7 @@ apps += Graph::App app_headers += apps/graph/app.h -app_src += $(addprefix apps/graph/,\ +app_graph_src = $(addprefix apps/graph/,\ app.cpp \ cartesian_function_store.cpp \ graph/banner_view.cpp \ @@ -26,6 +26,8 @@ app_src += $(addprefix apps/graph/,\ values/values_controller.cpp \ ) +app_src += $(app_graph_src) + i18n_files += $(addprefix apps/graph/,\ base.de.i18n\ base.en.i18n\ diff --git a/apps/hardware_test/Makefile b/apps/hardware_test/Makefile index 577e59bb5..6921f94ed 100644 --- a/apps/hardware_test/Makefile +++ b/apps/hardware_test/Makefile @@ -1,4 +1,4 @@ -app_src += $(addprefix apps/hardware_test/,\ +app_hardware_test_src = $(addprefix apps/hardware_test/,\ app.cpp \ arrow_view.cpp \ battery_test_controller.cpp \ @@ -14,3 +14,5 @@ app_src += $(addprefix apps/hardware_test/,\ serial_number_controller.cpp \ vblank_test_controller.cpp \ ) + +app_src += $(app_hardware_test_src) diff --git a/apps/home/Makefile b/apps/home/Makefile index b6c5428b9..5f4b7eb59 100644 --- a/apps/home/Makefile +++ b/apps/home/Makefile @@ -1,9 +1,11 @@ -app_src += $(addprefix apps/home/,\ +app_home_src = $(addprefix apps/home/,\ app.cpp \ app_cell.cpp \ controller.cpp \ ) +app_src += $(app_home_src) + i18n_files += $(addprefix apps/home/,\ base.de.i18n \ base.en.i18n \ diff --git a/apps/on_boarding/Makefile b/apps/on_boarding/Makefile index 66e866df9..723d19d76 100644 --- a/apps/on_boarding/Makefile +++ b/apps/on_boarding/Makefile @@ -1,4 +1,4 @@ -app_src += $(addprefix apps/on_boarding/,\ +app_on_boarding_src = $(addprefix apps/on_boarding/,\ app.cpp \ language_controller.cpp \ logo_controller.cpp \ @@ -7,6 +7,8 @@ app_src += $(addprefix apps/on_boarding/,\ power_on_self_test.cpp \ ) +app_src += $(app_on_boarding_src) + i18n_files += $(addprefix apps/on_boarding/,\ base.de.i18n\ base.en.i18n\ diff --git a/apps/probability/Makefile b/apps/probability/Makefile index 2087afa1c..247770690 100644 --- a/apps/probability/Makefile +++ b/apps/probability/Makefile @@ -1,7 +1,7 @@ apps += Probability::App app_headers += apps/probability/app.h -app_src += $(addprefix apps/probability/,\ +app_probability_src = $(addprefix apps/probability/,\ app.cpp \ calculation/calculation.cpp \ calculation/discrete_calculation.cpp \ @@ -27,6 +27,8 @@ app_src += $(addprefix apps/probability/,\ responder_image_cell.cpp \ ) +app_src += $(app_probability_src) + i18n_files += $(addprefix apps/probability/,\ base.de.i18n\ base.en.i18n\ @@ -35,7 +37,7 @@ i18n_files += $(addprefix apps/probability/,\ base.pt.i18n\ ) -tests += $(addprefix apps/probability/test/,\ +tests_src += $(addprefix apps/probability/test/,\ erf_inv.cpp\ ) diff --git a/apps/regression/Makefile b/apps/regression/Makefile index f31243396..06f065180 100644 --- a/apps/regression/Makefile +++ b/apps/regression/Makefile @@ -1,7 +1,7 @@ apps += Regression::App app_headers += apps/regression/app.h -app_src += $(addprefix apps/regression/,\ +app_regression_src = $(addprefix apps/regression/,\ app.cpp \ banner_view.cpp \ calculation_controller.cpp \ @@ -21,7 +21,7 @@ app_src += $(addprefix apps/regression/,\ store_parameter_controller.cpp \ ) -app_src += $(addprefix apps/regression/model/,\ +app_regression_src += $(addprefix apps/regression/model/,\ cubic_model.cpp \ exponential_model.cpp \ linear_model.cpp \ @@ -34,6 +34,8 @@ app_src += $(addprefix apps/regression/model/,\ trigonometric_model.cpp \ ) +app_src += $(app_regression_src) + i18n_files += $(addprefix apps/regression/,\ base.de.i18n\ base.en.i18n\ @@ -43,7 +45,7 @@ i18n_files += $(addprefix apps/regression/,\ base.universal.i18n\ ) -tests += $(addprefix apps/regression/test/,\ +tests_src += $(addprefix apps/regression/test/,\ model.cpp\ ) diff --git a/apps/sequence/Makefile b/apps/sequence/Makefile index 9f5702e4d..ee7475fec 100644 --- a/apps/sequence/Makefile +++ b/apps/sequence/Makefile @@ -1,7 +1,7 @@ apps += Sequence::App app_headers += apps/sequence/app.h -app_src += $(addprefix apps/sequence/,\ +app_sequence_src = $(addprefix apps/sequence/,\ app.cpp \ graph/curve_parameter_controller.cpp \ graph/curve_view_range.cpp \ @@ -22,6 +22,8 @@ app_src += $(addprefix apps/sequence/,\ sequence_title_cell.cpp \ ) +app_src += $(app_sequence_src) + i18n_files += $(addprefix apps/sequence/,\ base.de.i18n\ base.en.i18n\ @@ -30,7 +32,7 @@ i18n_files += $(addprefix apps/sequence/,\ base.pt.i18n\ ) -tests += $(addprefix apps/sequence/test/,\ +tests_src += $(addprefix apps/sequence/test/,\ sequence.cpp\ ) diff --git a/apps/settings/Makefile b/apps/settings/Makefile index 9d1ab8a62..5726653c7 100644 --- a/apps/settings/Makefile +++ b/apps/settings/Makefile @@ -1,7 +1,7 @@ apps += Settings::App app_headers += apps/settings/app.h -app_src += $(addprefix apps/settings/,\ +app_settings_src = $(addprefix apps/settings/,\ app.cpp \ main_controller.cpp \ settings_message_tree.cpp \ @@ -14,6 +14,8 @@ app_src += $(addprefix apps/settings/,\ sub_menu/preferences_controller.cpp \ ) +app_src += $(app_settings_src) + apps_prompt_none_src += apps/settings/main_controller_prompt_none.cpp apps_prompt_beta_src += apps/settings/main_controller_prompt_beta.cpp apps_prompt_update_src += apps/settings/main_controller_prompt_update.cpp diff --git a/apps/shared/Makefile b/apps/shared/Makefile index 1ef3a07b6..7ca761ccb 100644 --- a/apps/shared/Makefile +++ b/apps/shared/Makefile @@ -1,4 +1,4 @@ -app_src += $(addprefix apps/shared/,\ +app_shared_src = $(addprefix apps/shared/,\ banner_view.cpp \ buffer_function_title_cell.cpp \ buffer_text_view_with_text_field.cpp \ @@ -74,3 +74,5 @@ app_src += $(addprefix apps/shared/,\ xy_banner_view.cpp\ zoom_parameter_controller.cpp \ ) + +app_src += $(app_shared_src) diff --git a/apps/solver/Makefile b/apps/solver/Makefile index a87822ad6..a5ed65de9 100644 --- a/apps/solver/Makefile +++ b/apps/solver/Makefile @@ -1,7 +1,7 @@ apps += Solver::App app_headers += apps/solver/app.h -app_src += $(addprefix apps/solver/,\ +app_solver_src = $(addprefix apps/solver/,\ app.cpp \ equation_models_parameter_controller.cpp \ equation.cpp \ @@ -12,6 +12,8 @@ app_src += $(addprefix apps/solver/,\ solutions_controller.cpp \ ) +app_src += $(app_solver_src) + i18n_files += $(addprefix apps/solver/,\ base.de.i18n\ base.en.i18n\ @@ -20,7 +22,7 @@ i18n_files += $(addprefix apps/solver/,\ base.pt.i18n\ ) -tests += $(addprefix apps/solver/test/,\ +tests_src += $(addprefix apps/solver/test/,\ equation_store.cpp\ ) diff --git a/apps/statistics/Makefile b/apps/statistics/Makefile index 8e5fa5b7d..3096258c1 100644 --- a/apps/statistics/Makefile +++ b/apps/statistics/Makefile @@ -1,7 +1,7 @@ apps += Statistics::App app_headers += apps/statistics/app.h -app_src += $(addprefix apps/statistics/,\ +app_statistics_src = $(addprefix apps/statistics/,\ app.cpp \ box_axis_view.cpp \ box_banner_view.cpp \ @@ -23,6 +23,8 @@ app_src += $(addprefix apps/statistics/,\ store_controller.cpp \ ) +app_src += $(app_statistics_src) + i18n_files += $(addprefix apps/statistics/,\ base.de.i18n\ base.en.i18n\ @@ -31,7 +33,7 @@ i18n_files += $(addprefix apps/statistics/,\ base.pt.i18n\ ) -tests += $(addprefix apps/statistics/test/,\ +tests_src += $(addprefix apps/statistics/test/,\ store.cpp\ ) diff --git a/apps/usb/Makefile b/apps/usb/Makefile index 45c6e0d8d..c539f947c 100644 --- a/apps/usb/Makefile +++ b/apps/usb/Makefile @@ -1,8 +1,10 @@ -app_src += $(addprefix apps/usb/,\ +app_usb_src = $(addprefix apps/usb/,\ app.cpp \ usb_connected_controller.cpp \ ) +app_src += $(app_usb_src) + i18n_files += $(addprefix apps/usb/,\ base.de.i18n\ base.en.i18n\ diff --git a/escher/Makefile b/escher/Makefile index 91799fdf4..7a8e7d98e 100644 --- a/escher/Makefile +++ b/escher/Makefile @@ -1,6 +1,6 @@ SFLAGS += -Iescher/include -src += $(addprefix escher/src/,\ +escher_src += $(addprefix escher/src/,\ alternate_empty_view_controller.cpp \ app.cpp \ bank_view_controller.cpp \ @@ -114,5 +114,5 @@ $(eval $(call rule_for, \ define depends_on_image $(call object_for,$(1)): $(call object_for,$(2)) $(call object_for,$(1)): SFLAGS += $(foreach d,$(sort $(dir $(call object_for,$(1)))),-I$(d)) -src += $(2) +escher_src += $(2) endef diff --git a/ion/Makefile b/ion/Makefile index 6e420f78a..d41dcbbc4 100644 --- a/ion/Makefile +++ b/ion/Makefile @@ -22,7 +22,7 @@ include ion/src/shared/tools/Makefile initializer_list = $(shell echo $(1) | sed "s/\(.\)/'\1',/g")0 $(call object_for,ion/src/shared/platform_info.cpp): SFLAGS += -DPATCH_LEVEL="$(call initializer_list,$(PATCH_LEVEL))" -DEPSILON_VERSION="$(call initializer_list,$(EPSILON_VERSION))" -src += $(addprefix ion/src/shared/, \ +ion_src += $(addprefix ion/src/shared/, \ crc32_eat_byte.cpp \ decompress.cpp \ events.cpp \ @@ -32,9 +32,9 @@ src += $(addprefix ion/src/shared/, \ unicode/utf8_helper.cpp\ ) -src += ion/src/external/lz4/lz4.c +ion_src += ion/src/external/lz4/lz4.c -tests += $(addprefix ion/test/,\ +tests_src += $(addprefix ion/test/,\ crc32.cpp\ events.cpp\ keyboard.cpp\ diff --git a/ion/src/blackbox/Makefile b/ion/src/blackbox/Makefile index cf518fdf9..2ac36a1aa 100644 --- a/ion/src/blackbox/Makefile +++ b/ion/src/blackbox/Makefile @@ -1,11 +1,11 @@ -src += $(addprefix ion/src/blackbox/, \ +ion_src += $(addprefix ion/src/blackbox/, \ boot.cpp \ ion.cpp \ display.cpp \ events.cpp \ ) -src += $(addprefix ion/src/shared/, \ +ion_src += $(addprefix ion/src/shared/, \ console_line.cpp \ console_stdio.cpp \ crc32.cpp \ diff --git a/ion/src/blackbox/compare.cpp b/ion/src/blackbox/compare.cpp index b3c18aec5..fdb9810ad 100644 --- a/ion/src/blackbox/compare.cpp +++ b/ion/src/blackbox/compare.cpp @@ -7,13 +7,13 @@ * To use it, first create the two epsilon versions to compare, in a library * format: * git checkout first_hash - * make -j8 PLATFORM=blackbox clean libepsilon_first.o + * make -j8 PLATFORM=blackbox clean build/blackbox/libepsilon_first.o * git checkout second_hash - * make -j8 PLATFORM=blackbox clean libepsilon_second.o + * make -j8 PLATFORM=blackbox clean build/blackbox/libepsilon_second.o * * To compare the versions on a given scenario: - * make -j8 PLATFORM=blackbox compare - * ./compare < path/to/scenario + * make -j8 PLATFORM=blackbox build/blackbox/compare + * ./build/blackbox/compare < path/to/scenario * To fuzz over scenarios that are in a folder named "tests": * make -j8 PLATFORM=blackbox TOOLCHAIN=afl compare_fuzz */ diff --git a/ion/src/device/Makefile b/ion/src/device/Makefile index 621fef4c8..b77ef170f 100644 --- a/ion/src/device/Makefile +++ b/ion/src/device/Makefile @@ -6,7 +6,7 @@ include ion/src/device/$(MODEL)/Makefile $(call object_for,ion/src/shared/platform_info.cpp): SFLAGS += -DHEADER_SECTION="__attribute__((section(\".header\")))" -src += $(addprefix ion/src/shared/, \ +ion_src += $(addprefix ion/src/shared/, \ console_line.cpp \ events_keyboard.cpp \ events_modifier.cpp \ @@ -20,7 +20,7 @@ src += $(addprefix ion/src/shared/, \ ION_DEVICE_SFLAGS = -Iion/src/device/$(MODEL) -Iion/src/device/shared $(call object_for,$(ion_device_src) $(dfu_src) $(flasher_src) $(usb_src) $(bench_src) $(ion_device_dfu_xip_src) $(ion_device_dfu_relocated_src)): SFLAGS += $(ION_DEVICE_SFLAGS) -src += $(ion_device_src) +ion_src += $(ion_device_src) # When using the register.h C++ file in production mode, we expect the compiler # to completely inline all bit manipulations. For some reason, if we build using @@ -35,4 +35,4 @@ $(BUILD_DIR)/ion/src/device/console.o: SFLAGS+=-O3 $(BUILD_DIR)/ion/src/device/display.o: SFLAGS+=-O3 $(BUILD_DIR)/ion/src/device/swd.o: SFLAGS+=-O3 endif -endif \ No newline at end of file +endif diff --git a/ion/src/emscripten/Makefile b/ion/src/emscripten/Makefile index 26c85a7ea..3f3d8e85d 100644 --- a/ion/src/emscripten/Makefile +++ b/ion/src/emscripten/Makefile @@ -1,10 +1,10 @@ -src += $(addprefix ion/src/emscripten/, \ +ion_src += $(addprefix ion/src/emscripten/, \ display.cpp \ events_keyboard.cpp \ main.cpp \ ) -src += $(addprefix ion/src/shared/, \ +ion_src += $(addprefix ion/src/shared/, \ crc32.cpp \ events.cpp \ events_modifier.cpp \ diff --git a/ion/src/sdl/Makefile b/ion/src/sdl/Makefile index b77d3e247..c8cc23984 100644 --- a/ion/src/sdl/Makefile +++ b/ion/src/sdl/Makefile @@ -1,5 +1,5 @@ # TODO -src += $(addprefix ion/src/shared/, \ +ion_src += $(addprefix ion/src/shared/, \ crc32.cpp \ events.cpp \ events_keyboard.cpp \ @@ -17,7 +17,7 @@ src += $(addprefix ion/src/shared/, \ dummy/usb.cpp \ ) -src += $(addprefix ion/src/sdl/shared/, \ +ion_src += $(addprefix ion/src/sdl/shared/, \ display.cpp \ events_keyboard_platform.cpp \ keyboard.cpp \ diff --git a/ion/src/sdl/android/Makefile b/ion/src/sdl/android/Makefile index 4b028d32c..92ab951a5 100644 --- a/ion/src/sdl/android/Makefile +++ b/ion/src/sdl/android/Makefile @@ -1,4 +1,4 @@ -src += $(addprefix ion/src/sdl/android/src/cpp/, \ +ion_src += $(addprefix ion/src/sdl/android/src/cpp/, \ images.cpp \ language.cpp \ telemetry.cpp \ diff --git a/ion/src/sdl/external/Makefile b/ion/src/sdl/external/Makefile index 983587cc5..d65bce31a 100644 --- a/ion/src/sdl/external/Makefile +++ b/ion/src/sdl/external/Makefile @@ -100,4 +100,4 @@ include ion/src/sdl/external/config.$(MODEL).mak $(call object_for,$(sdl_src)): SFLAGS += $(SDL_SFLAGS) -src += $(sdl_src) +ion_src += $(sdl_src) diff --git a/ion/src/sdl/ios/Makefile b/ion/src/sdl/ios/Makefile index e3ca5d8c0..99fb3bf7c 100644 --- a/ion/src/sdl/ios/Makefile +++ b/ion/src/sdl/ios/Makefile @@ -1,4 +1,4 @@ -src += $(addprefix ion/src/sdl/ios/, \ +ion_src += $(addprefix ion/src/sdl/ios/, \ images.m \ language.m \ ) @@ -7,7 +7,7 @@ $(call object_for,ion/src/sdl/shared/main.cpp) : SFLAGS += -DEPSILON_SDL_FULLSCR GOOGLE_ANALYTICS = 1 ifeq ($(GOOGLE_ANALYTICS),1) -src += ion/src/sdl/ios/telemetry.m +ion_src += ion/src/sdl/ios/telemetry.m $(call object_for,ion/src/sdl/ios/telemetry.m): SFLAGS += -Iion/src/sdl/ios/GoogleAnalyticsServices/GoogleAnalytics/Library LDFLAGS += -lGoogleAnalyticsServices @@ -17,7 +17,7 @@ LDFLAGS += -framework SystemConfiguration LDFLAGS += -framework CoreData LDFLAGS += -Lion/src/sdl/ios/GoogleAnalyticsServices else -src += ion/src/sdl/shared/telemetry_dummy.cpp +ion_src += ion/src/sdl/shared/telemetry_dummy.cpp endif # Cross-ARCH epsilon.bin diff --git a/ion/src/sdl/macos/Makefile b/ion/src/sdl/macos/Makefile index 7168edb55..19edb9517 100644 --- a/ion/src/sdl/macos/Makefile +++ b/ion/src/sdl/macos/Makefile @@ -1,3 +1,3 @@ -src += $(addprefix ion/src/sdl/macos/, \ +ion_src += $(addprefix ion/src/sdl/macos/, \ images.m \ ) diff --git a/ion/src/sdl/windows/Makefile b/ion/src/sdl/windows/Makefile index 2045aa620..1b4b5c3ac 100644 --- a/ion/src/sdl/windows/Makefile +++ b/ion/src/sdl/windows/Makefile @@ -1,8 +1,8 @@ -src += $(addprefix ion/src/sdl/windows/, \ +ion_src += $(addprefix ion/src/sdl/windows/, \ images.cpp \ resources.rc \ ) -src += $(addprefix ion/src/sdl/windows/, \ +ion_src += $(addprefix ion/src/sdl/windows/, \ telemetry_dummy.cpp \ ) diff --git a/ion/src/simulator/Makefile b/ion/src/simulator/Makefile index 4b08536f7..6b9968ae1 100644 --- a/ion/src/simulator/Makefile +++ b/ion/src/simulator/Makefile @@ -1,12 +1,12 @@ -src += $(addprefix ion/src/simulator/, \ +ion_src += $(addprefix ion/src/simulator/, \ init.cpp \ ) -src += $(addprefix ion/src/simulator/boot/, main.cpp) -src += $(addprefix ion/src/simulator/display/, fltklcd.cpp) -src += $(addprefix ion/src/simulator/keyboard/, fltkkbd.cpp) +ion_src += $(addprefix ion/src/simulator/boot/, main.cpp) +ion_src += $(addprefix ion/src/simulator/display/, fltklcd.cpp) +ion_src += $(addprefix ion/src/simulator/keyboard/, fltkkbd.cpp) -src += $(addprefix ion/src/shared/, \ +ion_src += $(addprefix ion/src/shared/, \ crc32.cpp \ console_line.cpp \ console_stdio.cpp \ diff --git a/kandinsky/Makefile b/kandinsky/Makefile index 582c30977..7aaf9fca2 100644 --- a/kandinsky/Makefile +++ b/kandinsky/Makefile @@ -1,6 +1,6 @@ SFLAGS += -Ikandinsky/include -src += $(addprefix kandinsky/src/,\ +kandinsky_src += $(addprefix kandinsky/src/,\ color.cpp \ context.cpp \ context_line.cpp \ @@ -15,12 +15,12 @@ src += $(addprefix kandinsky/src/,\ rect.cpp \ ) -src += $(addprefix kandinsky/fonts/, \ +kandinsky_src += $(addprefix kandinsky/fonts/, \ LargeFont.ttf \ SmallFont.ttf \ ) -tests += $(addprefix kandinsky/test/,\ +tests_src += $(addprefix kandinsky/test/,\ color.cpp\ font.cpp\ rect.cpp\ diff --git a/liba/Makefile b/liba/Makefile index 96bf3f3bc..5b49d4576 100644 --- a/liba/Makefile +++ b/liba/Makefile @@ -1,6 +1,6 @@ SFLAGS += -Iliba/include -src += $(addprefix liba/src/, \ +liba_src += $(addprefix liba/src/, \ armv7m/setjmp.s \ armv7m/longjmp.s \ assert.c \ @@ -24,7 +24,7 @@ src += $(addprefix liba/src/, \ external/sqlite/mem5.c \ ) -src += $(addprefix liba/src/external/openbsd/, \ +liba_src += $(addprefix liba/src/external/openbsd/, \ b_exp__D.c \ b_log__D.c \ b_tgamma.c \ @@ -78,7 +78,7 @@ src += $(addprefix liba/src/external/openbsd/, \ w_lgammaf.c \ ) -src += $(addprefix liba/src/external/openbsd/, \ +liba_src += $(addprefix liba/src/external/openbsd/, \ e_acos.c \ e_acosh.c \ e_asin.c \ @@ -121,7 +121,7 @@ $(call object_for,liba/src/external/sqlite/mem5.c): CFLAGS += -w $(call object_for,liba/src/external/openbsd/%.c): SFLAGS := -Iliba/src/external/openbsd/include $(SFLAGS) $(call object_for,liba/src/external/openbsd/%.c): CFLAGS += -w -tests += $(addprefix liba/test/, \ +tests_src += $(addprefix liba/test/, \ aeabi.c \ double.c \ ieee754.c \ @@ -135,6 +135,6 @@ tests += $(addprefix liba/test/, \ # The use of aeabi-rt could be made conditional to an AEABI target. # In practice we're always using liba on such a target. -src += $(addprefix liba/src/aeabi-rt/, \ +liba_src += $(addprefix liba/src/aeabi-rt/, \ atexit.c \ ) diff --git a/liba/Makefile.bridge b/liba/Makefile.bridge index 70e190f58..f6e2eae1a 100644 --- a/liba/Makefile.bridge +++ b/liba/Makefile.bridge @@ -1,3 +1,3 @@ SFLAGS += -Iliba/include/bridge -src += liba/src/bridge.c +liba_src += liba/src/bridge.c diff --git a/libaxx/Makefile b/libaxx/Makefile index fd64e42ea..bdc297845 100644 --- a/libaxx/Makefile +++ b/libaxx/Makefile @@ -1,5 +1,5 @@ SFLAGS += -Ilibaxx/include -src += $(addprefix libaxx/src/, new.cpp) -src += $(addprefix libaxx/src/cxxabi/, atexit.cpp pure_virtual.cpp) -src += $(addprefix libaxx/include/external/libcxx/, complex.cpp) +libaxx_src += $(addprefix libaxx/src/, new.cpp) +libaxx_src += $(addprefix libaxx/src/cxxabi/, atexit.cpp pure_virtual.cpp) +libaxx_src += $(addprefix libaxx/include/external/libcxx/, complex.cpp) diff --git a/poincare/Makefile b/poincare/Makefile index 5283b67f0..caa5a6088 100644 --- a/poincare/Makefile +++ b/poincare/Makefile @@ -1,6 +1,6 @@ SFLAGS += -Ipoincare/include -src += $(addprefix poincare/src/,\ +poincare_src += $(addprefix poincare/src/,\ binomial_coefficient_layout.cpp \ bracket_layout.cpp \ bracket_pair_layout.cpp \ @@ -28,13 +28,13 @@ src += $(addprefix poincare/src/,\ vertical_offset_layout.cpp \ ) -src += $(addprefix poincare/src/,\ +poincare_src += $(addprefix poincare/src/,\ init.cpp \ exception_checkpoint.cpp \ helpers.cpp \ ) -src += $(addprefix poincare/src/,\ +poincare_src += $(addprefix poincare/src/,\ absolute_value.cpp \ addition.cpp \ approximation_helper.cpp \ @@ -131,12 +131,12 @@ src += $(addprefix poincare/src/,\ variable_context.cpp \ ) -src += $(addprefix poincare/src/parsing/,\ +poincare_src += $(addprefix poincare/src/parsing/,\ parser.cpp \ tokenizer.cpp \ ) -tests += $(addprefix poincare/test/,\ +tests_src += $(addprefix poincare/test/,\ tree/tree_handle.cpp\ tree/helpers.cpp\ addition.cpp\ @@ -183,8 +183,8 @@ tests += $(addprefix poincare/test/,\ # simplify_utils.cpp\ ifdef POINCARE_TESTS_PRINT_EXPRESSIONS -tests += poincare/src/expression_debug.o -src += poincare/src/expression_debug.cpp +tests_src += poincare/src/expression_debug.o +poincare_src += poincare/src/expression_debug.cpp SFLAGS += -DPOINCARE_TESTS_PRINT_EXPRESSIONS=1 endif diff --git a/python/Makefile b/python/Makefile index 1072474dd..81e533ae9 100644 --- a/python/Makefile +++ b/python/Makefile @@ -178,5 +178,3 @@ $(eval $(call rule_for, \ )) $(call object_for,$(python_src)): $(BUILD_DIR)/python/port/genhdr/qstrdefs.generated.h - -src += $(python_src) diff --git a/quiz/Makefile b/quiz/Makefile index 0ba932d45..6343b6f90 100644 --- a/quiz/Makefile +++ b/quiz/Makefile @@ -9,7 +9,7 @@ $$(BUILD_DIR)/quiz/src/$(subst _src,,$(1))_symbols.c: $$($(1)) | $$$$(@D)/. $$(Q) awk -f quiz/src/symbols.awk $$($(1)) > $$@ endef -$(eval $(call rule_for_quiz_symbols,tests)) +$(eval $(call rule_for_quiz_symbols,tests_src)) $(eval $(call rule_for_quiz_symbols,test_ion_external_flash_write_src)) $(eval $(call rule_for_quiz_symbols,test_ion_external_flash_read_src)) diff --git a/scripts/targets.blackbox.mak b/scripts/targets.blackbox.mak index 9d4241003..3eed66270 100644 --- a/scripts/targets.blackbox.mak +++ b/scripts/targets.blackbox.mak @@ -1,27 +1,29 @@ # Compare +# TODO: find a way to use rules define by rule_for instead of redeclaring them (we can't use them now because of the different basenames of the object and the source) + $(BUILD_DIR)/ion/src/blackbox/library_%.o: SFLAGS += -D EPSILON_LIB_PREFIX=$(*F) -$(BUILD_DIR)/ion/src/blackbox/library_%.o: ion/src/blackbox/library.cpp +$(BUILD_DIR)/ion/src/blackbox/library_%.o: ion/src/blackbox/library.cpp $(@D)/. @echo "CXX $@" $(Q) $(CXX) $(SFLAGS) $(CXXFLAGS) -c $< -o $@ -libepsilon_src = $(filter-out $(addprefix ion/src/blackbox/,boot.cpp events.cpp),$(src)) +libepsilon_src = $(filter-out $(addprefix ion/src/blackbox/,boot.cpp events.cpp),$(all_epsilon_default_src)) $(BUILD_DIR)/libepsilon_%.o: LDFLAGS += -exported_symbols_list ion/src/blackbox/lib_export_list.txt -$(BUILD_DIR)/libepsilon_%.o: $(call object_for,$(libepsilon_src)) $(call object_for,$(app_src)) $(BUILD_DIR)/ion/src/blackbox/library_%.o +$(BUILD_DIR)/libepsilon_%.o: $(call object_for,$(libepsilon_src)) $(BUILD_DIR)/ion/src/blackbox/library_%.o @echo "LD $@" $(Q) $(LD) $^ $(LDFLAGS) -r -s -o $@ $(BUILD_DIR)/compare: $(call object_for,ion/src/blackbox/compare.cpp) @echo "LD $@" - $(Q) $(LD) $^ libepsilon_first.o libepsilon_second.o $(LDFLAGS) -L. -o $@ + $(Q) $(LD) $^ $(BUILD_DIR)/libepsilon_first.o $(BUILD_DIR)/libepsilon_second.o $(LDFLAGS) -L. -o $@ # Integration tests .PHONY: tests/%.run tests/%.run: tests/%.esc epsilon.$(EXE) @echo "RUN $<" - @./epsilon.$(EXE) --logAfter 0 < $< > /dev/null + @./build/blackbox/epsilon.$(EXE) --logAfter 0 < $< > /dev/null .PHONY: tests/%.render tests/%.render: tests/%.esc epsilon.$(EXE) @@ -29,7 +31,7 @@ tests/%.render: tests/%.esc epsilon.$(EXE) @rm -rf tests/$(*F) @mkdir -p tests/$(*F) @rm -f event*.png - @./epsilon.$(EXE) --logAfter 0 < $< > /dev/null + @./build/blackbox/epsilon.$(EXE) --logAfter 0 < $< > /dev/null @mv event*.png tests/$(*F) scenarios = $(wildcard tests/*.esc) diff --git a/scripts/targets.device.mak b/scripts/targets.device.mak index 06ce84b9f..1868251cf 100644 --- a/scripts/targets.device.mak +++ b/scripts/targets.device.mak @@ -1,6 +1,6 @@ include scripts/targets.device.$(MODEL).mak -executables += flasher.light flasher.verbose bench.RAM bench.flash +executables += flasher.light flasher.verbose bench.ram bench.flash extensions = dfu hex bin $(foreach extension,$(extensions),$(foreach executable,$(executables),$(eval $(call rules_for_targets,$(executable),$(extension))))) @@ -24,28 +24,29 @@ $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.$(EXE) $(Q) printf "\xFF\xFF\xFF\xFF" >> $@ .PHONY: %_size -%_size: %.$(EXE) +%_size: $(BUILD_DIR)/%.$(EXE) @echo "========= BUILD OUTPUT ========" @echo "File: $<" @$(SIZE) $< | tail -n 1 | awk '{print "Code: " $$1 " bytes";print "Data: " $$2 " bytes"; print "Total: " int(($$1+$$2)/1024) " kB (" $$1 + $$2 " bytes)";}' @echo "===============================" .PHONY: %_run -%_run: %.$(EXE) +%_run: $(BUILD_DIR)/%.$(EXE) $(GDB) -x scripts/$(PLATFORM)/gdb_script.gdb $< -%.map: %.elf +$(BUILD_DIR)/%.map: $(BUILD_DIR)/%.elf @echo "LDMAP $@" $(Q) $(LD) $^ $(LDFLAGS) -Wl,-M -Wl,-Map=$@ -o /dev/null .PHONY: %_memory_map -%_memory_map: %.map +%_memory_map: $(BUILD_DIR)/%.map @echo "========== MEMORY MAP =========" $(Q) awk -f scripts/device/memory_map.awk < $< @echo "===============================" +# TODO: update the flash process for N0110 .PHONY: %_flash -%_flash: %.bin +%_flash: $(BUILD_DIR)/%.bin @echo "DFU $@" @echo "INFO About to flash your device. Please plug your device to your computer" @echo " using an USB cable and press the RESET button the back of your device." @@ -57,19 +58,21 @@ $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.$(EXE) openocd: openocd -f scripts/$(PLATFORM)/openocd.$(MODEL).cfg -# The flasher target is defined here because otherwise $(src) has not been +# The flasher target is defined here because otherwise $(%_src) has not been # fully filled $(BUILD_DIR)/flasher.%.$(EXE): LDFLAGS += -Lion/src/$(PLATFORM)/flasher $(BUILD_DIR)/flasher.%.$(EXE): LDSCRIPT = ion/src/$(PLATFORM)/shared/ram.ld -flasher_objs = $(call object_for,$(src) $(flasher_src) $(ion_device_dfu_xip_src)) +flasher_objs = $(call object_for,$(ion_src) $(liba_src) $(kandinsky_src) $(flasher_src) $(ion_device_dfu_xip_src)) $(BUILD_DIR)/flasher.light.$(EXE): $(BUILD_DIR)/ion/src/$(PLATFORM)/flasher/display_light.o $(flasher_objs) -$(BUILD_DIR)/flasher.verbose.$(EXE): $(BUILD_DIR)/ion/src/$(PLATFORM)/flasher/display_verbose.o $(flasher_objs) +$(BUILD_DIR)/flasher.verbose.$(EXE): $(BUILD_DIR)/ion/src/$(PLATFORM)/flasher/display_verbose.o $(flasher_objs) #TODO Do not build all apps... Put elsewhere? $(BUILD_DIR)/bench.ram.$(EXE): LDFLAGS += -Lion/src/$(PLATFORM)/bench $(BUILD_DIR)/bench.ram.$(EXE): LDSCRIPT = ion/src/$(PLATFORM)/shared/ram.ld $(BUILD_DIR)/bench.flash.$(EXE): LDSCRIPT = ion/src/$(PLATFORM)/$(MODEL)/internal_flash.ld -$(BUILD_DIR)/bench.%.$(EXE): $(call object_for,$(src) $(bench_src) $(ion_device_dfu_xip_src)) +bench_objs = $(call object_for,$(ion_src) $(liba_src) $(kandinsky_src) $(ion_device_dfu_xip_src) $(poincare_src) $(libaxx_src) $(bench_src) $(app_shared_src)) +$(BUILD_DIR)/bench.ram.$(EXE): $(bench_objs) +$(BUILD_DIR)/bench.flash.$(EXE): $(bench_objs) .PHONY: %.two_binaries %.two_binaries: %.elf diff --git a/scripts/targets.device.n0110.mak b/scripts/targets.device.n0110.mak index d0ec23b97..9737bee94 100644 --- a/scripts/targets.device.n0110.mak +++ b/scripts/targets.device.n0110.mak @@ -1,6 +1,6 @@ executables += 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 = $(src) $(ion_device_dfu_relogated_src) $(runner_src) +test_external_flash_src = $(ion_src) $(liba_src) $(libaxx_src) $(kandinsky_src) $(poincare_src) $(ion_device_dfu_relogated_src) $(runner_src) $(BUILD_DIR)/test.external_flash.read.$(EXE): $(BUILD_DIR)/quiz/src/test_ion_external_flash_read_symbols.o $(call object_for,$(test_external_flash_src) $(test_ion_external_flash_read_src)) $(BUILD_DIR)/test.external_flash.write.$(EXE): $(BUILD_DIR)/quiz/src/test_ion_external_flash_write_symbols.o $(call object_for,$(test_external_flash_src) $(test_ion_external_flash_write_src)) diff --git a/scripts/targets.emscripten.mak b/scripts/targets.emscripten.mak index ee7f8a15c..f8b9e7bcd 100644 --- a/scripts/targets.emscripten.mak +++ b/scripts/targets.emscripten.mak @@ -1,5 +1,5 @@ $(BUILD_DIR)/epsilon.packed.js: LDFLAGS += --memory-init-file 0 -$(BUILD_DIR)/epsilon.packed.js: $(call object_for,$(src) $(epsilon_src)) +$(BUILD_DIR)/epsilon.packed.js: $(call object_for,$(all_epsilon_default_src)) $(BUILD_DIR)/simulator.zip: $(BUILD_DIR)/epsilon.packed.js @rm -rf $(basename $@)