Author: Jean-François Milants <jf@codingfield.com>
CMake User Applications selection Use CMake's configure_file() functionality to generate the list of User Applications. All the apps included in current versions of InfiniTime are enabled by default, but this can now be overridden by setting variables ENABLE_APP_XXX to True or False. CMake CMP0140 is set to NEW to enable the return PROPAGATE functionality.
CMakeLists.txt | 38 +++++++++++++++++++++++++++++++++++++- | 2 ++ src/displayapp/UserApps.h | 2 +-
diff --git a/CMakeLists.txt b/CMakeLists.txt index ae6b1c5eef3a6116ed0ee1ea95a269575c3549d9..0c890870922c3eccdb75f437bfee290ac68c1400 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,8 +13,8 @@ set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - set(NRF_TARGET "nrf52") +cmake_policy(SET CMP0140 NEW) if (NOT ARM_NONE_EABI_TOOLCHAIN_PATH) message(FATAL_ERROR "The path to the toolchain (arm-none-eabi) must be specified on the command line (add -DARM_NONE_EABI_TOOLCHAIN_PATH=<path>") @@ -35,6 +35,19 @@ set(TARGET_DEVICE "PINETIME" CACHE STRING "Target device") set_property(CACHE TARGET_DEVICE PROPERTY STRINGS PINETIME MOY_TFK5 MOY_TIN5 MOY_TON5 MOY_UNK) +option(ENABLE_APP_STOPWATCH "Enable the Stopwatch application" True) +option(ENABLE_APP_ALARM "Enable the Alarm application" True) +option(ENABLE_APP_TIMER "Enable the Timer application" True) +option(ENABLE_APP_STEPS "Enable the Steps application" True) +option(ENABLE_APP_HEARTRATE "Enable the HeartRate application" True) +option(ENABLE_APP_MUSIC "Enable the Music application" True) +option(ENABLE_APP_PAINT "Enable the Paint application" True) +option(ENABLE_APP_PADDLE "Enable the Paddle game" True) +option(ENABLE_APP_TWOS "Enable the Twos game" True) +option(ENABLE_APP_METRONOME "Enable the Metronome application" True) +option(ENABLE_APP_NAVIGATION "Enable the Navigation application" True) +option(ENABLE_APP_MOTION "Enable the Motion application" False) + set(PROJECT_GIT_COMMIT_HASH "") execute_process(COMMAND git rev-parse --short HEAD @@ -70,5 +83,28 @@ set(VERSION_EDIT_WARNING "// Do not edit this file, it is automatically generated by CMAKE!") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/Version.h) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docker/post_build.sh.in ${CMAKE_CURRENT_BINARY_DIR}/post_build.sh) +function(AddToListIfEnabled list enabled type) + if(${enabled}) + list(APPEND ${list} ${type}) + endif () + return(PROPAGATE ${list}) +endfunction() + +# Generate the list of user apps to be compiled into the firmware +AddToListIfEnabled(USERAPP_TYPES_LIST ${ENABLE_APP_STOPWATCH} "Apps::StopWatch") +AddToListIfEnabled(USERAPP_TYPES_LIST ${ENABLE_APP_ALARM} "Apps::Alarm") +AddToListIfEnabled(USERAPP_TYPES_LIST ${ENABLE_APP_TIMER} "Apps::Timer") +AddToListIfEnabled(USERAPP_TYPES_LIST ${ENABLE_APP_STEPS} "Apps::Steps") +AddToListIfEnabled(USERAPP_TYPES_LIST ${ENABLE_APP_HEARTRATE} "Apps::HeartRate") +AddToListIfEnabled(USERAPP_TYPES_LIST ${ENABLE_APP_MUSIC} "Apps::Music") +AddToListIfEnabled(USERAPP_TYPES_LIST ${ENABLE_APP_PAINT} "Apps::Paint") +AddToListIfEnabled(USERAPP_TYPES_LIST ${ENABLE_APP_PADDLE} "Apps::Paddle") +AddToListIfEnabled(USERAPP_TYPES_LIST ${ENABLE_APP_TWOS} "Apps::Twos") +AddToListIfEnabled(USERAPP_TYPES_LIST ${ENABLE_APP_METRONOME} "Apps::Metronome") +AddToListIfEnabled(USERAPP_TYPES_LIST ${ENABLE_APP_NAVIGATION} "Apps::Navigation") +AddToListIfEnabled(USERAPP_TYPES_LIST ${ENABLE_APP_MOTION} "Apps::Motion") + +list(JOIN USERAPP_TYPES_LIST "," USERAPP_TYPES) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/displayapp/Apps.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/displayapp/Apps.h) add_subdirectory(src) diff --git a/src/displayapp/Apps.h b/src/displayapp/Apps.h deleted file mode 100644 index ebd8bf78d49bfa699079fcb20218f4d9b9d60abe..0000000000000000000000000000000000000000 --- a/src/displayapp/Apps.h +++ /dev/null @@ -1,97 +0,0 @@ -#pragma once -#include <cstddef> -#include <cstdint> - -namespace Pinetime { - namespace Applications { - enum class Apps : uint8_t { - None, - Launcher, - Clock, - SysInfo, - FirmwareUpdate, - FirmwareValidation, - NotificationsPreview, - Notifications, - Timer, - Alarm, - FlashLight, - BatteryInfo, - Music, - Paint, - Paddle, - Twos, - HeartRate, - Navigation, - StopWatch, - Metronome, - Motion, - Steps, - PassKey, - QuickSettings, - Settings, - SettingWatchFace, - SettingTimeFormat, - SettingDisplay, - SettingWakeUp, - SettingSteps, - SettingSetDateTime, - SettingChimes, - SettingShakeThreshold, - SettingBluetooth, - Error, - Weather - }; - - enum class WatchFace : uint8_t { - Digital, - Analog, - PineTimeStyle, - Terminal, - Infineat, - CasioStyleG7710, - }; - - template <Apps> - struct AppTraits {}; - - template <WatchFace> - struct WatchFaceTraits {}; - - template <Apps... As> - struct TypeList { - static constexpr size_t Count = sizeof...(As); - }; - - template <WatchFace... Ws> - struct WatchFaceTypeList { - static constexpr size_t Count = sizeof...(Ws); - }; - - using UserAppTypes = TypeList<Apps::StopWatch, - Apps::Alarm, - Apps::Timer, - Apps::Steps, - Apps::HeartRate, - Apps::Music, - Apps::Paint, - Apps::Paddle, - Apps::Twos, - Apps::Metronome, - Apps::Navigation - /* - Apps::Weather, - Apps::Motion - */ - >; - - using UserWatchFaceTypes = WatchFaceTypeList<WatchFace::Digital, - WatchFace::Analog, - WatchFace::PineTimeStyle, - WatchFace::Terminal, - WatchFace::Infineat, - WatchFace::CasioStyleG7710>; - - static_assert(UserWatchFaceTypes::Count >= 1); - } -} diff --git a/src/displayapp/Apps.h.in b/src/displayapp/Apps.h.in new file mode 100644 index 0000000000000000000000000000000000000000..23ad12a345424a38d88e9380486b17b7b57141af --- /dev/null +++ b/src/displayapp/Apps.h.in @@ -0,0 +1,99 @@ +#pragma once +#include <cstddef> +#include <cstdint> + +namespace Pinetime { + namespace Applications { + enum class Apps : uint8_t { + None, + Launcher, + Clock, + SysInfo, + FirmwareUpdate, + FirmwareValidation, + NotificationsPreview, + Notifications, + Timer, + Alarm, + FlashLight, + BatteryInfo, + Music, + Paint, + Paddle, + Twos, + HeartRate, + Navigation, + StopWatch, + Metronome, + Motion, + Steps, + PassKey, + QuickSettings, + Settings, + SettingWatchFace, + SettingTimeFormat, + SettingDisplay, + SettingWakeUp, + SettingSteps, + SettingSetDateTime, + SettingChimes, + SettingShakeThreshold, + SettingBluetooth, + Error, + Weather + }; + + enum class WatchFace : uint8_t { + Digital, + Analog, + PineTimeStyle, + Terminal, + Infineat, + CasioStyleG7710, + }; + + template <Apps> + struct AppTraits {}; + + template <WatchFace> + struct WatchFaceTraits {}; + + template <Apps... As> + struct TypeList { + static constexpr size_t Count = sizeof...(As); + }; + + using UserAppTypes = TypeList<@USERAPP_TYPES@>; + + template <WatchFace... Ws> + struct WatchFaceTypeList { + static constexpr size_t Count = sizeof...(Ws); + }; + + using UserAppTypes = TypeList<Apps::StopWatch, + Apps::Alarm, + Apps::Timer, + Apps::Steps, + Apps::HeartRate, + Apps::Music, + Apps::Paint, + Apps::Paddle, + Apps::Twos, + Apps::Metronome, + Apps::Navigation + /* + Apps::Weather, + Apps::Motion + */ + >; + + using UserWatchFaceTypes = WatchFaceTypeList<WatchFace::Digital, + WatchFace::Analog, + WatchFace::PineTimeStyle, + WatchFace::Terminal, + WatchFace::Infineat, + WatchFace::CasioStyleG7710>; + + static_assert(UserWatchFaceTypes::Count >= 1); + } +} diff --git a/src/displayapp/UserApps.h b/src/displayapp/UserApps.h index cb6d57795dacca57ccc47a78c805ca7883104f81..985b335fbc08b06e024ca90ccca71da034586be1 100644 --- a/src/displayapp/UserApps.h +++ b/src/displayapp/UserApps.h @@ -1,5 +1,5 @@ #pragma once -#include "Apps.h" +#include "displayapp/Apps.h" #include "Controllers.h" #include "displayapp/screens/Alarm.h"