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

Commit dc30b57

Browse files
committed
Merge remote-tracking branch 'origin/feature/code-cleanup' into develop
2 parents 982e8b9 + 9cc596c commit dc30b57

19 files changed

+185
-110
lines changed

cmake/Platform/Arduino.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@ cmake_minimum_required(VERSION 3.8)
33
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Utilities)
44
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/System)
55
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Other)
6-
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Targets)
6+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Properties)
77
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Sketches)
8+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Sources)
9+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Targets)
810

911
include(MathUtils)
1012
include(ListUtils)
1113
include(StringUtils)
1214
include(PropertyUtils)
15+
include(PlatformLibraryUtils)
1316

1417
include(BoardManager)
1518
include(RecipeParser)
1619
include(TargetFlagsManager)
1720
include(SourcesManager)
21+
include(SketchManager)
1822
include(DefaultsManager)
1923

2024
include(BuildSystemInitializer)

cmake/Platform/Other/ArduinoLibraryParser.cmake

Lines changed: 0 additions & 17 deletions
This file was deleted.

cmake/Platform/Other/RecipeParser.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function(parse_upload_recipe_pattern _board_id _port _return_var)
6666
list(FILTER original_list EXCLUDE REGEX ":|cmd")
6767

6868
# Upload recipe contains many elements which aren't named correctly
69-
# Setting a local variable here will keep in the resolving function scope
69+
# Setting a local variable here will keep it in the resolving function's scope
7070
# In other words, it makes the variable resolvable
7171
# So if a special elment is met, its' expected variable is locally set with correct value
7272
foreach (recipe_element ${original_list})

cmake/Platform/Sketches/SketchHeadersManager.cmake

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
1-
#=============================================================================#
2-
# Retrieves all headers used by a sketch, which is much like extracting the headers included
3-
# by a source file. Headers are returned by their name, with extension (such as '.h').
4-
# _sketch_file - Path to a sketch file to add to the target.
5-
# _return_var - Name of variable in parent-scope holding the return value.
6-
# Returns - List of headers names with extension that are included by the given sketch file.
7-
#=============================================================================#
8-
function(_get_sketch_headers _sketch_file _return_var)
9-
10-
file(STRINGS "${_sketch_file}" sketch_loc) # Loc = Lines of code
11-
list(FILTER sketch_loc INCLUDE REGEX ${ARDUINO_CMAKE_HEADER_INCLUDE_REGEX_PATTERN})
12-
13-
# Extract header names from inclusion
14-
foreach (loc ${sketch_loc})
15-
string(REGEX MATCH ${ARDUINO_CMAKE_HEADER_NAME_REGEX_PATTERN} ${loc} match)
16-
list(APPEND headers ${CMAKE_MATCH_1})
17-
endforeach ()
18-
19-
set(${_return_var} ${headers} PARENT_SCOPE)
20-
21-
endfunction()
22-
231
#=============================================================================#
242
# Validates a header file is included by the given target.
253
# i.e The header is located under one of the target's include directories.
@@ -51,23 +29,24 @@ endfunction()
5129
#=============================================================================#
5230
function(resolve_sketch_headers _target_name _board_id _sketch_file)
5331

54-
_get_sketch_headers("${_sketch_file}" sketch_headers)
32+
get_source_file_included_headers("${_sketch_file}" sketch_headers)
5533
foreach (header ${sketch_headers})
5634
# Header name without extension (such as '.h') can represent an Arduino/Platform library
5735
# So first we should check whether it's a library
58-
string(REGEX MATCH "(.+)\\." "${header}" header_we_match)
59-
set(header_we ${CMAKE_MATCH_1})
36+
get_name_without_file_extension("${header}" header_we)
6037

61-
if (${header_we} IN_LIST ARDUINO_CMAKE_PLATFORM_LIBRARIES)
62-
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})
6342
else ()
6443
find_arduino_library(${header_we}_sketch_lib ${header_we} ${_board_id})
6544
# If library isn't found, display a wraning since it might be a user library
66-
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")
6746
_validate_target_includes_header(${_target_name} ${header} is_header_validated)
6847
if (NOT is_header_validated)
6948
# Header hasn't been found in any of the target's include directories, Display warning
70-
message(WARNING "The header '${_header}' is used by the \
49+
message(WARNING "The header '${header_we}' is used by the \
7150
'${_sketch_file}' sketch \
7251
but it isn't a Arduino/Platform library, nor it's linked \
7352
to the target manually!")

cmake/Platform/Sketches/SketchManager.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ endfunction()
2727
#=============================================================================#
2828
function(add_sketch_to_target _target_name _board_id _sketch_file)
2929

30-
resolve_sketch_headers(${_target_name} ${_board_id} "${_sketch_file}")
3130
_get_converted_source_desired_path("${_sketch_file}" sketch_converted_source_path)
3231

3332
# Only perform conversion if policy is set or if sketch hasn't been converted yet
34-
if (CONVERT_SKETCHES_IF_CONVERTED_SOURCES_EXISTS OR NOT EXISTS "${sketch_file}")
33+
if (CONVERT_SKETCHES_IF_CONVERTED_SOURCES_EXISTS OR
34+
NOT EXISTS "${sketch_converted_source_path}")
35+
resolve_sketch_headers(${_target_name} ${_board_id} "${_sketch_file}")
3536
convert_sketch_to_source("${_sketch_file}" "${sketch_converted_source_path}")
3637
endif ()
3738

0 commit comments

Comments
 (0)