Skip to content

Commit

Permalink
compile lang modules depending of the TIC_RUNTIME_STATIC var is set
Browse files Browse the repository at this point in the history
  • Loading branch information
nesbox committed Apr 28, 2024
1 parent c590b88 commit 801fa86
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 150 deletions.
61 changes: 33 additions & 28 deletions cmake/core.cmake
Expand Up @@ -40,41 +40,46 @@ macro(MACRO_CORE SCRIPT DEFINE BUILD_DEPRECATED)

target_link_libraries(tic80core${SCRIPT} blipbuf zlib)

if(BUILD_WITH_LUA)
target_link_libraries(tic80core${SCRIPT} lua)
endif()

# if(BUILD_WITH_JS)
# target_link_libraries(tic80core${SCRIPT} js)
# endif()
if(BUILD_STATIC)
if(BUILD_WITH_LUA)
target_link_libraries(tic80core${SCRIPT} lua)
endif()

if(BUILD_WITH_JS)
target_link_libraries(tic80core${SCRIPT} js)
endif()

# if(BUILD_WITH_SCHEME)
# target_link_libraries(tic80core${SCRIPT} scheme)
# endif()
if(BUILD_WITH_SCHEME)
target_link_libraries(tic80core${SCRIPT} scheme)
endif()

# if(BUILD_WITH_SQUIRREL)
# target_link_libraries(tic80core${SCRIPT} squirrel)
# endif()
if(BUILD_WITH_SQUIRREL)
target_link_libraries(tic80core${SCRIPT} squirrel)
endif()

# if(BUILD_WITH_PYTHON)
# target_link_libraries(tic80core${SCRIPT} python)
# endif()
if(BUILD_WITH_PYTHON)
target_link_libraries(tic80core${SCRIPT} python)
endif()

# if(BUILD_WITH_WREN)
# target_link_libraries(tic80core${SCRIPT} wren)
# endif()
if(BUILD_WITH_WREN)
target_link_libraries(tic80core${SCRIPT} wren)
endif()

# if(BUILD_WITH_MRUBY)
# target_link_libraries(tic80core${SCRIPT} ruby)
# endif()
if(BUILD_WITH_MRUBY)
target_link_libraries(tic80core${SCRIPT} ruby)
endif()

# if(BUILD_WITH_JANET)
# target_link_libraries(tic80core${SCRIPT} janet)
# endif()
if(BUILD_WITH_JANET)
target_link_libraries(tic80core${SCRIPT} janet)
endif()

# if(BUILD_WITH_WASM)
# target_link_libraries(tic80core${SCRIPT} wasm)
# endif()
if(BUILD_WITH_WASM)
target_link_libraries(tic80core${SCRIPT} wasm)
endif()

target_compile_definitions(tic80core${SCRIPT} PUBLIC TIC_RUNTIME_STATIC)
endif()

if(${BUILD_DEPRECATED})
target_compile_definitions(tic80core${SCRIPT} PRIVATE BUILD_DEPRECATED)
Expand All @@ -91,7 +96,7 @@ endmacro()

MACRO_CORE("" "" TRUE)

if(BUILD_STUB)
if(BUILD_STATIC AND BUILD_STUB)

if(BUILD_WITH_LUA)
MACRO_CORE(lua TIC_BUILD_WITH_LUA FALSE)
Expand Down
36 changes: 18 additions & 18 deletions cmake/wasm.cmake
Expand Up @@ -45,28 +45,28 @@ if(BUILD_WITH_WASM)
# and the external WASM binary chunk since projects do not
# include BINARY chunks

if(BUILD_DEMO_CARTS)
# if(BUILD_DEMO_CARTS)

file(GLOB WASM_DEMOS
${DEMO_CARTS_IN}/wasm/*.wasmp
${DEMO_CARTS_IN}/bunny/wasmmark/*.wasmp
)
# file(GLOB WASM_DEMOS
# ${DEMO_CARTS_IN}/wasm/*.wasmp
# ${DEMO_CARTS_IN}/bunny/wasmmark/*.wasmp
# )

foreach(CART_FILE ${WASM_DEMOS})
# foreach(CART_FILE ${WASM_DEMOS})

get_filename_component(CART_NAME ${CART_FILE} NAME_WE)
get_filename_component(DIR ${CART_FILE} DIRECTORY)
# get_filename_component(CART_NAME ${CART_FILE} NAME_WE)
# get_filename_component(DIR ${CART_FILE} DIRECTORY)

set(OUTNAME ${CMAKE_SOURCE_DIR}/build/assets/${CART_NAME}.tic.dat)
set(WASM_BINARY ${DIR}/${CART_NAME}.wasm)
set(OUTPRJ ${CMAKE_SOURCE_DIR}/build/${CART_NAME}.tic)
list(APPEND DEMO_CARTS_OUT ${OUTNAME})
add_custom_command(OUTPUT ${OUTNAME}
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/wasmp2cart ${CART_FILE} ${OUTPRJ} --binary ${WASM_BINARY} && ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/bin2txt ${OUTPRJ} ${OUTNAME} -z
DEPENDS bin2txt wasmp2cart ${CART_FILE} ${WASM_BINARY}
)
# set(OUTNAME ${CMAKE_SOURCE_DIR}/build/assets/${CART_NAME}.tic.dat)
# set(WASM_BINARY ${DIR}/${CART_NAME}.wasm)
# set(OUTPRJ ${CMAKE_SOURCE_DIR}/build/${CART_NAME}.tic)
# list(APPEND DEMO_CARTS_OUT ${OUTNAME})
# add_custom_command(OUTPUT ${OUTNAME}
# COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/wasmp2cart ${CART_FILE} ${OUTPRJ} --binary ${WASM_BINARY} && ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/bin2txt ${OUTPRJ} ${OUTNAME} -z
# DEPENDS bin2txt wasmp2cart ${CART_FILE} ${WASM_BINARY}
# )

endforeach(CART_FILE)
endif()
# endforeach(CART_FILE)
# endif()

endif()
2 changes: 1 addition & 1 deletion src/api/mruby.c
Expand Up @@ -1216,7 +1216,7 @@ static const tic_outline_item* getMRubyOutline(const char* code, s32* size)
return items;
}

const tic_script_config MRubySyntaxConfig =
const tic_script_config RubySyntaxConfig =
{
.id = 11,
.name = "ruby",
Expand Down
132 changes: 69 additions & 63 deletions src/core/languages.c
@@ -1,95 +1,101 @@
#include <stddef.h>
#include "api.h"

#if defined (TIC_BUILD_WITH_LUA)
extern tic_script_config LuaSyntaxConfig;
#endif
#if defined(TIC_RUNTIME_STATIC)

// #if defined(TIC_BUILD_WITH_MRUBY)
// extern tic_script_config MRubySyntaxConfig;
// #endif
#if defined (TIC_BUILD_WITH_LUA)
extern tic_script_config LuaSyntaxConfig;
#endif

// #if defined(TIC_BUILD_WITH_JS)
// extern tic_script_config JsSyntaxConfig;
// #endif
#if defined(TIC_BUILD_WITH_MRUBY)
extern tic_script_config RubySyntaxConfig;
#endif

#if defined(TIC_BUILD_WITH_JS)
extern tic_script_config JsSyntaxConfig;
#endif

// #if defined(TIC_BUILD_WITH_MOON)
// extern tic_script_config MoonSyntaxConfig;
// #endif
#if defined(TIC_BUILD_WITH_MOON)
extern tic_script_config MoonSyntaxConfig;
#endif

// #if defined(TIC_BUILD_WITH_FENNEL)
// extern tic_script_config FennelSyntaxConfig;
// #endif
#if defined(TIC_BUILD_WITH_FENNEL)
extern tic_script_config FennelSyntaxConfig;
#endif

// #if defined(TIC_BUILD_WITH_SQUIRREL)
// extern tic_script_config SquirrelSyntaxConfig;
// #endif
#if defined(TIC_BUILD_WITH_SQUIRREL)
extern tic_script_config SquirrelSyntaxConfig;
#endif

// #if defined(TIC_BUILD_WITH_SCHEME)
// extern tic_script_config SchemeSyntaxConfig;
// #endif
#if defined(TIC_BUILD_WITH_SCHEME)
extern tic_script_config SchemeSyntaxConfig;
#endif

// #if defined(TIC_BUILD_WITH_WREN)
// extern tic_script_config WrenSyntaxConfig;
// #endif
#if defined(TIC_BUILD_WITH_WREN)
extern tic_script_config WrenSyntaxConfig;
#endif

// #if defined(TIC_BUILD_WITH_WASM)
// extern tic_script_config WasmSyntaxConfig;
// #endif
#if defined(TIC_BUILD_WITH_WASM)
extern tic_script_config WasmSyntaxConfig;
#endif

// #if defined(TIC_BUILD_WITH_JANET)
// extern tic_script_config JanetSyntaxConfig;
// #endif
#if defined(TIC_BUILD_WITH_JANET)
extern tic_script_config JanetSyntaxConfig;
#endif

// #if defined(TIC_BUILD_WITH_PYTHON)
// extern tic_script_config PythonSyntaxConfig;
// #endif
#if defined(TIC_BUILD_WITH_PYTHON)
extern tic_script_config PythonSyntaxConfig;
#endif
#endif

const tic_script_config* Languages[MAX_SUPPORTED_LANGS + 1] =
{

#if defined(TIC_RUNTIME_STATIC)

#if defined (TIC_BUILD_WITH_LUA)
&LuaSyntaxConfig,
#endif

// #if defined(TIC_BUILD_WITH_MRUBY)
// &MRubySyntaxConfig,
// #endif
#if defined(TIC_BUILD_WITH_MRUBY)
&RubySyntaxConfig,
#endif

// #if defined(TIC_BUILD_WITH_JS)
// &JsSyntaxConfig,
// #endif
#if defined(TIC_BUILD_WITH_JS)
&JsSyntaxConfig,
#endif

// #if defined(TIC_BUILD_WITH_MOON)
// &MoonSyntaxConfig,
// #endif
#if defined(TIC_BUILD_WITH_MOON)
&MoonSyntaxConfig,
#endif

// #if defined(TIC_BUILD_WITH_FENNEL)
// &FennelSyntaxConfig,
// #endif
#if defined(TIC_BUILD_WITH_FENNEL)
&FennelSyntaxConfig,
#endif

// #if defined(TIC_BUILD_WITH_SCHEME)
// &SchemeSyntaxConfig,
// #endif
#if defined(TIC_BUILD_WITH_SCHEME)
&SchemeSyntaxConfig,
#endif

// #if defined(TIC_BUILD_WITH_SQUIRREL)
// &SquirrelSyntaxConfig,
// #endif
#if defined(TIC_BUILD_WITH_SQUIRREL)
&SquirrelSyntaxConfig,
#endif

// #if defined(TIC_BUILD_WITH_WREN)
// &WrenSyntaxConfig,
// #endif
#if defined(TIC_BUILD_WITH_WREN)
&WrenSyntaxConfig,
#endif

#if defined(TIC_BUILD_WITH_WASM)
&WasmSyntaxConfig,
#endif

// #if defined(TIC_BUILD_WITH_WASM)
// &WasmSyntaxConfig,
// #endif
#if defined(TIC_BUILD_WITH_JANET)
&JanetSyntaxConfig,
#endif

// #if defined(TIC_BUILD_WITH_JANET)
// &JanetSyntaxConfig,
// #endif
#if defined(TIC_BUILD_WITH_PYTHON)
&PythonSyntaxConfig,
#endif

// #if defined(TIC_BUILD_WITH_PYTHON)
// &PythonSyntaxConfig,
// #endif
#endif
};

0 comments on commit 801fa86

Please sign in to comment.