Skip to content

Resolve property as long as possible #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: release-1.1-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 40 additions & 34 deletions Arduino/Utilities/PropertiesReader.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -200,43 +200,49 @@ function(_properties_expand_value value return_value namespace)
return()
endif ()

# Get the variables list
string(REGEX MATCHALL "{[^{}/]+}" _var_list "${_value}")
if (NOT "${_var_list}" STREQUAL "")
list(REMOVE_DUPLICATES _var_list)
endif()
foreach(_var_str IN LISTS _var_list)

# Get the variable name
string(REGEX MATCH "^{(.*)}$" _match "${_var_str}")
set(_var_name "${CMAKE_MATCH_1}")

# Check if not resolved already
if (NOT DEFINED "/prop_int_resolved.${_var_name}")
# If such a variable is not in the namespace, no need to resolve
if (NOT DEFINED "${namespace}.${_var_name}")
properties_set_value("/prop_int_unresolved" ${_var_name} "")
continue()
endif()

# Temporarily resolve it to the same variable to handle recursive
# references
properties_set_value("/prop_int_resolved" "${_var_name}"
"{${_var_name}}")

# message("=> Resolve *** ${_var_name} *** : "
# "${${namespace}.${_var_name}}")
_properties_expand_value("${${namespace}.${_var_name}}"
_var_value "${namespace}")
properties_set_value("/prop_int_resolved" "${_var_name}"
"${_var_value}")
# message("=> EXPANDED ${_var_name}: ${_var_value}")
# Set previous value to nothing so that there is at least one iteration
set(_previous_value "")
while(NOT "${_previous_value}" STREQUAL "${_value}")
set(_previous_value "${_value}")

# Get the variables list
string(REGEX MATCHALL "{[^{}/]+}" _var_list "${_value}")
if (NOT "${_var_list}" STREQUAL "")
list(REMOVE_DUPLICATES _var_list)
endif()
foreach(_var_str IN LISTS _var_list)

# Get the variable name
string(REGEX MATCH "^{(.*)}$" _match "${_var_str}")
set(_var_name "${CMAKE_MATCH_1}")

# Check if not resolved already
if (NOT DEFINED "/prop_int_resolved.${_var_name}")
# If such a variable is not in the namespace, no need to resolve
if (NOT DEFINED "${namespace}.${_var_name}")
properties_set_value("/prop_int_unresolved" ${_var_name} "")
continue()
endif()

# Temporarily resolve it to the same variable to handle recursive
# references
properties_set_value("/prop_int_resolved" "${_var_name}"
"{${_var_name}}")

# message("=> Resolve *** ${_var_name} *** : "
# "${${namespace}.${_var_name}}")
_properties_expand_value("${${namespace}.${_var_name}}"
_var_value "${namespace}")
properties_set_value("/prop_int_resolved" "${_var_name}"
"${_var_value}")
# message("=> EXPANDED ${_var_name}: ${_var_value}")
endif()

string(REPLACE "${_var_str}" "${/prop_int_resolved.${_var_name}}"
_value "${_value}")
string(REPLACE "${_var_str}" "${/prop_int_resolved.${_var_name}}"
_value "${_value}")

endforeach()
endforeach()
endwhile()

properties_set_parent_scope("/prop_int_resolved")
properties_set_parent_scope("/prop_int_unresolved")
Expand Down
2 changes: 2 additions & 0 deletions Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ function(SetupBoardTests)
set_tests_properties("${distinct_id}" PROPERTIES
FIXTURES_REQUIRED "PlTestResults"
SKIP_RETURN_CODE 100
TIMEOUT 3600
)

if ("${shell_cmd}" STREQUAL "" AND
Expand Down Expand Up @@ -354,6 +355,7 @@ function(SetupPlatformTests pl_url ref_url_list return_pl_tests)
set_tests_properties("${test_id}" PROPERTIES
FIXTURES_REQUIRED "TestResults"
SKIP_RETURN_CODE 100
TIMEOUT 3600
)
if ("${shell_cmd}" STREQUAL "" AND
NOT CMAKE_VERSION VERSION_LESS "3.16.0")
Expand Down