From f0e8bb26e94d4fd7c063c2fe5ead76c165cad5a0 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] 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 1537bda6..ca6b45bf 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 bb7b90c0..b9f333f6 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 349ca014..96bce4dd 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 fd79ef28..3a5c78d9 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 985b335f..0307035a 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 00000000..808496e5 --- /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 d8ed9668..993d65d1 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 978f0287..41a413af 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 c208bc48..c6119970 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 f7d6de53..b1f9741a 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 564229e6..17a25f82 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 9cd126f4..e13e068c 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 062bd968..52253321 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 e62745b2..5c7a0429 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 1ea25158..586cccf4 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 428e4b29..6443582f 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 b3bbba87..3386d042 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 8c1cd12c..f1b86246 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 d983d136..52449fd3 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 065417fa..cb5ba413 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;