update build script to allow skip.txt and only.txt both exist
This commit is contained in:
@@ -79,17 +79,27 @@ set(WARNING_FLAGS_IAR "")
|
|||||||
function(family_filter RESULT DIR)
|
function(family_filter RESULT DIR)
|
||||||
get_filename_component(DIR ${DIR} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
get_filename_component(DIR ${DIR} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
if (EXISTS "${DIR}/only.txt")
|
if (EXISTS "${DIR}/skip.txt")
|
||||||
file(READ "${DIR}/only.txt" ONLYS)
|
file(STRINGS "${DIR}/skip.txt" SKIPS_LINES)
|
||||||
# Replace newlines with semicolon so that it is treated as a list by CMake
|
foreach(MCU IN LISTS FAMILY_MCUS)
|
||||||
string(REPLACE "\n" ";" ONLYS_LINES ${ONLYS})
|
# For each line in only.txt
|
||||||
|
foreach(_line ${SKIPS_LINES})
|
||||||
|
# If mcu:xxx exists for this mcu then skip
|
||||||
|
if (${_line} STREQUAL "mcu:${MCU}" OR ${_line} STREQUAL "board:${BOARD}" OR ${_line} STREQUAL "family:${FAMILY}")
|
||||||
|
set(${RESULT} 0 PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endforeach()
|
||||||
|
endif ()
|
||||||
|
|
||||||
# For each mcu
|
if (EXISTS "${DIR}/only.txt")
|
||||||
|
file(STRINGS "${DIR}/only.txt" ONLYS_LINES)
|
||||||
foreach(MCU IN LISTS FAMILY_MCUS)
|
foreach(MCU IN LISTS FAMILY_MCUS)
|
||||||
# For each line in only.txt
|
# For each line in only.txt
|
||||||
foreach(_line ${ONLYS_LINES})
|
foreach(_line ${ONLYS_LINES})
|
||||||
# If mcu:xxx exists for this mcu or board:xxx then include
|
# If mcu:xxx exists for this mcu or board:xxx then include
|
||||||
if (${_line} STREQUAL "mcu:${MCU}" OR ${_line} STREQUAL "board:${BOARD}")
|
if (${_line} STREQUAL "mcu:${MCU}" OR ${_line} STREQUAL "board:${BOARD}" OR ${_line} STREQUAL "family:${FAMILY}")
|
||||||
set(${RESULT} 1 PARENT_SCOPE)
|
set(${RESULT} 1 PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
@@ -98,29 +108,8 @@ function(family_filter RESULT DIR)
|
|||||||
|
|
||||||
# Didn't find it in only file so don't build
|
# Didn't find it in only file so don't build
|
||||||
set(${RESULT} 0 PARENT_SCOPE)
|
set(${RESULT} 0 PARENT_SCOPE)
|
||||||
|
|
||||||
elseif (EXISTS "${DIR}/skip.txt")
|
|
||||||
file(READ "${DIR}/skip.txt" SKIPS)
|
|
||||||
# Replace newlines with semicolon so that it is treated as a list by CMake
|
|
||||||
string(REPLACE "\n" ";" SKIPS_LINES ${SKIPS})
|
|
||||||
|
|
||||||
# For each mcu
|
|
||||||
foreach(MCU IN LISTS FAMILY_MCUS)
|
|
||||||
# For each line in only.txt
|
|
||||||
foreach(_line ${SKIPS_LINES})
|
|
||||||
# If mcu:xxx exists for this mcu then skip
|
|
||||||
if (${_line} STREQUAL "mcu:${MCU}")
|
|
||||||
set(${RESULT} 0 PARENT_SCOPE)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# Didn't find in skip file so build
|
|
||||||
set(${RESULT} 1 PARENT_SCOPE)
|
|
||||||
else()
|
else()
|
||||||
|
# only.txt not exist so build
|
||||||
# Didn't find skip or only file so build
|
|
||||||
set(${RESULT} 1 PARENT_SCOPE)
|
set(${RESULT} 1 PARENT_SCOPE)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
@@ -64,18 +64,19 @@ def skip_example(example, board):
|
|||||||
skip_file = ex_dir / "skip.txt"
|
skip_file = ex_dir / "skip.txt"
|
||||||
only_file = ex_dir / "only.txt"
|
only_file = ex_dir / "only.txt"
|
||||||
|
|
||||||
if skip_file.exists() and only_file.exists():
|
if skip_file.exists():
|
||||||
raise RuntimeError("Only have a skip or only file. Not both.")
|
|
||||||
elif skip_file.exists():
|
|
||||||
skips = skip_file.read_text().split()
|
skips = skip_file.read_text().split()
|
||||||
return ("mcu:" + mcu in skips or
|
if ("mcu:" + mcu in skips or
|
||||||
"board:" + board in skips or
|
"board:" + board in skips or
|
||||||
"family:" + family in skips)
|
"family:" + family in skips):
|
||||||
elif only_file.exists():
|
return True
|
||||||
|
|
||||||
|
if only_file.exists():
|
||||||
onlys = only_file.read_text().split()
|
onlys = only_file.read_text().split()
|
||||||
return not ("mcu:" + mcu in onlys or
|
if not ("mcu:" + mcu in onlys or
|
||||||
"board:" + board in onlys or
|
"board:" + board in onlys or
|
||||||
"family:" + family in onlys)
|
"family:" + family in onlys):
|
||||||
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user