Compare commits

..

4 Commits

Author SHA1 Message Date
veclavtalica
630c6fb5d4 /apps/twnlua: automatically generate twnapi.lua file inside ~/data/scripts/ 2025-01-29 03:43:10 +03:00
veclavtalica
d7c744a6ca /apps/twnlua: mark with CODEGEN 2025-01-29 03:36:15 +03:00
veclavtalica
f8d7aa8a07 /apps/twnlua: propagate root project name for executable name 2025-01-29 03:22:04 +03:00
veclavtalica
ea2bbf5de0 /apps/twnlua: support dynlib game=off 2025-01-29 03:14:08 +03:00
3 changed files with 22 additions and 6 deletions

View File

@ -305,6 +305,7 @@ function(use_townengine target sources output_directory)
endif() endif()
set_target_properties(${target} PROPERTIES set_target_properties(${target} PROPERTIES
OUTPUT_NAME ${target}
LIBRARY_OUTPUT_DIRECTORY ${output_directory} LIBRARY_OUTPUT_DIRECTORY ${output_directory}
RUNTIME_OUTPUT_DIRECTORY ${output_directory}) RUNTIME_OUTPUT_DIRECTORY ${output_directory})

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.21) cmake_minimum_required(VERSION 3.21)
cmake_policy(SET CMP0171 NEW)
project(twnlua LANGUAGES C) project(twnlua LANGUAGES C)
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
@ -8,10 +8,26 @@ endif()
add_subdirectory($ENV{TWNROOT} $ENV{TWNROOT}/build) add_subdirectory($ENV{TWNROOT} $ENV{TWNROOT}/build)
set(FLAGS
$<$<NOT:$<BOOL:${TWN_FEATURE_DYNLIB_GAME}>>:--no-dynlib-game>
)
add_custom_command( add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/luabind.c OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/luabind.c
COMMAND ${PYTHON3} ${CMAKE_CURRENT_SOURCE_DIR}/bindgen.py $ENV{TWNROOT}/share/twn_api.json > ${CMAKE_CURRENT_SOURCE_DIR}/luabind.c COMMAND ${PYTHON3} ${CMAKE_CURRENT_SOURCE_DIR}/bindgen.py $ENV{TWNROOT}/share/twn_api.json ${FLAGS} > ${CMAKE_CURRENT_SOURCE_DIR}/luabind.c
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bindgen.py $ENV{TWNROOT}/share/twn_api.json DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bindgen.py $ENV{TWNROOT}/share/twn_api.json
CODEGEN
)
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/data/scripts/twnapi.lua
COMMAND ${PYTHON3} ${CMAKE_CURRENT_SOURCE_DIR}/docgen.py $ENV{TWNROOT}/share/twn_api.json > ${CMAKE_SOURCE_DIR}/data/scripts/twnapi.lua
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/docgen.py $ENV{TWNROOT}/share/twn_api.json
)
add_custom_target(
twnlua_docgen ALL
DEPENDS ${CMAKE_SOURCE_DIR}/data/scripts/twnapi.lua
) )
add_compile_definitions(LUA_32BITS) add_compile_definitions(LUA_32BITS)
@ -23,5 +39,4 @@ set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/luabind.c ${CMAKE_CURRENT_SOURCE_DIR}/luabind.c
) )
use_townengine(${CMAKE_PROJECT_NAME} "${SOURCE_FILES}" ${CMAKE_SOURCE_DIR})
use_townengine(${PROJECT_NAME} "${SOURCE_FILES}" ${CMAKE_SOURCE_DIR})

View File

@ -64,8 +64,8 @@ def from_table(typedesc, variable, indent = 0):
print('#include "twn_game_api.h"\n') print('#include "twn_game_api.h"\n')
# TODO: reuse implementation from the engine, this also breaks with statically compiled build if not "--no-dynlib-game" in sys.argv:
print('#define STB_DS_IMPLEMENTATION') print('#define STB_DS_IMPLEMENTATION')
print('#include <stb_ds.h>') print('#include <stb_ds.h>')
print('#include "minilua.h"\n') print('#include "minilua.h"\n')