forked from mirror/OpenTTD
Codechange: Make codestyle for CMake files consistent for 'control' statements
This commit is contained in:
@@ -12,13 +12,13 @@ set(ARG_READ NO)
|
||||
while(ARGC LESS CMAKE_ARGC)
|
||||
set(ARG ${CMAKE_ARGV${ARGC}})
|
||||
|
||||
if (ARG_READ)
|
||||
if(ARG_READ)
|
||||
list(APPEND LANG_SOURCE_FILES "${ARG}")
|
||||
endif (ARG_READ)
|
||||
endif()
|
||||
|
||||
if (ARG STREQUAL "--")
|
||||
if(ARG STREQUAL "--")
|
||||
set(ARG_READ YES)
|
||||
endif (ARG STREQUAL "--")
|
||||
endif()
|
||||
|
||||
math(EXPR ARGC "${ARGC} + 1")
|
||||
endwhile()
|
||||
@@ -33,17 +33,17 @@ string(REGEX REPLACE "@(.*)@" "\\1" PLACE_HOLDER "${PLACE_HOLDER}")
|
||||
foreach(LANGFILE IN LISTS LANG_SOURCE_FILES)
|
||||
file(STRINGS "${LANGFILE}" LANGLINES REGEX "^(##isocode|${STR_ID})" ENCODING UTF-8)
|
||||
string(FIND "${LANGLINES}" "${STR_ID}" HAS_STR_ID)
|
||||
if (HAS_STR_ID LESS 0)
|
||||
if(HAS_STR_ID LESS 0)
|
||||
continue()
|
||||
endif (HAS_STR_ID LESS 0)
|
||||
endif()
|
||||
string(REGEX REPLACE "##isocode ([^;]+).*" "\\1" ISOCODE "${LANGLINES}")
|
||||
if ("${ISOCODE}" STREQUAL "en_GB")
|
||||
if("${ISOCODE}" STREQUAL "en_GB")
|
||||
string(REGEX REPLACE "[^:]*:(.*)" "${INI_KEY} = \\1" LANGLINES "${LANGLINES}")
|
||||
else()
|
||||
string(REGEX REPLACE "[^:]*:(.*)" "${INI_KEY}.${ISOCODE} = \\1" LANGLINES "${LANGLINES}")
|
||||
endif()
|
||||
list(APPEND ${PLACE_HOLDER} ${LANGLINES})
|
||||
endforeach(LANGFILE)
|
||||
endforeach()
|
||||
list(SORT ${PLACE_HOLDER})
|
||||
string(REPLACE ";" "\n" ${PLACE_HOLDER} "${${PLACE_HOLDER}}")
|
||||
|
||||
|
@@ -5,18 +5,18 @@ cmake_minimum_required(VERSION 3.5)
|
||||
# files.
|
||||
#
|
||||
|
||||
if (NOT NFORENUM_EXECUTABLE)
|
||||
if(NOT NFORENUM_EXECUTABLE)
|
||||
message(FATAL_ERROR "Script needs NFORENUM_EXECUTABLE defined")
|
||||
endif (NOT NFORENUM_EXECUTABLE)
|
||||
if (NOT GRFCODEC_EXECUTABLE)
|
||||
endif()
|
||||
if(NOT GRFCODEC_EXECUTABLE)
|
||||
message(FATAL_ERROR "Script needs GRFCODEC_EXECUTABLE defined")
|
||||
endif (NOT GRFCODEC_EXECUTABLE)
|
||||
if (NOT GRF_SOURCE_FOLDER)
|
||||
endif()
|
||||
if(NOT GRF_SOURCE_FOLDER)
|
||||
message(FATAL_ERROR "Script needs GRF_SOURCE_FOLDER defined")
|
||||
endif (NOT GRF_SOURCE_FOLDER)
|
||||
if (NOT GRF_BINARY_FILE)
|
||||
endif()
|
||||
if(NOT GRF_BINARY_FILE)
|
||||
message(FATAL_ERROR "Script needs GRF_BINARY_FILE defined")
|
||||
endif (NOT GRF_BINARY_FILE)
|
||||
endif()
|
||||
|
||||
get_filename_component(GRF_SOURCE_FOLDER_NAME "${GRF_SOURCE_FOLDER}" NAME)
|
||||
|
||||
@@ -30,14 +30,14 @@ foreach(NFO_LINE IN LISTS NFO_LINES)
|
||||
# Recover the ; that was really in the text (and not a newline)
|
||||
string(REPLACE "\\;" ";" NFO_LINE "${NFO_LINE}")
|
||||
|
||||
if (NFO_LINE MATCHES "^#include")
|
||||
if(NFO_LINE MATCHES "^#include")
|
||||
string(REGEX REPLACE "^#include \"(.*)\"$" "\\1" INCLUDE_FILE ${NFO_LINE})
|
||||
file(READ ${GRF_SOURCE_FOLDER}/${INCLUDE_FILE} INCLUDE_LINES)
|
||||
file(APPEND sprites/${GRF_SOURCE_FOLDER_NAME}.nfo "${INCLUDE_LINES}")
|
||||
else (NFO_LINE MATCHES "^#include")
|
||||
else()
|
||||
file(APPEND sprites/${GRF_SOURCE_FOLDER_NAME}.nfo "${NFO_LINE}\n")
|
||||
endif (NFO_LINE MATCHES "^#include")
|
||||
endforeach(NFO_LINE)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
execute_process(COMMAND ${NFORENUM_EXECUTABLE} -s sprites/${GRF_SOURCE_FOLDER_NAME}.nfo)
|
||||
execute_process(COMMAND ${GRFCODEC_EXECUTABLE} -n -s -e -p1 ${GRF_SOURCE_FOLDER_NAME}.grf)
|
||||
|
@@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
find_package(Git QUIET)
|
||||
# ${CMAKE_SOURCE_DIR}/.git may be a directory or a regular file
|
||||
if (GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||
# Make sure LC_ALL is set to something desirable
|
||||
set(SAVED_LC_ALL "$ENV{LC_ALL}")
|
||||
set(ENV{LC_ALL} C)
|
||||
@@ -26,7 +26,7 @@ if (GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
if (NOT IS_MODIFIED STREQUAL "")
|
||||
if(NOT IS_MODIFIED STREQUAL "")
|
||||
set(REV_MODIFIED 2)
|
||||
endif()
|
||||
|
||||
@@ -69,34 +69,34 @@ if (GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||
)
|
||||
string(REGEX REPLACE "\^0$" "" TAG "${TAG}")
|
||||
|
||||
if (REV_MODIFIED EQUAL 0)
|
||||
if(REV_MODIFIED EQUAL 0)
|
||||
set(HASHPREFIX "-g")
|
||||
elseif (REV_MODIFIED EQUAL 2)
|
||||
elseif(REV_MODIFIED EQUAL 2)
|
||||
set(HASHPREFIX "-m")
|
||||
else ()
|
||||
else()
|
||||
set(HASHPREFIX "-u")
|
||||
endif()
|
||||
|
||||
# Set the version string
|
||||
if (NOT TAG STREQUAL "")
|
||||
if(NOT TAG STREQUAL "")
|
||||
set(REV_VERSION "${TAG}")
|
||||
set(REV_ISTAG 1)
|
||||
|
||||
string(REGEX REPLACE "^[0-9.]+$" "" STABLETAG "${TAG}")
|
||||
if (NOT STABLETAG STREQUAL "")
|
||||
if(NOT STABLETAG STREQUAL "")
|
||||
set(REV_ISSTABLETAG 1)
|
||||
else ()
|
||||
else()
|
||||
set(REV_ISSTABLETAG 0)
|
||||
endif ()
|
||||
else ()
|
||||
endif()
|
||||
else()
|
||||
set(REV_VERSION "${REV_ISODATE}-${BRANCH}${HASHPREFIX}${SHORTHASH}")
|
||||
set(REV_ISTAG 0)
|
||||
set(REV_ISSTABLETAG 0)
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
# Restore LC_ALL
|
||||
set(ENV{LC_ALL} "${SAVED_LC_ALL}")
|
||||
elseif (EXISTS "${CMAKE_SOURCE_DIR}/.ottdrev")
|
||||
elseif(EXISTS "${CMAKE_SOURCE_DIR}/.ottdrev")
|
||||
file(READ "${CMAKE_SOURCE_DIR}/.ottdrev" OTTDREV)
|
||||
string(REPLACE "\n" "" OTTDREV "${OTTDREV}")
|
||||
string(REPLACE "\t" ";" OTTDREV "${OTTDREV}")
|
||||
@@ -107,7 +107,7 @@ elseif (EXISTS "${CMAKE_SOURCE_DIR}/.ottdrev")
|
||||
list(GET OTTDREV 4 REV_ISTAG)
|
||||
list(GET OTTDREV 5 REV_ISSTABLETAG)
|
||||
list(GET OTTDREV 6 REV_YEAR)
|
||||
else ()
|
||||
else()
|
||||
message(WARNING "No version detected; this build will NOT be network compatible")
|
||||
set(REV_VERSION "norev0000")
|
||||
set(REV_ISODATE "19700101")
|
||||
@@ -116,25 +116,25 @@ else ()
|
||||
set(REV_ISTAG 0)
|
||||
set(REV_ISSTABLETAG 0)
|
||||
set(REV_YEAR "1970")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
message(STATUS "Version string: ${REV_VERSION}")
|
||||
|
||||
if (GENERATE_OTTDREV)
|
||||
if(GENERATE_OTTDREV)
|
||||
message(STATUS "Generating .ottdrev")
|
||||
file(WRITE ${CMAKE_SOURCE_DIR}/.ottdrev "${REV_VERSION}\t${REV_ISODATE}\t${REV_MODIFIED}\t${REV_HASH}\t${REV_ISTAG}\t${REV_ISSTABLETAG}\t${REV_YEAR}\n")
|
||||
else (GENERATE_OTTDREV)
|
||||
else()
|
||||
message(STATUS "Generating rev.cpp")
|
||||
configure_file("${CMAKE_SOURCE_DIR}/src/rev.cpp.in"
|
||||
"${FIND_VERSION_BINARY_DIR}/rev.cpp")
|
||||
|
||||
if (WIN32)
|
||||
if(WIN32)
|
||||
message(STATUS "Generating ottdres.rc")
|
||||
configure_file("${CMAKE_SOURCE_DIR}/src/os/windows/ottdres.rc.in"
|
||||
"${FIND_VERSION_BINARY_DIR}/ottdres.rc")
|
||||
endif (WIN32)
|
||||
endif()
|
||||
|
||||
message(STATUS "Generating CPackProperties.cmake")
|
||||
configure_file("${CMAKE_SOURCE_DIR}/CPackProperties.cmake.in"
|
||||
"${CPACK_BINARY_DIR}/CPackProperties.cmake" @ONLY)
|
||||
endif (GENERATE_OTTDREV)
|
||||
endif()
|
||||
|
@@ -15,12 +15,12 @@ cmake_minimum_required(VERSION 3.5)
|
||||
#
|
||||
#
|
||||
|
||||
if (NOT GENERATE_SOURCE_FILE)
|
||||
if(NOT GENERATE_SOURCE_FILE)
|
||||
message(FATAL_ERROR "Script needs GENERATE_SOURCE_FILE defined")
|
||||
endif (NOT GENERATE_SOURCE_FILE)
|
||||
if (NOT GENERATE_BINARY_FILE)
|
||||
endif()
|
||||
if(NOT GENERATE_BINARY_FILE)
|
||||
message(FATAL_ERROR "Script needs GENERATE_BINARY_FILE defined")
|
||||
endif (NOT GENERATE_BINARY_FILE)
|
||||
endif()
|
||||
|
||||
file(STRINGS ${GENERATE_SOURCE_FILE} ENUM_LINES REGEX "@enum")
|
||||
|
||||
@@ -46,38 +46,38 @@ foreach(ENUM IN LISTS ENUM_LINES)
|
||||
string(REPLACE "${RM_INDENT}" "" LINE "${LINE}")
|
||||
|
||||
# Remember possible doxygen comment before enum declaration
|
||||
if ((NOT ACTIVE) AND "${LINE}" MATCHES "/\\*\\*")
|
||||
if((NOT ACTIVE) AND "${LINE}" MATCHES "/\\*\\*")
|
||||
set(COMMENT "${ADD_INDENT}${LINE}")
|
||||
set(ACTIVE_COMMENT 1)
|
||||
elseif (ACTIVE_COMMENT EQUAL 1)
|
||||
elseif(ACTIVE_COMMENT EQUAL 1)
|
||||
string(APPEND COMMENT "\n${ADD_INDENT}${LINE}")
|
||||
endif()
|
||||
|
||||
# Check for enum match
|
||||
if ("${LINE}" MATCHES "^ *enum *${ENUM_PATTERN} *\{")
|
||||
if("${LINE}" MATCHES "^ *enum *${ENUM_PATTERN} *\{")
|
||||
# REGEX REPLACE does a REGEX MATCHALL and fails if an empty string is matched
|
||||
string(REGEX MATCH "[^ ]*" RESULT "${LINE}")
|
||||
string(REPLACE "${RESULT}" "" RM_INDENT "${LINE}")
|
||||
|
||||
set(ACTIVE 1)
|
||||
if (ACTIVE_COMMENT GREATER 0)
|
||||
if(ACTIVE_COMMENT GREATER 0)
|
||||
string(APPEND ${PLACE_HOLDER} "\n${COMMENT}")
|
||||
endif (ACTIVE_COMMENT GREATER 0)
|
||||
endif()
|
||||
unset(ACTIVE_COMMENT)
|
||||
unset(COMMENT)
|
||||
endif ("${LINE}" MATCHES "^ *enum *${ENUM_PATTERN} *\{")
|
||||
endif()
|
||||
|
||||
# Forget doxygen comment, if no enum follows
|
||||
if (ACTIVE_COMMENT EQUAL 2 AND NOT "${LINE}" STREQUAL "")
|
||||
if(ACTIVE_COMMENT EQUAL 2 AND NOT "${LINE}" STREQUAL "")
|
||||
unset(ACTIVE_COMMENT)
|
||||
unset(COMMENT)
|
||||
endif (ACTIVE_COMMENT EQUAL 2 AND NOT "${LINE}" STREQUAL "")
|
||||
if (ACTIVE_COMMENT EQUAL 1 AND "${LINE}" MATCHES "\\*/")
|
||||
endif()
|
||||
if(ACTIVE_COMMENT EQUAL 1 AND "${LINE}" MATCHES "\\*/")
|
||||
set(ACTIVE_COMMENT 2)
|
||||
endif (ACTIVE_COMMENT EQUAL 1 AND "${LINE}" MATCHES "\\*/")
|
||||
endif()
|
||||
|
||||
if (ACTIVE)
|
||||
if ("${LINE}" MATCHES "^ *[A-Za-z0-9_]* *[,=]")
|
||||
if(ACTIVE)
|
||||
if("${LINE}" MATCHES "^ *[A-Za-z0-9_]* *[,=]")
|
||||
# Transform enum values
|
||||
# REGEX REPLACE does a REGEX MATCHALL and replaces too much
|
||||
string(REGEX MATCH " *=[^,]*" RESULT "${LINE}")
|
||||
@@ -92,28 +92,28 @@ foreach(ENUM IN LISTS ENUM_LINES)
|
||||
unset(SPACES)
|
||||
foreach(i RANGE ${LEN})
|
||||
string(APPEND SPACES " ")
|
||||
endforeach(i)
|
||||
endforeach()
|
||||
|
||||
if (CMAKE_MATCH_3)
|
||||
if(CMAKE_MATCH_3)
|
||||
string(APPEND ${PLACE_HOLDER} "\n${ADD_INDENT}${CMAKE_MATCH_1}${CMAKE_MATCH_2}${SPACES} = ::${CMAKE_MATCH_2},${SPACES}${CMAKE_MATCH_3}")
|
||||
else (CMAKE_MATCH_3)
|
||||
else()
|
||||
string(APPEND ${PLACE_HOLDER} "\n${ADD_INDENT}${CMAKE_MATCH_1}${CMAKE_MATCH_2}${SPACES} = ::${CMAKE_MATCH_2},")
|
||||
endif (CMAKE_MATCH_3)
|
||||
elseif ("${LINE}" STREQUAL "")
|
||||
endif()
|
||||
elseif("${LINE}" STREQUAL "")
|
||||
string(APPEND ${PLACE_HOLDER} "\n")
|
||||
else ()
|
||||
else()
|
||||
string(APPEND ${PLACE_HOLDER} "\n${ADD_INDENT}${LINE}")
|
||||
endif ()
|
||||
endif (ACTIVE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if ("${LINE}" MATCHES "^ *\};")
|
||||
if (ACTIVE)
|
||||
if("${LINE}" MATCHES "^ *\};")
|
||||
if(ACTIVE)
|
||||
string(APPEND ${PLACE_HOLDER} "\n")
|
||||
endif (ACTIVE)
|
||||
endif()
|
||||
unset(ACTIVE)
|
||||
endif ("${LINE}" MATCHES "^ *\};")
|
||||
endforeach(LINE)
|
||||
endforeach(FILE)
|
||||
endforeach(ENUM)
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
configure_file(${GENERATE_SOURCE_FILE} ${GENERATE_BINARY_FILE})
|
||||
|
@@ -4,26 +4,26 @@ cmake_minimum_required(VERSION 3.5)
|
||||
# Runs a single regressoion test
|
||||
#
|
||||
|
||||
if (NOT REGRESSION_TEST)
|
||||
if(NOT REGRESSION_TEST)
|
||||
message(FATAL_ERROR "Script needs REGRESSION_TEST defined (tip: use -DREGRESSION_TEST=..)")
|
||||
endif (NOT REGRESSION_TEST)
|
||||
if (NOT OPENTTD_EXECUTABLE)
|
||||
endif()
|
||||
if(NOT OPENTTD_EXECUTABLE)
|
||||
message(FATAL_ERROR "Script needs OPENTTD_EXECUTABLE defined (tip: use -DOPENTTD_EXECUTABLE=..)")
|
||||
endif (NOT OPENTTD_EXECUTABLE)
|
||||
endif()
|
||||
|
||||
if (NOT EXISTS ai/${REGRESSION_TEST}/test.sav)
|
||||
if(NOT EXISTS ai/${REGRESSION_TEST}/test.sav)
|
||||
message(FATAL_ERROR "Regression test ${REGRESSION_TEST} does not exist (tip: check regression folder for the correct spelling)")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
# If editbin is given, copy the executable to a new folder, and change the
|
||||
# subsystem to console. The copy is needed as multiple regressions can run
|
||||
# at the same time.
|
||||
if (EDITBIN_EXECUTABLE)
|
||||
if(EDITBIN_EXECUTABLE)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${OPENTTD_EXECUTABLE} regression/${REGRESSION_TEST}.exe)
|
||||
set(OPENTTD_EXECUTABLE "regression/${REGRESSION_TEST}.exe")
|
||||
|
||||
execute_process(COMMAND ${EDITBIN_EXECUTABLE} /nologo /subsystem:console ${OPENTTD_EXECUTABLE})
|
||||
endif (EDITBIN_EXECUTABLE)
|
||||
endif()
|
||||
|
||||
# Run the regression test
|
||||
execute_process(COMMAND ${OPENTTD_EXECUTABLE}
|
||||
@@ -40,13 +40,13 @@ execute_process(COMMAND ${OPENTTD_EXECUTABLE}
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
if (REGRESSION_OUTPUT)
|
||||
if(REGRESSION_OUTPUT)
|
||||
message(FATAL_ERROR "Unexpected output: ${REGRESSION_OUTPUT}")
|
||||
endif (REGRESSION_OUTPUT)
|
||||
endif()
|
||||
|
||||
if (NOT REGRESSION_RESULT)
|
||||
if(NOT REGRESSION_RESULT)
|
||||
message(FATAL_ERROR "Regression did not output anything; did the compilation fail?")
|
||||
endif (NOT REGRESSION_RESULT)
|
||||
endif()
|
||||
|
||||
# For some reason pointer can be printed as '0x(nil)', '0x0000000000000000', or '0x0x0'
|
||||
string(REPLACE "0x(nil)" "0x00000000" REGRESSION_RESULT "${REGRESSION_RESULT}")
|
||||
@@ -76,21 +76,21 @@ list(LENGTH REGRESSION_EXPECTED REGRESSION_EXPECTED_LENGTH)
|
||||
foreach(RESULT IN LISTS REGRESSION_RESULT)
|
||||
list(GET REGRESSION_EXPECTED ${ARGC} EXPECTED)
|
||||
|
||||
if (NOT RESULT STREQUAL EXPECTED)
|
||||
if(NOT RESULT STREQUAL EXPECTED)
|
||||
message("${ARGC}: - ${EXPECTED}")
|
||||
message("${ARGC}: + ${RESULT}'")
|
||||
set(ERROR YES)
|
||||
endif (NOT RESULT STREQUAL EXPECTED)
|
||||
endif()
|
||||
|
||||
math(EXPR ARGC "${ARGC} + 1")
|
||||
endforeach(RESULT)
|
||||
endforeach()
|
||||
|
||||
if (NOT REGRESSION_EXPECTED_LENGTH EQUAL ARGC)
|
||||
if(NOT REGRESSION_EXPECTED_LENGTH EQUAL ARGC)
|
||||
math(EXPR MISSING "${REGRESSION_EXPECTED_LENGTH} - ${ARGC}")
|
||||
message("(${MISSING} more lines were expected than found)")
|
||||
set(ERROR YES)
|
||||
endif (NOT REGRESSION_EXPECTED_LENGTH EQUAL ARGC)
|
||||
endif()
|
||||
|
||||
if (ERROR)
|
||||
if(ERROR)
|
||||
message(FATAL_ERROR "Regression failed")
|
||||
endif (ERROR)
|
||||
endif()
|
||||
|
@@ -1,29 +1,29 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
if (NOT SCRIPT_API_SOURCE_FILE)
|
||||
if(NOT SCRIPT_API_SOURCE_FILE)
|
||||
message(FATAL_ERROR "Script needs SCRIPT_API_SOURCE_FILE defined")
|
||||
endif (NOT SCRIPT_API_SOURCE_FILE)
|
||||
if (NOT SCRIPT_API_BINARY_FILE)
|
||||
endif()
|
||||
if(NOT SCRIPT_API_BINARY_FILE)
|
||||
message(FATAL_ERROR "Script needs SCRIPT_API_BINARY_FILE defined")
|
||||
endif (NOT SCRIPT_API_BINARY_FILE)
|
||||
if (NOT SCRIPT_API_FILE)
|
||||
endif()
|
||||
if(NOT SCRIPT_API_FILE)
|
||||
message(FATAL_ERROR "Script needs SCRIPT_API_FILE defined")
|
||||
endif (NOT SCRIPT_API_FILE)
|
||||
if (NOT APIUC)
|
||||
endif()
|
||||
if(NOT APIUC)
|
||||
message(FATAL_ERROR "Script needs APIUC defined")
|
||||
endif (NOT APIUC)
|
||||
if (NOT APILC)
|
||||
endif()
|
||||
if(NOT APILC)
|
||||
message(FATAL_ERROR "Script needs APILC defined")
|
||||
endif (NOT APILC)
|
||||
endif()
|
||||
|
||||
macro(dump_fileheader)
|
||||
get_filename_component(SCRIPT_API_FILE_NAME "${SCRIPT_API_FILE}" NAME)
|
||||
string(APPEND SQUIRREL_EXPORT "\n#include \"../${SCRIPT_API_FILE_NAME}\"")
|
||||
if (NOT "${APIUC}" STREQUAL "Template")
|
||||
if(NOT "${APIUC}" STREQUAL "Template")
|
||||
string(REPLACE "script_" "template_" SCRIPT_API_FILE_NAME "${SCRIPT_API_FILE_NAME}")
|
||||
string(APPEND SQUIRREL_EXPORT "\n#include \"../template/${SCRIPT_API_FILE_NAME}.sq\"")
|
||||
endif (NOT "${APIUC}" STREQUAL "Template")
|
||||
endmacro(dump_fileheader)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(dump_class_templates NAME)
|
||||
string(REGEX REPLACE "^Script" "" REALNAME ${NAME})
|
||||
@@ -32,9 +32,9 @@ macro(dump_class_templates NAME)
|
||||
string(APPEND SQUIRREL_EXPORT "\n template <> inline ${NAME} &GetParam(ForceType<${NAME} &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(${NAME} *)instance; }")
|
||||
string(APPEND SQUIRREL_EXPORT "\n template <> inline const ${NAME} *GetParam(ForceType<const ${NAME} *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (${NAME} *)instance; }")
|
||||
string(APPEND SQUIRREL_EXPORT "\n template <> inline const ${NAME} &GetParam(ForceType<const ${NAME} &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(${NAME} *)instance; }")
|
||||
if ("${NAME}" STREQUAL "ScriptEvent")
|
||||
if("${NAME}" STREQUAL "ScriptEvent")
|
||||
string(APPEND SQUIRREL_EXPORT "\n template <> inline int Return<${NAME} *>(HSQUIRRELVM vm, ${NAME} *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } Squirrel::CreateClassInstanceVM(vm, \"${REALNAME}\", res, nullptr, DefSQDestructorCallback<${NAME}>, true); return 1; }")
|
||||
elseif ("${NAME}" STREQUAL "ScriptText")
|
||||
elseif("${NAME}" STREQUAL "ScriptText")
|
||||
string(APPEND SQUIRREL_EXPORT "\n")
|
||||
string(APPEND SQUIRREL_EXPORT "\n template <> inline Text *GetParam(ForceType<Text *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) {")
|
||||
string(APPEND SQUIRREL_EXPORT "\n if (sq_gettype(vm, index) == OT_INSTANCE) {")
|
||||
@@ -45,10 +45,10 @@ macro(dump_class_templates NAME)
|
||||
string(APPEND SQUIRREL_EXPORT "\n }")
|
||||
string(APPEND SQUIRREL_EXPORT "\n return nullptr;")
|
||||
string(APPEND SQUIRREL_EXPORT "\n }")
|
||||
else ()
|
||||
else()
|
||||
string(APPEND SQUIRREL_EXPORT "\n template <> inline int Return<${NAME} *>(HSQUIRRELVM vm, ${NAME} *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, \"${REALNAME}\", res, nullptr, DefSQDestructorCallback<${NAME}>, true); return 1; }")
|
||||
endif ()
|
||||
endmacro(dump_class_templates)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(reset_reader)
|
||||
unset(ENUMS)
|
||||
@@ -63,7 +63,7 @@ macro(reset_reader)
|
||||
unset(START_SQUIRREL_DEFINE_ON_NEXT_LINE)
|
||||
set(CLS_LEVEL 0)
|
||||
unset(CLS_IN_API)
|
||||
endmacro(reset_reader)
|
||||
endmacro()
|
||||
|
||||
reset_reader()
|
||||
|
||||
@@ -71,80 +71,80 @@ file(STRINGS "${SCRIPT_API_FILE}" SOURCE_LINES)
|
||||
|
||||
foreach(LINE IN LISTS SOURCE_LINES)
|
||||
# Ignore special doxygen blocks
|
||||
if ("${LINE}" MATCHES "^#ifndef DOXYGEN_API")
|
||||
if("${LINE}" MATCHES "^#ifndef DOXYGEN_API")
|
||||
set(DOXYGEN_SKIP "next")
|
||||
continue()
|
||||
endif ()
|
||||
if ("${LINE}" MATCHES "^#ifdef DOXYGEN_API")
|
||||
endif()
|
||||
if("${LINE}" MATCHES "^#ifdef DOXYGEN_API")
|
||||
set(DOXYGEN_SKIP "true")
|
||||
continue()
|
||||
endif ()
|
||||
if ("${LINE}" MATCHES "^#endif /\\* DOXYGEN_API \\*/")
|
||||
endif()
|
||||
if("${LINE}" MATCHES "^#endif /\\* DOXYGEN_API \\*/")
|
||||
unset(DOXYGEN_SKIP)
|
||||
continue()
|
||||
endif ()
|
||||
if ("${LINE}" MATCHES "^#else")
|
||||
if ("${DOXYGEN_SKIP}" STREQUAL "next")
|
||||
endif()
|
||||
if("${LINE}" MATCHES "^#else")
|
||||
if("${DOXYGEN_SKIP}" STREQUAL "next")
|
||||
set(DOXYGEN_SKIP "true")
|
||||
else()
|
||||
unset(DOXYGEN_SKIP)
|
||||
endif()
|
||||
continue()
|
||||
endif ()
|
||||
if ("${DOXYGEN_SKIP}" STREQUAL "true")
|
||||
endif()
|
||||
if("${DOXYGEN_SKIP}" STREQUAL "true")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
if ("${LINE}" MATCHES "^([ ]*)\\* @api (.*)$")
|
||||
if("${LINE}" MATCHES "^([ ]*)\\* @api (.*)$")
|
||||
set(LINE ${CMAKE_MATCH_2})
|
||||
# By default, classes are not selected
|
||||
if (NOT CLS_LEVEL)
|
||||
if(NOT CLS_LEVEL)
|
||||
set(API_SELECTED FALSE)
|
||||
endif (NOT CLS_LEVEL)
|
||||
endif()
|
||||
|
||||
if ("${APIUC}" STREQUAL "Template")
|
||||
if("${APIUC}" STREQUAL "Template")
|
||||
set(API_SELECTED TRUE)
|
||||
if ("${LINE}" STREQUAL "none" OR "${LINE}" STREQUAL "-all")
|
||||
if("${LINE}" STREQUAL "none" OR "${LINE}" STREQUAL "-all")
|
||||
set(API_SELECTED FALSE)
|
||||
endif ("${LINE}" STREQUAL "none" OR "${LINE}" STREQUAL "-all")
|
||||
endif()
|
||||
continue()
|
||||
endif("${APIUC}" STREQUAL "Template")
|
||||
endif()
|
||||
|
||||
if ("${LINE}" STREQUAL "none" OR "${LINE}" STREQUAL "-all")
|
||||
if("${LINE}" STREQUAL "none" OR "${LINE}" STREQUAL "-all")
|
||||
set(API_SELECTED FALSE)
|
||||
elseif ("${LINE}" MATCHES "-${APILC}")
|
||||
elseif("${LINE}" MATCHES "-${APILC}")
|
||||
set(API_SELECTED FALSE)
|
||||
elseif ("${LINE}" MATCHES "${APILC}")
|
||||
elseif("${LINE}" MATCHES "${APILC}")
|
||||
set(API_SELECTED TRUE)
|
||||
endif ()
|
||||
endif()
|
||||
continue()
|
||||
endif ("${LINE}" MATCHES "^([ ]*)\\* @api (.*)$")
|
||||
endif()
|
||||
|
||||
# Remove the old squirrel stuff
|
||||
if ("${LINE}" MATCHES "#ifdef DEFINE_SQUIRREL_CLASS")
|
||||
if("${LINE}" MATCHES "#ifdef DEFINE_SQUIRREL_CLASS")
|
||||
set(SQUIRREL_STUFF TRUE)
|
||||
continue()
|
||||
endif ("${LINE}" MATCHES "#ifdef DEFINE_SQUIRREL_CLASS")
|
||||
if ("${LINE}" MATCHES "^#endif /\\* DEFINE_SQUIRREL_CLASS \\*/")
|
||||
endif()
|
||||
if("${LINE}" MATCHES "^#endif /\\* DEFINE_SQUIRREL_CLASS \\*/")
|
||||
unset(SQUIRREL_STUFF)
|
||||
continue()
|
||||
endif ("${LINE}" MATCHES "^#endif /\\* DEFINE_SQUIRREL_CLASS \\*/")
|
||||
if (SQUIRREL_STUFF)
|
||||
endif()
|
||||
if(SQUIRREL_STUFF)
|
||||
continue()
|
||||
endif (SQUIRREL_STUFF)
|
||||
endif()
|
||||
|
||||
# Ignore forward declarations of classes
|
||||
if ("${LINE}" MATCHES "^( *)class(.*);")
|
||||
if("${LINE}" MATCHES "^( *)class(.*);")
|
||||
continue()
|
||||
endif ("${LINE}" MATCHES "^( *)class(.*);")
|
||||
endif()
|
||||
|
||||
# We only want to have public functions exported for now
|
||||
if ("${LINE}" MATCHES "^( *)class (.*) (: public|: protected|: private|:) ([^ ]*)")
|
||||
if (NOT CLS_LEVEL)
|
||||
if (NOT DEFINED API_SELECTED)
|
||||
if("${LINE}" MATCHES "^( *)class (.*) (: public|: protected|: private|:) ([^ ]*)")
|
||||
if(NOT CLS_LEVEL)
|
||||
if(NOT DEFINED API_SELECTED)
|
||||
message(WARNING "Class '${CMAKE_MATCH_2}' has no @api. It won't be published to any API.")
|
||||
set(API_SELECTED FALSE)
|
||||
endif (NOT DEFINED API_SELECTED)
|
||||
endif()
|
||||
unset(IS_PUBLIC)
|
||||
unset(CLS_PARAM_0)
|
||||
set(CLS_PARAM_1 1)
|
||||
@@ -153,132 +153,132 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||
unset(API_SELECTED)
|
||||
set(CLS "${CMAKE_MATCH_2}")
|
||||
set(SUPER_CLS "${CMAKE_MATCH_4}")
|
||||
elseif (CLS_LEVEL EQUAL 1)
|
||||
if (NOT DEFINED API_SELECTED)
|
||||
elseif(CLS_LEVEL EQUAL 1)
|
||||
if(NOT DEFINED API_SELECTED)
|
||||
set(API_SELECTED ${CLS_IN_API})
|
||||
endif (NOT API_SELECTED)
|
||||
endif()
|
||||
|
||||
if (API_SELECTED)
|
||||
if(API_SELECTED)
|
||||
list(APPEND STRUCTS "${CLS}::${CMAKE_MATCH_2}")
|
||||
endif (API_SELECTED)
|
||||
endif()
|
||||
unset(API_SELECTED)
|
||||
endif ()
|
||||
endif()
|
||||
math(EXPR CLS_LEVEL "${CLS_LEVEL} + 1")
|
||||
continue()
|
||||
endif ("${LINE}" MATCHES "^( *)class (.*) (: public|: protected|: private|:) ([^ ]*)")
|
||||
if ("${LINE}" MATCHES "^( *)public")
|
||||
if (CLS_LEVEL EQUAL 1)
|
||||
endif()
|
||||
if("${LINE}" MATCHES "^( *)public")
|
||||
if(CLS_LEVEL EQUAL 1)
|
||||
set(IS_PUBLIC TRUE)
|
||||
endif (CLS_LEVEL EQUAL 1)
|
||||
endif()
|
||||
continue()
|
||||
endif ("${LINE}" MATCHES "^( *)public")
|
||||
if ("${LINE}" MATCHES "^( *)protected")
|
||||
if (CLS_LEVEL EQUAL 1)
|
||||
endif()
|
||||
if("${LINE}" MATCHES "^( *)protected")
|
||||
if(CLS_LEVEL EQUAL 1)
|
||||
unset(IS_PUBLIC)
|
||||
endif (CLS_LEVEL EQUAL 1)
|
||||
endif()
|
||||
continue()
|
||||
endif ("${LINE}" MATCHES "^( *)protected")
|
||||
if ("${LINE}" MATCHES "^( *)private")
|
||||
if (CLS_LEVEL EQUAL 1)
|
||||
endif()
|
||||
if("${LINE}" MATCHES "^( *)private")
|
||||
if(CLS_LEVEL EQUAL 1)
|
||||
unset(IS_PUBLIC)
|
||||
endif (CLS_LEVEL EQUAL 1)
|
||||
endif()
|
||||
continue()
|
||||
endif ("${LINE}" MATCHES "^( *)private")
|
||||
endif()
|
||||
|
||||
# Ignore the comments
|
||||
if ("${LINE}" MATCHES "^#")
|
||||
if("${LINE}" MATCHES "^#")
|
||||
continue()
|
||||
endif ("${LINE}" MATCHES "^#")
|
||||
if ("${LINE}" MATCHES "/\\*.*\\*/")
|
||||
endif()
|
||||
if("${LINE}" MATCHES "/\\*.*\\*/")
|
||||
unset(COMMENT)
|
||||
continue()
|
||||
endif ("${LINE}" MATCHES "/\\*.*\\*/")
|
||||
if ("${LINE}" MATCHES "/\\*")
|
||||
endif()
|
||||
if("${LINE}" MATCHES "/\\*")
|
||||
set(COMMENT TRUE)
|
||||
continue()
|
||||
endif ("${LINE}" MATCHES "/\\*")
|
||||
if ("${LINE}" MATCHES "\\*/")
|
||||
endif()
|
||||
if("${LINE}" MATCHES "\\*/")
|
||||
unset(COMMENT)
|
||||
continue()
|
||||
endif ("${LINE}" MATCHES "\\*/")
|
||||
if (COMMENT)
|
||||
endif()
|
||||
if(COMMENT)
|
||||
continue()
|
||||
endif (COMMENT)
|
||||
endif()
|
||||
|
||||
# We need to make specialized conversions for structs
|
||||
if ("${LINE}" MATCHES "^( *)struct ([^ ]*)")
|
||||
if("${LINE}" MATCHES "^( *)struct ([^ ]*)")
|
||||
math(EXPR CLS_LEVEL "${CLS_LEVEL} + 1")
|
||||
|
||||
# Check if we want to publish this struct
|
||||
if (NOT DEFINED API_SELECTED)
|
||||
if(NOT DEFINED API_SELECTED)
|
||||
set(API_SELECTED ${CLS_IN_API})
|
||||
endif (NOT DEFINED API_SELECTED)
|
||||
if (NOT API_SELECTED)
|
||||
endif()
|
||||
if(NOT API_SELECTED)
|
||||
unset(API_SELECTED)
|
||||
continue()
|
||||
endif (NOT API_SELECTED)
|
||||
endif()
|
||||
unset(API_SELECTED)
|
||||
|
||||
if (NOT IS_PUBLIC OR NOT CLS_LEVEL EQUAL 1)
|
||||
if(NOT IS_PUBLIC OR NOT CLS_LEVEL EQUAL 1)
|
||||
continue()
|
||||
endif (NOT IS_PUBLIC OR NOT CLS_LEVEL EQUAL 1)
|
||||
endif()
|
||||
|
||||
list(APPEND STRUCTS "${CLS}::${CMAKE_MATCH_2}")
|
||||
continue()
|
||||
endif ("${LINE}" MATCHES "^( *)struct ([^ ]*)")
|
||||
endif()
|
||||
|
||||
# We need to make specialized conversions for enums
|
||||
if ("${LINE}" MATCHES "^( *)enum ([^ ]*)")
|
||||
if("${LINE}" MATCHES "^( *)enum ([^ ]*)")
|
||||
math(EXPR CLS_LEVEL "${CLS_LEVEL} + 1")
|
||||
|
||||
# Check if we want to publish this enum
|
||||
if (NOT DEFINED API_SELECTED)
|
||||
if(NOT DEFINED API_SELECTED)
|
||||
set(API_SELECTED ${CLS_IN_API})
|
||||
endif (NOT DEFINED API_SELECTED)
|
||||
if (NOT API_SELECTED)
|
||||
endif()
|
||||
if(NOT API_SELECTED)
|
||||
unset(API_SELECTED)
|
||||
continue()
|
||||
endif (NOT API_SELECTED)
|
||||
endif()
|
||||
unset(API_SELECTED)
|
||||
|
||||
if (NOT IS_PUBLIC)
|
||||
if(NOT IS_PUBLIC)
|
||||
continue()
|
||||
endif (NOT IS_PUBLIC)
|
||||
endif()
|
||||
|
||||
set(IN_ENUM TRUE)
|
||||
list(APPEND ENUMS "${CLS}::${CMAKE_MATCH_2}")
|
||||
continue()
|
||||
endif ("${LINE}" MATCHES "^( *)enum ([^ ]*)")
|
||||
endif()
|
||||
|
||||
# Maybe the end of the class, if so we can start with the Squirrel export pretty soon
|
||||
if ("${LINE}" MATCHES "};")
|
||||
if("${LINE}" MATCHES "};")
|
||||
math(EXPR CLS_LEVEL "${CLS_LEVEL} - 1")
|
||||
if (CLS_LEVEL)
|
||||
if(CLS_LEVEL)
|
||||
unset(IN_ENUM)
|
||||
continue()
|
||||
endif (CLS_LEVEL)
|
||||
endif()
|
||||
|
||||
if (CLS)
|
||||
if(CLS)
|
||||
set(START_SQUIRREL_DEFINE_ON_NEXT_LINE TRUE)
|
||||
endif (CLS)
|
||||
endif()
|
||||
continue()
|
||||
endif ("${LINE}" MATCHES "};")
|
||||
endif()
|
||||
|
||||
# Empty/white lines. When we may do the Squirrel export, do that export.
|
||||
if ("${LINE}" MATCHES "^([ ]*)$")
|
||||
if (NOT START_SQUIRREL_DEFINE_ON_NEXT_LINE)
|
||||
if("${LINE}" MATCHES "^([ ]*)$")
|
||||
if(NOT START_SQUIRREL_DEFINE_ON_NEXT_LINE)
|
||||
continue()
|
||||
endif (NOT START_SQUIRREL_DEFINE_ON_NEXT_LINE)
|
||||
endif()
|
||||
|
||||
if (NOT CLS_IN_API)
|
||||
if(NOT CLS_IN_API)
|
||||
reset_reader()
|
||||
continue()
|
||||
endif (NOT CLS_IN_API)
|
||||
endif()
|
||||
|
||||
if (NOT HAS_FILEHEADER)
|
||||
if(NOT HAS_FILEHEADER)
|
||||
dump_fileheader()
|
||||
set(HAS_FILEHEADER TRUE)
|
||||
endif (NOT HAS_FILEHEADER)
|
||||
endif()
|
||||
|
||||
unset(IS_PUBLIC)
|
||||
unset(NAMESPACE_OPENED)
|
||||
@@ -288,38 +288,38 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||
|
||||
string(APPEND SQUIRREL_EXPORT "\n")
|
||||
|
||||
if ("${APIUC}" STREQUAL "Template")
|
||||
if("${APIUC}" STREQUAL "Template")
|
||||
# First check whether we have enums to print
|
||||
if (DEFINED ENUMS)
|
||||
if (NOT NAMESPACE_OPENED)
|
||||
if(DEFINED ENUMS)
|
||||
if(NOT NAMESPACE_OPENED)
|
||||
string(APPEND SQUIRREL_EXPORT "\nnamespace SQConvert {")
|
||||
set(NAMESPACE_OPENED TRUE)
|
||||
endif (NOT NAMESPACE_OPENED)
|
||||
endif()
|
||||
string(APPEND SQUIRREL_EXPORT "\n /* Allow enums to be used as Squirrel parameters */")
|
||||
foreach(ENUM IN LISTS ENUMS)
|
||||
string(APPEND SQUIRREL_EXPORT "\n template <> inline ${ENUM} GetParam(ForceType<${ENUM}>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (${ENUM})tmp; }")
|
||||
string(APPEND SQUIRREL_EXPORT "\n template <> inline int Return<${ENUM}>(HSQUIRRELVM vm, ${ENUM} res) { sq_pushinteger(vm, (int32)res); return 1; }")
|
||||
endforeach(ENUM)
|
||||
endif (DEFINED ENUMS)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Then check whether we have structs/classes to print
|
||||
if (DEFINED STRUCTS)
|
||||
if (NOT NAMESPACE_OPENED)
|
||||
if(DEFINED STRUCTS)
|
||||
if(NOT NAMESPACE_OPENED)
|
||||
string(APPEND SQUIRREL_EXPORT "\nnamespace SQConvert {")
|
||||
set(NAMESPACE_OPENED TRUE)
|
||||
endif (NOT NAMESPACE_OPENED)
|
||||
endif()
|
||||
string(APPEND SQUIRREL_EXPORT "\n /* Allow inner classes/structs to be used as Squirrel parameters */")
|
||||
foreach(STRUCT IN LISTS STRUCTS)
|
||||
dump_class_templates(${STRUCT})
|
||||
endforeach(STRUCT)
|
||||
endif (DEFINED STRUCTS)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if (NOT NAMESPACE_OPENED)
|
||||
if(NOT NAMESPACE_OPENED)
|
||||
string(APPEND SQUIRREL_EXPORT "\nnamespace SQConvert {")
|
||||
set(NAMESPACE_OPENED TRUE)
|
||||
else (NOT NAMESPACE_OPENED)
|
||||
else()
|
||||
string(APPEND SQUIRREL_EXPORT "\n")
|
||||
endif (NOT NAMESPACE_OPENED)
|
||||
endif()
|
||||
string(APPEND SQUIRREL_EXPORT "\n /* Allow ${CLS} to be used as Squirrel parameter */")
|
||||
dump_class_templates(${CLS})
|
||||
|
||||
@@ -327,7 +327,7 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||
|
||||
reset_reader()
|
||||
continue()
|
||||
endif ("${APIUC}" STREQUAL "Template")
|
||||
endif()
|
||||
|
||||
string(APPEND SQUIRREL_EXPORT "\n")
|
||||
string(APPEND SQUIRREL_EXPORT "\ntemplate <> const char *GetClassName<${CLS}, ST_${APIUC}>() { return \"${API_CLS}\"; }")
|
||||
@@ -337,61 +337,61 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||
string(APPEND SQUIRREL_EXPORT "\nvoid SQ${API_CLS}_Register(Squirrel *engine)")
|
||||
string(APPEND SQUIRREL_EXPORT "\n{")
|
||||
string(APPEND SQUIRREL_EXPORT "\n DefSQClass<${CLS}, ST_${APIUC}> SQ${API_CLS}(\"${API_CLS}\");")
|
||||
if ("${SUPER_CLS}" STREQUAL "Text" OR "${SUPER_CLS}" STREQUAL "ScriptObject" OR "${SUPER_CLS}" STREQUAL "AIAbstractiveList::Valuator")
|
||||
if("${SUPER_CLS}" STREQUAL "Text" OR "${SUPER_CLS}" STREQUAL "ScriptObject" OR "${SUPER_CLS}" STREQUAL "AIAbstractiveList::Valuator")
|
||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.PreRegister(engine);")
|
||||
else ("${SUPER_CLS}" STREQUAL "Text" OR "${SUPER_CLS}" STREQUAL "ScriptObject" OR "${SUPER_CLS}" STREQUAL "AIAbstractiveList::Valuator")
|
||||
else()
|
||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.PreRegister(engine, \"${API_SUPER_CLS}\");")
|
||||
endif ("${SUPER_CLS}" STREQUAL "Text" OR "${SUPER_CLS}" STREQUAL "ScriptObject" OR "${SUPER_CLS}" STREQUAL "AIAbstractiveList::Valuator")
|
||||
if (NOT "${SUPER_CLS}" STREQUAL "ScriptEvent")
|
||||
if ("${CLS_PARAM_2}" STREQUAL "v")
|
||||
endif()
|
||||
if(NOT "${SUPER_CLS}" STREQUAL "ScriptEvent")
|
||||
if("${CLS_PARAM_2}" STREQUAL "v")
|
||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.AddSQAdvancedConstructor(engine);")
|
||||
else ("${CLS_PARAM_2}" STREQUAL "v")
|
||||
else()
|
||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.AddConstructor<void (${CLS}::*)(${CLS_PARAM_0}), ${CLS_PARAM_1}>(engine, \"${CLS_PARAM_2}\");")
|
||||
endif ("${CLS_PARAM_2}" STREQUAL "v")
|
||||
endif (NOT "${SUPER_CLS}" STREQUAL "ScriptEvent")
|
||||
endif()
|
||||
endif()
|
||||
string(APPEND SQUIRREL_EXPORT "\n")
|
||||
|
||||
# Enum values
|
||||
set(MLEN 0)
|
||||
foreach(ENUM_VALUE IN LISTS ENUM_VALUES)
|
||||
string(LENGTH "${ENUM_VALUE}" LEN)
|
||||
if (MLEN LESS LEN)
|
||||
if(MLEN LESS LEN)
|
||||
set(MLEN ${LEN})
|
||||
endif (MLEN LESS LEN)
|
||||
endforeach(ENUM_VALUE)
|
||||
endif()
|
||||
endforeach()
|
||||
foreach(ENUM_VALUE IN LISTS ENUM_VALUES)
|
||||
string(LENGTH "${ENUM_VALUE}" LEN)
|
||||
math(EXPR LEN "${MLEN} - ${LEN}")
|
||||
unset(SPACES)
|
||||
foreach(i RANGE ${LEN})
|
||||
string(APPEND SPACES " ")
|
||||
endforeach(i)
|
||||
endforeach()
|
||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.DefSQConst(engine, ${CLS}::${ENUM_VALUE},${SPACES}\"${ENUM_VALUE}\");")
|
||||
endforeach(ENUM_VALUE)
|
||||
if (MLEN)
|
||||
endforeach()
|
||||
if(MLEN)
|
||||
string(APPEND SQUIRREL_EXPORT "\n")
|
||||
endif (MLEN)
|
||||
endif()
|
||||
|
||||
# Const values
|
||||
set(MLEN 0)
|
||||
foreach(CONST_VALUE IN LISTS CONST_VALUES)
|
||||
string(LENGTH "${CONST_VALUE}" LEN)
|
||||
if (MLEN LESS LEN)
|
||||
if(MLEN LESS LEN)
|
||||
set(MLEN ${LEN})
|
||||
endif (MLEN LESS LEN)
|
||||
endforeach(CONST_VALUE)
|
||||
endif()
|
||||
endforeach()
|
||||
foreach(CONST_VALUE IN LISTS CONST_VALUES)
|
||||
string(LENGTH "${CONST_VALUE}" LEN)
|
||||
math(EXPR LEN "${MLEN} - ${LEN}")
|
||||
unset(SPACES)
|
||||
foreach(i RANGE ${LEN})
|
||||
string(APPEND SPACES " ")
|
||||
endforeach(i)
|
||||
endforeach()
|
||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.DefSQConst(engine, ${CLS}::${CONST_VALUE},${SPACES}\"${CONST_VALUE}\");")
|
||||
endforeach(CONST_VALUE)
|
||||
if (MLEN)
|
||||
endforeach()
|
||||
if(MLEN)
|
||||
string(APPEND SQUIRREL_EXPORT "\n")
|
||||
endif (MLEN)
|
||||
endif()
|
||||
|
||||
# Mapping of OTTD strings to errors
|
||||
set(MLEN 0)
|
||||
@@ -399,10 +399,10 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||
string(REPLACE ":" ";" ENUM_STRING_TO_ERROR "${ENUM_STRING_TO_ERROR}")
|
||||
list(GET ENUM_STRING_TO_ERROR 0 ENUM_STRING)
|
||||
string(LENGTH "${ENUM_STRING}" LEN)
|
||||
if (MLEN LESS LEN)
|
||||
if(MLEN LESS LEN)
|
||||
set(MLEN ${LEN})
|
||||
endif (MLEN LESS LEN)
|
||||
endforeach(ENUM_STRING_TO_ERROR)
|
||||
endif()
|
||||
endforeach()
|
||||
foreach(ENUM_STRING_TO_ERROR IN LISTS ENUM_STRING_TO_ERRORS)
|
||||
string(REPLACE ":" ";" ENUM_STRING_TO_ERROR "${ENUM_STRING_TO_ERROR}")
|
||||
list(GET ENUM_STRING_TO_ERROR 0 ENUM_STRING)
|
||||
@@ -412,33 +412,33 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||
unset(SPACES)
|
||||
foreach(i RANGE ${LEN})
|
||||
string(APPEND SPACES " ")
|
||||
endforeach(i)
|
||||
endforeach()
|
||||
string(APPEND SQUIRREL_EXPORT "\n ScriptError::RegisterErrorMap(${ENUM_STRING},${SPACES}${CLS}::${ENUM_ERROR});")
|
||||
endforeach(ENUM_STRING_TO_ERROR)
|
||||
if (MLEN)
|
||||
endforeach()
|
||||
if(MLEN)
|
||||
string(APPEND SQUIRREL_EXPORT "\n")
|
||||
endif (MLEN)
|
||||
endif()
|
||||
|
||||
# Mapping of errors to human 'readable' strings.
|
||||
set(MLEN 0)
|
||||
foreach(ENUM_ERROR_TO_STRING IN LISTS ENUM_ERROR_TO_STRINGS)
|
||||
string(LENGTH "${ENUM_ERROR_TO_STRING}" LEN)
|
||||
if (MLEN LESS LEN)
|
||||
if(MLEN LESS LEN)
|
||||
set(MLEN ${LEN})
|
||||
endif (MLEN LESS LEN)
|
||||
endforeach(ENUM_ERROR_TO_STRING)
|
||||
endif()
|
||||
endforeach()
|
||||
foreach(ENUM_ERROR_TO_STRING IN LISTS ENUM_ERROR_TO_STRINGS)
|
||||
string(LENGTH "${ENUM_ERROR_TO_STRING}" LEN)
|
||||
math(EXPR LEN "${MLEN} - ${LEN}")
|
||||
unset(SPACES)
|
||||
foreach(i RANGE ${LEN})
|
||||
string(APPEND SPACES " ")
|
||||
endforeach(i)
|
||||
endforeach()
|
||||
string(APPEND SQUIRREL_EXPORT "\n ScriptError::RegisterErrorMapString(${CLS}::${ENUM_ERROR_TO_STRING},${SPACES}\"${ENUM_ERROR_TO_STRING}\");")
|
||||
endforeach(ENUM_ERROR_TO_STRING)
|
||||
if (MLEN)
|
||||
endforeach()
|
||||
if(MLEN)
|
||||
string(APPEND SQUIRREL_EXPORT "\n")
|
||||
endif (MLEN)
|
||||
endif()
|
||||
|
||||
# Static methods
|
||||
set(MLEN 0)
|
||||
@@ -446,10 +446,10 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||
string(REPLACE ":" ";" STATIC_METHOD "${STATIC_METHOD}")
|
||||
list(GET STATIC_METHOD 0 FUNCNAME)
|
||||
string(LENGTH "${FUNCNAME}" LEN)
|
||||
if (MLEN LESS LEN)
|
||||
if(MLEN LESS LEN)
|
||||
set(MLEN ${LEN})
|
||||
endif (MLEN LESS LEN)
|
||||
endforeach(STATIC_METHOD)
|
||||
endif()
|
||||
endforeach()
|
||||
foreach(STATIC_METHOD IN LISTS STATIC_METHODS)
|
||||
string(REPLACE ":" ";" STATIC_METHOD "${STATIC_METHOD}")
|
||||
list(GET STATIC_METHOD 0 FUNCNAME)
|
||||
@@ -457,26 +457,26 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||
list(GET STATIC_METHOD 2 TYPES)
|
||||
string(LENGTH "${FUNCNAME}" LEN)
|
||||
math(EXPR LEN "${MLEN} - ${LEN}")
|
||||
if ("${TYPES}" STREQUAL "v")
|
||||
if (LEN GREATER 8)
|
||||
if("${TYPES}" STREQUAL "v")
|
||||
if(LEN GREATER 8)
|
||||
math(EXPR LEN "${LEN} - 8")
|
||||
else (LEN GREATER 8)
|
||||
else()
|
||||
set(LEN 0)
|
||||
endif (LEN GREATER 8)
|
||||
endif ("${TYPES}" STREQUAL "v")
|
||||
endif()
|
||||
endif()
|
||||
unset(SPACES)
|
||||
foreach(i RANGE ${LEN})
|
||||
string(APPEND SPACES " ")
|
||||
endforeach(i)
|
||||
if ("${TYPES}" STREQUAL "v")
|
||||
endforeach()
|
||||
if("${TYPES}" STREQUAL "v")
|
||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.DefSQAdvancedStaticMethod(engine, &${CLS}::${FUNCNAME},${SPACES}\"${FUNCNAME}\");")
|
||||
else ("${TYPES}" STREQUAL "v")
|
||||
else()
|
||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.DefSQStaticMethod(engine, &${CLS}::${FUNCNAME},${SPACES}\"${FUNCNAME}\",${SPACES}${ARGC}, \"${TYPES}\");")
|
||||
endif ("${TYPES}" STREQUAL "v")
|
||||
endforeach(STATIC_METHOD)
|
||||
if (MLEN)
|
||||
endif()
|
||||
endforeach()
|
||||
if(MLEN)
|
||||
string(APPEND SQUIRREL_EXPORT "\n")
|
||||
endif (MLEN)
|
||||
endif()
|
||||
|
||||
# Non-static methods
|
||||
set(MLEN 0)
|
||||
@@ -484,10 +484,10 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||
string(REPLACE ":" ";" METHOD "${METHOD}")
|
||||
list(GET METHOD 0 FUNCNAME)
|
||||
string(LENGTH "${FUNCNAME}" LEN)
|
||||
if (MLEN LESS LEN)
|
||||
if(MLEN LESS LEN)
|
||||
set(MLEN ${LEN})
|
||||
endif (MLEN LESS LEN)
|
||||
endforeach(METHOD)
|
||||
endif()
|
||||
endforeach()
|
||||
foreach(METHOD IN LISTS METHODS)
|
||||
string(REPLACE ":" ";" METHOD "${METHOD}")
|
||||
list(GET METHOD 0 FUNCNAME)
|
||||
@@ -495,26 +495,26 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||
list(GET METHOD 2 TYPES)
|
||||
string(LENGTH "${FUNCNAME}" LEN)
|
||||
math(EXPR LEN "${MLEN} - ${LEN}")
|
||||
if ("${TYPES}" STREQUAL "v")
|
||||
if (LEN GREATER 8)
|
||||
if("${TYPES}" STREQUAL "v")
|
||||
if(LEN GREATER 8)
|
||||
math(EXPR LEN "${LEN} - 8")
|
||||
else (LEN GREATER 8)
|
||||
else()
|
||||
set(LEN 0)
|
||||
endif (LEN GREATER 8)
|
||||
endif ("${TYPES}" STREQUAL "v")
|
||||
endif()
|
||||
endif()
|
||||
unset(SPACES)
|
||||
foreach(i RANGE ${LEN})
|
||||
string(APPEND SPACES " ")
|
||||
endforeach(i)
|
||||
if ("${TYPES}" STREQUAL "v")
|
||||
endforeach()
|
||||
if("${TYPES}" STREQUAL "v")
|
||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.DefSQAdvancedMethod(engine, &${CLS}::${FUNCNAME},${SPACES}\"${FUNCNAME}\");")
|
||||
else ("${TYPES}" STREQUAL "v")
|
||||
else()
|
||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.DefSQMethod(engine, &${CLS}::${FUNCNAME},${SPACES}\"${FUNCNAME}\",${SPACES}${ARGC}, \"${TYPES}\");")
|
||||
endif ("${TYPES}" STREQUAL "v")
|
||||
endforeach(METHOD)
|
||||
if (MLEN)
|
||||
endif()
|
||||
endforeach()
|
||||
if(MLEN)
|
||||
string(APPEND SQUIRREL_EXPORT "\n")
|
||||
endif (MLEN)
|
||||
endif()
|
||||
|
||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.PostRegister(engine);")
|
||||
string(APPEND SQUIRREL_EXPORT "\n}")
|
||||
@@ -522,64 +522,64 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||
reset_reader()
|
||||
|
||||
continue()
|
||||
endif ("${LINE}" MATCHES "^([ ]*)$")
|
||||
endif()
|
||||
|
||||
# Skip non-public functions
|
||||
if (NOT IS_PUBLIC)
|
||||
if(NOT IS_PUBLIC)
|
||||
continue()
|
||||
endif (NOT IS_PUBLIC)
|
||||
endif()
|
||||
|
||||
# Add enums
|
||||
if (IN_ENUM)
|
||||
if(IN_ENUM)
|
||||
string(REGEX MATCH "([^, ]+)" ENUM_VALUE "${LINE}")
|
||||
list(APPEND ENUM_VALUES "${ENUM_VALUE}")
|
||||
|
||||
# Check if this a special error enum
|
||||
list(GET ENUMS -1 ENUM)
|
||||
if ("${ENUM}" MATCHES ".*::ErrorMessages")
|
||||
if("${ENUM}" MATCHES ".*::ErrorMessages")
|
||||
# syntax:
|
||||
# enum ErrorMessages {
|
||||
# ERR_SOME_ERROR, // [STR_ITEM1, STR_ITEM2, ...]
|
||||
# }
|
||||
|
||||
# Set the mappings
|
||||
if ("${LINE}" MATCHES "\\[(.*)\\]")
|
||||
if("${LINE}" MATCHES "\\[(.*)\\]")
|
||||
string(REGEX REPLACE "[ ]" "" MAPPINGS "${CMAKE_MATCH_1}")
|
||||
string(REPLACE "," ";" MAPPINGS "${MAPPINGS}")
|
||||
|
||||
foreach(MAPPING IN LISTS MAPPINGS)
|
||||
list(APPEND ENUM_STRING_TO_ERRORS "${MAPPING}:${ENUM_VALUE}")
|
||||
endforeach(MAPPING)
|
||||
endforeach()
|
||||
|
||||
list(APPEND ENUM_ERROR_TO_STRINGS "${ENUM_VALUE}")
|
||||
endif ("${LINE}" MATCHES "\\[(.*)\\]")
|
||||
endif ("${ENUM}" MATCHES ".*::ErrorMessages")
|
||||
endif()
|
||||
endif()
|
||||
continue()
|
||||
endif (IN_ENUM)
|
||||
endif()
|
||||
|
||||
# Add a const (non-enum) value
|
||||
if ("${LINE}" MATCHES "^[ ]*static const [^ ]+ ([^ ]+) = -?\\(?[^ ]*\\)?[^ ]+;")
|
||||
if("${LINE}" MATCHES "^[ ]*static const [^ ]+ ([^ ]+) = -?\\(?[^ ]*\\)?[^ ]+;")
|
||||
list(APPEND CONST_VALUES "${CMAKE_MATCH_1}")
|
||||
continue()
|
||||
endif ("${LINE}" MATCHES "^[ ]*static const [^ ]+ ([^ ]+) = -?\\(?[^ ]*\\)?[^ ]+;")
|
||||
endif()
|
||||
|
||||
# Add a method to the list
|
||||
if ("${LINE}" MATCHES "^.*\\(.*\\).*$")
|
||||
if (NOT CLS_LEVEL EQUAL 1)
|
||||
if("${LINE}" MATCHES "^.*\\(.*\\).*$")
|
||||
if(NOT CLS_LEVEL EQUAL 1)
|
||||
continue()
|
||||
endif (NOT CLS_LEVEL EQUAL 1)
|
||||
if ("${LINE}" MATCHES "~")
|
||||
if (DEFINED API_SELECTED)
|
||||
endif()
|
||||
if("${LINE}" MATCHES "~")
|
||||
if(DEFINED API_SELECTED)
|
||||
message(WARNING "Destructor for '${CLS}' has @api. Tag ignored.")
|
||||
unset(API_SELECTED)
|
||||
endif (DEFINED API_SELECTED)
|
||||
endif()
|
||||
continue()
|
||||
endif ("${LINE}" MATCHES "~")
|
||||
endif()
|
||||
|
||||
unset(IS_STATIC)
|
||||
if ("${LINE}" MATCHES "static")
|
||||
if("${LINE}" MATCHES "static")
|
||||
set(IS_STATIC TRUE)
|
||||
endif ("${LINE}" MATCHES "static")
|
||||
endif()
|
||||
|
||||
string(REGEX REPLACE "(virtual|static|const)[ ]+" "" LINE "${LINE}")
|
||||
string(REGEX REPLACE "{.*" "" LINE "${LINE}")
|
||||
@@ -593,75 +593,75 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||
string(REGEX MATCH "([^ ]+)( ([^ ]+))?" RESULT "${LINE}")
|
||||
set(FUNCTYPE "${CMAKE_MATCH_1}")
|
||||
set(FUNCNAME "${CMAKE_MATCH_3}")
|
||||
if ("${FUNCTYPE}" STREQUAL "${CLS}" AND NOT FUNCNAME)
|
||||
if (DEFINED API_SELECTED)
|
||||
if("${FUNCTYPE}" STREQUAL "${CLS}" AND NOT FUNCNAME)
|
||||
if(DEFINED API_SELECTED)
|
||||
message(WARNING "Constructor for '${CLS}' has @api. Tag ignored.")
|
||||
unset(API_SELECTED)
|
||||
endif (DEFINED API_SELECTED)
|
||||
endif()
|
||||
set(CLS_PARAM_0 "${PARAM_S}")
|
||||
if (NOT PARAM_S)
|
||||
if(NOT PARAM_S)
|
||||
continue()
|
||||
endif (NOT PARAM_S)
|
||||
elseif (NOT FUNCNAME)
|
||||
endif()
|
||||
elseif(NOT FUNCNAME)
|
||||
continue()
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
string(REPLACE "," ";" PARAMS "${PARAM_S}")
|
||||
if (IS_STATIC)
|
||||
if(IS_STATIC)
|
||||
set(TYPES ".")
|
||||
else (IS_STATIC)
|
||||
else()
|
||||
set(TYPES "x")
|
||||
endif (IS_STATIC)
|
||||
endif()
|
||||
|
||||
set(LEN 1)
|
||||
foreach(PARAM IN LISTS PARAMS)
|
||||
math(EXPR LEN "${LEN} + 1")
|
||||
string(STRIP "${PARAM}" PARAM)
|
||||
if ("${PARAM}" MATCHES "\\*|&")
|
||||
if ("${PARAM}" MATCHES "^char")
|
||||
if("${PARAM}" MATCHES "\\*|&")
|
||||
if("${PARAM}" MATCHES "^char")
|
||||
# Many types can be converted to string, so use '.', not 's'. (handled by our glue code)
|
||||
string(APPEND TYPES ".")
|
||||
elseif ("${PARAM}" MATCHES "^void")
|
||||
elseif("${PARAM}" MATCHES "^void")
|
||||
string(APPEND TYPES "p")
|
||||
elseif ("${PARAM}" MATCHES "^Array")
|
||||
elseif("${PARAM}" MATCHES "^Array")
|
||||
string(APPEND TYPES "a")
|
||||
elseif ("${PARAM}" MATCHES "^struct Array")
|
||||
elseif("${PARAM}" MATCHES "^struct Array")
|
||||
string(APPEND TYPES "a")
|
||||
elseif ("${PARAM}" MATCHES "^Text")
|
||||
elseif("${PARAM}" MATCHES "^Text")
|
||||
string(APPEND TYPES ".")
|
||||
else ()
|
||||
else()
|
||||
string(APPEND TYPES "x")
|
||||
endif ()
|
||||
elseif ("${PARAM}" MATCHES "^bool")
|
||||
endif()
|
||||
elseif("${PARAM}" MATCHES "^bool")
|
||||
string(APPEND TYPES "b")
|
||||
elseif ("${PARAM}" MATCHES "^HSQUIRRELVM")
|
||||
elseif("${PARAM}" MATCHES "^HSQUIRRELVM")
|
||||
set(TYPES "v")
|
||||
else ()
|
||||
else()
|
||||
string(APPEND TYPES "i")
|
||||
endif ()
|
||||
endforeach(PARAM)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Check if we want to publish this function
|
||||
if (NOT DEFINED API_SELECTED)
|
||||
if(NOT DEFINED API_SELECTED)
|
||||
set(API_SELECTED ${CLS_IN_API})
|
||||
endif (NOT DEFINED API_SELECTED)
|
||||
if (NOT API_SELECTED)
|
||||
endif()
|
||||
if(NOT API_SELECTED)
|
||||
unset(API_SELECTED)
|
||||
continue()
|
||||
endif (NOT API_SELECTED)
|
||||
endif()
|
||||
unset(API_SELECTED)
|
||||
|
||||
if ("${FUNCTYPE}" STREQUAL "${CLS}" AND NOT FUNCNAME)
|
||||
if("${FUNCTYPE}" STREQUAL "${CLS}" AND NOT FUNCNAME)
|
||||
set(CLS_PARAM_1 ${LEN})
|
||||
set(CLS_PARAM_2 "${TYPES}")
|
||||
elseif ("${FUNCNAME}" MATCHES "^_" AND NOT "${TYPES}" STREQUAL "v")
|
||||
elseif (IS_STATIC)
|
||||
elseif("${FUNCNAME}" MATCHES "^_" AND NOT "${TYPES}" STREQUAL "v")
|
||||
elseif(IS_STATIC)
|
||||
list(APPEND STATIC_METHODS "${FUNCNAME}:${LEN}:${TYPES}")
|
||||
else ()
|
||||
else()
|
||||
list(APPEND METHODS "${FUNCNAME}:${LEN}:${TYPES}")
|
||||
endif ()
|
||||
endif()
|
||||
continue()
|
||||
endif ("${LINE}" MATCHES "^.*\\(.*\\).*$")
|
||||
endforeach(LINE)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
configure_file(${SCRIPT_API_SOURCE_FILE} ${SCRIPT_API_BINARY_FILE})
|
||||
|
@@ -1,17 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
if (NOT INCLUDES_SOURCE_FILE)
|
||||
if(NOT INCLUDES_SOURCE_FILE)
|
||||
message(FATAL_ERROR "Script needs INCLUDES_SOURCE_FILE defined")
|
||||
endif (NOT INCLUDES_SOURCE_FILE)
|
||||
if (NOT INCLUDES_BINARY_FILE)
|
||||
endif()
|
||||
if(NOT INCLUDES_BINARY_FILE)
|
||||
message(FATAL_ERROR "Script needs INCLUDES_BINARY_FILE defined")
|
||||
endif (NOT INCLUDES_BINARY_FILE)
|
||||
if (NOT APILC)
|
||||
endif()
|
||||
if(NOT APILC)
|
||||
message(FATAL_ERROR "Script needs APILC defined")
|
||||
endif (NOT APILC)
|
||||
if (NOT APIUC)
|
||||
endif()
|
||||
if(NOT APIUC)
|
||||
message(FATAL_ERROR "Script needs APIUC defined")
|
||||
endif (NOT APIUC)
|
||||
endif()
|
||||
|
||||
set(ARGC 1)
|
||||
set(ARG_READ NO)
|
||||
@@ -21,32 +21,32 @@ set(ARG_READ NO)
|
||||
while(ARGC LESS CMAKE_ARGC)
|
||||
set(ARG ${CMAKE_ARGV${ARGC}})
|
||||
|
||||
if (ARG_READ)
|
||||
if(ARG_READ)
|
||||
list(APPEND SCRIPT_API_BINARY_FILES "${ARG}")
|
||||
endif (ARG_READ)
|
||||
endif()
|
||||
|
||||
if (ARG STREQUAL "--")
|
||||
if(ARG STREQUAL "--")
|
||||
set(ARG_READ YES)
|
||||
endif (ARG STREQUAL "--")
|
||||
endif()
|
||||
|
||||
math(EXPR ARGC "${ARGC} + 1")
|
||||
endwhile()
|
||||
|
||||
foreach(FILE IN LISTS SCRIPT_API_BINARY_FILES)
|
||||
file(STRINGS "${FILE}" LINES REGEX "^void SQ${APIUC}.*_Register\\(Squirrel \\*engine\\)$")
|
||||
if (LINES)
|
||||
if(LINES)
|
||||
string(REGEX REPLACE ".*api/${APILC}/(.*)" "#include \"\\1\"" FILE "${FILE}")
|
||||
list(APPEND SQUIRREL_INCLUDES "${FILE}")
|
||||
foreach(LINE IN LISTS LINES)
|
||||
if ("${LINE}" MATCHES "SQ${APIUC}(List|Controller)_Register")
|
||||
if("${LINE}" MATCHES "SQ${APIUC}(List|Controller)_Register")
|
||||
continue()
|
||||
endif ("${LINE}" MATCHES "SQ${APIUC}(List|Controller)_Register")
|
||||
endif()
|
||||
string(REGEX REPLACE "^.*void " " " LINE "${LINE}")
|
||||
string(REGEX REPLACE "Squirrel \\*" "" LINE "${LINE}")
|
||||
list(APPEND SQUIRREL_REGISTER "${LINE}")
|
||||
endforeach(LINE)
|
||||
endif (LINES)
|
||||
endforeach(FILE)
|
||||
endforeach()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
list(SORT SQUIRREL_INCLUDES)
|
||||
string(REPLACE ";" "\n" SQUIRREL_INCLUDES "${SQUIRREL_INCLUDES}")
|
||||
|
Reference in New Issue
Block a user