Skip to content

Commit 96cef4e

Browse files
committed
feat: manage dependencies wrt. core version
Using: - platform.txt to get the version of the core - the dev version of the JSON describing all the tools+versions+deps - stand-alone: Python, wrt. version and modules. Changes: - The download folder is no longer inside Arduino_Core_STM32, but alongside. - The options to control the download (clearance + folder) are removed. - CMake: harmonize the `cmake_minimum_required()`s CMSIS and xpack are no longer downloaded _in_ the root folder, but alongside. All this parsing is costly (e.g., on rebuild), so shortcuts have been implemented if it looks like the dependencies are satisfied already.
1 parent b8224a4 commit 96cef4e

File tree

522 files changed

+1813
-248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

522 files changed

+1813
-248
lines changed

Diff for: .gitignore

-5
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,3 @@ __pycache__/
3232
# VisualStudioCode
3333
.vscode/*
3434
*.code-workspace
35-
36-
# CMake-related
37-
/CMSIS_5/
38-
/xpack-arm-none-eabi-gcc/
39-
/ctags

Diff for: CI/update/templates/CMakeLists.txt

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
{% if objlib and sources %}
21
# v3.21 implemented semantic changes regarding $<TARGET_OBJECTS:...>
32
# See https://cmake.org/cmake/help/v3.21/command/target_link_libraries.html#linking-object-libraries-via-target-objects
43
cmake_minimum_required(VERSION 3.21)
5-
{% endif %}
64

75
add_library({{target}} INTERFACE)
86
add_library({{target}}_usage INTERFACE)

Diff for: CI/update/templates/easy_cmake.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Use it in your CMake configuration by `include()`'ing it.
33
# You can also copy it in your sketch's folder and edit it to fit your project.
44

5-
cmake_minimum_required(VERSION 3.13)
5+
cmake_minimum_required(VERSION 3.21)
66

77
# STEP 1: set up bases of environment
88
# -----------------------------------------------------------------------------

Diff for: CMakeLists.txt

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
1-
cmake_minimum_required(VERSION 3.13)
1+
cmake_minimum_required(VERSION 3.21)
22

33
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
4+
find_package(ArduinoCtags REQUIRED)
45

5-
include(ensure_CMSIS)
6-
include(ensure_ctags)
76

87
project("Arduino_Core_STM32" CXX C ASM)
98

109

1110
set(BUILD_CORE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cores/arduino")
1211
set(BUILD_SYSTEM_PATH "${CMAKE_CURRENT_SOURCE_DIR}/system")
1312
set(BUILD_LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/libraries")
14-
set(CMSIS5_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMSIS_5" CACHE STRING "Path to CMSIS_5")
15-
set(CTAGS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/ctags" CACHE STRING "Folder to find/put ctags in")
16-
17-
option(AUTODL_CMSIS OFF)
18-
option(AUTODL_CTAGS OFF)
19-
20-
ensure_CMSIS(${CMSIS5_PATH} ${AUTODL_CMSIS})
21-
ensure_ctags(${CTAGS_PATH} ${AUTODL_CTAGS})
2213

2314
add_library(base_config INTERFACE)
2415

@@ -58,6 +49,7 @@ target_link_options(base_config INTERFACE
5849
target_link_directories(base_config INTERFACE
5950
"${CMSIS5_PATH}/CMSIS/DSP/Lib/GCC"
6051
)
52+
6153
target_include_directories(base_config INTERFACE
6254
"${BUILD_CORE_PATH}"
6355
"${BUILD_CORE_PATH}/avr"

Diff for: cmake/FindArduinoCtags.cmake

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
cmake_minimum_required(VERSION 3.21)
2+
include(FetchContent)
3+
include(FindPackageHandleStandardArgs)
4+
5+
file(REAL_PATH "${CMAKE_CURRENT_LIST_DIR}/../../.Arduino_Core_STM32_downloads" DL_DIR)
6+
7+
function(get_ctags)
8+
cmake_host_system_information(
9+
RESULT HOSTINFO
10+
QUERY OS_NAME OS_PLATFORM
11+
)
12+
list(GET HOSTINFO 0 HOST_OS)
13+
list(GET HOSTINFO 1 HOST_ARCH)
14+
15+
unset(CPUCODE)
16+
string(TOUPPER ${HOST_ARCH} HOST_ARCH)
17+
if (${HOST_ARCH} MATCHES "^(AMD64|X86_64|x64)$")
18+
set(CPUCODE "x86_64")
19+
elseif (${HOST_ARCH} MATCHES "^(ARM|ARM64)$")
20+
# not sure there, am I specific enough?
21+
set(CPUCODE "armv6")
22+
elseif (${HOST_ARCH} MATCHES "^(I386|IA32|x86|i686)$")
23+
set(CPUCODE "i686")
24+
endif()
25+
26+
unset(OSCODE)
27+
unset(ARCHIVE_EXT)
28+
if (${HOST_OS} STREQUAL "Linux")
29+
if(${CPUCODE} STREQUAL "armv6")
30+
set(OSCODE "linux-gnueabihf")
31+
# ... I guess? Is there any further check to perform?
32+
else()
33+
set(OSCODE "pc-linux-gnu")
34+
endif()
35+
set(ARCHIVE_EXT ".tar.bz2")
36+
elseif (${HOST_OS} STREQUAL "Windows")
37+
if(${CPUCODE} MATCHES "i686|x86_64")
38+
# ctags supports only 32-bit for Windows
39+
set(CPUCODE "i686")
40+
set(OSCODE "mingw32")
41+
set(ARCHIVE_EXT ".zip")
42+
endif()
43+
elseif (${HOST_OS} STREQUAL "Darwin")
44+
if(${CPUCODE} STREQUAL "x86_64")
45+
set(OSCODE "apple-darwin")
46+
set(ARCHIVE_EXT ".zip")
47+
endif()
48+
endif()
49+
50+
# the SHA512 file is of the form "hash_in_hexa filename"
51+
if(NOT EXISTS ${DL_DIR}/ctags_sha512.txt)
52+
file(DOWNLOAD
53+
"https://github.com/arduino/ctags/releases/download/5.8-arduino11/ctags-5.8-arduino11-${CPUCODE}-${OSCODE}${ARCHIVE_EXT}.sha512"
54+
${DL_DIR}/ctags_sha512.txt
55+
)
56+
endif()
57+
file(READ ${DL_DIR}/ctags_sha512.txt CHECKSUM_FULLTEXT)
58+
string(SUBSTRING "${CHECKSUM_FULLTEXT}" 0 128 CHECKSUM) # keep just the hash; 512 bits make 128 hex characters
59+
60+
FetchContent_Declare(
61+
ctags
62+
SOURCE_DIR ${DL_DIR}/dist/ctags
63+
PREFIX ${DL_DIR}
64+
URL "https://github.com/arduino/ctags/releases/download/5.8-arduino11/ctags-5.8-arduino11-${CPUCODE}-${OSCODE}${ARCHIVE_EXT}"
65+
URL_HASH SHA512=${CHECKSUM}
66+
UPDATE_DISCONNECTED
67+
)
68+
FetchContent_MakeAvailable(ctags)
69+
endfunction()
70+
71+
# -------------------------------------------------------------------------------
72+
73+
if(NOT EXISTS ${DL_DIR}/dist/ctags)
74+
get_ctags()
75+
endif()
76+
77+
find_program(ARDUINOCTAGS_EXECUTABLE ctags PATHS ${DL_DIR}/dist/ctags)
78+
79+
find_package_handle_standard_args(ArduinoCtags DEFAULT_MSG
80+
ARDUINOCTAGS_EXECUTABLE
81+
)

Diff for: cmake/build_sketch.cmake

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## core feature
1+
cmake_minimum_required(VERSION 3.21)
22

33
set(SCRIPTS_FOLDER ${CMAKE_CURRENT_LIST_DIR}/../scripts)
44
include(sketch_preprocess_sources)
@@ -46,9 +46,9 @@ function(build_sketch)
4646
BYPRODUCTS ${MAPFILE}
4747
)
4848

49-
if(EXISTS ${PYTHON3})
49+
if(EXISTS ${Python3_EXECUTABLE})
5050
add_custom_command(TARGET ${SKBD_TARGET} POST_BUILD
51-
COMMAND ${PYTHON3} ${SCRIPTS_FOLDER}/sizereport.py -x ${CMAKE_SIZE} -f $<TARGET_FILE:${SKBD_TARGET}> --progmem ${BOARD_MAXSIZE} --datamem ${BOARD_MAXDATASIZE}
51+
COMMAND ${Python3_EXECUTABLE} ${SCRIPTS_FOLDER}/sizereport.py -x ${CMAKE_SIZE} -f $<TARGET_FILE:${SKBD_TARGET}> --progmem ${BOARD_MAXSIZE} --datamem ${BOARD_MAXDATASIZE}
5252
)
5353
else() # STREQUAL "PYTHON3-NOTFOUND"
5454
message(WARNING "python3 not found; the final size report will not be displayed")

Diff for: cmake/convert_file.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
cmake_minimum_required(VERSION 3.21)
22
function(elf2bin ELFTGT)
33
add_custom_command(TARGET ${ELFTGT} POST_BUILD
44
COMMAND ${CMAKE_OBJCOPY} -O binary $<TARGET_FILE:${ELFTGT}> $<TARGET_FILE:${ELFTGT}>.bin

Diff for: cmake/ensure_CMSIS.cmake

-26
This file was deleted.

Diff for: cmake/ensure_binutils.cmake

-87
This file was deleted.

0 commit comments

Comments
 (0)