diff --git a/apps/Makefile b/apps/Makefile index 441a7d396..5040c3743 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -1,14 +1,20 @@ +include apps/shared/Makefile +include apps/home/Makefile +include apps/on_boarding/Makefile +include apps/hardware_test/Makefile +snapshots = + +# You can select below which apps you want to include in your build, as well as +# their order on the home screen. Each Makefile below is responsible for setting +# the $snapshots variable (name of the snapshot class) and the $snapshot_headers +# (path to the snapshot header). include apps/calculation/Makefile include apps/graph/Makefile -include apps/home/Makefile -include apps/hardware_test/Makefile -include apps/on_boarding/Makefile -include apps/probability/Makefile -include apps/regression/Makefile include apps/sequence/Makefile include apps/settings/Makefile -include apps/shared/Makefile include apps/statistics/Makefile +include apps/probability/Makefile +include apps/regression/Makefile include apps/code/Makefile #include apps/picview/Makefile @@ -38,6 +44,14 @@ app_objs += $(addprefix apps/,\ variable_box_leaf_cell.o\ ) +snapshots_declaration = $(foreach i,$(snapshots),$(i) m_snapshot$(subst :,,$(i));) +snapshots_construction = $(foreach i,$(snapshots),,m_snapshot$(subst :,,$(i))()) +snapshots_list = $(foreach i,$(snapshots),,&m_snapshot$(subst :,,$(i))) +snapshots_count = $(words $(snapshots)) +snapshot_includes = $(foreach i,$(snapshot_headers),-include $(i) ) + +apps/apps_container_storage.o apps/main.o: CXXFLAGS += $(snapshot_includes) -DAPPS_CONTAINER_SNAPSHOT_DECLARATIONS="$(snapshots_declaration)" -DAPPS_CONTAINER_SNAPSHOT_CONSTRUCTORS="$(snapshots_construction)" -DAPPS_CONTAINER_SNAPSHOT_LIST="$(snapshots_list)" -DAPPS_CONTAINER_SNAPSHOT_COUNT=$(snapshots_count) + app_images += apps/exam_icon.png # Tracking which source file uses which image is painful. But we need to ensure diff --git a/apps/apps_container_storage.cpp b/apps/apps_container_storage.cpp index fcf93f1e4..2ef60aafa 100644 --- a/apps/apps_container_storage.cpp +++ b/apps/apps_container_storage.cpp @@ -1,15 +1,22 @@ #include "apps_container_storage.h" +#ifndef APPS_CONTAINER_SNAPSHOT_CONSTRUCTORS +#error Missing snapshot constructors +#endif + +#ifndef APPS_CONTAINER_SNAPSHOT_LIST +#error Missing snapshot list +#endif + +#ifndef APPS_CONTAINER_SNAPSHOT_COUNT +#error Missing snapshot count +#endif + +constexpr int k_numberOfCommonApps = 1+APPS_CONTAINER_SNAPSHOT_COUNT; // Take the Home app into account + AppsContainerStorage::AppsContainerStorage() : - AppsContainer(), - m_calculationSnapshot(), - m_graphSnapshot(), - m_sequenceSnapshot(), - m_settingsSnapshot(), - m_statisticsSnapshot(), - m_probabilitySnapshot(), - m_regressionSnapshot(), - m_codeSnapshot() + AppsContainer() + APPS_CONTAINER_SNAPSHOT_CONSTRUCTORS { } @@ -22,15 +29,8 @@ App::Snapshot * AppsContainerStorage::appSnapshotAtIndex(int index) { return nullptr; } App::Snapshot * snapshots[] = { - homeAppSnapshot(), - &m_calculationSnapshot, - &m_graphSnapshot, - &m_sequenceSnapshot, - &m_settingsSnapshot, - &m_statisticsSnapshot, - &m_probabilitySnapshot, - &m_regressionSnapshot, - &m_codeSnapshot + homeAppSnapshot() + APPS_CONTAINER_SNAPSHOT_LIST }; assert(sizeof(snapshots)/sizeof(snapshots[0]) == k_numberOfCommonApps); assert(index >= 0 && index < k_numberOfCommonApps); diff --git a/apps/apps_container_storage.h b/apps/apps_container_storage.h index b21f693b7..379c4ef95 100644 --- a/apps/apps_container_storage.h +++ b/apps/apps_container_storage.h @@ -2,14 +2,10 @@ #define APPS_CONTAINER_STORAGE_H #include "apps_container.h" -#include "graph/app.h" -#include "probability/app.h" -#include "calculation/app.h" -#include "regression/app.h" -#include "sequence/app.h" -#include "settings/app.h" -#include "statistics/app.h" -#include "code/app.h" + +#ifndef APPS_CONTAINER_SNAPSHOT_DECLARATIONS +#error Missing snapshot declarations +#endif class AppsContainerStorage : public AppsContainer { public: @@ -17,16 +13,7 @@ public: int numberOfApps() override; App::Snapshot * appSnapshotAtIndex(int index) override; private: - static constexpr int k_numberOfCommonApps = 9; - static constexpr int k_totalNumberOfApps = 2+k_numberOfCommonApps; - Calculation::App::Snapshot m_calculationSnapshot; - Graph::App::Snapshot m_graphSnapshot; - Sequence::App::Snapshot m_sequenceSnapshot; - Settings::App::Snapshot m_settingsSnapshot; - Statistics::App::Snapshot m_statisticsSnapshot; - Probability::App::Snapshot m_probabilitySnapshot; - Regression::App::Snapshot m_regressionSnapshot; - Code::App::Snapshot m_codeSnapshot; + APPS_CONTAINER_SNAPSHOT_DECLARATIONS }; #endif diff --git a/apps/calculation/Makefile b/apps/calculation/Makefile index 22457b7c3..0482f9e6f 100644 --- a/apps/calculation/Makefile +++ b/apps/calculation/Makefile @@ -1,3 +1,6 @@ +snapshots += Calculation::App::Snapshot +snapshot_headers += apps/calculation/app.h + app_objs += $(addprefix apps/calculation/,\ app.o\ calculation.o\ diff --git a/apps/code/Makefile b/apps/code/Makefile index a9279dfdd..2ac5c50bf 100644 --- a/apps/code/Makefile +++ b/apps/code/Makefile @@ -1,3 +1,6 @@ +snapshots += Code::App::Snapshot +snapshot_headers += apps/code/app.h + app_objs += $(addprefix apps/code/,\ app.o\ editor_controller.o\ diff --git a/apps/graph/Makefile b/apps/graph/Makefile index 12d99d887..24e5b3daf 100644 --- a/apps/graph/Makefile +++ b/apps/graph/Makefile @@ -1,3 +1,6 @@ +snapshots += Graph::App::Snapshot +snapshot_headers += apps/graph/app.h + app_objs += $(addprefix apps/graph/,\ app.o\ cartesian_function.o\ diff --git a/apps/probability/Makefile b/apps/probability/Makefile index 73e90cc91..6d8768159 100644 --- a/apps/probability/Makefile +++ b/apps/probability/Makefile @@ -1,3 +1,6 @@ +snapshots += Probability::App::Snapshot +snapshot_headers += apps/probability/app.h + app_objs += $(addprefix apps/probability/,\ app.o\ calculation/calculation.o\ diff --git a/apps/regression/Makefile b/apps/regression/Makefile index f3e878140..29e835fa4 100644 --- a/apps/regression/Makefile +++ b/apps/regression/Makefile @@ -1,3 +1,6 @@ +snapshots += Regression::App::Snapshot +snapshot_headers += apps/regression/app.h + app_objs += $(addprefix apps/regression/,\ app.o\ banner_view.o\ diff --git a/apps/sequence/Makefile b/apps/sequence/Makefile index eaf862a5e..fba909b35 100644 --- a/apps/sequence/Makefile +++ b/apps/sequence/Makefile @@ -1,3 +1,6 @@ +snapshots += Sequence::App::Snapshot +snapshot_headers += apps/sequence/app.h + app_objs += $(addprefix apps/sequence/,\ app.o\ graph/banner_view.o\ diff --git a/apps/settings/Makefile b/apps/settings/Makefile index 2d0f7287e..800f6c6bb 100644 --- a/apps/settings/Makefile +++ b/apps/settings/Makefile @@ -1,3 +1,6 @@ +snapshots += Settings::App::Snapshot +snapshot_headers += apps/settings/app.h + app_objs += $(addprefix apps/settings/,\ app.o\ main_controller.o\ diff --git a/apps/statistics/Makefile b/apps/statistics/Makefile index a41297390..b1a27576d 100644 --- a/apps/statistics/Makefile +++ b/apps/statistics/Makefile @@ -1,3 +1,6 @@ +snapshots += Statistics::App::Snapshot +snapshot_headers += apps/statistics/app.h + app_objs += $(addprefix apps/statistics/,\ app.o\ box_banner_view.o\