From 4f1d74f44bb213c3ccdd050781b57ae527865ce0 Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Tue, 5 Mar 2019 17:13:47 +0100 Subject: [PATCH] [build] Use an out-of-tree build --- .gitignore | 46 +---- Makefile | 99 +++++++--- apps/Makefile | 64 +++--- apps/calculation/Makefile | 22 +-- apps/code/Makefile | 42 ++-- apps/graph/Makefile | 44 ++--- apps/hardware_test/Makefile | 28 +-- apps/home/Makefile | 18 +- apps/on_boarding/Makefile | 15 +- apps/on_boarding/logo_controller.cpp | 1 - apps/probability/Makefile | 95 ++++----- apps/regression/Makefile | 58 +++--- apps/sequence/Makefile | 42 ++-- apps/settings/Makefile | 24 +-- apps/shared/Makefile | 174 ++++++++-------- apps/solver/Makefile | 20 +- apps/statistics/Makefile | 42 ++-- apps/usb/Makefile | 6 +- escher/Makefile | 204 ++++++++++--------- escher/image/inliner.c | 8 +- ion/Makefile | 16 +- ion/src/device/Makefile | 54 ++--- ion/src/device/bench/Makefile | 36 ++-- ion/src/device/boot/Makefile | 2 +- ion/src/device/usb/Makefile | 101 +++++----- kandinsky/Makefile | 75 +++---- liba/Makefile | 229 +++++++++++---------- liba/Makefile.bridge | 2 +- libaxx/Makefile | 7 +- poincare/Makefile | 258 ++++++++++++------------ python/Makefile | 286 +++++++++++++-------------- 31 files changed, 1071 insertions(+), 1047 deletions(-) diff --git a/.gitignore b/.gitignore index cfd17d43a..36f753c92 100644 --- a/.gitignore +++ b/.gitignore @@ -1,52 +1,8 @@ -# No objects files. -*.o -*.elf -*.exe - -# No dependency files -*.d - -# No lex / yacc generated files. -poincare/src/expression_lexer.cpp -poincare/src/expression_lexer.hpp -poincare/src/expression_parser.cpp -poincare/src/expression_parser.hpp - -# No rulegen generated files -poincare/src/simplification/rulegen/rules_tokens.h -poincare/src/simplification/rulegen/rules_lexer.cpp -poincare/src/simplification/rulegen/rules_parser.cpp -poincare/src/simplification/rulegen/rulegen -poincare/src/simplification/demo_ruleset.h - -# Font related generated files. -kandinsky/fonts/rasterizer -kandinsky/src/font_large.cpp -kandinsky/src/font_small.cpp - # No i18n headers apps/i18n.h apps/i18n.cpp -# No PicView generated files -apps/picview/image.raw -apps/picview/image.c - -# No AST file -*.ast -*.ast.json - # Quiz output quiz/src/symbols.c -# No generated icon & font files -*_icon.cpp -*_icon.h -*_font.c -*_font.h - -# Ignore inliner binary -escher/image/inliner - -# Ignore generated qtsrdefs file -python/port/genhdr/qstrdefs.generated.h +outputs diff --git a/Makefile b/Makefile index bb10ae979..b626d010b 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,28 @@ include build/config.mak -default: epsilon.$(EXE) +# Disable default Make rules +.SUFFIXES: + +OUTPUT_DIRECTORY = outputs +object_for = $(addprefix $(OUTPUT_DIRECTORY)/,$(addsuffix .o,$(basename $(1)))) + +default: $(OUTPUT_DIRECTORY)/epsilon.$(EXE) + +# Define a standard rule helper +# If passed a last parameter value of with_local_version, we also define an +# extra rule that can build source files within the $(OUTPUT_DIRECTORY). This is +# useful for rules that can be applied for intermediate objects (for example, +# when going .png -> .cpp -> .o). +define rule_for +$(addprefix $$(OUTPUT_DIRECTORY)/,$(strip $(2))): $(strip $(3)) | $$$$(@D)/. + @ echo "$(shell printf "%-8s" $(strip $(1)))$$(@:$$(OUTPUT_DIRECTORY)/%=%)" + $(Q) $(4) +ifeq ($(strip $(5)),with_local_version) +$(addprefix $$(OUTPUT_DIRECTORY)/,$(strip $(2))): $(addprefix $$(OUTPUT_DIRECTORY)/,$(strip $(3))) + @ echo "$(shell printf "%-8s" $(strip $(1)))$$(@:$$(OUTPUT_DIRECTORY)/%=%)" + $(Q) $(4) +endif +endef .PHONY: info info: @@ -10,16 +32,22 @@ info: @echo "EPSILON_APPS = $(EPSILON_APPS)" @echo "EPSILON_I18N = $(EPSILON_I18N)" -# Each sub-Makefile can either add objects to the $(objs) variable or define a -# new executable target. The $(objs) variable lists the objects that will be -# linked to every executable being generated. Each Makefile is also responsible -# for keeping the $(product) variable updated. This variable lists all files -# that could be generated during the build and that needs to be cleaned up -# afterwards. +# Since we're building out-of-tree, we need to make sure the output directories +# are created, otherwise the receipes will fail (e.g. gcc will fail to create +# "output/foo/bar.o" because the directory "output/foo" doesn't exist). +# We need to mark those directories as precious, otherwise Make will try to get +# rid of them upon completion (and fail, since those folders won't be empty). +.PRECIOUS: $(OUTPUT_DIRECTORY)/. $(OUTPUT_DIRECTORY)%/. +$(OUTPUT_DIRECTORY)/. $(OUTPUT_DIRECTORY)%/.: + $(Q) mkdir -p $(dir $@) -products := +# 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. -# Library Makefiles ifeq ($(USE_LIBA),0) include liba/Makefile.bridge else @@ -38,39 +66,46 @@ include build/struct_layout/Makefile include build/scenario/Makefile include quiz/Makefile # Quiz needs to be included at the end -products += $(objs) +objs = $(call object_for,$(src)) -all_objs = $(filter %.o, $(products)) -dependencies = $(all_objs:.o=.d) --include $(dependencies) -products += $(dependencies) - -$(all_objs): $(generated_headers) - -epsilon.$(EXE): $(objs) -test.$(EXE): $(objs) +# Load source-based dependencies +# Compilers can generate Makefiles that states the dependencies of a given +# objet to other source and headers. This serve no purpose for a clean build, +# but allows correct yet optimal incremental builds. +-include $(objs:.o=.d) .SECONDARY: $(objs) -%.$(EXE): - @echo "LD $@" - $(Q) $(LD) $^ $(LDFLAGS) -o $@ +$(OUTPUT_DIRECTORY)/epsilon.$(EXE): $(objs) +$(OUTPUT_DIRECTORY)/test.$(EXE): $(objs) -%.o: %.c - @echo "CC $@" - $(Q) $(CC) $(SFLAGS) $(CFLAGS) -c $< -o $@ +# Define standard compilation rules -%.o: %.s - @echo "AS $@" - $(Q) $(CC) $(SFLAGS) -c $< -o $@ +$(eval $(call rule_for, \ + AS, %.o, %.s, \ + $$(CC) $$(SFLAGS) -c $$< -o $$@ \ +)) -%.o: %.cpp - @echo "CXX $@" - $(Q) $(CXX) $(SFLAGS) $(CXXFLAGS) -c $< -o $@ +$(eval $(call rule_for, \ + CC, %.o, %.c, \ + $$(CC) $$(SFLAGS) $$(CFLAGS) -c $$< -o $$@, \ + with_local_version \ +)) + +$(eval $(call rule_for, \ + CXX, %.o, %.cpp, \ + $$(CC) $$(SFLAGS) $$(CXXFLAGS) -c $$< -o $$@, \ + with_local_version \ +)) + +$(eval $(call rule_for, \ + LD, %.$$(EXE), , \ + $$(LD) $$^ $$(LDFLAGS) -o $$@ \ +)) .PHONY: clean clean: @echo "CLEAN" - $(Q) rm -f $(products) + $(Q) rm -rf $(OUTPUT_DIRECTORY) .PHONY: cowsay_% cowsay_%: diff --git a/apps/Makefile b/apps/Makefile index 98141b448..31ef222b2 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -10,26 +10,26 @@ apps = # (path to the apps header). $(foreach i,${EPSILON_APPS},$(eval include apps/$(i)/Makefile)) -app_objs += $(addprefix apps/,\ - apps_container.o\ - apps_container_storage.o\ - apps_window.o\ - battery_timer.o\ - battery_view.o\ - constant.o\ - backlight_dimming_timer.o\ - empty_battery_window.o\ - exam_pop_up_controller.o\ - global_preferences.o\ - i18n.o\ - lock_view.o\ - main.o\ - math_toolbox.o\ - shift_alpha_lock_view.o\ - suspend_timer.o\ - title_bar_view.o\ - variable_box_controller.o\ - variable_box_empty_controller.o\ +app_src += $(addprefix apps/,\ + apps_container.cpp \ + apps_container_storage.cpp \ + apps_window.cpp \ + backlight_dimming_timer.cpp \ + battery_timer.cpp \ + battery_view.cpp \ + constant.cpp \ + empty_battery_window.cpp \ + exam_pop_up_controller.cpp \ + global_preferences.cpp \ + i18n.cpp \ + lock_view.cpp \ + main.cpp \ + math_toolbox.cpp \ + shift_alpha_lock_view.cpp \ + suspend_timer.cpp \ + title_bar_view.cpp \ + variable_box_controller.cpp \ + variable_box_empty_controller.cpp \ ) snapshots_declaration = $(foreach i,$(apps),$(i)::Snapshot m_snapshot$(subst :,,$(i))Snapshot;) @@ -40,7 +40,7 @@ snapshots_count = $(words $(apps)) snapshot_includes = $(foreach i,$(app_headers),-include $(i) ) epsilon_app_names = '$(foreach i,${EPSILON_APPS},"$(i)", )' -apps/apps_container_storage.o apps/main.o: CXXFLAGS += $(snapshot_includes) -DAPPS_CONTAINER_APPS_DECLARATION="$(apps_declaration)" -DAPPS_CONTAINER_SNAPSHOT_DECLARATIONS="$(snapshots_declaration)" -DAPPS_CONTAINER_SNAPSHOT_CONSTRUCTORS="$(snapshots_construction)" -DAPPS_CONTAINER_SNAPSHOT_LIST="$(snapshots_list)" -DAPPS_CONTAINER_SNAPSHOT_COUNT=$(snapshots_count) -DEPSILON_APPS_NAMES=$(epsilon_app_names) +$(call object_for,apps/apps_container_storage.cpp apps/main.cpp): CXXFLAGS += $(snapshot_includes) -DAPPS_CONTAINER_APPS_DECLARATION="$(apps_declaration)" -DAPPS_CONTAINER_SNAPSHOT_DECLARATIONS="$(snapshots_declaration)" -DAPPS_CONTAINER_SNAPSHOT_CONSTRUCTORS="$(snapshots_construction)" -DAPPS_CONTAINER_SNAPSHOT_LIST="$(snapshots_list)" -DAPPS_CONTAINER_SNAPSHOT_COUNT=$(snapshots_count) -DEPSILON_APPS_NAMES=$(epsilon_app_names) i18n_files += $(addprefix apps/language_,$(addsuffix .universal.i18n, $(EPSILON_I18N))) @@ -68,11 +68,12 @@ apps/i18n.cpp: $(i18n_files) @echo "I18N $@" $(Q) $(PYTHON) apps/i18n.py --header $(subst .cpp,.h,$@) --implementation $@ --locales $(EPSILON_I18N) --files $^ -$(app_objs): apps/i18n.h +#$(app_objs): apps/i18n.h products += apps/i18n.h apps/i18n.cpp -app_images += apps/exam_icon.png +$(eval $(call depends_on_image,apps/title_bar_view.cpp,apps/exam_icon.png)) + # Tracking which source file uses which image is painful. But we need to ensure # that a .png file has been inlined before building any source file that uses @@ -80,15 +81,20 @@ app_images += apps/exam_icon.png # As a shortcut, we simply say that every app file depends on every image. In # practice, this forces all the images to be before the app. -app_image_objs := $(app_images:.png=.o) -.SECONDARY: $(app_images:.png=.cpp) -$(app_objs): $(app_image_objs) +#app_image_objs := $(OUTPUT_DIRECTORY)/$(app_images:.png=.o) +#.SECONDARY: $(OUTPUT_DIRECTORY)/$(app_images:.png=.cpp) +#$(app_objs): $(app_image_objs) +#app_image_src := $(app_images:.png=.cpp) -epsilon.$(EXE): $(app_objs) $(app_image_objs) +#epsilon.$(EXE): $(app_objs) $(app_image_objs) +#app_objs = $(call object_for,$(app_src)) + +#epsilon.$(EXE): $(app_objs) + +src += $(app_src) +#$(app_image_src) TO_REMOVE := apps/main.o apps/i18n.o TMP := $(app_objs) $(app_image_objs) VAR := $(filter-out $(TO_REMOVE), $(TMP)) test.$(EXE): $(VAR) - -products += epsilon.$(EXE) $(app_objs) $(call INLINER_PRODUCTS,$(app_images)) diff --git a/apps/calculation/Makefile b/apps/calculation/Makefile index 7b797bea7..c8960bb30 100644 --- a/apps/calculation/Makefile +++ b/apps/calculation/Makefile @@ -1,16 +1,16 @@ apps += Calculation::App app_headers += apps/calculation/app.h -app_objs += $(addprefix apps/calculation/,\ - app.o\ - calculation.o\ - calculation_store.o\ - edit_expression_controller.o\ - expression_field.o\ - history_view_cell.o\ - history_controller.o\ - scrollable_expression_view.o\ - selectable_table_view.o\ +app_src += $(addprefix apps/calculation/,\ + app.cpp \ + calculation.cpp \ + calculation_store.cpp \ + edit_expression_controller.cpp \ + expression_field.cpp \ + history_view_cell.cpp \ + history_controller.cpp \ + scrollable_expression_view.cpp \ + selectable_table_view.cpp \ ) i18n_files += $(addprefix apps/calculation/,\ @@ -25,4 +25,4 @@ tests += $(addprefix apps/calculation/test/,\ calculation_store.cpp\ ) -app_images += apps/calculation/calculation_icon.png +$(eval $(call depends_on_image,apps/calculation/app.cpp,apps/calculation/calculation_icon.png)) diff --git a/apps/code/Makefile b/apps/code/Makefile index 25b63e4ee..891aa24d2 100644 --- a/apps/code/Makefile +++ b/apps/code/Makefile @@ -1,26 +1,26 @@ apps += Code::App app_headers += apps/code/app.h -app_objs += $(addprefix apps/code/,\ - app.o\ - console_controller.o\ - console_edit_cell.o\ - console_line_cell.o\ - console_store.o\ - editor_controller.o\ - editor_view.o\ - helpers.o\ - menu_controller.o\ - python_toolbox.o\ - python_text_area.o\ - sandbox_controller.o\ - script.o\ - script_name_cell.o\ - script_node_cell.o\ - script_parameter_controller.o\ - script_store.o\ - script_template.o\ - variable_box_controller.o\ +app_src += $(addprefix apps/code/,\ + app.cpp \ + console_controller.cpp \ + console_edit_cell.cpp \ + console_line_cell.cpp \ + console_store.cpp \ + editor_controller.cpp \ + editor_view.cpp \ + helpers.cpp \ + menu_controller.cpp \ + python_toolbox.cpp \ + python_text_area.cpp \ + sandbox_controller.cpp \ + script.cpp \ + script_name_cell.cpp \ + script_node_cell.cpp \ + script_parameter_controller.cpp \ + script_store.cpp \ + script_template.cpp \ + variable_box_controller.cpp \ ) i18n_files += $(addprefix apps/code/,\ @@ -44,4 +44,4 @@ i18n_files += $(addprefix apps/code/,\ toolbox.universal.i18n\ ) -app_images += apps/code/code_icon.png +$(eval $(call depends_on_image,apps/code/app.cpp,apps/code/code_icon.png)) diff --git a/apps/graph/Makefile b/apps/graph/Makefile index 9c631beff..8e7b1ef68 100644 --- a/apps/graph/Makefile +++ b/apps/graph/Makefile @@ -1,27 +1,27 @@ apps += Graph::App app_headers += apps/graph/app.h -app_objs += $(addprefix apps/graph/,\ - app.o\ - storage_cartesian_function_store.o\ - graph/banner_view.o\ - graph/calculation_graph_controller.o\ - graph/calculation_parameter_controller.o\ - graph/curve_parameter_controller.o\ - graph/extremum_graph_controller.o\ - graph/graph_controller.o\ - graph/graph_controller_helper.o\ - graph/graph_view.o\ - graph/integral_graph_controller.o\ - graph/intersection_graph_controller.o\ - graph/root_graph_controller.o\ - graph/tangent_graph_controller.o\ - list/list_parameter_controller.o\ - list/storage_list_controller.o\ - list/text_field_function_title_cell.o\ - values/storage_derivative_parameter_controller.o\ - values/storage_function_parameter_controller.o\ - values/storage_values_controller.o\ +app_src += $(addprefix apps/graph/,\ + app.cpp \ + storage_cartesian_function_store.cpp \ + graph/banner_view.cpp \ + graph/calculation_graph_controller.cpp \ + graph/calculation_parameter_controller.cpp \ + graph/curve_parameter_controller.cpp \ + graph/extremum_graph_controller.cpp \ + graph/graph_controller.cpp \ + graph/graph_controller_helper.cpp \ + graph/graph_view.cpp \ + graph/integral_graph_controller.cpp \ + graph/intersection_graph_controller.cpp \ + graph/root_graph_controller.cpp \ + graph/tangent_graph_controller.cpp \ + list/list_parameter_controller.cpp \ + list/storage_list_controller.cpp \ + list/text_field_function_title_cell.cpp \ + values/storage_derivative_parameter_controller.cpp \ + values/storage_function_parameter_controller.cpp \ + values/storage_values_controller.cpp \ ) i18n_files += $(addprefix apps/graph/,\ @@ -32,4 +32,4 @@ i18n_files += $(addprefix apps/graph/,\ base.pt.i18n\ ) -app_images += apps/graph/graph_icon.png +$(eval $(call depends_on_image,apps/graph/app.cpp,apps/graph/graph_icon.png)) diff --git a/apps/hardware_test/Makefile b/apps/hardware_test/Makefile index 209104e22..f6a490b0d 100644 --- a/apps/hardware_test/Makefile +++ b/apps/hardware_test/Makefile @@ -1,15 +1,15 @@ -app_objs += $(addprefix apps/hardware_test/,\ - app.o\ - arrow_view.o\ - battery_test_controller.o\ - code_128b_view.o\ - keyboard_test_controller.o\ - keyboard_view.o\ - led_test_controller.o\ - pattern.o\ - pattern_view.o\ - pop_up_controller.o\ - screen_test_controller.o\ - screen_test_controller.o\ - serial_number_controller.o\ +app_src += $(addprefix apps/hardware_test/,\ + app.cpp \ + arrow_view.cpp \ + battery_test_controller.cpp \ + code_128b_view.cpp \ + keyboard_test_controller.cpp \ + keyboard_view.cpp \ + led_test_controller.cpp \ + pattern.cpp \ + pattern_view.cpp \ + pop_up_controller.cpp \ + screen_test_controller.cpp \ + screen_test_controller.cpp \ + serial_number_controller.cpp \ ) diff --git a/apps/home/Makefile b/apps/home/Makefile index ac3e309e1..b6c5428b9 100644 --- a/apps/home/Makefile +++ b/apps/home/Makefile @@ -1,13 +1,13 @@ -app_objs += $(addprefix apps/home/,\ - app.o\ - app_cell.o\ - controller.o\ +app_src += $(addprefix apps/home/,\ + app.cpp \ + app_cell.cpp \ + controller.cpp \ ) i18n_files += $(addprefix apps/home/,\ - base.de.i18n\ - base.en.i18n\ - base.es.i18n\ - base.fr.i18n\ - base.pt.i18n\ + base.de.i18n \ + base.en.i18n \ + base.es.i18n \ + base.fr.i18n \ + base.pt.i18n \ ) diff --git a/apps/on_boarding/Makefile b/apps/on_boarding/Makefile index b11b5d216..c013f074e 100644 --- a/apps/on_boarding/Makefile +++ b/apps/on_boarding/Makefile @@ -1,9 +1,9 @@ -app_objs += $(addprefix apps/on_boarding/,\ - app.o\ - language_controller.o\ - logo_controller.o\ - logo_view.o\ - pop_up_controller.o\ +app_src += $(addprefix apps/on_boarding/,\ + app.cpp \ + language_controller.cpp \ + logo_controller.cpp \ + logo_view.cpp \ + pop_up_controller.cpp \ ) i18n_files += $(addprefix apps/on_boarding/,\ @@ -14,5 +14,4 @@ i18n_files += $(addprefix apps/on_boarding/,\ base.pt.i18n\ ) -app_images += apps/on_boarding/logo_icon.png - +$(eval $(call depends_on_image,apps/on_boarding/logo_view.cpp,apps/on_boarding/logo_icon.png)) diff --git a/apps/on_boarding/logo_controller.cpp b/apps/on_boarding/logo_controller.cpp index 9fa2f10cb..3068da16c 100644 --- a/apps/on_boarding/logo_controller.cpp +++ b/apps/on_boarding/logo_controller.cpp @@ -1,5 +1,4 @@ #include "logo_controller.h" -#include "logo_icon.h" namespace OnBoarding { diff --git a/apps/probability/Makefile b/apps/probability/Makefile index 8093a11a1..2087afa1c 100644 --- a/apps/probability/Makefile +++ b/apps/probability/Makefile @@ -1,30 +1,30 @@ apps += Probability::App app_headers += apps/probability/app.h -app_objs += $(addprefix apps/probability/,\ - app.o\ - calculation/calculation.o\ - calculation/discrete_calculation.o\ - calculation/left_integral_calculation.o\ - calculation/right_integral_calculation.o\ - calculation/finite_integral_calculation.o\ - calculation_controller.o\ - calculation_cell.o\ - calculation_type_controller.o\ - cell.o\ - image_cell.o\ - law/binomial_law.o\ - law/erf_inv.o\ - law/exponential_law.o\ - law/law.o\ - law/normal_law.o\ - law/poisson_law.o\ - law/two_parameter_law.o\ - law/uniform_law.o\ - law_controller.o\ - law_curve_view.o\ - parameters_controller.o\ - responder_image_cell.o\ +app_src += $(addprefix apps/probability/,\ + app.cpp \ + calculation/calculation.cpp \ + calculation/discrete_calculation.cpp \ + calculation/left_integral_calculation.cpp \ + calculation/right_integral_calculation.cpp \ + calculation/finite_integral_calculation.cpp \ + calculation_controller.cpp \ + calculation_cell.cpp \ + calculation_type_controller.cpp \ + cell.cpp \ + image_cell.cpp \ + law/binomial_law.cpp \ + law/erf_inv.cpp \ + law/exponential_law.cpp \ + law/law.cpp \ + law/normal_law.cpp \ + law/poisson_law.cpp \ + law/two_parameter_law.cpp \ + law/uniform_law.cpp \ + law_controller.cpp \ + law_curve_view.cpp \ + parameters_controller.cpp \ + responder_image_cell.cpp \ ) i18n_files += $(addprefix apps/probability/,\ @@ -39,25 +39,30 @@ tests += $(addprefix apps/probability/test/,\ erf_inv.cpp\ ) -app_images += apps/probability/probability_icon.png +# Image dependencies -app_images += $(addprefix apps/probability/images/,\ - binomial_icon.png\ - calcul1_icon.png\ - calcul2_icon.png\ - calcul3_icon.png\ - calcul4_icon.png\ - exponential_icon.png\ - focused_binomial_icon.png\ - focused_calcul1_icon.png\ - focused_calcul2_icon.png\ - focused_calcul3_icon.png\ - focused_calcul4_icon.png\ - focused_exponential_icon.png\ - focused_normal_icon.png\ - focused_poisson_icon.png\ - focused_uniform_icon.png\ - normal_icon.png\ - poisson_icon.png\ - uniform_icon.png\ -) +$(eval $(call depends_on_image,apps/probability/app.cpp,apps/probability/probability_icon.png)) + +$(eval $(call depends_on_image,apps/probability/law_controller.cpp,$(addprefix apps/probability/images/, \ + binomial_icon.png \ + exponential_icon.png \ + focused_binomial_icon.png \ + focused_exponential_icon.png \ + focused_normal_icon.png \ + focused_poisson_icon.png \ + focused_uniform_icon.png \ + normal_icon.png \ + poisson_icon.png \ + uniform_icon.png \ +))) + +$(eval $(call depends_on_image,$(addprefix apps/probability/,calculation_type_controller.cpp calculation_controller.cpp),$(addprefix apps/probability/images/, \ + calcul1_icon.png \ + calcul2_icon.png \ + calcul3_icon.png \ + calcul4_icon.png \ + focused_calcul1_icon.png \ + focused_calcul2_icon.png \ + focused_calcul3_icon.png \ + focused_calcul4_icon.png \ +))) diff --git a/apps/regression/Makefile b/apps/regression/Makefile index 3065bc27f..450d3a471 100644 --- a/apps/regression/Makefile +++ b/apps/regression/Makefile @@ -1,36 +1,36 @@ apps += Regression::App app_headers += apps/regression/app.h -app_objs += $(addprefix apps/regression/,\ - app.o\ - banner_view.o\ - calculation_controller.o\ - column_title_cell.o\ - even_odd_buffer_text_cell_with_margin.o\ - even_odd_double_buffer_text_cell_with_separator.o\ - go_to_parameter_controller.o\ - graph_controller.o\ - graph_options_controller.o\ - graph_view.o\ - initialisation_parameter_controller.o\ - regression_context.o\ - regression_controller.o\ - store.o\ - store_controller.o\ - store_parameter_controller.o\ +app_src += $(addprefix apps/regression/,\ + app.cpp \ + banner_view.cpp \ + calculation_controller.cpp \ + column_title_cell.cpp \ + even_odd_buffer_text_cell_with_margin.cpp \ + even_odd_double_buffer_text_cell_with_separator.cpp \ + go_to_parameter_controller.cpp \ + graph_controller.cpp \ + graph_options_controller.cpp \ + graph_view.cpp \ + initialisation_parameter_controller.cpp \ + regression_context.cpp \ + regression_controller.cpp \ + store.cpp \ + store_controller.cpp \ + store_parameter_controller.cpp \ ) -app_objs += $(addprefix apps/regression/model/,\ - cubic_model.o\ - exponential_model.o\ - linear_model.o\ - logarithmic_model.o\ - logistic_model.o\ - model.o\ - power_model.o\ - quadratic_model.o\ - quartic_model.o\ - trigonometric_model.o\ +app_src += $(addprefix apps/regression/model/,\ + cubic_model.cpp \ + exponential_model.cpp \ + linear_model.cpp \ + logarithmic_model.cpp \ + logistic_model.cpp \ + model.cpp \ + power_model.cpp \ + quadratic_model.cpp \ + quartic_model.cpp \ + trigonometric_model.cpp \ ) i18n_files += $(addprefix apps/regression/,\ @@ -46,4 +46,4 @@ tests += $(addprefix apps/regression/test/,\ model.cpp\ ) -app_images += apps/regression/regression_icon.png +$(eval $(call depends_on_image,apps/regression/app.cpp,apps/regression/regression_icon.png)) diff --git a/apps/sequence/Makefile b/apps/sequence/Makefile index 76354d74c..149b48e4e 100644 --- a/apps/sequence/Makefile +++ b/apps/sequence/Makefile @@ -1,26 +1,26 @@ apps += Sequence::App app_headers += apps/sequence/app.h -app_objs += $(addprefix apps/sequence/,\ - app.o\ - graph/banner_view.o\ - graph/curve_parameter_controller.o\ - graph/curve_view_range.o\ - graph/go_to_parameter_controller.o\ - graph/graph_controller.o\ - graph/graph_view.o\ - graph/term_sum_controller.o\ - list/list_controller.o\ - list/list_parameter_controller.o\ - list/sequence_toolbox.o\ - list/type_parameter_controller.o\ - values/interval_parameter_controller.o\ - values/values_controller.o\ - cache_context.o\ - sequence.o\ - sequence_context.o\ - sequence_store.o\ - sequence_title_cell.o\ +app_src += $(addprefix apps/sequence/,\ + app.cpp \ + graph/banner_view.cpp \ + graph/curve_parameter_controller.cpp \ + graph/curve_view_range.cpp \ + graph/go_to_parameter_controller.cpp \ + graph/graph_controller.cpp \ + graph/graph_view.cpp \ + graph/term_sum_controller.cpp \ + list/list_controller.cpp \ + list/list_parameter_controller.cpp \ + list/sequence_toolbox.cpp \ + list/type_parameter_controller.cpp \ + values/interval_parameter_controller.cpp \ + values/values_controller.cpp \ + cache_context.cpp \ + sequence.cpp \ + sequence_context.cpp \ + sequence_store.cpp \ + sequence_title_cell.cpp \ ) i18n_files += $(addprefix apps/sequence/,\ @@ -35,4 +35,4 @@ tests += $(addprefix apps/sequence/test/,\ sequence.cpp\ ) -app_images += apps/sequence/sequence_icon.png +$(eval $(call depends_on_image,apps/sequence/app.cpp,apps/sequence/sequence_icon.png)) diff --git a/apps/settings/Makefile b/apps/settings/Makefile index d19995855..7061f6951 100644 --- a/apps/settings/Makefile +++ b/apps/settings/Makefile @@ -1,17 +1,17 @@ apps += Settings::App app_headers += apps/settings/app.h -app_objs += $(addprefix apps/settings/,\ - app.o\ - main_controller.o\ - settings_message_tree.o\ - sub_menu/about_controller.o\ - sub_menu/display_mode_controller.o\ - sub_menu/exam_mode_controller.o\ - sub_menu/generic_sub_controller.o\ - sub_menu/language_controller.o\ - sub_menu/message_table_cell_with_editable_text_with_separator.o\ - sub_menu/preferences_controller.o\ +app_src += $(addprefix apps/settings/,\ + app.cpp \ + main_controller.cpp \ + settings_message_tree.cpp \ + sub_menu/about_controller.cpp \ + sub_menu/display_mode_controller.cpp \ + sub_menu/exam_mode_controller.cpp \ + sub_menu/generic_sub_controller.cpp \ + sub_menu/language_controller.cpp \ + sub_menu/message_table_cell_with_editable_text_with_separator.cpp \ + sub_menu/preferences_controller.cpp \ ) i18n_files += $(addprefix apps/settings/,\ @@ -22,4 +22,4 @@ i18n_files += $(addprefix apps/settings/,\ base.pt.i18n\ ) -app_images += apps/settings/settings_icon.png +$(eval $(call depends_on_image,apps/settings/app.cpp,apps/settings/settings_icon.png)) diff --git a/apps/shared/Makefile b/apps/shared/Makefile index db1d6dd7f..93e7e4d52 100644 --- a/apps/shared/Makefile +++ b/apps/shared/Makefile @@ -1,88 +1,88 @@ -app_objs += $(addprefix apps/shared/,\ - banner_view.o\ - buffer_function_title_cell.o\ - buffer_text_view_with_text_field.o\ - button_with_separator.o\ - cursor_view.o\ - curve_view.o\ - curve_view_cursor.o\ - curve_view_range.o\ - double_pair_store.o\ - editable_cell_table_view_controller.o\ - expression_field_delegate_app.o\ - expression_model.o\ - expression_model_list_controller.o\ - expression_model_store.o\ - float_parameter_controller.o\ - function.o\ - function_app.o\ - function_banner_delegate.o\ - function_curve_parameter_controller.o\ - function_expression_cell.o\ - function_go_to_parameter_controller.o\ - function_graph_view.o\ - function_graph_controller.o\ - function_list_controller.o\ - function_store.o\ - function_title_cell.o\ - global_context.o\ - go_to_parameter_controller.o\ - hideable_even_odd_cell.o\ - hideable_even_odd_editable_text_cell.o\ - initialisation_parameter_controller.o\ - input_event_handler_delegate_app.o\ - interactive_curve_view_controller.o\ - interactive_curve_view_range.o\ - interactive_curve_view_range_delegate.o\ - interval.o\ - interval_parameter_controller.o\ - language_controller.o\ - layout_field_delegate.o\ - list_parameter_controller.o\ - margin_even_odd_message_text_cell.o\ - memoized_curve_view_range.o\ - message_view.o\ - ok_view.o\ - parameter_text_field_delegate.o\ - range_parameter_controller.o\ - regular_table_view_data_source.o\ - round_cursor_view.o\ - scrollable_exact_approximate_expressions_cell.o\ - scrollable_exact_approximate_expressions_view.o\ - separator_even_odd_buffer_text_cell.o\ - simple_interactive_curve_view_controller.o\ - storage_cartesian_function.o\ - storage_expression_model.o\ - storage_expression_model_store.o\ - storage_expression_model_list_controller.o\ - storage_function.o\ - storage_function_app.o\ - storage_function_banner_delegate.o\ - storage_function_curve_parameter_controller.o\ - storage_function_go_to_parameter_controller.o\ - storage_function_graph_controller.o\ - storage_function_graph_view.o\ - storage_function_list_controller.o\ - storage_function_store.o\ - storage_list_parameter_controller.o\ - storage_sum_graph_controller.o\ - storage_values_function_parameter_controller.o\ - storage_values_controller.o\ - store_cell.o\ - store_context.o\ - store_controller.o\ - store_parameter_controller.o\ - store_selectable_table_view.o\ - store_title_cell.o\ - sum_graph_controller.o\ - tab_table_controller.o\ - text_field_delegate.o\ - text_field_delegate_app.o\ - text_field_with_extension.o\ - toolbox_helpers.o\ - values_function_parameter_controller.o\ - values_parameter_controller.o\ - values_controller.o\ - vertical_cursor_view.o\ - zoom_parameter_controller.o\ +app_src += $(addprefix apps/shared/,\ + banner_view.cpp \ + buffer_function_title_cell.cpp \ + buffer_text_view_with_text_field.cpp \ + button_with_separator.cpp \ + cursor_view.cpp \ + curve_view.cpp \ + curve_view_cursor.cpp \ + curve_view_range.cpp \ + double_pair_store.cpp \ + editable_cell_table_view_controller.cpp \ + expression_field_delegate_app.cpp \ + expression_model.cpp \ + expression_model_list_controller.cpp \ + expression_model_store.cpp \ + float_parameter_controller.cpp \ + function.cpp \ + function_app.cpp \ + function_banner_delegate.cpp \ + function_curve_parameter_controller.cpp \ + function_expression_cell.cpp \ + function_go_to_parameter_controller.cpp \ + function_graph_controller.cpp \ + function_graph_view.cpp \ + function_list_controller.cpp \ + function_store.cpp \ + function_title_cell.cpp \ + global_context.cpp \ + go_to_parameter_controller.cpp \ + hideable_even_odd_cell.cpp \ + hideable_even_odd_editable_text_cell.cpp \ + initialisation_parameter_controller.cpp \ + input_event_handler_delegate_app.cpp \ + interactive_curve_view_controller.cpp \ + interactive_curve_view_range.cpp \ + interactive_curve_view_range_delegate.cpp \ + interval.cpp \ + interval_parameter_controller.cpp \ + language_controller.cpp \ + layout_field_delegate.cpp \ + list_parameter_controller.cpp \ + margin_even_odd_message_text_cell.cpp \ + memoized_curve_view_range.cpp \ + message_view.cpp \ + ok_view.cpp \ + parameter_text_field_delegate.cpp \ + range_parameter_controller.cpp \ + regular_table_view_data_source.cpp \ + round_cursor_view.cpp \ + scrollable_exact_approximate_expressions_cell.cpp \ + scrollable_exact_approximate_expressions_view.cpp \ + separator_even_odd_buffer_text_cell.cpp \ + simple_interactive_curve_view_controller.cpp \ + storage_cartesian_function.cpp \ + storage_expression_model.cpp \ + storage_expression_model_list_controller.cpp \ + storage_expression_model_store.cpp \ + storage_function.cpp \ + storage_function_app.cpp \ + storage_function_banner_delegate.cpp \ + storage_function_curve_parameter_controller.cpp \ + storage_function_go_to_parameter_controller.cpp \ + storage_function_graph_controller.cpp \ + storage_function_graph_view.cpp \ + storage_function_list_controller.cpp \ + storage_function_store.cpp \ + storage_list_parameter_controller.cpp \ + storage_sum_graph_controller.cpp \ + storage_values_controller.cpp \ + storage_values_function_parameter_controller.cpp \ + store_cell.cpp \ + store_context.cpp \ + store_controller.cpp \ + store_parameter_controller.cpp \ + store_selectable_table_view.cpp \ + store_title_cell.cpp \ + sum_graph_controller.cpp \ + tab_table_controller.cpp \ + text_field_delegate.cpp \ + text_field_delegate_app.cpp \ + text_field_with_extension.cpp \ + toolbox_helpers.cpp \ + values_controller.cpp \ + values_function_parameter_controller.cpp \ + values_parameter_controller.cpp \ + vertical_cursor_view.cpp \ + zoom_parameter_controller.cpp \ ) diff --git a/apps/solver/Makefile b/apps/solver/Makefile index a15ab0b36..a87822ad6 100644 --- a/apps/solver/Makefile +++ b/apps/solver/Makefile @@ -1,15 +1,15 @@ apps += Solver::App app_headers += apps/solver/app.h -app_objs += $(addprefix apps/solver/,\ - app.o\ - equation_models_parameter_controller.o\ - equation.o\ - equation_list_view.o\ - equation_store.o\ - interval_controller.o\ - list_controller.o\ - solutions_controller.o\ +app_src += $(addprefix apps/solver/,\ + app.cpp \ + equation_models_parameter_controller.cpp \ + equation.cpp \ + equation_list_view.cpp \ + equation_store.cpp \ + interval_controller.cpp \ + list_controller.cpp \ + solutions_controller.cpp \ ) i18n_files += $(addprefix apps/solver/,\ @@ -24,4 +24,4 @@ tests += $(addprefix apps/solver/test/,\ equation_store.cpp\ ) -app_images += apps/solver/solver_icon.png +$(eval $(call depends_on_image,apps/solver/app.cpp,apps/solver/solver_icon.png)) diff --git a/apps/statistics/Makefile b/apps/statistics/Makefile index 424fb48c0..8e5fa5b7d 100644 --- a/apps/statistics/Makefile +++ b/apps/statistics/Makefile @@ -1,26 +1,26 @@ apps += Statistics::App app_headers += apps/statistics/app.h -app_objs += $(addprefix apps/statistics/,\ - app.o\ - box_axis_view.o\ - box_banner_view.o\ - box_controller.o\ - box_range.o\ - box_view.o\ - calculation_controller.o\ - calculation_selectable_table_view.o\ - histogram_banner_view.o\ - histogram_controller.o\ - histogram_parameter_controller.o\ - histogram_view.o\ - multiple_boxes_view.o\ - multiple_data_view.o\ - multiple_data_view_controller.o\ - multiple_histograms_view.o\ - statistics_context.o\ - store.o\ - store_controller.o\ +app_src += $(addprefix apps/statistics/,\ + app.cpp \ + box_axis_view.cpp \ + box_banner_view.cpp \ + box_controller.cpp \ + box_range.cpp \ + box_view.cpp \ + calculation_controller.cpp \ + calculation_selectable_table_view.cpp \ + histogram_banner_view.cpp \ + histogram_controller.cpp \ + histogram_parameter_controller.cpp \ + histogram_view.cpp \ + multiple_boxes_view.cpp \ + multiple_data_view.cpp \ + multiple_data_view_controller.cpp \ + multiple_histograms_view.cpp \ + statistics_context.cpp \ + store.cpp \ + store_controller.cpp \ ) i18n_files += $(addprefix apps/statistics/,\ @@ -35,4 +35,4 @@ tests += $(addprefix apps/statistics/test/,\ store.cpp\ ) -app_images += apps/statistics/stat_icon.png +$(eval $(call depends_on_image,apps/statistics/app.cpp,apps/statistics/stat_icon.png)) diff --git a/apps/usb/Makefile b/apps/usb/Makefile index 0bb37aa5f..45c6e0d8d 100644 --- a/apps/usb/Makefile +++ b/apps/usb/Makefile @@ -1,6 +1,6 @@ -app_objs += $(addprefix apps/usb/,\ - app.o\ - usb_connected_controller.o\ +app_src += $(addprefix apps/usb/,\ + app.cpp \ + usb_connected_controller.cpp \ ) i18n_files += $(addprefix apps/usb/,\ diff --git a/escher/Makefile b/escher/Makefile index 3c96dcd46..12aee399e 100644 --- a/escher/Makefile +++ b/escher/Makefile @@ -1,102 +1,118 @@ SFLAGS += -Iescher/include -objs += $(addprefix escher/src/,\ - alternate_empty_view_controller.o\ - app.o\ - bank_view_controller.o\ - buffer_text_view.o\ - button.o\ - button_row_controller.o\ - chevron_view.o\ - clipboard.o\ - container.o\ - editable_text_cell.o\ - ellipsis_view.o\ - expression_field.o\ - even_odd_cell.o\ - even_odd_cell_with_ellipsis.o\ - even_odd_buffer_text_cell.o\ - even_odd_editable_text_cell.o\ - even_odd_expression_cell.o\ - even_odd_message_text_cell.o\ - expression_table_cell.o\ - expression_table_cell_with_pointer.o\ - expression_table_cell_with_expression.o\ - expression_view.o\ - highlight_cell.o\ - gauge_view.o\ - image_view.o\ - input_event_handler.o\ - invocation.o\ - input_view_controller.o\ - key_view.o\ - layout_field.o\ - list_view_data_source.o\ - message_table_cell.o\ - message_table_cell_with_buffer.o\ - message_table_cell_with_chevron.o\ - message_table_cell_with_chevron_and_message.o\ - message_table_cell_with_chevron_and_expression.o\ - message_table_cell_with_editable_text.o\ - message_table_cell_with_expression.o\ - message_table_cell_with_gauge.o\ - message_table_cell_with_message.o\ - message_table_cell_with_switch.o\ - message_text_view.o\ - message_tree.o\ - modal_view_controller.o\ - nested_menu_controller.o\ - palette.o\ - pointer_text_view.o\ - responder.o\ - run_loop.o\ - scroll_view.o\ - scroll_view_data_source.o\ - scroll_view_indicator.o\ - scrollable_view.o\ - selectable_table_view.o\ - selectable_table_view_data_source.o\ - selectable_table_view_delegate.o\ - simple_list_view_data_source.o\ - simple_table_view_data_source.o\ - solid_color_view.o\ - solid_text_area.o\ - stack_view.o\ - stack_view_controller.o\ - switch_view.o\ - tab_view.o\ - tab_view_cell.o\ - tab_view_controller.o\ - tab_view_data_source.o\ - table_cell.o\ - table_view.o\ - table_view_data_source.o\ - text_cursor_view.o\ - text_area.o\ - text_field.o\ - text_input.o\ - text_input_helpers.o\ - text_view.o\ - tiled_view.o\ - timer.o\ - toolbox.o\ - transparent_view.o\ - view.o\ - view_controller.o\ - warning_controller.o\ - window.o\ +src += $(addprefix escher/src/,\ + alternate_empty_view_controller.cpp \ + app.cpp \ + bank_view_controller.cpp \ + buffer_text_view.cpp \ + button.cpp \ + button_row_controller.cpp \ + chevron_view.cpp \ + clipboard.cpp \ + container.cpp \ + editable_text_cell.cpp \ + ellipsis_view.cpp \ + expression_field.cpp \ + even_odd_cell.cpp \ + even_odd_cell_with_ellipsis.cpp \ + even_odd_buffer_text_cell.cpp \ + even_odd_editable_text_cell.cpp \ + even_odd_expression_cell.cpp \ + even_odd_message_text_cell.cpp \ + expression_table_cell.cpp \ + expression_table_cell_with_pointer.cpp \ + expression_table_cell_with_expression.cpp \ + expression_view.cpp \ + highlight_cell.cpp \ + gauge_view.cpp \ + image_view.cpp \ + input_event_handler.cpp \ + invocation.cpp \ + input_view_controller.cpp \ + key_view.cpp \ + layout_field.cpp \ + list_view_data_source.cpp \ + message_table_cell.cpp \ + message_table_cell_with_buffer.cpp \ + message_table_cell_with_chevron.cpp \ + message_table_cell_with_chevron_and_message.cpp \ + message_table_cell_with_chevron_and_expression.cpp \ + message_table_cell_with_editable_text.cpp \ + message_table_cell_with_expression.cpp \ + message_table_cell_with_gauge.cpp \ + message_table_cell_with_message.cpp \ + message_table_cell_with_switch.cpp \ + message_text_view.cpp \ + message_tree.cpp \ + modal_view_controller.cpp \ + nested_menu_controller.cpp \ + palette.cpp \ + pointer_text_view.cpp \ + responder.cpp \ + run_loop.cpp \ + scroll_view.cpp \ + scroll_view_data_source.cpp \ + scroll_view_indicator.cpp \ + scrollable_view.cpp \ + selectable_table_view.cpp \ + selectable_table_view_data_source.cpp \ + selectable_table_view_delegate.cpp \ + simple_list_view_data_source.cpp \ + simple_table_view_data_source.cpp \ + solid_color_view.cpp \ + solid_text_area.cpp \ + stack_view.cpp \ + stack_view_controller.cpp \ + switch_view.cpp \ + tab_view.cpp \ + tab_view_cell.cpp \ + tab_view_controller.cpp \ + tab_view_data_source.cpp \ + table_cell.cpp \ + table_view.cpp \ + table_view_data_source.cpp \ + text_cursor_view.cpp \ + text_area.cpp \ + text_field.cpp \ + text_input.cpp \ + text_input_helpers.cpp \ + text_view.cpp \ + tiled_view.cpp \ + timer.cpp \ + toolbox.cpp \ + transparent_view.cpp \ + view.cpp \ + view_controller.cpp \ + warning_controller.cpp \ + window.cpp \ ) -INLINER := escher/image/inliner -$(INLINER): escher/image/inliner.c $(addprefix ion/src/external/lz4/, lz4.c lz4hc.c) - @echo "HOSTCC $@" - $(Q) $(HOSTCC) -std=c99 `libpng-config --cflags` $^ `libpng-config --ldflags` -o $@ +$(eval $(call rule_for, \ + HOSTCC, \ + escher/image/inliner, \ + escher/image/inliner.c $(addprefix ion/src/external/lz4/, lz4.c lz4hc.c), \ + $$(HOSTCC) -std=c99 `libpng-config --cflags` $$^ `libpng-config --ldflags` -o $$@ \ +)) -%.h %.cpp : %.png $(INLINER) - @echo "INLINER $@" - $(Q) $(INLINER) $< +INLINER := $(OUTPUT_DIRECTORY)/escher/image/inliner -INLINER_PRODUCTS = $(1:.png=.h) $(1:.png=.cpp) $(1:.png=.o) +.PRECIOUS: $(OUTPUT_DIRECTORY)/%.h $(OUTPUT_DIRECTORY)/%.cpp +$(eval $(call rule_for, \ + INLINER, \ + %.h %.cpp, \ + %.png $$(INLINER), \ + $$(INLINER) $$< $$(basename $$@).h $$(basename $$@).cpp \ +)) -products += $(INLINER) +# Mark a .cpp file as depending on a .png one +# This is called with $1 = code.cpp and $2 = image.png +# First, we mark code.o as requiring image.o. Rules will take care of inlining +# the PNG and building the inlined cpp file. Second, we add the directory +# corresponding to the one of code.cpp in the output dir as a header search +# path. Since $1 can be a list, we have to map with foreach. +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) +endef diff --git a/escher/image/inliner.c b/escher/image/inliner.c index 4f3a4290b..67d983feb 100644 --- a/escher/image/inliner.c +++ b/escher/image/inliner.c @@ -16,7 +16,7 @@ #include #include "../../ion/src/external/lz4/lz4hc.h" -#define ERROR_IF(cond, message) if (cond) { printf(message); return -1; }; +#define ERROR_IF(cond, message) if (cond) { printf(message "\n"); return -1; }; #define MAX_FILENAME_LENGTH 255 void generateHeaderFromImage(FILE * file, const char * guardian, const char * variable); @@ -29,7 +29,7 @@ void camelCaseNameFromSnakeCaseNames(const char * snakeCaseName, const char * up // TODO: truncate the app image dimensions to 55x56 pixels int main(int argc, char * argv[]) { - ERROR_IF(argc != 2, "Usage: inliner source.png"); + ERROR_IF(argc != 4, "Usage: inliner source.png output.h output.cpp"); const char * inputPath = argv[1]; FILE * inputFile = fopen(inputPath, "rb"); @@ -79,6 +79,7 @@ int main(int argc, char * argv[]) { snakeCaseNameToUpperSnakeName(lowerSnakeCaseName, upperSnakeCaseName, MAX_FILENAME_LENGTH); camelCaseNameFromSnakeCaseNames(lowerSnakeCaseName, upperSnakeCaseName, camelCaseName, MAX_FILENAME_LENGTH); + /* char headerPath[MAX_FILENAME_LENGTH]; size_t pathLength = strlen(inputPath); strcpy(headerPath, inputPath); @@ -92,6 +93,9 @@ int main(int argc, char * argv[]) { implementationPath[pathLength-3] = 'c'; implementationPath[pathLength-2] = 'p'; implementationPath[pathLength-1] = 'p'; + */ + char * headerPath = argv[2]; + char * implementationPath = argv[3]; FILE * header = fopen(headerPath, "w"); generateHeaderFromImage(header, upperSnakeCaseName, camelCaseName); diff --git a/ion/Makefile b/ion/Makefile index e123b4595..5dbe116b6 100644 --- a/ion/Makefile +++ b/ion/Makefile @@ -14,17 +14,17 @@ include ion/src/shared/tools/Makefile # char test[4]= "ab"; is valid and should initialize test to 'a','b',0,0). # Older versions of GCC are not conformant so we resort to an initializer list. initializer_list = $(shell echo $(1) | sed "s/\(.\)/'\1',/g")0 -ion/src/shared/platform_info.o: SFLAGS += -DPATCH_LEVEL="$(call initializer_list,$(PATCH_LEVEL))" -DEPSILON_VERSION="$(call initializer_list,$(EPSILON_VERSION))" +$(call object_for,ion/src/shared/platform_info.cpp): SFLAGS += -DPATCH_LEVEL="$(call initializer_list,$(PATCH_LEVEL))" -DEPSILON_VERSION="$(call initializer_list,$(EPSILON_VERSION))" -objs += $(addprefix ion/src/shared/, \ - crc32_padded.o\ - events.o \ - platform_info.o \ - storage.o \ - decompress.o \ +src += $(addprefix ion/src/shared/, \ + crc32_padded.cpp \ + decompress.cpp \ + events.cpp \ + platform_info.cpp \ + storage.cpp \ ) -objs += ion/src/external/lz4/lz4.o +src += ion/src/external/lz4/lz4.c tests += $(addprefix ion/test/,\ crc32.cpp\ diff --git a/ion/src/device/Makefile b/ion/src/device/Makefile index 3d243bd47..d6f784acc 100644 --- a/ion/src/device/Makefile +++ b/ion/src/device/Makefile @@ -2,35 +2,35 @@ include ion/src/device/boot/Makefile include ion/src/device/bench/Makefile include ion/src/device/usb/Makefile -ion/src/shared/platform_info.o: SFLAGS += -DHEADER_SECTION="__attribute__((section(\".header\")))" +$(call object_for,ion/src/shared/platform_info.cpp): SFLAGS += -DHEADER_SECTION="__attribute__((section(\".header\")))" -objs += $(addprefix ion/src/shared/, \ - console_line.o \ - crc32_padded.o\ - events_modifier.o \ +src += $(addprefix ion/src/shared/, \ + console_line.cpp \ + crc32_padded.cpp \ + events_modifier.cpp \ ) # If you need to profile execution, you can replace events_keyboard with # events_replay.o and dummy/events_modifier.o -objs += $(addprefix ion/src/device/, \ - backlight.o \ - battery.o\ - base64.o\ - console.o \ - device.o\ - display.o\ - events.o\ - flash.o\ - keyboard.o\ - led.o\ - power.o\ - sd_card.o\ - stack.o\ - swd.o \ - timing.o \ - usb.o \ - wakeup.o \ +src += $(addprefix ion/src/device/, \ + backlight.cpp \ + battery.cpp \ + base64.cpp \ + console.cpp \ + device.cpp \ + display.cpp \ + events.cpp \ + flash.cpp \ + keyboard.cpp \ + led.cpp \ + power.cpp \ + sd_card.cpp \ + stack.cpp \ + swd.cpp \ + timing.cpp \ + usb.cpp \ + wakeup.cpp \ ) # When using the register.h C++ file in production mode, we expect the compiler @@ -41,10 +41,10 @@ objs += $(addprefix ion/src/device/, \ ifneq ($(DEBUG),1) ifneq ($(COMPILER),llvm) -ion/src/device/led.o: SFLAGS+=-O3 -ion/src/device/console.o: SFLAGS+=-O3 -ion/src/device/display.o: SFLAGS+=-O3 -ion/src/device/swd.o: SFLAGS+=-O3 +$(OUTPUT_DIRECTORY)/ion/src/device/led.o: SFLAGS+=-O3 +$(OUTPUT_DIRECTORY)/ion/src/device/console.o: SFLAGS+=-O3 +$(OUTPUT_DIRECTORY)/ion/src/device/display.o: SFLAGS+=-O3 +$(OUTPUT_DIRECTORY)/ion/src/device/swd.o: SFLAGS+=-O3 endif endif diff --git a/ion/src/device/bench/Makefile b/ion/src/device/bench/Makefile index 90b0c82b6..c882e1393 100644 --- a/ion/src/device/bench/Makefile +++ b/ion/src/device/bench/Makefile @@ -1,21 +1,21 @@ -objs += $(addprefix ion/src/device/bench/, \ - bench.o \ - command_handler.o \ - command_list.o \ +src += $(addprefix ion/src/device/bench/, \ + bench.cpp \ + command_handler.cpp \ + command_list.cpp \ ) -objs += $(addprefix ion/src/device/bench/command/, \ - command.o \ - adc.o \ - backlight.o \ - charge.o \ - display.o \ - exit.o \ - keyboard.o \ - led.o \ - mcu_serial.o \ - ping.o \ - print.o \ - suspend.o \ - vblank.o \ +src += $(addprefix ion/src/device/bench/command/, \ + adc.cpp \ + backlight.cpp \ + charge.cpp \ + command.cpp \ + display.cpp \ + exit.cpp \ + keyboard.cpp \ + led.cpp \ + mcu_serial.cpp \ + ping.cpp \ + print.cpp \ + suspend.cpp \ + vblank.cpp \ ) diff --git a/ion/src/device/boot/Makefile b/ion/src/device/boot/Makefile index ded572acd..275c45bb5 100644 --- a/ion/src/device/boot/Makefile +++ b/ion/src/device/boot/Makefile @@ -1,2 +1,2 @@ -objs += $(addprefix ion/src/device/boot/, isr.o rt0.o) +src += $(addprefix ion/src/device/boot/, isr.c rt0.cpp) LDSCRIPT = ion/src/device/boot/flash.ld diff --git a/ion/src/device/usb/Makefile b/ion/src/device/usb/Makefile index a2d840eef..aca2218de 100644 --- a/ion/src/device/usb/Makefile +++ b/ion/src/device/usb/Makefile @@ -1,67 +1,74 @@ -usb_objs += $(addprefix ion/src/device/usb/, \ - calculator.o \ - dfu_interface.o\ +usb_src += $(addprefix ion/src/device/usb/, \ + calculator.cpp \ + dfu_interface.cpp \ ) -usb_objs += $(addprefix ion/src/device/usb/stack/, \ - device.o\ - endpoint0.o \ - interface.o\ - request_recipient.o\ - setup_packet.o\ - streamable.o\ +usb_src += $(addprefix ion/src/device/usb/stack/, \ + device.cpp \ + endpoint0.cpp \ + interface.cpp \ + request_recipient.cpp \ + setup_packet.cpp \ + streamable.cpp \ ) -usb_objs += $(addprefix ion/src/device/usb/stack/descriptor/, \ - bos_descriptor.o\ - configuration_descriptor.o \ - descriptor.o\ - device_descriptor.o\ - device_capability_descriptor.o\ - dfu_functional_descriptor.o\ - extended_compat_id_descriptor.o \ - interface_descriptor.o\ - language_id_string_descriptor.o \ - microsoft_os_string_descriptor.o\ - platform_device_capability_descriptor.o\ - string_descriptor.o\ - url_descriptor.o\ - webusb_platform_descriptor.o\ +usb_src += $(addprefix ion/src/device/usb/stack/descriptor/, \ + bos_descriptor.cpp \ + configuration_descriptor.cpp \ + descriptor.cpp \ + device_capability_descriptor.cpp \ + device_descriptor.cpp \ + dfu_functional_descriptor.cpp \ + extended_compat_id_descriptor.cpp \ + interface_descriptor.cpp \ + language_id_string_descriptor.cpp \ + microsoft_os_string_descriptor.cpp \ + platform_device_capability_descriptor.cpp \ + string_descriptor.cpp \ + url_descriptor.cpp \ + webusb_platform_descriptor.cpp \ ) EPSILON_USB_DFU_XIP ?= 0 ifeq ($(EPSILON_USB_DFU_XIP),1) -objs += ion/src/device/usb/dfu_xip.o -objs += $(usb_objs) +src += ion/src/device/usb/dfu_xip.cpp +src += $(usb_src) else -dfu_objs += liba/src/assert.o -dfu_objs += liba/src/strlen.o -dfu_objs += liba/src/strlcpy.o -dfu_objs += liba/src/memset.o -dfu_objs += liba/src/memcpy.o -dfu_objs += libaxx/src/cxxabi/pure_virtual.o -dfu_objs += ion/src/device/usb/boot.o -dfu_objs += ion/src/device/keyboard.o -dfu_objs += ion/src/device/device.o -dfu_objs += ion/src/device/usb.o -dfu_objs += ion/src/device/base64.o -dfu_objs += ion/src/device/flash.o -dfu_objs += ion/src/device/timing.o +dfu_src += liba/src/assert.cpp +dfu_src += liba/src/strlen.cpp +dfu_src += liba/src/strlcpy.cpp +dfu_src += liba/src/memset.cpp +dfu_src += liba/src/memcpy.cpp +dfu_src += libaxx/src/cxxabi/pure_virtual.cpp +dfu_src += ion/src/device/usb/boot.cpp +dfu_src += ion/src/device/keyboard.cpp +dfu_src += ion/src/device/device.cpp +dfu_src += ion/src/device/usb.cpp +dfu_src += ion/src/device/base64.cpp +dfu_src += ion/src/device/flash.cpp +dfu_src += ion/src/device/timing.cpp -ion/src/device/usb/dfu.elf: LDSCRIPT = ion/src/device/usb/dfu.ld -ion/src/device/usb/dfu.elf: $(usb_objs) $(dfu_objs) +$(OUTPUT_DIRECTORY)/ion/src/device/usb/dfu.elf: LDSCRIPT = ion/src/device/usb/dfu.ld +$(OUTPUT_DIRECTORY)/ion/src/device/usb/dfu.elf: $(call object_for,$(usb_src)) $(call object_for,$(dfu_src)) -ion/src/device/usb/dfu.o: ion/src/device/usb/dfu.bin +# This command embeds a binary file into an object one. +# This allows us to embed standalone code (the dfu routines) into the final +# executable, and easily relocate it to RAM for execution. The objcopy command +# that turns binary data into an ELF object generates three symbols (start, size +# and end), but prefixes them with a mangled file path. To have consistent names +# we simply "cd" into the directory. This assumes input and output lives in the +# same directory. +$(OUTPUT_DIRECTORY)/ion/src/device/usb/dfu.o: $(OUTPUT_DIRECTORY)/ion/src/device/usb/dfu.bin @echo "OBJCOPY $@" - $(Q) $(OBJCOPY) -I binary -O elf32-littlearm -B arm --rename-section .data=.rodata --redefine-sym _binary_ion_src_device_usb_dfu_bin_start=_dfu_bootloader_flash_start --redefine-sym _binary_ion_src_device_usb_dfu_bin_end=_dfu_bootloader_flash_end $< $@ + $(Q) cd $(dir $<) ; $(OBJCOPY) -I binary -O elf32-littlearm -B arm --rename-section .data=.rodata --redefine-sym _binary_dfu_bin_start=_dfu_bootloader_flash_start --redefine-sym _binary_dfu_bin_end=_dfu_bootloader_flash_end $(notdir $<) $(notdir $@) -objs += ion/src/device/usb/dfu.o -objs += ion/src/device/usb/dfu_relocated.o +src += ion/src/device/usb/dfu.cpp +src += ion/src/device/usb/dfu_relocated.cpp -products += $(usb_objs) $(addprefix ion/src/device/usb/dfu, .elf .bin) +#products += $(usb_objs) $(addprefix ion/src/device/usb/dfu, .elf .bin) endif diff --git a/kandinsky/Makefile b/kandinsky/Makefile index 5c23b1b64..d9d3793ea 100644 --- a/kandinsky/Makefile +++ b/kandinsky/Makefile @@ -1,19 +1,23 @@ SFLAGS += -Ikandinsky/include -objs += $(addprefix kandinsky/src/,\ - color.o\ - context.o\ - context_line.o\ - context_pixel.o\ - context_rect.o\ - context_text.o\ - font.o\ - font_large.o\ - font_small.o\ - framebuffer.o\ - framebuffer_context.o\ - ion_context.o\ - point.o\ - rect.o\ + +src += $(addprefix kandinsky/src/,\ + color.cpp \ + context.cpp \ + context_line.cpp \ + context_pixel.cpp \ + context_rect.cpp \ + context_text.cpp \ + font.cpp \ + framebuffer.cpp \ + framebuffer_context.cpp \ + ion_context.cpp \ + point.cpp \ + rect.cpp \ +) + +src += $(addprefix kandinsky/fonts/, \ + LargeSourcePixel.ttf \ + SmallSourcePixel.ttf \ ) tests += $(addprefix kandinsky/test/,\ @@ -21,14 +25,6 @@ tests += $(addprefix kandinsky/test/,\ rect.cpp\ ) -FREETYPE_PATH := /usr/local/Cellar/freetype/2.6.3 -# LIBPNG_PATH is optional. If LIBPNG_PATH is not defined, rasterizer will be -# built w/o PNG support and simply won't output an image of the rasterization -#LIBPNG_PATH := /usr/local/Cellar/libpng/1.6.21 - -small_font_files = $(addprefix kandinsky/src/, font_small.cpp) -large_font_files = $(addprefix kandinsky/src/, font_large.cpp) - RASTERIZER_CFLAGS := -std=c99 `pkg-config freetype2 --cflags` RASTERIZER_LDFLAGS := `pkg-config freetype2 --libs` @@ -38,20 +34,25 @@ ifdef LIBPNG_PATH RASTERIZER_CFLAGS += -I$(LIBPNG_PATH)/include -DGENERATE_PNG=1 -L$(LIBPNG_PATH)/lib -lpng endif -# Even though raster will generate both .c and .h files, we don't declare it as -# such to make. If we did, "make -jN" with N>1 may call "raster" twice. +$(eval $(call rule_for, \ + HOSTCC, \ + kandinsky/fonts/rasterizer, \ + kandinsky/fonts/rasterizer.c kandinsky/fonts/unicode_for_symbol.c $(addprefix ion/src/external/lz4/, lz4.c lz4hc.c), \ + $$(HOSTCC) $$(RASTERIZER_CFLAGS) $$^ $$(RASTERIZER_LDFLAGS) -o $$@ \ +)) -kandinsky/src/font_small.cpp: kandinsky/fonts/rasterizer - @echo "RASTER $(small_font_files)" - $(Q) $< kandinsky/fonts/SmallSourcePixel.ttf 12 12 SmallFont $(small_font_files) +RASTERIZER := $(OUTPUT_DIRECTORY)/kandinsky/fonts/rasterizer -kandinsky/src/font_large.cpp: kandinsky/fonts/rasterizer - @echo "RASTER $(large_font_files)" - $(Q) $< kandinsky/fonts/LargeSourcePixel.ttf 16 16 LargeFont $(large_font_files) - -kandinsky/fonts/rasterizer: kandinsky/fonts/rasterizer.c kandinsky/fonts/unicode_for_symbol.c $(addprefix ion/src/external/lz4/, lz4.c lz4hc.c) - @echo "HOSTCC $@" - $(Q) $(HOSTCC) $(RASTERIZER_CFLAGS) $^ $(RASTERIZER_LDFLAGS) -o $@ - -products += $(small_font_files) $(large_font_files) kandinsky/fonts/rasterizer +$(eval $(call rule_for, \ + RASTER, \ + kandinsky/fonts/SmallSourcePixel.cpp, \ + kandinsky/fonts/SmallSourcePixel.ttf $$(RASTERIZER), \ + $$(RASTERIZER) $$< 12 12 SmallFont $$@ \ +)) +$(eval $(call rule_for, \ + RASTER, \ + kandinsky/fonts/LargeSourcePixel.cpp, \ + kandinsky/fonts/LargeSourcePixel.ttf $$(RASTERIZER), \ + $$(RASTERIZER) $$< 16 16 LargeFont $$@ \ +)) diff --git a/liba/Makefile b/liba/Makefile index da54983c1..96bf3f3bc 100644 --- a/liba/Makefile +++ b/liba/Makefile @@ -1,126 +1,125 @@ SFLAGS += -Iliba/include -liba/src/external/sqlite/mem5.o: CFLAGS += -w - -objs += $(addprefix liba/src/, \ - armv7m/setjmp.o \ - armv7m/longjmp.o \ - assert.o \ - bzero.o \ - ctype.o \ - errno.o \ - fpclassify.o \ - fpclassifyf.o \ - ieee754.o \ - malloc.o \ - memcmp.o \ - memcpy.o \ - memmove.o \ - memset.o \ - nearbyint.o \ - nearbyintf.o \ - strcmp.o \ - strchr.o \ - strlcpy.o \ - strlen.o \ - external/sqlite/mem5.o \ +src += $(addprefix liba/src/, \ + armv7m/setjmp.s \ + armv7m/longjmp.s \ + assert.c \ + bzero.c \ + ctype.c \ + errno.c \ + fpclassify.c \ + fpclassifyf.c \ + ieee754.c \ + malloc.c \ + memcmp.c \ + memcpy.c \ + memmove.c \ + memset.c \ + nearbyint.c \ + nearbyintf.c \ + strcmp.c \ + strchr.c \ + strlcpy.c \ + strlen.c \ + external/sqlite/mem5.c \ ) -objs += $(addprefix liba/src/external/openbsd/, \ - b_exp__D.o \ - b_log__D.o \ - b_tgamma.o \ - e_acosf.o \ - e_acoshf.o \ - e_asinf.o \ - e_atanhf.o \ - e_atan2f.o \ - e_coshf.o \ - e_expf.o \ - e_fmodf.o \ - e_hypotf.o \ - e_lgammaf_r.o \ - e_log10f.o \ - e_log2.o \ - e_logf.o \ - e_powf.o \ - e_rem_pio2f.o \ - e_scalb.o \ - e_sinhf.o \ - e_sqrtf.o \ - k_cosf.o \ - k_rem_pio2f.o \ - k_sinf.o \ - k_tanf.o \ +src += $(addprefix liba/src/external/openbsd/, \ + b_exp__D.c \ + b_log__D.c \ + b_tgamma.c \ + e_acosf.c \ + e_acoshf.c \ + e_asinf.c \ + e_atanhf.c \ + e_atan2f.c \ + e_coshf.c \ + e_expf.c \ + e_fmodf.c \ + e_hypotf.c \ + e_lgammaf_r.c \ + e_log10f.c \ + e_log2.c \ + e_logf.c \ + e_powf.c \ + e_rem_pio2f.c \ + e_scalb.c \ + e_sinhf.c \ + e_sqrtf.c \ + k_cosf.c \ + k_rem_pio2f.c \ + k_sinf.c \ + k_tanf.c \ s_asinhf.o\ - s_atanf.o \ - s_ceilf.o \ - s_copysignf.o \ - s_cosf.o \ - s_erf.o \ + s_atanf.c \ + s_ceilf.c \ + s_copysignf.c \ + s_cosf.c \ + s_erf.c \ s_expm1f.o\ - s_fabsf.o \ - s_fmaxf.o \ - s_floorf.o \ - s_frexpf.o \ - s_frexp.o \ - s_log1pf.o \ - s_logb.o \ - s_modf.o \ - s_modff.o \ - s_rint.o \ - s_roundf.o \ - s_scalbnf.o \ - s_signgam.o \ - s_sinf.o \ - s_tanf.o \ - s_tanhf.o \ - s_trunc.o \ - s_truncf.o \ - w_lgammaf.o \ + s_fabsf.c \ + s_fmaxf.c \ + s_floorf.c \ + s_frexpf.c \ + s_frexp.c \ + s_log1pf.c \ + s_logb.c \ + s_modf.c \ + s_modff.c \ + s_rint.c \ + s_roundf.c \ + s_scalbnf.c \ + s_signgam.c \ + s_sinf.c \ + s_tanf.c \ + s_tanhf.c \ + s_trunc.c \ + s_truncf.c \ + w_lgammaf.c \ ) -objs += $(addprefix liba/src/external/openbsd/, \ - e_acos.o \ - e_acosh.o \ - e_asin.o \ - e_atanh.o \ - e_atan2.o \ - e_cosh.o \ - e_exp.o \ - e_fmod.o \ - e_hypot.o \ - e_lgamma_r.o \ - e_log.o \ - e_log10.o \ - e_pow.o \ - e_rem_pio2.o \ - e_sinh.o \ - e_sqrt.o \ - k_cos.o \ - k_rem_pio2.o \ - k_sin.o \ - k_tan.o \ - s_asinh.o \ - s_atan.o \ - s_ceil.o \ - s_copysign.o \ - s_cos.o \ - s_expm1.o \ - s_fabs.o \ - s_fmax.o \ - s_floor.o \ - s_log1p.o \ - s_round.o \ - s_scalbn.o \ - s_sin.o \ - s_tan.o \ - s_tanh.o \ - w_lgamma.o \ +src += $(addprefix liba/src/external/openbsd/, \ + e_acos.c \ + e_acosh.c \ + e_asin.c \ + e_atanh.c \ + e_atan2.c \ + e_cosh.c \ + e_exp.c \ + e_fmod.c \ + e_hypot.c \ + e_lgamma_r.c \ + e_log.c \ + e_log10.c \ + e_pow.c \ + e_rem_pio2.c \ + e_sinh.c \ + e_sqrt.c \ + k_cos.c \ + k_rem_pio2.c \ + k_sin.c \ + k_tan.c \ + s_asinh.c \ + s_atan.c \ + s_ceil.c \ + s_copysign.c \ + s_cos.c \ + s_expm1.c \ + s_fabs.c \ + s_fmax.c \ + s_floor.c \ + s_log1p.c \ + s_round.c \ + s_scalbn.c \ + s_sin.c \ + s_tan.c \ + s_tanh.c \ + w_lgamma.c \ ) -liba/src/external/openbsd/%.o: SFLAGS := -Iliba/src/external/openbsd/include $(SFLAGS) -liba/src/external/openbsd/%.o: CFLAGS += -w +$(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/, \ aeabi.c \ @@ -136,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. -objs += $(addprefix liba/src/aeabi-rt/, \ - atexit.o \ +src += $(addprefix liba/src/aeabi-rt/, \ + atexit.c \ ) diff --git a/liba/Makefile.bridge b/liba/Makefile.bridge index f9157402a..70e190f58 100644 --- a/liba/Makefile.bridge +++ b/liba/Makefile.bridge @@ -1,3 +1,3 @@ SFLAGS += -Iliba/include/bridge -objs += liba/src/bridge.o +src += liba/src/bridge.c diff --git a/libaxx/Makefile b/libaxx/Makefile index f2e6702f5..fd64e42ea 100644 --- a/libaxx/Makefile +++ b/libaxx/Makefile @@ -1,6 +1,5 @@ SFLAGS += -Ilibaxx/include -objs += $(addprefix libaxx/src/, new.o) -objs += $(addprefix libaxx/src/cxxabi/, atexit.o pure_virtual.o) -objs += $(addprefix libaxx/include/external/libcxx/, complex.o) - +src += $(addprefix libaxx/src/, new.cpp) +src += $(addprefix libaxx/src/cxxabi/, atexit.cpp pure_virtual.cpp) +src += $(addprefix libaxx/include/external/libcxx/, complex.cpp) diff --git a/poincare/Makefile b/poincare/Makefile index 28c3096e6..4a41680f9 100644 --- a/poincare/Makefile +++ b/poincare/Makefile @@ -1,140 +1,138 @@ SFLAGS += -Ipoincare/include -#include poincare/src/simplify/Makefile -#include poincare/src/simplification/Makefile -objs += $(addprefix poincare/src/,\ - binomial_coefficient_layout.o\ - bracket_layout.o\ - bracket_pair_layout.o\ - char_layout.o\ - condensed_sum_layout.o\ - conjugate_layout.o\ - empty_layout.o\ - fraction_layout.o\ - grid_layout.o\ - horizontal_layout.o\ - integral_layout.o\ - layout_cursor.o\ - layout.o\ - layout_node.o\ - left_parenthesis_layout.o\ - left_square_bracket_layout.o\ - matrix_layout.o\ - nth_root_layout.o\ - parenthesis_layout.o\ - product_layout.o\ - right_parenthesis_layout.o\ - right_square_bracket_layout.o\ - sequence_layout.o\ - sum_layout.o\ - vertical_offset_layout.o\ +src += $(addprefix poincare/src/,\ + binomial_coefficient_layout.cpp \ + bracket_layout.cpp \ + bracket_pair_layout.cpp \ + char_layout.cpp \ + condensed_sum_layout.cpp \ + conjugate_layout.cpp \ + empty_layout.cpp \ + fraction_layout.cpp \ + grid_layout.cpp \ + horizontal_layout.cpp \ + integral_layout.cpp \ + layout_cursor.cpp \ + layout.cpp \ + layout_node.cpp \ + left_parenthesis_layout.cpp \ + left_square_bracket_layout.cpp \ + matrix_layout.cpp \ + nth_root_layout.cpp \ + parenthesis_layout.cpp \ + product_layout.cpp \ + right_parenthesis_layout.cpp \ + right_square_bracket_layout.cpp \ + sequence_layout.cpp \ + sum_layout.cpp \ + vertical_offset_layout.cpp \ ) -objs += $(addprefix poincare/src/,\ - init.o\ - exception_checkpoint.o\ - helpers.o\ +src += $(addprefix poincare/src/,\ + init.cpp \ + exception_checkpoint.cpp \ + helpers.cpp \ ) -objs += $(addprefix poincare/src/,\ - absolute_value.o\ - addition.o\ - approximation_helper.o\ - arc_cosine.o\ - arc_sine.o\ - arc_tangent.o\ - arithmetic.o\ - binomial_coefficient.o\ - ceiling.o\ - complex.o\ - complex_argument.o\ - complex_cartesian.o\ - confidence_interval.o\ - conjugate.o\ - constant.o\ - cosine.o\ - decimal.o\ - derivative.o\ - determinant.o\ - division.o\ - division_quotient.o\ - division_remainder.o\ - empty_expression.o\ - equal.o\ - evaluation.o\ - expression.o\ - expression_node.o\ - factor.o\ - factorial.o\ - float.o\ - floor.o\ - frac_part.o\ - function.o\ - great_common_divisor.o\ - hyperbolic_arc_cosine.o\ - hyperbolic_arc_sine.o\ - hyperbolic_arc_tangent.o\ - hyperbolic_cosine.o\ - hyperbolic_sine.o\ - hyperbolic_tangent.o\ - hyperbolic_trigonometric_function.o\ - imaginary_part.o\ - infinity.o\ - integer.o\ - integral.o\ - layout_helper.o\ - least_common_multiple.o\ - logarithm.o\ - matrix.o\ - matrix_complex.o\ - matrix_dimension.o\ - matrix_inverse.o\ - matrix_trace.o\ - matrix_transpose.o\ - multiplication.o\ - n_ary_expression_node.o\ - naperian_logarithm.o\ - nth_root.o\ - number.o\ - opposite.o\ - parametered_expression_helper.o\ - parenthesis.o\ - permute_coefficient.o\ - power.o\ - prediction_interval.o\ - preferences.o\ - print_float.o\ - product.o\ - randint.o\ - random.o\ - rational.o\ - real_part.o\ - round.o\ - sequence.o\ - serialization_helper.o\ - sign_function.o\ - simplification_helper.o\ - sine.o\ - square_root.o\ - store.o\ - subtraction.o\ - sum.o\ - symbol.o\ - symbol_abstract.o\ - tangent.o\ - tree_handle.o\ - tree_node.o\ - tree_pool.o\ - trigonometry.o\ - trigonometry_cheat_table.o\ - undefined.o\ - unreal.o\ - variable_context.o\ +src += $(addprefix poincare/src/,\ + absolute_value.cpp \ + addition.cpp \ + approximation_helper.cpp \ + arc_cosine.cpp \ + arc_sine.cpp \ + arc_tangent.cpp \ + arithmetic.cpp \ + binomial_coefficient.cpp \ + ceiling.cpp \ + complex.cpp \ + complex_argument.cpp \ + complex_cartesian.cpp \ + confidence_interval.cpp \ + conjugate.cpp \ + constant.cpp \ + cosine.cpp \ + decimal.cpp \ + derivative.cpp \ + determinant.cpp \ + division.cpp \ + division_quotient.cpp \ + division_remainder.cpp \ + empty_expression.cpp \ + equal.cpp \ + evaluation.cpp \ + expression.cpp \ + expression_node.cpp \ + factor.cpp \ + factorial.cpp \ + float.cpp \ + floor.cpp \ + frac_part.cpp \ + function.cpp \ + great_common_divisor.cpp \ + hyperbolic_arc_cosine.cpp \ + hyperbolic_arc_sine.cpp \ + hyperbolic_arc_tangent.cpp \ + hyperbolic_cosine.cpp \ + hyperbolic_sine.cpp \ + hyperbolic_tangent.cpp \ + hyperbolic_trigonometric_function.cpp \ + imaginary_part.cpp \ + infinity.cpp \ + integer.cpp \ + integral.cpp \ + layout_helper.cpp \ + least_common_multiple.cpp \ + logarithm.cpp \ + matrix.cpp \ + matrix_complex.cpp \ + matrix_dimension.cpp \ + matrix_inverse.cpp \ + matrix_trace.cpp \ + matrix_transpose.cpp \ + multiplication.cpp \ + n_ary_expression_node.cpp \ + naperian_logarithm.cpp \ + nth_root.cpp \ + number.cpp \ + opposite.cpp \ + parametered_expression_helper.cpp \ + parenthesis.cpp \ + permute_coefficient.cpp \ + power.cpp \ + prediction_interval.cpp \ + preferences.cpp \ + print_float.cpp \ + product.cpp \ + randint.cpp \ + random.cpp \ + rational.cpp \ + real_part.cpp \ + round.cpp \ + sequence.cpp \ + serialization_helper.cpp \ + sign_function.cpp \ + simplification_helper.cpp \ + sine.cpp \ + square_root.cpp \ + store.cpp \ + subtraction.cpp \ + sum.cpp \ + symbol.cpp \ + symbol_abstract.cpp \ + tangent.cpp \ + tree_handle.cpp \ + tree_node.cpp \ + tree_pool.cpp \ + trigonometry.cpp \ + trigonometry_cheat_table.cpp \ + undefined.cpp \ + unreal.cpp \ + variable_context.cpp \ ) -objs += $(addprefix poincare/src/parsing/,\ - parser.o\ - tokenizer.o\ +src += $(addprefix poincare/src/parsing/,\ + parser.cpp \ + tokenizer.cpp \ ) tests += $(addprefix poincare/test/,\ @@ -185,7 +183,7 @@ test_objs += $(addprefix apps/shared/, global_context.o) ifdef POINCARE_TESTS_PRINT_EXPRESSIONS tests += poincare/src/expression_debug.o -objs += poincare/src/expression_debug.o +src += poincare/src/expression_debug.cpp SFLAGS += -DPOINCARE_TESTS_PRINT_EXPRESSIONS=1 endif diff --git a/python/Makefile b/python/Makefile index a053976a1..35c23812c 100644 --- a/python/Makefile +++ b/python/Makefile @@ -1,142 +1,143 @@ SFLAGS += -Ipython/src SFLAGS += -Ipython/port +SFLAGS += -I$(OUTPUT_DIRECTORY)/python/port # How to maintain this Makefile # - Copy PY_CORE_O_BASENAME from py.mk into py_objs # - Copy select PY_EXTMOD_O_BASENAME from py.mk into extmod_objs # - Edit special-case workarounds below as needed -py_objs = $(addprefix python/src/py/,\ - mpstate.o \ - nlr.o \ - nlrx86.o \ - nlrx64.o \ - nlrthumb.o \ - nlrxtensa.o \ - nlrsetjmp.o \ - malloc.o \ - gc.o \ - pystack.o \ - qstr.o \ - vstr.o \ - mpprint.o \ - unicode.o \ - mpz.o \ - reader.o \ - lexer.o \ - parse.o \ - scope.o \ - compile.o \ - emitcommon.o \ - emitbc.o \ - asmbase.o \ - asmx64.o \ - emitnx64.o \ - asmx86.o \ - emitnx86.o \ - asmthumb.o \ - emitnthumb.o \ - emitinlinethumb.o \ - asmarm.o \ - emitnarm.o \ - asmxtensa.o \ - emitnxtensa.o \ - emitinlinextensa.o \ - formatfloat.o \ - parsenumbase.o \ - parsenum.o \ - emitglue.o \ - persistentcode.o \ - runtime.o \ - runtime_utils.o \ - scheduler.o \ - nativeglue.o \ - stackctrl.o \ - argcheck.o \ - warning.o \ - map.o \ - obj.o \ - objarray.o \ - objattrtuple.o \ - objbool.o \ - objboundmeth.o \ - objcell.o \ - objclosure.o \ - objcomplex.o \ - objdeque.o \ - objdict.o \ - objenumerate.o \ - objexcept.o \ - objfilter.o \ - objfloat.o \ - objfun.o \ - objgenerator.o \ - objgetitemiter.o \ - objint.o \ - objint_longlong.o \ - objint_mpz.o \ - objlist.o \ - objmap.o \ - objmodule.o \ - objobject.o \ - objpolyiter.o \ - objproperty.o \ - objnone.o \ - objnamedtuple.o \ - objrange.o \ - objreversed.o \ - objset.o \ - objsingleton.o \ - objslice.o \ - objstr.o \ - objstrunicode.o \ - objstringio.o \ - objtuple.o \ - objtype.o \ - objzip.o \ - opmethods.o \ - sequence.o \ - stream.o \ - binary.o \ - builtinimport.o \ - builtinevex.o \ - builtinhelp.o \ - modarray.o \ - modbuiltins.o \ - modcollections.o \ - modgc.o \ - modio.o \ - modmath.o \ - modcmath.o \ - modmicropython.o \ - modstruct.o \ - modsys.o \ - moduerrno.o \ - modthread.o \ - vm.o \ - bc.o \ - showbc.o \ - repl.o \ - smallint.o \ - frozenmod.o \ +py_src = $(addprefix python/src/py/,\ + mpstate.c \ + nlr.c \ + nlrx86.c \ + nlrx64.c \ + nlrthumb.c \ + nlrxtensa.c \ + nlrsetjmp.c \ + malloc.c \ + gc.c \ + pystack.c \ + qstr.c \ + vstr.c \ + mpprint.c \ + unicode.c \ + mpz.c \ + reader.c \ + lexer.c \ + parse.c \ + scope.c \ + compile.c \ + emitcommon.c \ + emitbc.c \ + asmbase.c \ + asmx64.c \ + emitnx64.c \ + asmx86.c \ + emitnx86.c \ + asmthumb.c \ + emitnthumb.c \ + emitinlinethumb.c \ + asmarm.c \ + emitnarm.c \ + asmxtensa.c \ + emitnxtensa.c \ + emitinlinextensa.c \ + formatfloat.c \ + parsenumbase.c \ + parsenum.c \ + emitglue.c \ + persistentcode.c \ + runtime.c \ + runtime_utils.c \ + scheduler.c \ + nativeglue.c \ + stackctrl.c \ + argcheck.c \ + warning.c \ + map.c \ + obj.c \ + objarray.c \ + objattrtuple.c \ + objbool.c \ + objboundmeth.c \ + objcell.c \ + objclosure.c \ + objcomplex.c \ + objdeque.c \ + objdict.c \ + objenumerate.c \ + objexcept.c \ + objfilter.c \ + objfloat.c \ + objfun.c \ + objgenerator.c \ + objgetitemiter.c \ + objint.c \ + objint_longlong.c \ + objint_mpz.c \ + objlist.c \ + objmap.c \ + objmodule.c \ + objobject.c \ + objpolyiter.c \ + objproperty.c \ + objnone.c \ + objnamedtuple.c \ + objrange.c \ + objreversed.c \ + objset.c \ + objsingleton.c \ + objslice.c \ + objstr.c \ + objstrunicode.c \ + objstringio.c \ + objtuple.c \ + objtype.c \ + objzip.c \ + opmethods.c \ + sequence.c \ + stream.c \ + binary.c \ + builtinimport.c \ + builtinevex.c \ + builtinhelp.c \ + modarray.c \ + modbuiltins.c \ + modcollections.c \ + modgc.c \ + modio.c \ + modmath.c \ + modcmath.c \ + modmicropython.c \ + modstruct.c \ + modsys.c \ + moduerrno.c \ + modthread.c \ + vm.c \ + bc.c \ + showbc.c \ + repl.c \ + smallint.c \ + frozenmod.c \ ) -extmod_objs += $(addprefix python/src/extmod/,\ - modurandom.o \ +extmod_src += $(addprefix python/src/extmod/,\ + modurandom.c \ ) -port_objs += $(addprefix python/port/,\ - port.o \ - builtins.o\ - helpers.o \ - mod/kandinsky/modkandinsky.o \ - mod/kandinsky/modkandinsky_table.o \ - mod/time/modtime.o \ - mod/time/modtime_table.o \ - mod/turtle/modturtle.o \ - mod/turtle/modturtle_table.o \ - mod/turtle/turtle.o \ - mphalport.o \ +port_src += $(addprefix python/port/,\ + port.c \ + builtins.c \ + helpers.c \ + mod/kandinsky/modkandinsky.cpp \ + mod/kandinsky/modkandinsky_table.cpp \ + mod/time/modtime.c \ + mod/time/modtime_table.c \ + mod/turtle/modturtle.cpp \ + mod/turtle/modturtle_table.cpp \ + mod/turtle/turtle.cpp \ + mphalport.c \ ) # Workarounds @@ -145,14 +146,14 @@ port_objs += $(addprefix python/port/,\ # In order to change the name of the micropython module 'urandom' to 'random' # (without altering micropython files), we redefined the macro MP_QSTR_urandom # by DMP_QSTR_random. -python/src/py/objmodule.o: SFLAGS += -DMP_QSTR_urandom="MP_QSTR_random" -python/src/extmod/modurandom.o: SFLAGS += -DMP_QSTR_urandom="MP_QSTR_random" +$(call object_for,python/src/py/objmodule.c): SFLAGS += -DMP_QSTR_urandom="MP_QSTR_random" +$(call object_for,python/src/extmod/modurandom.c): SFLAGS += -DMP_QSTR_urandom="MP_QSTR_random" # Handle upward-growing stack # Some platforms such as emscripten have a stack that grows up. We've rewritten # the stack control file to handle this case. -py_objs := $(filter-out python/src/py/stackctrl.o, $(py_objs)) -port_objs += python/port/stackctrl.o +py_src := $(filter-out python/src/py/stackctrl.c, $(py_src)) +port_src += python/port/stackctrl.c # Fix the GC on emscripten # With optimizations, register and stack variables might be held in a JavaScript @@ -162,21 +163,20 @@ port_objs += python/port/stackctrl.o # computing resumes, if necessary heap objects have been destroyed, the Python # program crashes. ifeq ($(PLATFORM),emscripten) -$(py_objs): SFLAGS := $(subst -Os,-O0,$(SFLAGS)) +$(call object_for,$(py_src)): SFLAGS := $(subst -Os,-O0,$(SFLAGS)) endif +python_src = $(py_src) $(extmod_src) $(port_src) + # QSTR generation -generated_headers += $(addprefix python/port/genhdr/, qstrdefs.generated.h) +$(eval $(call rule_for, \ + QSTRDAT, \ + python/port/genhdr/qstrdefs.generated.h, \ + python/port/genhdr/qstrdefs.in.h, \ + $$(PYTHON) python/src/py/makeqstrdata.py $$< > $$@ \ +)) -python/port/genhdr/qstrdefs.generated.h: python/port/genhdr/qstrdefs.in.h - @echo "QSTRDAT $@" - $(Q) $(PYTHON) python/src/py/makeqstrdata.py $< > $@ +$(call object_for,$(python_src)): $(OUTPUT_DIRECTORY)/python/port/genhdr/qstrdefs.generated.h -products += python/port/genhdr/qstrdefs.generated.h - -$(py_objs) $(extmod_objs) $(port_objs): python/port/genhdr/qstrdefs.generated.h - -# List all objects needed - -objs += $(extmod_objs) $(py_objs) $(port_objs) \ No newline at end of file +src += $(python_src)