From f5736b6fee5a13e6e7714021afd46a85f667fbae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Milants?= Date: Sun, 17 Dec 2023 16:34:00 +0100 Subject: [PATCH 1/9] 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 +++++++++++++++++++++++++++- src/displayapp/{Apps.h => Apps.h.in} | 2 ++ src/displayapp/UserApps.h | 2 +- 3 files changed, 40 insertions(+), 2 deletions(-) rename src/displayapp/{Apps.h => Apps.h.in} (97%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae6b1c5eef..0c89087092 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=") @@ -35,6 +35,19 @@ endif() 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 generate 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.in similarity index 97% rename from src/displayapp/Apps.h rename to src/displayapp/Apps.h.in index ebd8bf78d4..23ad12a345 100644 --- a/src/displayapp/Apps.h +++ b/src/displayapp/Apps.h.in @@ -63,6 +63,8 @@ namespace Pinetime { static constexpr size_t Count = sizeof...(As); }; + using UserAppTypes = TypeList<@USERAPP_TYPES@>; + template struct WatchFaceTypeList { static constexpr size_t Count = sizeof...(Ws); diff --git a/src/displayapp/UserApps.h b/src/displayapp/UserApps.h index cb6d57795d..985b335fbc 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" From 96727c5fc9931abda2ecbe258507ed9d2db4abd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Milants?= Date: Sun, 17 Dec 2023 16:51:44 +0100 Subject: [PATCH 2/9] CMake User Applications selection Revert changes that need "return PROPAGATE" since this is not available in our Docker build (it needs CMake 3.25 and we have 3.22). --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c89087092..c5d30874dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,6 @@ 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=") @@ -87,7 +86,8 @@ function(AddToListIfEnabled list enabled type) if(${enabled}) list(APPEND ${list} ${type}) endif () - return(PROPAGATE ${list}) + #return(PROPAGATE ${list}) + set(${list} "${${list}}" PARENT_SCOPE) endfunction() # Generate the list of user apps to be compiled into the firmware From 20c9aad7f180ec2f6f3692d8132a885a03500d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Milants?= Date: Sun, 17 Dec 2023 17:18:25 +0100 Subject: [PATCH 3/9] CMake User Applications selection Update documentation about building a new application and add instructions to add the app in CMake files. --- doc/code/Apps.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/doc/code/Apps.md b/doc/code/Apps.md index 714e004561..2d49c60e97 100644 --- a/doc/code/Apps.md +++ b/doc/code/Apps.md @@ -59,7 +59,7 @@ and then the function `create` is called to create an instance of the app. The list of user applications is generated at build time by the `consteval` function `CreateAppDescriptions()` in `UserApps.h`. This method takes the list of applications that must be built into the firmware image. -This list of applications is defined as a list `Apps` enum values named `UserAppTypes` in `Apps.h`. +This list of applications is defined as a list `Apps` enum values named `UserAppTypes` in `Apps.h`. For each application listed in `UserAppTypes`, an entry of type `AppDescription` is added to the array `userApps`. This entry is created by using the information provided by a template `AppTraits` that is customized for every user application. @@ -159,6 +159,24 @@ If your application is a **user** application, you don't need to add anything in everything will be automatically generated for you. The user application will also be automatically be added to the app launcher menu. +Since the list of **user** application is generated by CMake, add a new `option` in the main [CMakeLists.txt file](../../CMakeLists.txt). The application will be built by default if the value is set to `True`. : + +```cmake +option(ENABLE_APP_MYAPP "Enable the MyApp application" True) +``` + +The default value can be overridden by passing an additional parameter to the command line of CMake : + +```cmake +$ cmake ... -DENABLE_APP_MYAPP=True ... +``` + +Then add your **user app** to the list of apps by calling `AddToListIfEnabled()` : + +```cmake +AddToListIfEnabled(USERAPP_TYPES_LIST ${ENABLE_APP_MYAPP} "Apps::MyApp") +``` + You should now be able to [build](../buildAndProgram.md) the firmware and flash it to your PineTime. Yay! From 7ed65d3cd74bf4ad3c221dd10c20d8106addf993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Milants?= Date: Tue, 19 Dec 2023 16:37:04 +0100 Subject: [PATCH 4/9] Watch face selection at build time Replace the options that allowed to select the user apps independently by a single string variable that contains the ordered list of apps to build. --- CMakeLists.txt | 40 ++++++---------------------------------- doc/code/Apps.md | 16 ++-------------- 2 files changed, 8 insertions(+), 48 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c5d30874dd..1537bda6c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,18 +34,11 @@ endif() 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) +if(ENABLE_USERAPPS) + set(USERAPP_TYPES ${ENABLE_USERAPPS}) +else () + set(USERAPP_TYPES "Apps::Navigation, Apps::StopWatch, Apps::Alarm, Apps::Timer, Apps::Steps, Apps::HeartRate, Apps::Music, Apps::Paint, Apps::Paddle, Apps::Twos, Apps::Metronome") +endif () set(PROJECT_GIT_COMMIT_HASH "") @@ -77,34 +70,13 @@ if(BUILD_RESOURCES) else() message(" * Build resources : Disabled") endif() +message(" * User apps : " ${USERAPP_TYPES}) 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}) - set(${list} "${${list}}" PARENT_SCOPE) -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/doc/code/Apps.md b/doc/code/Apps.md index 2d49c60e97..16cb3992f7 100644 --- a/doc/code/Apps.md +++ b/doc/code/Apps.md @@ -159,22 +159,10 @@ If your application is a **user** application, you don't need to add anything in everything will be automatically generated for you. The user application will also be automatically be added to the app launcher menu. -Since the list of **user** application is generated by CMake, add a new `option` in the main [CMakeLists.txt file](../../CMakeLists.txt). The application will be built by default if the value is set to `True`. : +Since the list of **user** application is generated by CMake, you need to add the variable `ENABLE_USERAPPS` to the command line of CMake. This variable must be set with a string composed of an ordered list of the **user** applications that must be built into the firmware. The items of the list are fields from the enumeration `Apps`. Ex : build the firmware with 3 user application : Alarm, Timer and MyApp (the application will be listed in this specific order in the application menu). ```cmake -option(ENABLE_APP_MYAPP "Enable the MyApp application" True) -``` - -The default value can be overridden by passing an additional parameter to the command line of CMake : - -```cmake -$ cmake ... -DENABLE_APP_MYAPP=True ... -``` - -Then add your **user app** to the list of apps by calling `AddToListIfEnabled()` : - -```cmake -AddToListIfEnabled(USERAPP_TYPES_LIST ${ENABLE_APP_MYAPP} "Apps::MyApp") +$ cmake ... -DENABLE_USERAPPS="Apps::Alarm, Apps::Timer, Apps::MyApp" ... ``` You should now be able to [build](../buildAndProgram.md) the firmware From a4577f32819f690f08ca1f7b575bc6f65b7d3d92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Milants?= Date: Tue, 19 Dec 2023 17:53:48 +0100 Subject: [PATCH 5/9] Watch face selection with CMake Move displayapp/Apps.h into a header only library (to make the integration easier in InfiniSim. --- CMakeLists.txt | 16 ++++++---------- src/CMakeLists.txt | 14 ++++++++------ src/displayapp/DisplayApp.h | 2 +- src/displayapp/DisplayAppRecovery.h | 2 +- src/displayapp/UserApps.h | 2 +- src/displayapp/{ => apps}/Apps.h.in | 0 src/displayapp/apps/CMakeLists.txt | 6 ++++++ src/displayapp/screens/Alarm.h | 2 +- src/displayapp/screens/ApplicationList.h | 2 +- src/displayapp/screens/CheckboxList.h | 2 +- src/displayapp/screens/InfiniPaint.h | 2 +- src/displayapp/screens/List.h | 2 +- src/displayapp/screens/Motion.h | 2 +- src/displayapp/screens/Music.h | 2 +- src/displayapp/screens/Navigation.h | 2 +- src/displayapp/screens/Paddle.h | 2 +- src/displayapp/screens/Steps.h | 2 +- src/displayapp/screens/StopWatch.h | 2 +- src/displayapp/screens/Tile.h | 2 +- src/displayapp/screens/Twos.h | 2 +- src/displayapp/screens/settings/Settings.cpp | 2 +- 21 files changed, 37 insertions(+), 33 deletions(-) rename src/displayapp/{ => apps}/Apps.h.in (100%) create mode 100644 src/displayapp/apps/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 1537bda6c3..ca6b45bf5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,12 +34,6 @@ endif() set(TARGET_DEVICE "PINETIME" CACHE STRING "Target device") set_property(CACHE TARGET_DEVICE PROPERTY STRINGS PINETIME MOY_TFK5 MOY_TIN5 MOY_TON5 MOY_UNK) -if(ENABLE_USERAPPS) - set(USERAPP_TYPES ${ENABLE_USERAPPS}) -else () - set(USERAPP_TYPES "Apps::Navigation, Apps::StopWatch, Apps::Alarm, Apps::Timer, Apps::Steps, Apps::HeartRate, Apps::Music, Apps::Paint, Apps::Paddle, Apps::Twos, Apps::Metronome") -endif () - set(PROJECT_GIT_COMMIT_HASH "") execute_process(COMMAND git rev-parse --short HEAD @@ -51,6 +45,12 @@ string(STRIP "${PROJECT_GIT_COMMIT_HASH}" PROJECT_GIT_COMMIT_HASH) message("PROJECT_GIT_COMMIT_HASH_SUCCESS? " ${PROJECT_GIT_COMMIT_HASH_SUCCESS}) +if(DEFINED ENABLE_USERAPPS) + set(USERAPP_TYPES ${ENABLE_USERAPPS} CACHE STRING "List of user apps to build into the firmware") +else () + set(USERAPP_TYPES "Apps::Navigation, Apps::StopWatch, Apps::Alarm, Apps::Timer, Apps::Steps, Apps::HeartRate, Apps::Music, Apps::Paint, Apps::Paddle, Apps::Twos, Apps::Metronome" CACHE STRING "List of user apps to build into the firmware") +endif () + message("") message("BUILD CONFIGURATION") message("-------------------") @@ -70,13 +70,9 @@ if(BUILD_RESOURCES) else() message(" * Build resources : Disabled") endif() -message(" * User apps : " ${USERAPP_TYPES}) 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) -# Generate the list of user apps to be compiled into the firmware -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/CMakeLists.txt b/src/CMakeLists.txt index bb7b90c006..b9f333f6b7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -845,6 +845,8 @@ target_compile_options(infinitime_fonts PUBLIC $<$: ${ASM_FLAGS}> ) +add_subdirectory(displayapp/apps) + # NRF SDK add_library(nrf-sdk STATIC ${SDK_SOURCE_FILES}) target_include_directories(nrf-sdk SYSTEM PUBLIC . ../) @@ -900,7 +902,7 @@ set(EXECUTABLE_FILE_NAME ${EXECUTABLE_NAME}-${pinetime_VERSION_MAJOR}.${pinetime set(NRF5_LINKER_SCRIPT "${CMAKE_SOURCE_DIR}/gcc_nrf52.ld") add_executable(${EXECUTABLE_NAME} ${SOURCE_FILES}) set_target_properties(${EXECUTABLE_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_FILE_NAME}) -target_link_libraries(${EXECUTABLE_NAME} nimble nrf-sdk lvgl littlefs infinitime_fonts) +target_link_libraries(${EXECUTABLE_NAME} nimble nrf-sdk lvgl littlefs infinitime_fonts infinitime_apps) target_compile_options(${EXECUTABLE_NAME} PUBLIC ${COMMON_FLAGS} ${WARNING_FLAGS} @@ -934,7 +936,7 @@ set(IMAGE_MCUBOOT_FILE_NAME_BIN ${EXECUTABLE_MCUBOOT_NAME}-image-${pinetime_VERS set(DFU_MCUBOOT_FILE_NAME ${EXECUTABLE_MCUBOOT_NAME}-dfu-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.zip) set(NRF5_LINKER_SCRIPT_MCUBOOT "${CMAKE_SOURCE_DIR}/gcc_nrf52-mcuboot.ld") add_executable(${EXECUTABLE_MCUBOOT_NAME} ${SOURCE_FILES}) -target_link_libraries(${EXECUTABLE_MCUBOOT_NAME} nimble nrf-sdk lvgl littlefs infinitime_fonts) +target_link_libraries(${EXECUTABLE_MCUBOOT_NAME} nimble nrf-sdk lvgl littlefs infinitime_fonts infinitime_apps) set_target_properties(${EXECUTABLE_MCUBOOT_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_MCUBOOT_FILE_NAME}) target_compile_options(${EXECUTABLE_MCUBOOT_NAME} PUBLIC ${COMMON_FLAGS} @@ -976,7 +978,7 @@ endif() set(EXECUTABLE_RECOVERY_NAME "pinetime-recovery") set(EXECUTABLE_RECOVERY_FILE_NAME ${EXECUTABLE_RECOVERY_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}) add_executable(${EXECUTABLE_RECOVERY_NAME} ${RECOVERY_SOURCE_FILES}) -target_link_libraries(${EXECUTABLE_RECOVERY_NAME} nimble nrf-sdk littlefs infinitime_fonts) +target_link_libraries(${EXECUTABLE_RECOVERY_NAME} nimble nrf-sdk littlefs infinitime_fonts infinitime_apps) set_target_properties(${EXECUTABLE_RECOVERY_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_RECOVERY_FILE_NAME}) target_compile_definitions(${EXECUTABLE_RECOVERY_NAME} PUBLIC "PINETIME_IS_RECOVERY") target_compile_options(${EXECUTABLE_RECOVERY_NAME} PUBLIC @@ -1008,7 +1010,7 @@ set(IMAGE_RECOVERY_MCUBOOT_FILE_NAME ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}-image-$ set(IMAGE_RECOVERY_MCUBOOT_FILE_NAME_HEX ${IMAGE_RECOVERY_MCUBOOT_FILE_NAME}.hex) set(DFU_RECOVERY_MCUBOOT_FILE_NAME ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}-dfu-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.zip) add_executable(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} ${RECOVERY_SOURCE_FILES}) -target_link_libraries(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} nimble nrf-sdk littlefs infinitime_fonts) +target_link_libraries(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} nimble nrf-sdk littlefs infinitime_fonts infinitime_apps) set_target_properties(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}) target_compile_definitions(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PUBLIC "PINETIME_IS_RECOVERY") target_compile_options(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PUBLIC @@ -1048,7 +1050,7 @@ endif() set(EXECUTABLE_RECOVERYLOADER_NAME "pinetime-recovery-loader") set(EXECUTABLE_RECOVERYLOADER_FILE_NAME ${EXECUTABLE_RECOVERYLOADER_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}) add_executable(${EXECUTABLE_RECOVERYLOADER_NAME} ${RECOVERYLOADER_SOURCE_FILES}) -target_link_libraries(${EXECUTABLE_RECOVERYLOADER_NAME} nrf-sdk infinitime_fonts) +target_link_libraries(${EXECUTABLE_RECOVERYLOADER_NAME} nrf-sdk infinitime_fonts infinitime_apps) set_target_properties(${EXECUTABLE_RECOVERYLOADER_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_RECOVERYLOADER_FILE_NAME}) target_compile_options(${EXECUTABLE_RECOVERYLOADER_NAME} PUBLIC ${COMMON_FLAGS} @@ -1083,7 +1085,7 @@ set(IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_N set(IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME_HEX ${IMAGE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.hex) set(DFU_MCUBOOT_RECOVERYLOADER_FILE_NAME ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME}-dfu-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}.zip) add_executable(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} ${RECOVERYLOADER_SOURCE_FILES}) -target_link_libraries(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} nrf-sdk infinitime_fonts) +target_link_libraries(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} nrf-sdk infinitime_fonts infinitime_apps) set_target_properties(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}) target_compile_options(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} PUBLIC ${COMMON_FLAGS} diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h index 349ca01424..96bce4dd1d 100644 --- a/src/displayapp/DisplayApp.h +++ b/src/displayapp/DisplayApp.h @@ -4,7 +4,7 @@ #include #include #include -#include "displayapp/Apps.h" +#include "displayapp/apps/Apps.h" #include "displayapp/LittleVgl.h" #include "displayapp/TouchEvents.h" #include "components/brightness/BrightnessController.h" diff --git a/src/displayapp/DisplayAppRecovery.h b/src/displayapp/DisplayAppRecovery.h index fd79ef287b..3a5c78d909 100644 --- a/src/displayapp/DisplayAppRecovery.h +++ b/src/displayapp/DisplayAppRecovery.h @@ -11,7 +11,7 @@ #include #include "BootErrors.h" #include "displayapp/TouchEvents.h" -#include "displayapp/Apps.h" +#include "displayapp/apps/Apps.h" #include "displayapp/Messages.h" namespace Pinetime { diff --git a/src/displayapp/UserApps.h b/src/displayapp/UserApps.h index 985b335fbc..0307035a01 100644 --- a/src/displayapp/UserApps.h +++ b/src/displayapp/UserApps.h @@ -1,5 +1,5 @@ #pragma once -#include "displayapp/Apps.h" +#include "displayapp/apps/Apps.h" #include "Controllers.h" #include "displayapp/screens/Alarm.h" diff --git a/src/displayapp/Apps.h.in b/src/displayapp/apps/Apps.h.in similarity index 100% rename from src/displayapp/Apps.h.in rename to src/displayapp/apps/Apps.h.in diff --git a/src/displayapp/apps/CMakeLists.txt b/src/displayapp/apps/CMakeLists.txt new file mode 100644 index 0000000000..808496e541 --- /dev/null +++ b/src/displayapp/apps/CMakeLists.txt @@ -0,0 +1,6 @@ +add_library(infinitime_apps INTERFACE) +target_sources(infinitime_apps INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/Apps.h") +target_include_directories(infinitime_apps INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/") + +# Generate the list of user apps to be compiled into the firmware +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Apps.h.in ${CMAKE_CURRENT_BINARY_DIR}/Apps.h) \ No newline at end of file diff --git a/src/displayapp/screens/Alarm.h b/src/displayapp/screens/Alarm.h index d8ed9668dc..993d65d171 100644 --- a/src/displayapp/screens/Alarm.h +++ b/src/displayapp/screens/Alarm.h @@ -17,7 +17,7 @@ */ #pragma once -#include "displayapp/Apps.h" +#include "displayapp/apps/Apps.h" #include "components/settings/Settings.h" #include "displayapp/screens/Screen.h" #include "displayapp/widgets/Counter.h" diff --git a/src/displayapp/screens/ApplicationList.h b/src/displayapp/screens/ApplicationList.h index 978f028749..41a413af1a 100644 --- a/src/displayapp/screens/ApplicationList.h +++ b/src/displayapp/screens/ApplicationList.h @@ -2,7 +2,7 @@ #include #include -#include "displayapp/Apps.h" +#include "displayapp/apps/Apps.h" #include "Screen.h" #include "ScreenList.h" #include "displayapp/Controllers.h" diff --git a/src/displayapp/screens/CheckboxList.h b/src/displayapp/screens/CheckboxList.h index c208bc489d..c6119970a1 100644 --- a/src/displayapp/screens/CheckboxList.h +++ b/src/displayapp/screens/CheckboxList.h @@ -1,6 +1,6 @@ #pragma once -#include "displayapp/Apps.h" +#include "displayapp/apps/Apps.h" #include "displayapp/screens/Screen.h" #include #include diff --git a/src/displayapp/screens/InfiniPaint.h b/src/displayapp/screens/InfiniPaint.h index f7d6de535e..b1f9741a02 100644 --- a/src/displayapp/screens/InfiniPaint.h +++ b/src/displayapp/screens/InfiniPaint.h @@ -6,7 +6,7 @@ #include "displayapp/screens/Screen.h" #include "components/motor/MotorController.h" #include "Symbols.h" -#include +#include "displayapp/apps/Apps.h" #include namespace Pinetime { diff --git a/src/displayapp/screens/List.h b/src/displayapp/screens/List.h index 564229e694..17a25f8209 100644 --- a/src/displayapp/screens/List.h +++ b/src/displayapp/screens/List.h @@ -5,7 +5,7 @@ #include #include "displayapp/screens/Screen.h" #include "displayapp/widgets/PageIndicator.h" -#include "displayapp/Apps.h" +#include "displayapp/apps/Apps.h" #include "components/settings/Settings.h" #define MAXLISTITEMS 4 diff --git a/src/displayapp/screens/Motion.h b/src/displayapp/screens/Motion.h index 9cd126f440..e13e068cd9 100644 --- a/src/displayapp/screens/Motion.h +++ b/src/displayapp/screens/Motion.h @@ -7,7 +7,7 @@ #include #include #include "displayapp/Controllers.h" -#include "displayapp/Apps.h" +#include "displayapp/apps/Apps.h" namespace Pinetime { namespace Applications { diff --git a/src/displayapp/screens/Music.h b/src/displayapp/screens/Music.h index 062bd968af..522533215b 100644 --- a/src/displayapp/screens/Music.h +++ b/src/displayapp/screens/Music.h @@ -21,7 +21,7 @@ #include #include #include "displayapp/screens/Screen.h" -#include "displayapp/Apps.h" +#include "displayapp/apps/Apps.h" #include "displayapp/Controllers.h" #include "Symbols.h" diff --git a/src/displayapp/screens/Navigation.h b/src/displayapp/screens/Navigation.h index e62745b2ca..5c7a04299f 100644 --- a/src/displayapp/screens/Navigation.h +++ b/src/displayapp/screens/Navigation.h @@ -22,7 +22,7 @@ #include #include "displayapp/screens/Screen.h" #include -#include "displayapp/Apps.h" +#include "displayapp/apps/Apps.h" #include "displayapp/Controllers.h" #include "Symbols.h" diff --git a/src/displayapp/screens/Paddle.h b/src/displayapp/screens/Paddle.h index 1ea2515881..586cccf4cf 100644 --- a/src/displayapp/screens/Paddle.h +++ b/src/displayapp/screens/Paddle.h @@ -3,7 +3,7 @@ #include #include #include "displayapp/screens/Screen.h" -#include "displayapp/Apps.h" +#include "displayapp/apps/Apps.h" #include "displayapp/Controllers.h" #include "Symbols.h" diff --git a/src/displayapp/screens/Steps.h b/src/displayapp/screens/Steps.h index 428e4b2980..6443582f5e 100644 --- a/src/displayapp/screens/Steps.h +++ b/src/displayapp/screens/Steps.h @@ -4,7 +4,7 @@ #include #include "displayapp/screens/Screen.h" #include -#include "displayapp/Apps.h" +#include "displayapp/apps/Apps.h" #include "displayapp/Controllers.h" #include "Symbols.h" diff --git a/src/displayapp/screens/StopWatch.h b/src/displayapp/screens/StopWatch.h index b3bbba8744..3386d042b8 100644 --- a/src/displayapp/screens/StopWatch.h +++ b/src/displayapp/screens/StopWatch.h @@ -7,7 +7,7 @@ #include "portmacro_cmsis.h" #include "systemtask/SystemTask.h" -#include "displayapp/Apps.h" +#include "displayapp/apps/Apps.h" #include "displayapp/Controllers.h" #include "Symbols.h" diff --git a/src/displayapp/screens/Tile.h b/src/displayapp/screens/Tile.h index 8c1cd12cdc..f1b86246ce 100644 --- a/src/displayapp/screens/Tile.h +++ b/src/displayapp/screens/Tile.h @@ -4,7 +4,7 @@ #include #include #include "displayapp/screens/Screen.h" -#include "displayapp/Apps.h" +#include "displayapp/apps/Apps.h" #include "components/datetime/DateTimeController.h" #include "components/settings/Settings.h" #include "components/battery/BatteryController.h" diff --git a/src/displayapp/screens/Twos.h b/src/displayapp/screens/Twos.h index d983d13640..52449fd36c 100644 --- a/src/displayapp/screens/Twos.h +++ b/src/displayapp/screens/Twos.h @@ -1,6 +1,6 @@ #pragma once -#include "displayapp/Apps.h" +#include "displayapp/apps/Apps.h" #include "displayapp/screens/Screen.h" #include "displayapp/Controllers.h" diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp index 065417fa7c..cb5ba413e8 100644 --- a/src/displayapp/screens/settings/Settings.cpp +++ b/src/displayapp/screens/settings/Settings.cpp @@ -1,7 +1,7 @@ #include "displayapp/screens/settings/Settings.h" #include #include -#include "displayapp/Apps.h" +#include "displayapp/apps/Apps.h" #include "displayapp/DisplayApp.h" using namespace Pinetime::Applications::Screens; From 009c1d2096397a06c0afe51ea738d384c9a30691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Milants?= Date: Thu, 21 Dec 2023 20:37:09 +0100 Subject: [PATCH 6/9] CMake user application selection Move ENABLE_USERAPPS and USERAPP_TYPES from the root CMake file to src/displayapp/apps/CMakeLists.txt so we do not need to repeat it in InfiniSim --- CMakeLists.txt | 6 ------ src/displayapp/apps/CMakeLists.txt | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ca6b45bf5d..2e3a033d38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,12 +45,6 @@ string(STRIP "${PROJECT_GIT_COMMIT_HASH}" PROJECT_GIT_COMMIT_HASH) message("PROJECT_GIT_COMMIT_HASH_SUCCESS? " ${PROJECT_GIT_COMMIT_HASH_SUCCESS}) -if(DEFINED ENABLE_USERAPPS) - set(USERAPP_TYPES ${ENABLE_USERAPPS} CACHE STRING "List of user apps to build into the firmware") -else () - set(USERAPP_TYPES "Apps::Navigation, Apps::StopWatch, Apps::Alarm, Apps::Timer, Apps::Steps, Apps::HeartRate, Apps::Music, Apps::Paint, Apps::Paddle, Apps::Twos, Apps::Metronome" CACHE STRING "List of user apps to build into the firmware") -endif () - message("") message("BUILD CONFIGURATION") message("-------------------") diff --git a/src/displayapp/apps/CMakeLists.txt b/src/displayapp/apps/CMakeLists.txt index 808496e541..fd9f94efa0 100644 --- a/src/displayapp/apps/CMakeLists.txt +++ b/src/displayapp/apps/CMakeLists.txt @@ -1,3 +1,9 @@ +if(DEFINED ENABLE_USERAPPS) + set(USERAPP_TYPES ${ENABLE_USERAPPS} CACHE STRING "List of user apps to build into the firmware") +else () + set(USERAPP_TYPES "Apps::Navigation, Apps::StopWatch, Apps::Alarm, Apps::Timer, Apps::Steps, Apps::HeartRate, Apps::Music, Apps::Paint, Apps::Paddle, Apps::Twos, Apps::Metronome" CACHE STRING "List of user apps to build into the firmware") +endif () + add_library(infinitime_apps INTERFACE) target_sources(infinitime_apps INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/Apps.h") target_include_directories(infinitime_apps INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/") From 996c045d67fac81ce727d3c1af65ddb157f8dcf9 Mon Sep 17 00:00:00 2001 From: JF Date: Sat, 23 Dec 2023 20:37:20 +0100 Subject: [PATCH 7/9] Fix trailing space in doc/code/Apps.md Co-authored-by: NeroBurner --- doc/code/Apps.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/code/Apps.md b/doc/code/Apps.md index 16cb3992f7..3be47ad76a 100644 --- a/doc/code/Apps.md +++ b/doc/code/Apps.md @@ -59,7 +59,7 @@ and then the function `create` is called to create an instance of the app. The list of user applications is generated at build time by the `consteval` function `CreateAppDescriptions()` in `UserApps.h`. This method takes the list of applications that must be built into the firmware image. -This list of applications is defined as a list `Apps` enum values named `UserAppTypes` in `Apps.h`. +This list of applications is defined as a list `Apps` enum values named `UserAppTypes` in `Apps.h`. For each application listed in `UserAppTypes`, an entry of type `AppDescription` is added to the array `userApps`. This entry is created by using the information provided by a template `AppTraits` that is customized for every user application. From 5aae9fea9c8e9afc165e182880001df7d7bf2ae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Milants?= Date: Sat, 23 Dec 2023 20:43:59 +0100 Subject: [PATCH 8/9] User applications selection using CMake Fix typos in Apps.md and add new line in src/displayapp/apps/CMakeLists.txt --- doc/code/Apps.md | 5 ++++- src/displayapp/apps/CMakeLists.txt | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/code/Apps.md b/doc/code/Apps.md index 3be47ad76a..6ca844815b 100644 --- a/doc/code/Apps.md +++ b/doc/code/Apps.md @@ -159,7 +159,10 @@ If your application is a **user** application, you don't need to add anything in everything will be automatically generated for you. The user application will also be automatically be added to the app launcher menu. -Since the list of **user** application is generated by CMake, you need to add the variable `ENABLE_USERAPPS` to the command line of CMake. This variable must be set with a string composed of an ordered list of the **user** applications that must be built into the firmware. The items of the list are fields from the enumeration `Apps`. Ex : build the firmware with 3 user application : Alarm, Timer and MyApp (the application will be listed in this specific order in the application menu). +Since the list of **user** application is generated by CMake, you need to add the variable `ENABLE_USERAPPS` to the command line of CMake. +This variable must be set with a string composed of an ordered list of the **user** applications that must be built into the firmware. +The items of the list are fields from the enumeration `Apps`. +Ex : build the firmware with 3 user application : Alarm, Timer and MyApp (the application will be listed in this specific order in the application menu). ```cmake $ cmake ... -DENABLE_USERAPPS="Apps::Alarm, Apps::Timer, Apps::MyApp" ... diff --git a/src/displayapp/apps/CMakeLists.txt b/src/displayapp/apps/CMakeLists.txt index fd9f94efa0..ddf95171fb 100644 --- a/src/displayapp/apps/CMakeLists.txt +++ b/src/displayapp/apps/CMakeLists.txt @@ -9,4 +9,4 @@ target_sources(infinitime_apps INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/Apps.h") target_include_directories(infinitime_apps INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/") # Generate the list of user apps to be compiled into the firmware -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Apps.h.in ${CMAKE_CURRENT_BINARY_DIR}/Apps.h) \ No newline at end of file +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Apps.h.in ${CMAKE_CURRENT_BINARY_DIR}/Apps.h) From f69983e3b1003b0fd4e993406835e5ff67cc676b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Milants?= Date: Sat, 23 Dec 2023 21:24:33 +0100 Subject: [PATCH 9/9] User applications selection using CMake Fix include path since last rebase. --- src/components/settings/Settings.h | 2 +- src/displayapp/apps/Apps.h.in | 17 ----------------- .../screens/WatchFaceCasioStyleG7710.h | 2 +- src/displayapp/screens/WatchFaceDigital.h | 2 +- src/displayapp/screens/WatchFaceInfineat.h | 2 +- 5 files changed, 4 insertions(+), 21 deletions(-) diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index c9a0b799ce..89c2ba97a1 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -3,7 +3,7 @@ #include #include "components/brightness/BrightnessController.h" #include "components/fs/FS.h" -#include "displayapp/Apps.h" +#include "displayapp/apps/Apps.h" namespace Pinetime { namespace Controllers { diff --git a/src/displayapp/apps/Apps.h.in b/src/displayapp/apps/Apps.h.in index 23ad12a345..b4f117206d 100644 --- a/src/displayapp/apps/Apps.h.in +++ b/src/displayapp/apps/Apps.h.in @@ -70,23 +70,6 @@ namespace Pinetime { static constexpr size_t Count = sizeof...(Ws); }; - using UserAppTypes = TypeList; - using UserWatchFaceTypes = WatchFaceTypeList