1 cmake_minimum_required(VERSION 3.5)
3 if(NOT INCLUDES_SOURCE_FILE)
4 message(FATAL_ERROR "Script needs INCLUDES_SOURCE_FILE defined")
6 if(NOT INCLUDES_BINARY_FILE)
7 message(FATAL_ERROR "Script needs INCLUDES_BINARY_FILE defined")
10 message(FATAL_ERROR "Script needs APILC defined")
13 message(FATAL_ERROR "Script needs APIUC defined")
16 message(FATAL_ERROR "Script needs API_FILES defined")
19 file(READ "${API_FILES}" SCRIPT_API_BINARY_FILES)
21 foreach(FILE IN LISTS SCRIPT_API_BINARY_FILES)
22 file(STRINGS "${FILE}" LINES REGEX "^void SQ${APIUC}.*_Register\\(Squirrel \\*engine\\)$")
24 string(REGEX REPLACE ".*api/${APILC}/(.*)" "#include \"\\1\"" FILE "${FILE}")
25 list(APPEND SQUIRREL_INCLUDES "${FILE}")
26 foreach(LINE IN LISTS LINES)
27 if("${LINE}" MATCHES "SQ${APIUC}(List|Controller)_Register")
30 string(REGEX REPLACE "^.*void " " " LINE "${LINE}")
31 string(REGEX REPLACE "Squirrel \\*" "" LINE "${LINE}")
32 list(APPEND SQUIRREL_REGISTER "${LINE}")
37 list(SORT SQUIRREL_INCLUDES)
38 string(REPLACE ";" "\n" SQUIRREL_INCLUDES "${SQUIRREL_INCLUDES}")
40 string(REGEX REPLACE "_Register" "0000Register" SQUIRREL_REGISTER "${SQUIRREL_REGISTER}")
41 list(SORT SQUIRREL_REGISTER)
42 string(REGEX REPLACE "0000Register" "_Register" SQUIRREL_REGISTER "${SQUIRREL_REGISTER}")
43 string(REPLACE ";" ";\n" SQUIRREL_REGISTER "${SQUIRREL_REGISTER}")
44 set(SQUIRREL_REGISTER " SQ${APIUC}List_Register(engine);\n${SQUIRREL_REGISTER};")
46 configure_file(${INCLUDES_SOURCE_FILE} ${INCLUDES_BINARY_FILE})