Skip to content

Commit 58b8bdc

Browse files
authored
Merge pull request hathach#1277 from liamfraser/fix-cmake-skip
Fix family_support.cmake to use new skip.txt and only.txt files
2 parents 61d392f + 3db9cf3 commit 58b8bdc

File tree

1 file changed

+41
-12
lines changed

1 file changed

+41
-12
lines changed

hw/bsp/family_support.cmake

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,52 @@ if (NOT TARGET _family_support_marker)
1111

1212
function(family_filter RESULT DIR)
1313
get_filename_component(DIR ${DIR} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
14-
file(GLOB ONLYS "${DIR}/.only.MCU_*")
15-
if (ONLYS)
14+
15+
if (EXISTS "${DIR}/only.txt")
16+
file(READ "${DIR}/only.txt" ONLYS)
17+
# Replace newlines with semicolon so that it is treated as a list by CMake
18+
string(REPLACE "\n" ";" ONLYS_LINES ${ONLYS})
19+
# For each mcu
1620
foreach(MCU IN LISTS FAMILY_MCUS)
17-
if (EXISTS ${DIR}/.only.MCU_${MCU})
18-
set(${RESULT} 1 PARENT_SCOPE)
19-
return()
20-
endif()
21+
# For each line in only.txt
22+
foreach(_line ${ONLYS_LINES})
23+
# If mcu:xxx exists for this mcu then include
24+
if (${_line} STREQUAL "mcu:${MCU}")
25+
set(${RESULT} 1 PARENT_SCOPE)
26+
return()
27+
endif()
28+
endforeach()
2129
endforeach()
22-
else()
30+
31+
# Didn't find it in only file so don't build
32+
set(${RESULT} 0 PARENT_SCOPE)
33+
34+
elseif (EXISTS "${DIR}/skip.txt")
35+
file(READ "${DIR}/skip.txt" SKIPS)
36+
# Replace newlines with semicolon so that it is treated as a list by CMake
37+
string(REPLACE "\n" ";" SKIPS_LINES ${SKIPS})
38+
# For each mcu
2339
foreach(MCU IN LISTS FAMILY_MCUS)
24-
if (EXISTS ${DIR}/.skip.MCU_${MCU})
25-
set(${RESULT} 0 PARENT_SCOPE)
26-
return()
27-
endif()
40+
# For each line in only.txt
41+
foreach(_line ${SKIPS_LINES})
42+
# If mcu:xxx exists for this mcu then skip
43+
if (${_line} STREQUAL "mcu:${MCU}")
44+
set(${RESULT} 0 PARENT_SCOPE)
45+
return()
46+
endif()
47+
endforeach()
2848
endforeach()
49+
50+
# Didn't find in skip file so build
51+
set(${RESULT} 1 PARENT_SCOPE)
52+
53+
else()
54+
55+
# Didn't find skip or only file so build
56+
set(${RESULT} 1 PARENT_SCOPE)
57+
2958
endif()
30-
set(${RESULT} 1 PARENT_SCOPE)
59+
3160
endfunction()
3261

3362
function(family_add_subdirectory DIR)

0 commit comments

Comments
 (0)