From 8f7d55a46488b7c2af2b72a79903121337a1b231 Mon Sep 17 00:00:00 2001 From: noseglasses Date: Sat, 18 Nov 2017 16:17:35 +0200 Subject: [PATCH 01/11] Fixed bug where memory could be exploded due to undesired library inclusion. Solution was to remove duplicates if those exist. Also set recurse libraries to have a custom-defined default value - Up till now is has been always 'False', but this change allows users to set the 'ARDUINO_CMAKE_RECURSION_DEFAULT' variable to 'True'. It's possible since this variable is stored in CMake's cache. --- .../Core/Libraries/ArduinoLibraryFactory.cmake | 12 ++++++++++-- cmake/Platform/Initialization/SetDefaults.cmake | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cmake/Platform/Core/Libraries/ArduinoLibraryFactory.cmake b/cmake/Platform/Core/Libraries/ArduinoLibraryFactory.cmake index 982dd03..0878707 100644 --- a/cmake/Platform/Core/Libraries/ArduinoLibraryFactory.cmake +++ b/cmake/Platform/Core/Libraries/ArduinoLibraryFactory.cmake @@ -27,7 +27,7 @@ function(make_arduino_library VAR_NAME BOARD_ID LIB_PATH COMPILE_FLAGS LINK_FLAG # Detect if recursion is needed if (NOT DEFINED ${LIB_SHORT_NAME}_RECURSE) - set(${LIB_SHORT_NAME}_RECURSE False) + set(${LIB_SHORT_NAME}_RECURSE ${ARDUINO_CMAKE_RECURSION_DEFAULT}) endif () find_sources(LIB_SRCS ${LIB_PATH} ${${LIB_SHORT_NAME}_RECURSE}) @@ -54,24 +54,32 @@ function(make_arduino_library VAR_NAME BOARD_ID LIB_PATH COMPILE_FLAGS LINK_FLAG set_target_properties(${TARGET_LIB_NAME} PROPERTIES COMPILE_FLAGS "${ARDUINO_COMPILE_FLAGS} ${LIB_INCLUDES} -I\"${LIB_PATH}\" -I\"${LIB_PATH}/utility\" ${COMPILE_FLAGS}" LINK_FLAGS "${ARDUINO_LINK_FLAGS} ${LINK_FLAGS}") - list(APPEND LIB_INCLUDES "-I\"${LIB_PATH}\" -I\"${LIB_PATH}/utility\"") + list(APPEND LIB_INCLUDES "-I\"${LIB_PATH}\";-I\"${LIB_PATH}/utility\"") if (LIB_TARGETS) list(REMOVE_ITEM LIB_TARGETS ${TARGET_LIB_NAME}) endif () + target_link_libraries(${TARGET_LIB_NAME} ${BOARD_ID}_CORE ${LIB_TARGETS}) list(APPEND LIB_TARGETS ${TARGET_LIB_NAME}) endif () + else () # Target already exists, skiping creating list(APPEND LIB_TARGETS ${TARGET_LIB_NAME}) endif () + if (LIB_TARGETS) list(REMOVE_DUPLICATES LIB_TARGETS) endif () + if (LIB_INCLUDES) + list(REMOVE_DUPLICATES LIB_INCLUDES) + endif () + set(${VAR_NAME} ${LIB_TARGETS} PARENT_SCOPE) set(${VAR_NAME}_INCLUDES ${LIB_INCLUDES} PARENT_SCOPE) + endfunction() #=============================================================================# diff --git a/cmake/Platform/Initialization/SetDefaults.cmake b/cmake/Platform/Initialization/SetDefaults.cmake index 14ee7a1..945a9d0 100644 --- a/cmake/Platform/Initialization/SetDefaults.cmake +++ b/cmake/Platform/Initialization/SetDefaults.cmake @@ -2,3 +2,5 @@ set(ARDUINO_DEFAULT_BOARD uno CACHE STRING "Default Arduino Board ID when not sp set(ARDUINO_DEFAULT_PORT CACHE STRING "Default Arduino port when not specified.") set(ARDUINO_DEFAULT_SERIAL CACHE STRING "Default Arduino Serial command when not specified.") set(ARDUINO_DEFAULT_PROGRAMMER CACHE STRING "Default Arduino Programmer ID when not specified.") +set(ARDUINO_CMAKE_RECURSION_DEFAULT FALSE CACHE BOOL + "The default recursion behavior during library setup") From 536d6182c4b74d1a95ac38a382be60f402262867 Mon Sep 17 00:00:00 2001 From: noseglasses Date: Sat, 18 Nov 2017 20:32:43 +0200 Subject: [PATCH 02/11] Added feature to keep blacklist of libraries which should be removed on search. Those libraries are constantly removed in the 'find_arudino_libraries' function. --- cmake/Platform/Arduino.cmake | 1 + .../BlacklistedLibrariesRemover.cmake | 35 +++++++++++++++++++ cmake/Platform/Core/LibraryFinder.cmake | 5 ++- .../Platform/Initialization/Initializer.cmake | 1 + .../SetupLibraryBlacklist.cmake | 3 ++ 5 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 cmake/Platform/Core/Libraries/BlacklistedLibrariesRemover.cmake create mode 100644 cmake/Platform/Initialization/SetupLibraryBlacklist.cmake diff --git a/cmake/Platform/Arduino.cmake b/cmake/Platform/Arduino.cmake index b11569a..951e664 100644 --- a/cmake/Platform/Arduino.cmake +++ b/cmake/Platform/Arduino.cmake @@ -40,6 +40,7 @@ include(ArduinoSketchFactory) include(CoreLibraryFactory) include(ArduinoLibraryFactory) +include(BlacklistedLibrariesRemover) include(ArduinoExampleFactory) include(ArduinoLibraryExampleFactory) diff --git a/cmake/Platform/Core/Libraries/BlacklistedLibrariesRemover.cmake b/cmake/Platform/Core/Libraries/BlacklistedLibrariesRemover.cmake new file mode 100644 index 0000000..9265244 --- /dev/null +++ b/cmake/Platform/Core/Libraries/BlacklistedLibrariesRemover.cmake @@ -0,0 +1,35 @@ +#=============================================================================# +# _REMOVE_BLACKLISTED_LIBRARIES +# [PRIVATE/INTERNAL] +# +# _REMOVE_BLACKLISTED_LIBRARIES(LIBRARY_LIST OUTPUT_VAR) +# +# LIBRARY_LIST - List of libraries to remove blacklisted libraries from +# OUTPUT_VAR - Original list of libraries without blacklisted libraries. +# +# Returns a list of libraries without blacklisted libraries. +# +# Arduino-CMake looks for Arduino libraries whose names match those of include files encountered. +# Under certain circumstances this leads to undesired behavior. +# An example is an include file 'Keyboard.h' in a project that has no relation to +# Arduino's standard Keyboard library. +# To prevent the standard library from being falsely added to the list of libraries to build, +# this function removes all blacklisted libraries from the source list, which contains +# all the included libraries found in the search process. +# In the example above the blacklisted and remove library would be +# ${ARDUINO_SDK_PATH}/libraries/Keyboard/src). +# +function(_REMOVE_BLACKLISTED_LIBRARIES LIBRARY_LIST OUTPUT_VAR) + set(OLD_LIBS "${${LIBRARY_LIST}}") + set(NEW_LIBS) + foreach (LIB ${OLD_LIBS}) + list(FIND ARDUINO_LIBRARY_BLACKLIST "${LIB}" BLACKLISTED_LIB_INDEX) + if (NOT ${BLACKLISTED_LIB_INDEX} GREATER -1) + list(APPEND NEW_LIBS "${LIB}") + else () + ARDUINO_DEBUG_MSG("Suppressing blacklisted library ${LIB}") + endif () + endforeach () + + set("${LIBRARY_LIST}" "${NEW_LIBS}" PARENT_SCOPE) +endfunction() \ No newline at end of file diff --git a/cmake/Platform/Core/LibraryFinder.cmake b/cmake/Platform/Core/LibraryFinder.cmake index a2e45c4..f638839 100644 --- a/cmake/Platform/Core/LibraryFinder.cmake +++ b/cmake/Platform/Core/LibraryFinder.cmake @@ -129,5 +129,8 @@ function(find_arduino_libraries VAR_NAME SRCS ARDLIBS) if (ARDUINO_LIBS) list(REMOVE_DUPLICATES ARDUINO_LIBS) endif () - set(${VAR_NAME} ${ARDUINO_LIBS} PARENT_SCOPE) + + _REMOVE_BLACKLISTED_LIBRARIES(ARDUINO_LIBS FILTERED_LIBRARIES) + set(${VAR_NAME} ${FILTERED_LIBRARIES} PARENT_SCOPE) + endfunction() diff --git a/cmake/Platform/Initialization/Initializer.cmake b/cmake/Platform/Initialization/Initializer.cmake index b8c866a..80e63be 100644 --- a/cmake/Platform/Initialization/Initializer.cmake +++ b/cmake/Platform/Initialization/Initializer.cmake @@ -14,6 +14,7 @@ if (NOT ARDUINO_FOUND AND ARDUINO_SDK_PATH) include(FindPrograms) include(SetDefaults) include(SetupFirmwareSizeScript) + include(SetupLibraryBlacklist) include(TestSetup) include(DefineAdvancedVariables) diff --git a/cmake/Platform/Initialization/SetupLibraryBlacklist.cmake b/cmake/Platform/Initialization/SetupLibraryBlacklist.cmake new file mode 100644 index 0000000..94253c2 --- /dev/null +++ b/cmake/Platform/Initialization/SetupLibraryBlacklist.cmake @@ -0,0 +1,3 @@ +set(ARDUINO_LIBRARY_BLACKLIST "" CACHE STRING + "A list of absolute paths to Arduino libraries that are meant to be ignored \ +during library search") \ No newline at end of file From 4badac238ed55a33fab9cec7afa55dc6132a6e27 Mon Sep 17 00:00:00 2001 From: noseglasses Date: Sat, 18 Nov 2017 21:02:09 +0200 Subject: [PATCH 03/11] Fixed bug in latest commit where libraries hasn't been found at all. Solution was to change the return variable of the '_remove_blacklisted_libraries' function, as it was incorrect and always returned an empty string. --- .../Core/Libraries/BlacklistedLibrariesRemover.cmake | 5 ++--- cmake/Platform/Core/LibraryFinder.cmake | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cmake/Platform/Core/Libraries/BlacklistedLibrariesRemover.cmake b/cmake/Platform/Core/Libraries/BlacklistedLibrariesRemover.cmake index 9265244..6bf27eb 100644 --- a/cmake/Platform/Core/Libraries/BlacklistedLibrariesRemover.cmake +++ b/cmake/Platform/Core/Libraries/BlacklistedLibrariesRemover.cmake @@ -20,9 +20,8 @@ # ${ARDUINO_SDK_PATH}/libraries/Keyboard/src). # function(_REMOVE_BLACKLISTED_LIBRARIES LIBRARY_LIST OUTPUT_VAR) - set(OLD_LIBS "${${LIBRARY_LIST}}") set(NEW_LIBS) - foreach (LIB ${OLD_LIBS}) + foreach (LIB ${LIBRARY_LIST}) list(FIND ARDUINO_LIBRARY_BLACKLIST "${LIB}" BLACKLISTED_LIB_INDEX) if (NOT ${BLACKLISTED_LIB_INDEX} GREATER -1) list(APPEND NEW_LIBS "${LIB}") @@ -31,5 +30,5 @@ function(_REMOVE_BLACKLISTED_LIBRARIES LIBRARY_LIST OUTPUT_VAR) endif () endforeach () - set("${LIBRARY_LIST}" "${NEW_LIBS}" PARENT_SCOPE) + set("${OUTPUT_VAR}" "${NEW_LIBS}" PARENT_SCOPE) endfunction() \ No newline at end of file diff --git a/cmake/Platform/Core/LibraryFinder.cmake b/cmake/Platform/Core/LibraryFinder.cmake index f638839..5425bc3 100644 --- a/cmake/Platform/Core/LibraryFinder.cmake +++ b/cmake/Platform/Core/LibraryFinder.cmake @@ -130,7 +130,7 @@ function(find_arduino_libraries VAR_NAME SRCS ARDLIBS) list(REMOVE_DUPLICATES ARDUINO_LIBS) endif () - _REMOVE_BLACKLISTED_LIBRARIES(ARDUINO_LIBS FILTERED_LIBRARIES) + _REMOVE_BLACKLISTED_LIBRARIES("${ARDUINO_LIBS}" FILTERED_LIBRARIES) set(${VAR_NAME} ${FILTERED_LIBRARIES} PARENT_SCOPE) endfunction() From 5915f8c178928941d2c0e5c60dd29f434f6990f9 Mon Sep 17 00:00:00 2001 From: Timor Gruber Date: Fri, 24 Nov 2017 14:33:58 +0200 Subject: [PATCH 04/11] Added Revision to SDK's version. Added feature to detect SDK's revision (Currently represented as a date) by reading the 'revisions.txt' file and parsing the revision that matches the current version from it. Stored revision in cache. --- .../Initialization/DetectVersion.cmake | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/cmake/Platform/Initialization/DetectVersion.cmake b/cmake/Platform/Initialization/DetectVersion.cmake index a7da37b..279db49 100644 --- a/cmake/Platform/Initialization/DetectVersion.cmake +++ b/cmake/Platform/Initialization/DetectVersion.cmake @@ -13,9 +13,13 @@ find_file(ARDUINO_VERSION_PATH PATHS ${ARDUINO_SDK_PATH} DOC "Path to Arduino version file.") +find_file(ARDUINO_REVISION_PATH + NAMES revisions.txt + PATHS ${ARDUINO_SDK_PATH} + DOC "Path to Arduino's revision-tracking file.") + if (NOT ARDUINO_VERSION_PATH) message(FATAL_ERROR "Couldn't find SDK's version file, aborting.") - return() endif () file(READ ${ARDUINO_VERSION_PATH} RAW_VERSION) @@ -27,20 +31,37 @@ elseif ("${RAW_VERSION}" MATCHES "[ ]*([0-9]+[.][0-9]+)") set(PARSED_VERSION ${CMAKE_MATCH_1}.0) endif () +if (NOT ARDUINO_REVISION_PATH) + message(WARNING "Couldn't find SDK's revisions file, defaulting to 0.") +else () + file(READ ${ARDUINO_REVISION_PATH} RAW_REVISION 0 30) + if ("${RAW_REVISION}" MATCHES ".*${PARSED_VERSION}.*[-].*") + string(REGEX MATCH "[-][ ]?([0-9]+[.][0-9]+[.][0-9]+)" + TMP_REV ${RAW_REVISION}) + set(PARSED_REVISION ${CMAKE_MATCH_1}) + else () + set(PARSED_REVISION 0) + endif () +endif () + if (NOT PARSED_VERSION STREQUAL "") string(REPLACE "." ";" SPLIT_VERSION ${PARSED_VERSION}) list(GET SPLIT_VERSION 0 SPLIT_VERSION_MAJOR) list(GET SPLIT_VERSION 1 SPLIT_VERSION_MINOR) list(GET SPLIT_VERSION 2 SPLIT_VERSION_PATCH) + string(CONCAT FULL_SDK_VERSION "${PARSED_VERSION}" "-" "${PARSED_REVISION}") + set(ARDUINO_SDK_VERSION "${PARSED_VERSION}" CACHE STRING "Arduino SDK Version") + set(ARUDINO_SDK_FULL_VERSION "${FULL_SDK_VERSION}" CACHE STRING "Full Arduino SDK version") set(ARDUINO_SDK_VERSION_MAJOR ${ARDUINO_SDK_VERSION_MAJOR} CACHE STRING "Arduino SDK Major Version") set(ARDUINO_SDK_VERSION_MINOR ${ARDUINO_SDK_VERSION_MINOR} CACHE STRING "Arduino SDK Minor Version") set(ARDUINO_SDK_VERSION_PATCH ${ARDUINO_SDK_VERSION_PATCH} CACHE STRING "Arduino SDK Patch Version") + set(ARDUINO_SDK_VERSION_REVISION ${PARSED_REVISION} CACHE STRING "Arduino SDK Revision") endif () if (ARDUINO_SDK_VERSION VERSION_LESS 0.19) message(FATAL_ERROR "Unsupported Arduino SDK (requires version 0.19 or higher)") endif () -message(STATUS "Arduino SDK version ${ARDUINO_SDK_VERSION}: ${ARDUINO_SDK_PATH}") +message(STATUS "Arduino SDK version ${ARUDINO_SDK_FULL_VERSION}: ${ARDUINO_SDK_PATH}") From d7dea7c554fa4d1a9f5dd2cb63e115937ff8c653 Mon Sep 17 00:00:00 2001 From: Timor Gruber Date: Fri, 24 Nov 2017 14:38:13 +0200 Subject: [PATCH 05/11] Fixed potential bug causing split version artifacts to be stored as empty. Solution was to set their cached variables the variables holding the split artifacts instead of themselves. For example: ARDUINO_SDK_VERSION_MAJOR has been assigned itself before existing, thus resulting in an empty string. Instead, set it to SPLIT_VERSION_MAJOR, which currently resolves to "1". --- cmake/Platform/Initialization/DetectVersion.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/Platform/Initialization/DetectVersion.cmake b/cmake/Platform/Initialization/DetectVersion.cmake index 279db49..d7d1115 100644 --- a/cmake/Platform/Initialization/DetectVersion.cmake +++ b/cmake/Platform/Initialization/DetectVersion.cmake @@ -54,9 +54,9 @@ if (NOT PARSED_VERSION STREQUAL "") set(ARDUINO_SDK_VERSION "${PARSED_VERSION}" CACHE STRING "Arduino SDK Version") set(ARUDINO_SDK_FULL_VERSION "${FULL_SDK_VERSION}" CACHE STRING "Full Arduino SDK version") - set(ARDUINO_SDK_VERSION_MAJOR ${ARDUINO_SDK_VERSION_MAJOR} CACHE STRING "Arduino SDK Major Version") - set(ARDUINO_SDK_VERSION_MINOR ${ARDUINO_SDK_VERSION_MINOR} CACHE STRING "Arduino SDK Minor Version") - set(ARDUINO_SDK_VERSION_PATCH ${ARDUINO_SDK_VERSION_PATCH} CACHE STRING "Arduino SDK Patch Version") + set(ARDUINO_SDK_VERSION_MAJOR ${SPLIT_VERSION_MAJOR} CACHE STRING "Arduino SDK Major Version") + set(ARDUINO_SDK_VERSION_MINOR ${SPLIT_VERSION_MINOR} CACHE STRING "Arduino SDK Minor Version") + set(ARDUINO_SDK_VERSION_PATCH ${SPLIT_VERSION_PATCH} CACHE STRING "Arduino SDK Patch Version") set(ARDUINO_SDK_VERSION_REVISION ${PARSED_REVISION} CACHE STRING "Arduino SDK Revision") endif () From 188a831fdf00e9725908b9044da75c02ff6c685a Mon Sep 17 00:00:00 2001 From: Timor Gruber Date: Fri, 24 Nov 2017 14:55:56 +0200 Subject: [PATCH 06/11] Modified `FlagsSetter` to get normalized sdk version from cached variables. Up to this commit every call to the 'set_flags' function would result in validating the SDK's version, then extracting it's artifacts to form a normalized version - This is no longer needed due to the bug fix in the last commit, where the artifacts are properly stored in cache. --- .../Core/BoardFlags/CompilerFlagsSetter.cmake | 4 +-- .../Core/BoardFlags/FlagsSetter.cmake | 36 +++++++------------ 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/cmake/Platform/Core/BoardFlags/CompilerFlagsSetter.cmake b/cmake/Platform/Core/BoardFlags/CompilerFlagsSetter.cmake index a1989bf..dcf4bd5 100644 --- a/cmake/Platform/Core/BoardFlags/CompilerFlagsSetter.cmake +++ b/cmake/Platform/Core/BoardFlags/CompilerFlagsSetter.cmake @@ -1,7 +1,7 @@ # ToDo: Comment -function(set_board_compiler_flags COMPILER_FLAGS ARDUINO_DEFINED_VERSION BOARD_ID IS_MANUAL) +function(set_board_compiler_flags COMPILER_FLAGS NORMALIZED_SDK_VERSION BOARD_ID IS_MANUAL) - set(COMPILE_FLAGS "-DF_CPU=${${BOARD_ID}.build.f_cpu} -DARDUINO=${ARDUINO_DEFINED_VERSION} -mmcu=${${BOARD_ID}.build.mcu}") + set(COMPILE_FLAGS "-DF_CPU=${${BOARD_ID}.build.f_cpu} -DARDUINO=${NORMALIZED_SDK_VERSION} -mmcu=${${BOARD_ID}.build.mcu}") if (DEFINED ${BOARD_ID}.build.vid) set(COMPILE_FLAGS "${COMPILE_FLAGS} -DUSB_VID=${${BOARD_ID}.build.vid}") endif () diff --git a/cmake/Platform/Core/BoardFlags/FlagsSetter.cmake b/cmake/Platform/Core/BoardFlags/FlagsSetter.cmake index 1624b48..10e4960 100644 --- a/cmake/Platform/Core/BoardFlags/FlagsSetter.cmake +++ b/cmake/Platform/Core/BoardFlags/FlagsSetter.cmake @@ -19,12 +19,10 @@ function(set_board_flags COMPILER_FLAGS LINKER_FLAGS BOARD_ID IS_MANUAL) set(BOARD_CORE ${${BOARD_ID}.build.core}) if (BOARD_CORE) - is_sdk_version_valid(IS_VERSION_VALID DEFINED_VERSION) - if (NOT ${IS_VERSION_VALID}) - return() - endif () + _get_normalized_sdk_version(NORMALIZED_SDK_VERSION) + message(STATUS "Normalized Version: ${NORMALIZED_SDK_VERSION}") - set_board_compiler_flags(COMPILE_FLAGS ${DEFINED_VERSION} ${BOARD_ID} ${IS_MANUAL}) + set_board_compiler_flags(COMPILE_FLAGS ${NORMALIZED_SDK_VERSION} ${BOARD_ID} ${IS_MANUAL}) set_board_linker_flags(LINK_FLAGS ${BOARD_ID} ${IS_MANUAL}) # output @@ -37,25 +35,17 @@ function(set_board_flags COMPILER_FLAGS LINKER_FLAGS BOARD_ID IS_MANUAL) endfunction() -function(is_sdk_version_valid IS_VALID OUTPUT_VAR) - - if (ARDUINO_SDK_VERSION MATCHES "([0-9]+)[.]([0-9]+)") - string(REPLACE "." "" ARDUINO_VERSION_DEFINE "${ARDUINO_SDK_VERSION}") # Normalize version (remove all periods) - set(ARDUINO_VERSION_DEFINE "") - if (CMAKE_MATCH_1 GREATER 0) - set(ARDUINO_VERSION_DEFINE "${CMAKE_MATCH_1}") - endif () - if (CMAKE_MATCH_2 GREATER 10) - set(ARDUINO_VERSION_DEFINE "${ARDUINO_VERSION_DEFINE}${CMAKE_MATCH_2}") - else () - set(ARDUINO_VERSION_DEFINE "${ARDUINO_VERSION_DEFINE}0${CMAKE_MATCH_2}") - endif () - else () - message(WARNING "Invalid Arduino SDK Version (${ARDUINO_SDK_VERSION})") - set(${IS_VALID} False PARENT_SCOPE) +function(_get_normalized_sdk_version OUTPUT_VAR) + + set(CONCATENATED_VERSION "${ARDUINO_SDK_VERSION_MAJOR}") + if (${ARDUINO_SDK_VERSION_MINOR} LESS 10) + string(CONCAT CONCATENATED_VERSION "${CONCATENATED_VERSION}" "0") endif () + string(CONCAT CONCATENATED_VERSION "${CONCATENATED_VERSION}" + "${ARDUINO_SDK_VERSION_MINOR}") + string(CONCAT CONCATENATED_VERSION "${CONCATENATED_VERSION}" + "${ARDUINO_SDK_VERSION_PATCH}") - set(${IS_VALID} True PARENT_SCOPE) - set(${OUTPUT_VAR} ${ARDUINO_VERSION_DEFINE} PARENT_SCOPE) + set(${OUTPUT_VAR} ${CONCATENATED_VERSION} PARENT_SCOPE) endfunction() From 17d60adf04c92a2e24ad4da37ebc9ac63feaf506 Mon Sep 17 00:00:00 2001 From: Timor Gruber Date: Fri, 24 Nov 2017 15:28:56 +0200 Subject: [PATCH 07/11] Added ability to register custom hardware platforms. It's more a bug-fix combined with a feature, since the function to register a platform simply been inlined, defaulting 'Arduino' and 'avr' as platform and architecture. This commit allows developers to specify their own platform and architecture by setting the `PLATFORM_PATH` and `PLATFORM_ARCHITECTURE` variables BEFORE including the Arduino-CMake toolchain. --- .../RegisterHardwarePlatform.cmake | 102 ++---------------- .../RegisterSpecificHardwarePlatform.cmake | 96 +++++++++++++++++ 2 files changed, 106 insertions(+), 92 deletions(-) create mode 100644 cmake/Platform/Initialization/RegisterSpecificHardwarePlatform.cmake diff --git a/cmake/Platform/Initialization/RegisterHardwarePlatform.cmake b/cmake/Platform/Initialization/RegisterHardwarePlatform.cmake index 0fbbdd2..3d79195 100644 --- a/cmake/Platform/Initialization/RegisterHardwarePlatform.cmake +++ b/cmake/Platform/Initialization/RegisterHardwarePlatform.cmake @@ -1,96 +1,14 @@ -#=============================================================================# -# ToDo: Document -#=============================================================================# -set(PLATFORM_PATH ${ARDUINO_SDK_PATH}/hardware/arduino/) -string(REGEX REPLACE "/$" "" PLATFORM_PATH ${PLATFORM_PATH}) -GET_FILENAME_COMPONENT(PLATFORM ${PLATFORM_PATH} NAME) - -# platform path changed in versions 1.5 and greater -if (ARDUINO_SDK_VERSION VERSION_GREATER 1.0.5) - set(PLATFORM_PATH "${PLATFORM_PATH}/avr") -endif () - -if (NOT PLATFORM) - return() -endif () - -# Avoid defining a platform multiple times if it has already been defined before -string(TOUPPER ${PLATFORM} PLATFORM) -list(FIND ARDUINO_PLATFORMS ${PLATFORM} PLATFORM_EXISTS) - -if (PLATFORM_EXISTS GREATER -1) - return() -endif () - -set(${PLATFORM}_PLATFORM_PATH ${PLATFORM_PATH} CACHE INTERNAL "The path to ${PLATFORM}") -set(ARDUINO_PLATFORMS ${ARDUINO_PLATFORMS} ${PLATFORM} CACHE INTERNAL "A list of registered platforms") - -find_file(${PLATFORM}_CORES_PATH - NAMES cores - PATHS ${PLATFORM_PATH} - DOC "Path to directory containing the Arduino core sources.") - -find_file(${PLATFORM}_VARIANTS_PATH - NAMES variants - PATHS ${PLATFORM_PATH} - DOC "Path to directory containing the Arduino variant sources.") - -find_file(${PLATFORM}_BOOTLOADERS_PATH - NAMES bootloaders - PATHS ${PLATFORM_PATH} - DOC "Path to directory containing the Arduino bootloader images and sources.") - -find_file(${PLATFORM}_PROGRAMMERS_PATH - NAMES programmers.txt - PATHS ${PLATFORM_PATH} - DOC "Path to Arduino programmers definition file.") - -find_file(${PLATFORM}_BOARDS_PATH - NAMES boards.txt - PATHS ${PLATFORM_PATH} - DOC "Path to Arduino boards definition file.") - -# some libraries are in platform path in versions 1.5 and greater -if (ARDUINO_SDK_VERSION VERSION_GREATER 1.0.5) - find_file(${PLATFORM}_PLATFORM_LIBRARIES_PATH - NAMES libraries - PATHS ${PLATFORM_PATH} - DOC "Path to platform directory containing the Arduino libraries.") - set(ARDUINO_PLATFORM_LIBRARIES_PATH "${${PLATFORM}_PLATFORM_LIBRARIES_PATH}") -else () - set(ARDUINO_PLATFORM_LIBRARIES_PATH "") -endif () - -if (${PLATFORM}_BOARDS_PATH) - set(SETTINGS_LIST ${PLATFORM}_BOARDS) - set(SETTINGS_PATH "${${PLATFORM}_BOARDS_PATH}") - include(LoadArduinoPlatformSettings) -endif () - -if (${PLATFORM}_PROGRAMMERS_PATH) - set(SETTINGS_LIST ${PLATFORM}_PROGRAMMERS) - set(SETTINGS_PATH "${${PLATFORM}_PROGRAMMERS_PATH}") - include(LoadArduinoPlatformSettings) +if (NOT PLATFORM_PATH) + # Arduino is assumed as the default platform + set(PLATFORM_PATH ${ARDUINO_SDK_PATH}/hardware/arduino/) endif () +string(REGEX REPLACE "/$" "" PLATFORM_PATH ${PLATFORM_PATH}) +GET_FILENAME_COMPONENT(VENDOR_ID ${PLATFORM_PATH} NAME) +GET_FILENAME_COMPONENT(BASE_PATH ${PLATFORM_PATH} PATH) -if (${PLATFORM}_VARIANTS_PATH) - file(GLOB sub-dir ${${PLATFORM}_VARIANTS_PATH}/*) - foreach (dir ${sub-dir}) - if (IS_DIRECTORY ${dir}) - get_filename_component(variant ${dir} NAME) - set(VARIANTS ${VARIANTS} ${variant} CACHE INTERNAL "A list of registered variant boards") - set(${variant}.path ${dir} CACHE INTERNAL "The path to the variant ${variant}") - endif () - endforeach () +if (NOT PLATFORM_ARCHITECTURE) + # avr is the default architecture + set(PLATFORM_ARCHITECTURE "avr") endif () -if (${PLATFORM}_CORES_PATH) - file(GLOB sub-dir ${${PLATFORM}_CORES_PATH}/*) - foreach (dir ${sub-dir}) - if (IS_DIRECTORY ${dir}) - get_filename_component(core ${dir} NAME) - set(CORES ${CORES} ${core} CACHE INTERNAL "A list of registered cores") - set(${core}.path ${dir} CACHE INTERNAL "The path to the core ${core}") - endif () - endforeach () -endif () +include(RegisterSpecificHardwarePlatform) diff --git a/cmake/Platform/Initialization/RegisterSpecificHardwarePlatform.cmake b/cmake/Platform/Initialization/RegisterSpecificHardwarePlatform.cmake new file mode 100644 index 0000000..434384f --- /dev/null +++ b/cmake/Platform/Initialization/RegisterSpecificHardwarePlatform.cmake @@ -0,0 +1,96 @@ +#=============================================================================# +# ToDo: Document +#=============================================================================# + +set(PLATFORM_PATH "${BASE_PATH}/${VENDOR_ID}/${PLATFORM_ARCHITECTURE}") +set(PLATFORM "${VENDOR_ID}") +set(ARCHITECTURE_ID ${PLATFORM_ARCHITECTURE}) + +# Avoid defining a platform multiple times if it has already been defined before +string(TOUPPER ${PLATFORM} PLATFORM) +list(FIND ARDUINO_PLATFORMS ${PLATFORM} PLATFORM_EXISTS) + +if (PLATFORM_EXISTS GREATER -1) + return() +endif () + +set(${PLATFORM}_PLATFORM_PATH ${PLATFORM_PATH} CACHE INTERNAL "The path to ${PLATFORM}") +set(ARDUINO_PLATFORMS ${ARDUINO_PLATFORMS} ${PLATFORM} CACHE INTERNAL "A list of registered platforms") + +find_file(${PLATFORM}_CORES_PATH + NAMES cores + PATHS ${PLATFORM_PATH} + DOC "Path to directory containing the Arduino core sources.") + +find_file(${PLATFORM}_VARIANTS_PATH + NAMES variants + PATHS ${PLATFORM_PATH} + DOC "Path to directory containing the Arduino variant sources.") + +find_file(${PLATFORM}_BOOTLOADERS_PATH + NAMES bootloaders + PATHS ${PLATFORM_PATH} + DOC "Path to directory containing the Arduino bootloader images and sources.") + +find_file(${PLATFORM}_PROGRAMMERS_PATH + NAMES programmers.txt + PATHS ${PLATFORM_PATH} + DOC "Path to Arduino programmers definition file.") + +find_file(${PLATFORM}_BOARDS_PATH + NAMES boards.txt + PATHS ${PLATFORM_PATH} + DOC "Path to Arduino boards definition file.") + +# some libraries are in platform path in versions 1.5 and greater +if (ARDUINO_SDK_VERSION VERSION_GREATER 1.0.5) + find_file(${PLATFORM}_PLATFORM_LIBRARIES_PATH + NAMES libraries + PATHS ${PLATFORM_PATH} + DOC "Path to platform directory containing the Arduino libraries.") + set(ARDUINO_PLATFORM_LIBRARIES_PATH "${${PLATFORM}_PLATFORM_LIBRARIES_PATH}") +else () + set(ARDUINO_PLATFORM_LIBRARIES_PATH "") +endif () + +if (${PLATFORM}_BOARDS_PATH) + set(SETTINGS_LIST ${PLATFORM}_BOARDS) + set(SETTINGS_PATH "${${PLATFORM}_BOARDS_PATH}") + include(LoadArduinoPlatformSettings) +endif () + +if (${PLATFORM}_PROGRAMMERS_PATH) + set(SETTINGS_LIST ${PLATFORM}_PROGRAMMERS) + set(SETTINGS_PATH "${${PLATFORM}_PROGRAMMERS_PATH}") + include(LoadArduinoPlatformSettings) +endif () + +if (${PLATFORM}_VARIANTS_PATH) + file(GLOB sub-dir ${${PLATFORM}_VARIANTS_PATH}/*) + foreach (dir ${sub-dir}) + if (IS_DIRECTORY ${dir}) + get_filename_component(variant ${dir} NAME) + set(VARIANTS ${VARIANTS} ${variant} CACHE INTERNAL "A list of registered variant boards") + set(${variant}.path ${dir} CACHE INTERNAL "The path to the variant ${variant}") + endif () + endforeach () +endif () + +if (${PLATFORM}_CORES_PATH) + file(GLOB sub-dir ${${PLATFORM}_CORES_PATH}/*) + foreach (dir ${sub-dir}) + if (IS_DIRECTORY ${dir}) + get_filename_component(core ${dir} NAME) + set(CORES ${CORES} ${core} CACHE INTERNAL "A list of registered cores") + set(${core}.path ${dir} CACHE INTERNAL "The path to the core ${core}") + + # See https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#referencing-another-core-variant-or-tool + # for an explanation why cores must also be available as : + # and :: + set(CORES ${CORES} "${VENDOR_ID}:${core}" CACHE INTERNAL "A list of registered cores") + set(${VENDOR_ID}:${core}.path ${dir} CACHE INTERNAL "The path to the core ${core}") + set(CORES ${CORES} "${VENDOR_ID}:${ARCHITECTURE_ID}:${core}" CACHE INTERNAL "A list of registered cores") + + endif () + endforeach () +endif () From 17ea2a9befae95c40667f96bc4b7202683265bdb Mon Sep 17 00:00:00 2001 From: Timor Gruber Date: Fri, 24 Nov 2017 15:38:44 +0200 Subject: [PATCH 08/11] Added ability to specify custom platform-registration script. This commit complements the last one, allowing even further customization to the platform-registration process. --- .../Platform/Initialization/RegisterHardwarePlatform.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/Platform/Initialization/RegisterHardwarePlatform.cmake b/cmake/Platform/Initialization/RegisterHardwarePlatform.cmake index 3d79195..a890266 100644 --- a/cmake/Platform/Initialization/RegisterHardwarePlatform.cmake +++ b/cmake/Platform/Initialization/RegisterHardwarePlatform.cmake @@ -11,4 +11,8 @@ if (NOT PLATFORM_ARCHITECTURE) set(PLATFORM_ARCHITECTURE "avr") endif () -include(RegisterSpecificHardwarePlatform) +if (CUSTOM_PLATFORM_REGISTRATION_SCRIPT) + include("${CUSTOM_PLATFORM_REGISTRATION_SCRIPT}") +else () + include(RegisterSpecificHardwarePlatform) +endif () From ee3da9b8716c7dad70c9cc7828aafb2cac8e1f53 Mon Sep 17 00:00:00 2001 From: Timor Gruber Date: Fri, 24 Nov 2017 15:40:20 +0200 Subject: [PATCH 09/11] Removed unnecessary cmake messages. --- cmake/Platform/Core/BoardFlags/FlagsSetter.cmake | 1 - cmake/Platform/Core/Sketch/ArduinoSketchFactory.cmake | 1 - 2 files changed, 2 deletions(-) diff --git a/cmake/Platform/Core/BoardFlags/FlagsSetter.cmake b/cmake/Platform/Core/BoardFlags/FlagsSetter.cmake index 10e4960..d8bdd2b 100644 --- a/cmake/Platform/Core/BoardFlags/FlagsSetter.cmake +++ b/cmake/Platform/Core/BoardFlags/FlagsSetter.cmake @@ -20,7 +20,6 @@ function(set_board_flags COMPILER_FLAGS LINKER_FLAGS BOARD_ID IS_MANUAL) set(BOARD_CORE ${${BOARD_ID}.build.core}) if (BOARD_CORE) _get_normalized_sdk_version(NORMALIZED_SDK_VERSION) - message(STATUS "Normalized Version: ${NORMALIZED_SDK_VERSION}") set_board_compiler_flags(COMPILE_FLAGS ${NORMALIZED_SDK_VERSION} ${BOARD_ID} ${IS_MANUAL}) set_board_linker_flags(LINK_FLAGS ${BOARD_ID} ${IS_MANUAL}) diff --git a/cmake/Platform/Core/Sketch/ArduinoSketchFactory.cmake b/cmake/Platform/Core/Sketch/ArduinoSketchFactory.cmake index e889f6e..5949659 100644 --- a/cmake/Platform/Core/Sketch/ArduinoSketchFactory.cmake +++ b/cmake/Platform/Core/Sketch/ArduinoSketchFactory.cmake @@ -30,7 +30,6 @@ function(make_arduino_sketch TARGET_NAME SKETCH_PATH OUTPUT_VAR) (${SKETCH_NAME}.pde or ${SKETCH_NAME}.ino) at ${SKETCH_PATH}!") endif () list(SORT SKETCH_SOURCES) - message(STATUS "SKETCH_SOURCES: ${SKETCH_SOURCES}") convert_sketch_to_cpp(${SKETCH_SOURCES} ${SKETCH_CPP}) From 0e784ee2735c3bd6c3cdd34e16bb6587726b34ef Mon Sep 17 00:00:00 2001 From: Timor Gruber Date: Fri, 24 Nov 2017 16:22:23 +0200 Subject: [PATCH 10/11] Fixed bug after merging where Arduino version has been set to old non-existent variable. --- cmake/Platform/Core/BoardFlags/CompilerFlagsSetter.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Platform/Core/BoardFlags/CompilerFlagsSetter.cmake b/cmake/Platform/Core/BoardFlags/CompilerFlagsSetter.cmake index 1047e7c..1de85d2 100644 --- a/cmake/Platform/Core/BoardFlags/CompilerFlagsSetter.cmake +++ b/cmake/Platform/Core/BoardFlags/CompilerFlagsSetter.cmake @@ -3,7 +3,7 @@ function(set_board_compiler_flags COMPILER_FLAGS NORMALIZED_SDK_VERSION BOARD_ID _get_board_property(${BOARD_ID} build.f_cpu FCPU) _get_board_property(${BOARD_ID} build.mcu MCU) - set(COMPILE_FLAGS "-DF_CPU=${FCPU} -DARDUINO=${ARDUINO_DEFINED_VERSION} -mmcu=${MCU}") + set(COMPILE_FLAGS "-DF_CPU=${FCPU} -DARDUINO=${NORMALIZED_SDK_VERSION} -mmcu=${MCU}") _get_board_property_if_exists(${BOARD_ID} build.vid VID) _get_board_property_if_exists(${BOARD_ID} build.pid PID) From c8bc6844d7e0c1550eca2be2790f41c530c6c44b Mon Sep 17 00:00:00 2001 From: Timor Gruber Date: Fri, 1 Dec 2017 00:46:41 +0200 Subject: [PATCH 11/11] Improved 'normalized_version' construction by differentiating specific versions. The '_get_normalized_sdk_version' function of the `FlagsSetter` has been improved to return different results, depending on the current SDK version, as the '-DARDUINO' flag intended to use it has different accepted formats over the versions. Also renamed '_get_board_property_if_exists' function to '_try_get_board_property' as a convention. --- .../Core/BoardFlags/CompilerFlagsSetter.cmake | 4 +- .../Core/BoardFlags/FlagsSetter.cmake | 79 ++++++++++++++++--- .../Platform/Core/BoardPropertiesReader.cmake | 2 +- .../ArduinoBootloaderBurnTargetCreator.cmake | 6 +- 4 files changed, 73 insertions(+), 18 deletions(-) diff --git a/cmake/Platform/Core/BoardFlags/CompilerFlagsSetter.cmake b/cmake/Platform/Core/BoardFlags/CompilerFlagsSetter.cmake index 1de85d2..fd7c58a 100644 --- a/cmake/Platform/Core/BoardFlags/CompilerFlagsSetter.cmake +++ b/cmake/Platform/Core/BoardFlags/CompilerFlagsSetter.cmake @@ -5,8 +5,8 @@ function(set_board_compiler_flags COMPILER_FLAGS NORMALIZED_SDK_VERSION BOARD_ID _get_board_property(${BOARD_ID} build.mcu MCU) set(COMPILE_FLAGS "-DF_CPU=${FCPU} -DARDUINO=${NORMALIZED_SDK_VERSION} -mmcu=${MCU}") - _get_board_property_if_exists(${BOARD_ID} build.vid VID) - _get_board_property_if_exists(${BOARD_ID} build.pid PID) + _try_get_board_property(${BOARD_ID} build.vid VID) + _try_get_board_property(${BOARD_ID} build.pid PID) if (VID) set(COMPILE_FLAGS "${COMPILE_FLAGS} -DUSB_VID=${VID}") endif () diff --git a/cmake/Platform/Core/BoardFlags/FlagsSetter.cmake b/cmake/Platform/Core/BoardFlags/FlagsSetter.cmake index 394533b..df05924 100644 --- a/cmake/Platform/Core/BoardFlags/FlagsSetter.cmake +++ b/cmake/Platform/Core/BoardFlags/FlagsSetter.cmake @@ -2,17 +2,17 @@ include(CompilerFlagsSetter) include(LinkerFlagsSetter) #=============================================================================# -# get_arduino_flags +# set_board_flags # [PRIVATE/INTERNAL] # -# get_arduino_flags(COMPILE_FLAGS LINK_FLAGS BOARD_ID IS_MANUAL) +# set_board_flags(COMPILER_FLAGS LINKER_FLAGS BOARD_ID IS_MANUAL) # -# COMPILER_FLAGS -Variable holding compiler flags +# COMPILER_FLAGS - Variable holding compiler flags # LINKER_FLAGS - Variable holding linker flags # BOARD_ID - The board id name # IS_MANUAL - (Advanced) Only use AVR Libc/Includes # -# Configures the the build settings for the specified Arduino Board. +# Configures the build settings for the specified Arduino Board. # #=============================================================================# function(set_board_flags COMPILER_FLAGS LINKER_FLAGS BOARD_ID IS_MANUAL) @@ -34,17 +34,72 @@ function(set_board_flags COMPILER_FLAGS LINKER_FLAGS BOARD_ID IS_MANUAL) endfunction() +#=============================================================================# +# _get_normalized_sdk_version +# [PRIVATE/INTERNAL] +# +# _get_normalized_sdk_version(OUTPUT_VAR) +# +# OUTPUT_VAR - Returned variable storing the normalized version +# +# Normalizes SDK's version for a proper use of the '-DARDUINO' compile flag. +# Note that there are differences between normalized versions in specific SDK versions: +# SDK Version 1.5.8 and above - Appends zeros to version parts. +# e.g Version 1.6.5 will be normalized as 10605 +# SDK Versions between 1.0.0 and 1.5.8 - Joins all version parts together. +# e.g Version 1.5.3 will be normalized as 153 +# SDK Version 1.0.0 and below - Uses only the 'Minor' version part. +# e.g Version 0.20.0 will be normalized as 20 +# +#=============================================================================# function(_get_normalized_sdk_version OUTPUT_VAR) - set(CONCATENATED_VERSION "${ARDUINO_SDK_VERSION_MAJOR}") - if (${ARDUINO_SDK_VERSION_MINOR} LESS 10) - string(CONCAT CONCATENATED_VERSION "${CONCATENATED_VERSION}" "0") + if (${ARDUINO_SDK_VERSION} VERSION_GREATER 1.5.8) + # -DARDUINO format has changed since 1.6.0 by appending zeros when required, + # e.g for 1.6.5 version -DARDUINO=10605 + _append_suffix_zero_to_version_if_required(${ARDUINO_SDK_VERSION_MAJOR} 10 MAJOR_VERSION) + _append_suffix_zero_to_version_if_required(${ARDUINO_SDK_VERSION_MINOR} 10 MINOR_VERSION) + set(NORMALIZED_VERSION + "${MAJOR_VERSION}${MINOR_VERSION}${ARDUINO_SDK_VERSION_PATCH}") + else () + # -DARDUINO format before 1.0.0 uses only minor version, + # e.g. for 0020 version -DARDUINO=20 + if (${ARDUINO_SDK_VERSION} VERSION_LESS 1.0.0) + set(NORMALIZED_VERSION "${ARDUINO_SDK_VERSION_MINOR}") + else () + # -DARDUINO format after 1.0.0 combines all 3 version parts together, + # e.g. for 1.5.3 version -DARDUINO=153 + set(NORMALIZED_VERSION + "${ARDUINO_SDK_VERSION_MAJOR}\ + ${ARDUINO_SDK_VERSION_MINOR}\ + ${ARDUINO_SDK_VERSION_PATCH}") + endif () endif () - string(CONCAT CONCATENATED_VERSION "${CONCATENATED_VERSION}" - "${ARDUINO_SDK_VERSION_MINOR}") - string(CONCAT CONCATENATED_VERSION "${CONCATENATED_VERSION}" - "${ARDUINO_SDK_VERSION_PATCH}") - set(${OUTPUT_VAR} ${CONCATENATED_VERSION} PARENT_SCOPE) + set(${OUTPUT_VAR} ${NORMALIZED_VERSION} PARENT_SCOPE) endfunction() + +#=============================================================================# +# _append_suffix_zero_to_version_if_required +# [PRIVATE/INTERNAL] +# +# _append_suffix_zero_to_version_if_required(VERSION_PART VERSION_LIMIT OUTPUT_VAR) +# +# VERSION_PART - Version to check and possibly append to. +# Must be a version part - Major, Minor or Patch. +# VERSION_LIMIT - Append limit. For a version greater than this number +# a zero will NOT be appended. +# OUTPUT_VAR - Returned variable storing the normalized version. +# +# Appends a suffic zero to the given version part if it's below than the given limit. +# Otherwise, the version part is returned as it is. +# +#=============================================================================# +macro(_append_suffix_zero_to_version_if_required VERSION_PART VERSION_LIMIT OUTPUT_VAR) + if (${VERSION_PART} LESS ${VERSION_LIMIT}) + set(${OUTPUT_VAR} "${VERSION_PART}0") + else () + set(${OUTPUT_VAR} "${VERSION_PART}") + endif () +endmacro() diff --git a/cmake/Platform/Core/BoardPropertiesReader.cmake b/cmake/Platform/Core/BoardPropertiesReader.cmake index d836dc3..7fbc5b7 100644 --- a/cmake/Platform/Core/BoardPropertiesReader.cmake +++ b/cmake/Platform/Core/BoardPropertiesReader.cmake @@ -73,7 +73,7 @@ endfunction() # # Similar to _get_board_property, except it returns empty value if value was not found. #=============================================================================# -function(_GET_BOARD_PROPERTY_IF_EXISTS BOARD_ID PROPERTY_NAME OUTPUT_VAR) +function(_try_get_board_property BOARD_ID PROPERTY_NAME OUTPUT_VAR) string(REPLACE "." ";" BOARD_INFO ${BOARD_ID}) list(GET BOARD_INFO 0 BOARD_NAME) set(VALUE ${${BOARD_NAME}.${PROPERTY_NAME}}) diff --git a/cmake/Platform/Core/Targets/ArduinoBootloaderBurnTargetCreator.cmake b/cmake/Platform/Core/Targets/ArduinoBootloaderBurnTargetCreator.cmake index ef49a62..a28a2ef 100644 --- a/cmake/Platform/Core/Targets/ArduinoBootloaderBurnTargetCreator.cmake +++ b/cmake/Platform/Core/Targets/ArduinoBootloaderBurnTargetCreator.cmake @@ -28,7 +28,7 @@ function(create_arduino_bootloader_burn_target TARGET_NAME BOARD_ID PROGRAMMER P endif () # look at bootloader.file - _get_board_property_if_exists(${BOARD_ID} bootloader.file BOOTLOADER_FILE) + _try_get_board_property(${BOARD_ID} bootloader.file BOOTLOADER_FILE) if (NOT BOOTLOADER_FILE) message("Missing bootloader.file, not creating bootloader burn target ${BOOTLOADER_TARGET}.") return() @@ -49,7 +49,7 @@ function(create_arduino_bootloader_burn_target TARGET_NAME BOARD_ID PROGRAMMER P #check for required bootloader parameters foreach (ITEM lock_bits unlock_bits high_fuses low_fuses) #do not make fatal error if field doesn't exists, just don't create bootloader burn target - _get_board_property_if_exists(${BOARD_ID} bootloader.${ITEM} BOOTLOADER_${ITEM}) + _try_get_board_property(${BOARD_ID} bootloader.${ITEM} BOOTLOADER_${ITEM}) if (NOT BOOTLOADER_${ITEM}) message("Missing bootloader.${ITEM}, not creating bootloader burn target ${BOOTLOADER_TARGET}.") return() @@ -62,7 +62,7 @@ function(create_arduino_bootloader_burn_target TARGET_NAME BOARD_ID PROGRAMMER P # Set unlock bits and fuses (because chip is going to be erased) list(APPEND AVRDUDE_ARGS "-Ulock:w:${BOOTLOADER_unlock_bits}:m") # extended fuses is optional - _get_board_property_if_exists(${BOARD_ID} bootloader.extended_fuses BOOTLOADER_extended_fuses) + _try_get_board_property(${BOARD_ID} bootloader.extended_fuses BOOTLOADER_extended_fuses) if (BOOTLOADER_extended_fuses) list(APPEND AVRDUDE_ARGS "-Uefuse:w:${BOOTLOADER_extended_fuses}:m") endif()