Changeset - r26234:cc6e82620beb
[Not reviewed]
master
0 2 0
Loïc Guilloux - 2 years ago 2022-04-30 22:39:59
glx22@users.noreply.github.com
Codechange: [CMake] Pass API files list via a file to minimise command line length (#9874)
2 files changed with 8 insertions and 27 deletions:
0 comments (0 inline, 0 general)
cmake/scripts/SquirrelIncludes.cmake
Show inline comments
 
@@ -12,32 +12,11 @@ endif()
 
if(NOT APIUC)
 
    message(FATAL_ERROR "Script needs APIUC 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(NOT API_FILES)
 
    message(FATAL_ERROR "Script needs API_FILES defined")
 
endif()
 

	
 
    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\\)$")
src/script/api/CMakeLists.txt
Show inline comments
 
@@ -75,17 +75,19 @@ foreach(API "ai;AI" "game;GS" "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"
0 comments (0 inline, 0 general)