Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Commit 9058ed6

Browse files
committed
Fixed bug in sketch header resolving where Arduino libraries couldn't be linked.
Renamed `ArduinoLibraryParser` module to `PlatformLibraryUtils` as it's a better suited name. Added a utility function to check if a given name resolves to a platform library.
1 parent a0e20bd commit 9058ed6

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

cmake/Platform/Arduino.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ include(MathUtils)
1212
include(ListUtils)
1313
include(StringUtils)
1414
include(PropertyUtils)
15+
include(PlatformLibraryUtils)
1516

1617
include(BoardManager)
1718
include(RecipeParser)

cmake/Platform/Sketches/SketchHeadersManager.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,18 @@ function(resolve_sketch_headers _target_name _board_id _sketch_file)
3535
# So first we should check whether it's a library
3636
get_name_without_file_extension("${header}" header_we)
3737

38-
if (${header_we} IN_LIST ARDUINO_CMAKE_PLATFORM_LIBRARIES)
39-
link_platform_library(${_target_name} ${header_we} ${_board_id})
38+
is_platform_library(${header_we} is_header_platform_lib)
39+
if (is_header_platform_lib)
40+
string(TOLOWER ${header_we} header_we_lower)
41+
link_platform_library(${_target_name} ${header_we_lower} ${_board_id})
4042
else ()
4143
find_arduino_library(${header_we}_sketch_lib ${header_we} ${_board_id})
4244
# If library isn't found, display a wraning since it might be a user library
43-
if (NOT ${header_we}_sketch_lib OR "${${header_we}_sketch_lib}" MATCHES "NOTFOUND")
45+
if (NOT TARGET ${header_we}_sketch_lib OR "${${header_we}_sketch_lib}" MATCHES "NOTFOUND")
4446
_validate_target_includes_header(${_target_name} ${header} is_header_validated)
4547
if (NOT is_header_validated)
4648
# Header hasn't been found in any of the target's include directories, Display warning
47-
message(WARNING "The header '${_header}' is used by the \
49+
message(WARNING "The header '${header_we}' is used by the \
4850
'${_sketch_file}' sketch \
4951
but it isn't a Arduino/Platform library, nor it's linked \
5052
to the target manually!")

cmake/Platform/Targets/PlatformLibraryTarget.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
include(ArduinoLibraryParser)
2-
31
#=============================================================================#
42
# Looks for any platform libraries (Resolved earlier when platform has been initialized)
53
# within the given sources and returns them in a list.

cmake/Platform/Other/ArduinoLibraryParser.cmake renamed to cmake/Platform/Utilities/PlatformLibraryUtils.cmake

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
#=============================================================================#
2+
# Checks whether the given name resolves to one of the platform libraries' names.
3+
# _name - Name to check.
4+
# _return_var - Name of variable in parent-scope holding the return value.
5+
# Returns - True if name resolves to a platform library's name, false otherwise.
6+
#=============================================================================#
7+
function(is_platform_library _name _return_var)
8+
9+
string(TOLOWER "${_name}" name_lower)
10+
if ("${name_lower}" IN_LIST ARDUINO_CMAKE_PLATFORM_LIBRARIES)
11+
set(lib_found TRUE)
12+
else ()
13+
set(lib_found FALSE)
14+
endif ()
15+
16+
set(${_return_var} ${lib_found} PARENT_SCOPE)
17+
18+
endfunction()
19+
120
#=============================================================================#
221
# Retrieves all registered platform library names from the given list of names,
322
# which usually resolves to names of headers included by a source file.
@@ -8,6 +27,7 @@
827
function(get_platform_libraries_from_names _names _return_var)
928

1029
foreach (name ${_names})
30+
# Can't use `is_platform_library` function since it returns just a boolean
1131
string(TOLOWER "${name}" name_lower)
1232
if ("${name_lower}" IN_LIST ARDUINO_CMAKE_PLATFORM_LIBRARIES)
1333
list(APPEND platform_libs "${name}")
@@ -17,3 +37,4 @@ function(get_platform_libraries_from_names _names _return_var)
1737
set(${_return_var} ${platform_libs} PARENT_SCOPE)
1838

1939
endfunction()
40+

0 commit comments

Comments
 (0)