@@ -1519,7 +1519,8 @@ endfunction()
1519
1519
# build string as first item in the list.
1520
1520
# The full order of build strings returned in the list will be:
1521
1521
# - Normalized board target build string, this includes qualifiers and revision
1522
- # - Normalized board target build string, without revision
1522
+ # - Build string with board variants removed in addition
1523
+ # - Build string with cpuset removed in addition
1523
1524
# - Build string with soc removed in addition
1524
1525
#
1525
1526
# If BUILD is supplied, then build type will be appended to each entry in the
@@ -1538,6 +1539,7 @@ endfunction()
1538
1539
# )
1539
1540
#
1540
1541
# <out-variable>: Output variable where the build string will be returned.
1542
+ # SHORT <out-variable>: Output variable where the shortened build string will be returned.
1541
1543
# BOARD <board>: Board name to use when creating the build string.
1542
1544
# BOARD_REVISION <revision>: Board revision to use when creating the build string.
1543
1545
# BUILD <type>: Build type to use when creating the build string.
@@ -1560,11 +1562,17 @@ endfunction()
1560
1562
# calling
1561
1563
# zephyr_build_string(build_string BOARD alpha BOARD_REVISION 1.0.0 BOARD_QUALIFIERS /soc/bar MERGE)
1562
1564
# will return a list of the following strings
1563
- # `alpha_soc_bar_1_0_0;alpha_soc_bar;alpha_bar` in `build_string` parameter.
1565
+ # `alpha_soc_bar_1_0_0;alpha_soc_bar` in `build_string` parameter.
1566
+ #
1567
+ # calling
1568
+ # zephyr_build_string(build_string SHORTENED short_build_string BOARD alpha BOARD_REVISION 1.0.0 BOARD_QUALIFIERS /soc/bar MERGE)
1569
+ # will return two lists of the following strings
1570
+ # `alpha_soc_bar_1_0_0;alpha_soc_bar` in `build_string` parameter.
1571
+ # `alpha_bar_1_0_0;alpha_bar` in `short_build_string` parameter.
1564
1572
#
1565
1573
function (zephyr_build_string outvar)
1566
1574
set (options MERGE REVERSE )
1567
- set (single_args BOARD BOARD_QUALIFIERS BOARD_REVISION BUILD )
1575
+ set (single_args BOARD BOARD_QUALIFIERS BOARD_REVISION BUILD SHORT )
1568
1576
1569
1577
cmake_parse_arguments (BUILD_STR "${options} " "${single_args} " "" ${ARGN} )
1570
1578
if (BUILD_STR_UNPARSED_ARGUMENTS)
@@ -1588,28 +1596,44 @@ function(zephyr_build_string outvar)
1588
1596
)
1589
1597
endif ()
1590
1598
1591
- string (REPLACE "/" ";" str_segment_list "${BUILD_STR_BOARD}${ BUILD_STR_BOARD_QUALIFIERS} " )
1599
+ string (REPLACE "/" ";" str_segment_list "${BUILD_STR_BOARD_QUALIFIERS} " )
1592
1600
string (REPLACE "." "_" revision_string "${BUILD_STR_BOARD_REVISION} " )
1593
1601
1594
- string (JOIN "_" ${outvar} ${str_segment_list} ${revision_string} ${BUILD_STR_BUILD} )
1602
+ string (JOIN "_" ${outvar} ${BUILD_STR_BOARD} ${ str_segment_list} ${revision_string} ${BUILD_STR_BUILD} )
1595
1603
1596
1604
if (BUILD_STR_MERGE)
1597
- string (JOIN "_" variant_string ${str_segment_list} ${BUILD_STR_BUILD} )
1605
+ string (JOIN "_" variant_string ${BUILD_STR_BOARD} ${ str_segment_list} ${BUILD_STR_BUILD} )
1598
1606
1599
1607
if (NOT "${variant_string} " IN_LIST ${outvar} )
1600
1608
list (APPEND ${outvar} "${variant_string} " )
1601
1609
endif ()
1602
-
1603
- if (BUILD_STR_BOARD_QUALIFIERS)
1604
- string (REGEX REPLACE "^/[^/]*(.*)" "\\ 1" qualifiers_without_soc "${BUILD_STR_BOARD_QUALIFIERS} " )
1605
- string (REPLACE "/" "_" qualifiers_without_soc "${qualifiers_without_soc} " )
1606
- list (APPEND ${outvar} "${BUILD_STR_BOARD}${qualifiers_without_soc} " )
1607
- endif ()
1608
1610
endif ()
1609
1611
1610
1612
if (BUILD_STR_REVERSE)
1611
1613
list (REVERSE ${outvar} )
1612
1614
endif ()
1615
+ list (REMOVE_DUPLICATES ${outvar} )
1616
+
1617
+ if (BUILD_STR_SHORT AND BUILD_STR_BOARD_QUALIFIERS)
1618
+ string (REGEX REPLACE "^/[^/]*(.*)" "\\ 1" shortened_qualifiers "${BOARD_QUALIFIERS} " )
1619
+ string (REPLACE "/" ";" str_short_segment_list "${shortened_qualifiers} " )
1620
+ string (JOIN "_" ${BUILD_STR_SHORT}
1621
+ ${BUILD_STR_BOARD} ${str_short_segment_list} ${revision_string} ${BUILD_STR_BUILD}
1622
+ )
1623
+ if (BUILD_STR_MERGE)
1624
+ string (JOIN "_" variant_string ${BUILD_STR_BOARD} ${str_short_segment_list} ${BUILD_STR_BUILD} )
1625
+
1626
+ if (NOT "${variant_string} " IN_LIST ${BUILD_STR_SHORT} )
1627
+ list (APPEND ${BUILD_STR_SHORT} "${variant_string} " )
1628
+ endif ()
1629
+ endif ()
1630
+
1631
+ if (BUILD_STR_REVERSE)
1632
+ list (REVERSE ${BUILD_STR_SHORT} )
1633
+ endif ()
1634
+ list (REMOVE_DUPLICATES ${BUILD_STR_SHORT} )
1635
+ set (${BUILD_STR_SHORT} ${${BUILD_STR_SHORT} } PARENT_SCOPE)
1636
+ endif ()
1613
1637
1614
1638
# This updates the provided outvar in parent scope (callers scope)
1615
1639
set (${outvar} ${${outvar} } PARENT_SCOPE)
@@ -2522,7 +2546,6 @@ endfunction()
2522
2546
# creating file names based on board settings.
2523
2547
# Only the first match found in <paths> will be
2524
2548
# returned in the <list>
2525
- #
2526
2549
# DTS <list>: List to append DTS overlay files in <path> to
2527
2550
# KCONF <list>: List to append Kconfig fragment files in <path> to
2528
2551
# DEFCONF <list>: List to append _defconfig files in <path> to
@@ -2618,32 +2641,44 @@ Relative paths are only allowed with `-D${ARGV1}=<path>`")
2618
2641
set (kconf_filename_list ${ZFILE_NAMES} )
2619
2642
else ()
2620
2643
zephyr_build_string(filename_list
2644
+ SHORT shortened_filename_list
2621
2645
BOARD ${ZFILE_BOARD}
2622
2646
BOARD_REVISION ${ZFILE_BOARD_REVISION}
2623
2647
BOARD_QUALIFIERS ${ZFILE_BOARD_QUALIFIERS}
2624
2648
BUILD ${ZFILE_BUILD}
2625
2649
MERGE REVERSE
2626
2650
)
2627
- list ( REMOVE_DUPLICATES filename_list)
2651
+
2628
2652
set (dts_filename_list ${filename_list} )
2653
+ set (dts_shortened_filename_list ${shortened_filename_list} )
2629
2654
list (TRANSFORM dts_filename_list APPEND ".overlay" )
2655
+ list (TRANSFORM dts_shortened_filename_list APPEND ".overlay" )
2630
2656
2631
2657
set (kconf_filename_list ${filename_list} )
2658
+ set (kconf_shortened_filename_list ${shortened_filename_list} )
2632
2659
list (TRANSFORM kconf_filename_list APPEND ".conf" )
2660
+ list (TRANSFORM kconf_shortened_filename_list APPEND ".conf" )
2633
2661
endif ()
2634
2662
2635
2663
if (ZFILE_DTS)
2636
2664
foreach (path ${ZFILE_CONF_FILES} )
2637
- foreach (filename ${dts_filename_list} )
2638
- if (NOT IS_ABSOLUTE ${filename} )
2639
- set (test_file ${path} /${filename} )
2640
- else ()
2641
- set (test_file ${filename} )
2642
- endif ()
2643
- zephyr_file_suffix(test_file SUFFIX ${ZFILE_SUFFIX} )
2665
+ foreach (filename IN ZIP_LISTS dts_filename_list dts_shortened_filename_list)
2666
+ foreach (i RANGE 1)
2667
+ if (NOT IS_ABSOLUTE filename_${i} AND DEFINED filename_${i} )
2668
+ set (test_file_${i} ${path} /${filename_${i} })
2669
+ else ()
2670
+ set (test_file_${i} ${filename_${i} })
2671
+ endif ()
2672
+ zephyr_file_suffix(test_file_${i} SUFFIX ${ZFILE_SUFFIX} )
2644
2673
2645
- if (EXISTS ${test_file} )
2646
- list (APPEND ${ZFILE_DTS} ${test_file} )
2674
+ if (NOT EXISTS ${test_file_${i} })
2675
+ set (test_file_${i} )
2676
+ endif ()
2677
+ endforeach ()
2678
+
2679
+ if (test_file_0 OR test_file_1)
2680
+ list (APPEND found_dts_files ${test_file_0} )
2681
+ list (APPEND found_dts_files ${test_file_1} )
2647
2682
2648
2683
if (DEFINED ZFILE_BUILD)
2649
2684
set (deprecated_file_found y)
@@ -2653,29 +2688,48 @@ Relative paths are only allowed with `-D${ARGV1}=<path>`")
2653
2688
break ()
2654
2689
endif ()
2655
2690
endif ()
2691
+
2692
+ if (test_file_1 AND NOT BOARD_${ZFILE_BOARD} _SINGLE_SOC)
2693
+ message (FATAL_ERROR "Board ${ZFILE_BOARD} defines multiple SoCs.\n Shortened file name "
2694
+ "(${filename_1} ) not allowed, use '<board>_<soc>.overlay' naming"
2695
+ )
2696
+ endif ()
2697
+
2698
+ if (test_file_0 AND test_file_1)
2699
+ message (FATAL_ERROR "Conflicting file names discovered. Cannot use both ${filename_0} "
2700
+ "and ${filename_1} . Please choose one naming style, "
2701
+ "${filename_0} is recommended."
2702
+ )
2703
+ endif ()
2656
2704
endforeach ()
2657
2705
endforeach ()
2658
2706
2707
+ list (APPEND ${ZFILE_DTS} ${found_dts_files} )
2708
+
2659
2709
# This updates the provided list in parent scope (callers scope)
2660
2710
set (${ZFILE_DTS} ${${ZFILE_DTS} } PARENT_SCOPE)
2661
-
2662
- if (NOT ${ZFILE_DTS} )
2663
- set (not_found ${dts_filename_list} )
2664
- endif ()
2665
2711
endif ()
2666
2712
2667
2713
if (ZFILE_KCONF)
2714
+ set (found_conf_files)
2668
2715
foreach (path ${ZFILE_CONF_FILES} )
2669
- foreach (filename ${kconf_filename_list} )
2670
- if (NOT IS_ABSOLUTE ${filename} )
2671
- set (test_file ${path} /${filename} )
2672
- else ()
2673
- set (test_file ${filename} )
2674
- endif ()
2675
- zephyr_file_suffix(test_file SUFFIX ${ZFILE_SUFFIX} )
2716
+ foreach (filename IN ZIP_LISTS kconf_filename_list kconf_shortened_filename_list)
2717
+ foreach (i RANGE 1)
2718
+ if (NOT IS_ABSOLUTE filename_${i} AND DEFINED filename_${i} )
2719
+ set (test_file_${i} ${path} /${filename_${i} })
2720
+ else ()
2721
+ set (test_file_${i} ${filename_${i} })
2722
+ endif ()
2723
+ zephyr_file_suffix(test_file_${i} SUFFIX ${ZFILE_SUFFIX} )
2724
+
2725
+ if (NOT EXISTS ${test_file_${i} })
2726
+ set (test_file_${i} )
2727
+ endif ()
2728
+ endforeach ()
2676
2729
2677
- if (EXISTS ${test_file} )
2678
- list (APPEND ${ZFILE_KCONF} ${test_file} )
2730
+ if (test_file_0 OR test_file_1)
2731
+ list (APPEND found_conf_files ${test_file_0} )
2732
+ list (APPEND found_conf_files ${test_file_1} )
2679
2733
2680
2734
if (DEFINED ZFILE_BUILD)
2681
2735
set (deprecated_file_found y)
@@ -2685,9 +2739,24 @@ Relative paths are only allowed with `-D${ARGV1}=<path>`")
2685
2739
break ()
2686
2740
endif ()
2687
2741
endif ()
2742
+
2743
+ if (test_file_1 AND NOT BOARD_${ZFILE_BOARD} _SINGLE_SOC)
2744
+ message (FATAL_ERROR "Board ${ZFILE_BOARD} defines multiple SoCs.\n Shortened file name "
2745
+ "(${filename_1} ) not allowed, use '<board>_<soc>.conf' naming"
2746
+ )
2747
+ endif ()
2748
+
2749
+ if (test_file_0 AND test_file_1)
2750
+ message (FATAL_ERROR "Conflicting file names discovered. Cannot use both ${filename_0} "
2751
+ "and ${filename_1} . Please choose one naming style, "
2752
+ "${filename_0} is recommended."
2753
+ )
2754
+ endif ()
2688
2755
endforeach ()
2689
2756
endforeach ()
2690
2757
2758
+ list (APPEND ${ZFILE_KCONF} ${found_conf_files} )
2759
+
2691
2760
# This updates the provided list in parent scope (callers scope)
2692
2761
set (${ZFILE_KCONF} ${${ZFILE_KCONF} } PARENT_SCOPE)
2693
2762
@@ -2709,13 +2778,34 @@ Relative paths are only allowed with `-D${ARGV1}=<path>`")
2709
2778
endif ()
2710
2779
2711
2780
if (ZFILE_DEFCONFIG)
2781
+ set (found_defconf_files)
2712
2782
foreach (path ${ZFILE_CONF_FILES} )
2713
- foreach (filename ${filename_list} )
2714
- if (EXISTS ${path} /${filename} _defconfig)
2715
- list (APPEND ${ZFILE_DEFCONFIG} ${path} /${filename} _defconfig)
2783
+ foreach (filename IN ZIP_LISTS filename_list shortened_filename_list)
2784
+ foreach (i RANGE 1)
2785
+ set (test_file_${i} ${path} /${filename_${i} }_defconfig)
2786
+
2787
+ if (EXISTS ${test_file_${i} })
2788
+ list (APPEND found_defconf_files ${test_file_${i} })
2789
+ else ()
2790
+ set (test_file_${i} )
2791
+ endif ()
2792
+ endforeach ()
2793
+
2794
+ if (test_file_1 AND NOT BOARD_${ZFILE_BOARD} _SINGLE_SOC)
2795
+ message (FATAL_ERROR "Board ${ZFILE_BOARD} defines multiple SoCs.\n Shortened file name "
2796
+ "(${filename_1} _defconfig) not allowed, use '<board>_<soc>_defconfig' naming"
2797
+ )
2798
+ endif ()
2799
+
2800
+ if (test_file_0 AND test_file_1)
2801
+ message (FATAL_ERROR "Conflicting file names discovered. Cannot use both "
2802
+ "${filename_0} _defconfig and ${filename_1} _defconfig. Please choose one "
2803
+ "naming style, ${filename_0} _defconfig is recommended."
2804
+ )
2716
2805
endif ()
2717
2806
endforeach ()
2718
2807
endforeach ()
2808
+ list (APPEND ${ZFILE_DEFCONFIG} ${found_defconf_files} )
2719
2809
2720
2810
# This updates the provided list in parent scope (callers scope)
2721
2811
set (${ZFILE_DEFCONFIG} ${${ZFILE_DEFCONFIG} } PARENT_SCOPE)
@@ -4377,7 +4467,7 @@ function(zephyr_linker_dts_section)
4377
4467
4378
4468
if (DTS_SECTION_UNPARSED_ARGUMENTS)
4379
4469
message (FATAL_ERROR "zephyr_linker_dts_section(${ARGV0} ...) given unknown "
4380
- "arguments: ${DTS_SECTION_UNPARSED_ARGUMENTS} "
4470
+ "arguments: ${DTS_SECTION_UNPARSED_ARGUMENTS} "
4381
4471
)
4382
4472
endif ()
4383
4473
0 commit comments