mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-01-19 05:30:04 +00:00
Codechange: [CMake] Pass API files list via a file to minimise command line length (#9874)
This commit is contained in:
parent
fb1ac307a4
commit
7331149dde
@ -12,32 +12,11 @@ endif()
|
||||
if(NOT APIUC)
|
||||
message(FATAL_ERROR "Script needs APIUC defined")
|
||||
endif()
|
||||
if(NOT API_FILES)
|
||||
message(FATAL_ERROR "Script needs API_FILES defined")
|
||||
endif()
|
||||
|
||||
set(ARGC 1)
|
||||
set(ARG_READ NO)
|
||||
|
||||
# For MSVC CMake runs this script from a batch file using || to detect errors,
|
||||
# depending on source path it may quote args, and cause cmd to not understand ||
|
||||
# and pass it as argument to ourself.
|
||||
# Read all the arguments given to CMake; we are looking for -- and everything
|
||||
# that follows, until ||. Those are our api files.
|
||||
while(ARGC LESS CMAKE_ARGC)
|
||||
set(ARG ${CMAKE_ARGV${ARGC}})
|
||||
|
||||
if(ARG STREQUAL "||")
|
||||
set(ARG_READ NO)
|
||||
endif()
|
||||
|
||||
if(ARG_READ)
|
||||
list(APPEND SCRIPT_API_BINARY_FILES "${ARG}")
|
||||
endif()
|
||||
|
||||
if(ARG STREQUAL "--")
|
||||
set(ARG_READ YES)
|
||||
endif()
|
||||
|
||||
math(EXPR ARGC "${ARGC} + 1")
|
||||
endwhile()
|
||||
file(READ "${API_FILES}" SCRIPT_API_BINARY_FILES)
|
||||
|
||||
foreach(FILE IN LISTS SCRIPT_API_BINARY_FILES)
|
||||
file(STRINGS "${FILE}" LINES REGEX "^void SQ${APIUC}.*_Register\\(Squirrel \\*engine\\)$")
|
||||
|
@ -75,17 +75,19 @@ foreach(API "ai;AI" "game;GS" "template;Template")
|
||||
if(NOT "${APILC}" STREQUAL "template")
|
||||
list(APPEND SCRIPT_${APIUC}_BINARY_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${APILC}/${APILC}_controller.hpp.sq")
|
||||
set(INCLUDES_BINARY_FILE "${CMAKE_BINARY_DIR}/generated/script/api/${APILC}/${APILC}_includes.hpp")
|
||||
set(API_FILES "${CMAKE_CURRENT_BINARY_DIR}/${APILC}.files")
|
||||
file(GENERATE OUTPUT ${API_FILES} CONTENT "${SCRIPT_${APIUC}_BINARY_FILES}")
|
||||
add_custom_command_timestamp(OUTPUT ${INCLUDES_BINARY_FILE}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DINCLUDES_SOURCE_FILE=${CMAKE_CURRENT_SOURCE_DIR}/script_includes.hpp.in
|
||||
-DINCLUDES_BINARY_FILE=${INCLUDES_BINARY_FILE}
|
||||
-DAPIUC=${APIUC}
|
||||
-DAPILC=${APILC}
|
||||
-DAPI_FILES=${API_FILES}
|
||||
-P ${CMAKE_SOURCE_DIR}/cmake/scripts/SquirrelIncludes.cmake
|
||||
--
|
||||
${SCRIPT_${APIUC}_BINARY_FILES}
|
||||
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/script_includes.hpp.in
|
||||
DEPENDS ${SCRIPT_${APIUC}_BINARY_FILES}
|
||||
${API_FILES}
|
||||
${CMAKE_SOURCE_DIR}/cmake/scripts/SquirrelIncludes.cmake
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating ${APILC}/${APILC}_includes.hpp"
|
||||
|
Loading…
Reference in New Issue
Block a user