Files
EVEngine/cmake/scan_source.cmake
T
西风逍遥游 20289b3f3a fix(build): use ',' (not '|') to join exclude lists for rescan target
The add_custom_target(rescan) runs through /bin/sh on Linux/macOS Ninja
builds. ';' is a command separator and '|' is a pipe operator there, so
both caused the -Dexclude_files=... value to be split/executed as separate
shell commands (exit 127 'JsonDocument.cpp: not found'). Comma is shell-safe
unquoted on POSIX sh, cmd.exe and emcc. Update scan/rescan scripts to split
on ','.
2026-08-17 10:35:12 +08:00

57 lines
2.0 KiB
CMake

# The exclude lists arrive ','-joined (semicolons and pipes are shell
# metacharacters, so they would be split/executed by the shell running this
# script on Linux/macOS Ninja builds).
string(REPLACE "," ";" exclude_dirs "${exclude_dirs}")
string(REPLACE "," ";" exclude_files "${exclude_files}")
file(GLOB_RECURSE source_files ${CMAKE_CURRENT_SOURCE_DIR}/${module_name}/*.cpp)
file(GLOB_RECURSE sub_source_files ${CMAKE_CURRENT_SOURCE_DIR}/${module_name}/**/*.cpp)
# Semicolon-separated list of backend subdirectories to exclude from the module
# (e.g. "vulkan" for webgpu builds, "webgpu" for native builds). Entries match
# either an exact file name or a path fragment.
# Semicolon-separated list of exact file base names to exclude (e.g. Poco-heavy
# files trimmed from the WASM build).
set(file_list "")
foreach(file ${source_files})
set(_eve_skip FALSE)
foreach(exc ${exclude_dirs})
if(file MATCHES "/${exc}/" OR file MATCHES "${exc}[\\/]+")
set(_eve_skip TRUE)
endif()
endforeach()
if(NOT _eve_skip)
foreach(exc ${exclude_files})
get_filename_component(_eve_fname "${file}" NAME)
if(_eve_fname STREQUAL "${exc}")
set(_eve_skip TRUE)
endif()
endforeach()
endif()
if(NOT _eve_skip)
set(file_list "${file_list}${file}\n")
endif()
endforeach()
foreach(file ${sub_source_files})
set(_eve_skip FALSE)
foreach(exc ${exclude_dirs})
if(file MATCHES "/${exc}/" OR file MATCHES "${exc}[\\/]+")
set(_eve_skip TRUE)
endif()
endforeach()
if(NOT _eve_skip)
foreach(exc ${exclude_files})
get_filename_component(_eve_fname "${file}" NAME)
if(_eve_fname STREQUAL "${exc}")
set(_eve_skip TRUE)
endif()
endforeach()
endif()
if(NOT _eve_skip)
set(file_list "${file_list}${file}\n")
endif()
endforeach()
file(WRITE ${output_dir}/${module_name}_src.txt "${file_list}")
message(STATUS "detected source files: ${output_dir}/${module_name}_src.txt")