cmake: Don't lose global sysbuild value with zephyr_get(... MERGE)
According to the doc comment:
If using MERGE then SYSBUILD GLOBAL will get both the local and global
sysbuild scope variables (in that order, if both exist).
This stopped working in commit 8460d91e32
,
when support for `zephyr_get(... VAR <multiple-variables>)` was added.
Instead of returning both values, the local sysbuild scope value would
clobber the global one. Fix this by splitting the internal `sysbuild`
scope into `sysbuild_local` and `sysbuild_global`, in that order.
Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
This commit is contained in:
parent
5ef7229a8c
commit
7f4b1abb39
|
@ -2641,14 +2641,17 @@ function(zephyr_get variable)
|
||||||
if(SYSBUILD)
|
if(SYSBUILD)
|
||||||
get_property(sysbuild_name TARGET sysbuild_cache PROPERTY SYSBUILD_NAME)
|
get_property(sysbuild_name TARGET sysbuild_cache PROPERTY SYSBUILD_NAME)
|
||||||
get_property(sysbuild_main_app TARGET sysbuild_cache PROPERTY SYSBUILD_MAIN_APP)
|
get_property(sysbuild_main_app TARGET sysbuild_cache PROPERTY SYSBUILD_MAIN_APP)
|
||||||
get_property(sysbuild_${var} TARGET sysbuild_cache PROPERTY ${sysbuild_name}_${var})
|
get_property(sysbuild_local_${var} TARGET sysbuild_cache PROPERTY ${sysbuild_name}_${var})
|
||||||
if(NOT DEFINED sysbuild_${var} AND
|
get_property(sysbuild_global_${var} TARGET sysbuild_cache PROPERTY ${var})
|
||||||
("${GET_VAR_SYSBUILD}" STREQUAL "GLOBAL" OR sysbuild_main_app)
|
if(NOT DEFINED sysbuild_local_${var} AND sysbuild_main_app)
|
||||||
)
|
set(sysbuild_local_${var} ${sysbuild_global_${var}})
|
||||||
get_property(sysbuild_${var} TARGET sysbuild_cache PROPERTY ${var})
|
endif()
|
||||||
|
if(NOT "${GET_VAR_SYSBUILD}" STREQUAL "GLOBAL")
|
||||||
|
set(sysbuild_global_${var})
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
set(sysbuild_${var})
|
set(sysbuild_local_${var})
|
||||||
|
set(sysbuild_global_${var})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(TARGET snippets_scope)
|
if(TARGET snippets_scope)
|
||||||
|
@ -2656,7 +2659,7 @@ function(zephyr_get variable)
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
set(scopes "sysbuild;CACHE;snippets;ENV;current")
|
set(scopes "sysbuild_local;sysbuild_global;CACHE;snippets;ENV;current")
|
||||||
if(GET_VAR_REVERSE)
|
if(GET_VAR_REVERSE)
|
||||||
list(REVERSE scopes)
|
list(REVERSE scopes)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -230,7 +230,7 @@ function(test_merge)
|
||||||
IMAGE no_sysbuild ""
|
IMAGE no_sysbuild ""
|
||||||
# This image's LOCAL and GLOBAL are identical; duplicates are removed.
|
# This image's LOCAL and GLOBAL are identical; duplicates are removed.
|
||||||
IMAGE zephyr_get "sysbuild.main"
|
IMAGE zephyr_get "sysbuild.main"
|
||||||
IMAGE zephyr_get_2nd "sysbuild.2nd" # BUG
|
IMAGE zephyr_get_2nd "sysbuild.2nd;sysbuild.main"
|
||||||
IMAGE zephyr_get_3rd "sysbuild.main"
|
IMAGE zephyr_get_3rd "sysbuild.main"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ function(test_merge)
|
||||||
assert_equal(TESTCASE_VARIABLE
|
assert_equal(TESTCASE_VARIABLE
|
||||||
IMAGE no_sysbuild "cmake cache;environment;local"
|
IMAGE no_sysbuild "cmake cache;environment;local"
|
||||||
IMAGE zephyr_get "cmake cache;sysbuild.main;environment;local" # BUG
|
IMAGE zephyr_get "cmake cache;sysbuild.main;environment;local" # BUG
|
||||||
IMAGE zephyr_get_2nd "cmake cache;sysbuild.2nd;environment;local" # BUG
|
IMAGE zephyr_get_2nd "cmake cache;sysbuild.2nd;sysbuild.main;environment;local" # BUG
|
||||||
IMAGE zephyr_get_3rd "cmake cache;sysbuild.main;environment;local" # BUG
|
IMAGE zephyr_get_3rd "cmake cache;sysbuild.main;environment;local" # BUG
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ function(test_merge)
|
||||||
assert_equal(TESTCASE_VARIABLE
|
assert_equal(TESTCASE_VARIABLE
|
||||||
IMAGE no_sysbuild "environment"
|
IMAGE no_sysbuild "environment"
|
||||||
IMAGE zephyr_get "sysbuild.main;environment"
|
IMAGE zephyr_get "sysbuild.main;environment"
|
||||||
IMAGE zephyr_get_2nd "sysbuild.2nd;environment" # BUG
|
IMAGE zephyr_get_2nd "sysbuild.2nd;sysbuild.main;environment"
|
||||||
IMAGE zephyr_get_3rd "sysbuild.main;environment"
|
IMAGE zephyr_get_3rd "sysbuild.main;environment"
|
||||||
)
|
)
|
||||||
assert_equal(CACHE{TESTCASE_VARIABLE} "")
|
assert_equal(CACHE{TESTCASE_VARIABLE} "")
|
||||||
|
@ -377,7 +377,7 @@ function(test_multivar)
|
||||||
assert_equal(RESULT
|
assert_equal(RESULT
|
||||||
IMAGE no_sysbuild "cmake cache s;cmake cache 2;environment s;environment 1;environment 3;local s;local 2;local 3"
|
IMAGE no_sysbuild "cmake cache s;cmake cache 2;environment s;environment 1;environment 3;local s;local 2;local 3"
|
||||||
IMAGE zephyr_get "sysbuild.main;cmake cache s;cmake cache 2;environment s;environment 1;environment 3;local s;local 2;local 3"
|
IMAGE zephyr_get "sysbuild.main;cmake cache s;cmake cache 2;environment s;environment 1;environment 3;local s;local 2;local 3"
|
||||||
IMAGE zephyr_get_2nd "sysbuild.2nd;cmake cache s;cmake cache 2;environment s;environment 1;environment 3;local s;local 2;local 3" # BUG
|
IMAGE zephyr_get_2nd "sysbuild.2nd;sysbuild.main;cmake cache s;cmake cache 2;environment s;environment 1;environment 3;local s;local 2;local 3"
|
||||||
IMAGE zephyr_get_3rd "sysbuild.main;cmake cache s;cmake cache 2;environment s;environment 1;environment 3;local s;local 2;local 3"
|
IMAGE zephyr_get_3rd "sysbuild.main;cmake cache s;cmake cache 2;environment s;environment 1;environment 3;local s;local 2;local 3"
|
||||||
)
|
)
|
||||||
unset(RESULT)
|
unset(RESULT)
|
||||||
|
@ -393,7 +393,7 @@ function(test_multivar)
|
||||||
assert_equal(RESULT
|
assert_equal(RESULT
|
||||||
IMAGE no_sysbuild "cmake cache 2;cmake cache s;environment 3;environment 1;environment s;local 3;local 2;local s"
|
IMAGE no_sysbuild "cmake cache 2;cmake cache s;environment 3;environment 1;environment s;local 3;local 2;local s"
|
||||||
IMAGE zephyr_get "sysbuild.main;cmake cache 2;cmake cache s;environment 3;environment 1;environment s;local 3;local 2;local s"
|
IMAGE zephyr_get "sysbuild.main;cmake cache 2;cmake cache s;environment 3;environment 1;environment s;local 3;local 2;local s"
|
||||||
IMAGE zephyr_get_2nd "sysbuild.2nd;cmake cache 2;cmake cache s;environment 3;environment 1;environment s;local 3;local 2;local s" # BUG
|
IMAGE zephyr_get_2nd "sysbuild.2nd;sysbuild.main;cmake cache 2;cmake cache s;environment 3;environment 1;environment s;local 3;local 2;local s"
|
||||||
IMAGE zephyr_get_3rd "sysbuild.main;cmake cache 2;cmake cache s;environment 3;environment 1;environment s;local 3;local 2;local s"
|
IMAGE zephyr_get_3rd "sysbuild.main;cmake cache 2;cmake cache s;environment 3;environment 1;environment s;local 3;local 2;local s"
|
||||||
)
|
)
|
||||||
unset(RESULT)
|
unset(RESULT)
|
||||||
|
@ -449,7 +449,7 @@ function(test_merge_reverse)
|
||||||
assert_equal(TESTCASE_VARIABLE
|
assert_equal(TESTCASE_VARIABLE
|
||||||
IMAGE no_sysbuild ""
|
IMAGE no_sysbuild ""
|
||||||
IMAGE zephyr_get "sysbuild.main"
|
IMAGE zephyr_get "sysbuild.main"
|
||||||
IMAGE zephyr_get_2nd "sysbuild.2nd" # BUG
|
IMAGE zephyr_get_2nd "sysbuild.main;sysbuild.2nd"
|
||||||
IMAGE zephyr_get_3rd "sysbuild.main"
|
IMAGE zephyr_get_3rd "sysbuild.main"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -462,7 +462,7 @@ function(test_merge_reverse)
|
||||||
assert_equal(TESTCASE_VARIABLE
|
assert_equal(TESTCASE_VARIABLE
|
||||||
IMAGE no_sysbuild "local s;environment s;cmake cache s"
|
IMAGE no_sysbuild "local s;environment s;cmake cache s"
|
||||||
IMAGE zephyr_get "local s;environment s;cmake cache s;sysbuild.main"
|
IMAGE zephyr_get "local s;environment s;cmake cache s;sysbuild.main"
|
||||||
IMAGE zephyr_get_2nd "local s;environment s;cmake cache s;sysbuild.2nd" # BUG
|
IMAGE zephyr_get_2nd "local s;environment s;cmake cache s;sysbuild.main;sysbuild.2nd"
|
||||||
IMAGE zephyr_get_3rd "local s;environment s;cmake cache s;sysbuild.main"
|
IMAGE zephyr_get_3rd "local s;environment s;cmake cache s;sysbuild.main"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -483,7 +483,7 @@ function(test_merge_reverse)
|
||||||
assert_equal(RESULT
|
assert_equal(RESULT
|
||||||
IMAGE no_sysbuild "local s;local 1;local 2;environment s;environment 1;environment 2;cmake cache s;cmake cache 1;cmake cache 2"
|
IMAGE no_sysbuild "local s;local 1;local 2;environment s;environment 1;environment 2;cmake cache s;cmake cache 1;cmake cache 2"
|
||||||
IMAGE zephyr_get "local s;local 1;local 2;environment s;environment 1;environment 2;cmake cache s;cmake cache 1;cmake cache 2;sysbuild.main"
|
IMAGE zephyr_get "local s;local 1;local 2;environment s;environment 1;environment 2;cmake cache s;cmake cache 1;cmake cache 2;sysbuild.main"
|
||||||
IMAGE zephyr_get_2nd "local s;local 1;local 2;environment s;environment 1;environment 2;cmake cache s;cmake cache 1;cmake cache 2;sysbuild.2nd" # BUG
|
IMAGE zephyr_get_2nd "local s;local 1;local 2;environment s;environment 1;environment 2;cmake cache s;cmake cache 1;cmake cache 2;sysbuild.main;sysbuild.2nd"
|
||||||
IMAGE zephyr_get_3rd "local s;local 1;local 2;environment s;environment 1;environment 2;cmake cache s;cmake cache 1;cmake cache 2;sysbuild.main"
|
IMAGE zephyr_get_3rd "local s;local 1;local 2;environment s;environment 1;environment 2;cmake cache s;cmake cache 1;cmake cache 2;sysbuild.main"
|
||||||
)
|
)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
@ -556,7 +556,7 @@ function(test_snippets_scope)
|
||||||
assert_equal(TESTCASE_VARIABLE
|
assert_equal(TESTCASE_VARIABLE
|
||||||
IMAGE no_sysbuild "snippet s"
|
IMAGE no_sysbuild "snippet s"
|
||||||
IMAGE zephyr_get "sysbuild.main;snippet s"
|
IMAGE zephyr_get "sysbuild.main;snippet s"
|
||||||
IMAGE zephyr_get_2nd "sysbuild.2nd;snippet s" # BUG
|
IMAGE zephyr_get_2nd "sysbuild.2nd;sysbuild.main;snippet s"
|
||||||
IMAGE zephyr_get_3rd "sysbuild.main;snippet s"
|
IMAGE zephyr_get_3rd "sysbuild.main;snippet s"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue