Skip to content

Commit

Permalink
build fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nesbox committed May 12, 2024
1 parent 7f6bf28 commit cafff38
Show file tree
Hide file tree
Showing 17 changed files with 1,805 additions and 1,764 deletions.
6 changes: 1 addition & 5 deletions cmake/fennel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
option(BUILD_WITH_FENNEL "Fennel Enabled" ${BUILD_WITH_ALL})
message("BUILD_WITH_FENNEL: ${BUILD_WITH_FENNEL}")

if(BUILD_WITH_FENNEL)
set(BUILD_WITH_LUA TRUE)
endif()

if(BUILD_WITH_FENNEL)

add_library(fennel ${TIC_RUNTIME} ${CMAKE_SOURCE_DIR}/src/api/fennel.c)
Expand All @@ -17,7 +13,7 @@ if(BUILD_WITH_FENNEL)
set_target_properties(fennel PROPERTIES PREFIX "")
endif()

target_link_libraries(fennel PRIVATE lua runtime)
target_link_libraries(fennel PRIVATE runtime luaapi)
target_include_directories(fennel
PRIVATE
${THIRDPARTY_DIR}/fennel
Expand Down
23 changes: 19 additions & 4 deletions cmake/lua.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
################################

option(BUILD_WITH_LUA "Lua Enabled" ON)

if(BUILD_WITH_MOON OR BUILD_WITH_FENNEL)
set(BUILD_WITH_LUA TRUE)
endif()

message("BUILD_WITH_LUA: ${BUILD_WITH_LUA}")

if(BUILD_WITH_LUA)
Expand Down Expand Up @@ -44,18 +49,28 @@ if(BUILD_WITH_LUA)
${LUA_DIR}/lbitlib.c
)

list(APPEND LUA_SRC ${CMAKE_SOURCE_DIR}/src/api/lua.c)
list(APPEND LUA_SRC ${CMAKE_SOURCE_DIR}/src/api/parse_note.c)
add_library(luaapi STATIC
${LUA_SRC}
${CMAKE_SOURCE_DIR}/src/api/luaapi.c
${CMAKE_SOURCE_DIR}/src/api/parse_note.c
)

add_library(lua ${TIC_RUNTIME} ${LUA_SRC})
add_library(lua ${TIC_RUNTIME} ${CMAKE_SOURCE_DIR}/src/api/lua.c)

if(NOT BUILD_STATIC)
set_target_properties(lua PROPERTIES PREFIX "")
endif()

target_link_libraries(lua PRIVATE runtime)
target_link_libraries(lua PRIVATE runtime luaapi)

target_compile_definitions(lua PRIVATE LUA_COMPAT_5_2)

target_include_directories(luaapi
PUBLIC ${THIRDPARTY_DIR}/lua
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/src
)

target_include_directories(lua
PUBLIC ${THIRDPARTY_DIR}/lua
PRIVATE
Expand Down
6 changes: 1 addition & 5 deletions cmake/moon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
option(BUILD_WITH_MOON "Moon Enabled" ${BUILD_WITH_ALL})
message("BUILD_WITH_MOON: ${BUILD_WITH_MOON}")

if(BUILD_WITH_MOON)
set(BUILD_WITH_LUA TRUE)
endif()

if(BUILD_WITH_MOON)

set(LPEG_DIR ${THIRDPARTY_DIR}/lpeg)
Expand All @@ -29,7 +25,7 @@ if(BUILD_WITH_MOON)
set_target_properties(moon PROPERTIES PREFIX "")
endif()

target_link_libraries(moon PRIVATE lpeg lua runtime)
target_link_libraries(moon PRIVATE lpeg runtime luaapi)

target_include_directories(moon
PRIVATE
Expand Down
16 changes: 13 additions & 3 deletions include/tic80_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
# undef __TIC_WINDOWS__
# define __TIC_WINDOWS__ 1
# define TIC_MODULE_EXT ".dll"
# if defined(_MSC_VER) && defined(_USING_V110_SDK71_)
# define __TIC_WIN7__ 1
# endif
# if defined(_MSC_VER) && defined(_USING_V110_SDK71_)
# define __TIC_WIN7__ 1
# endif
#endif

#if defined(ANDROID) || defined(__ANDROID__)
Expand All @@ -52,6 +52,16 @@
# define TIC_MODULE_EXT ".so"
#endif

#if defined(TIC_RUNTIME_STATIC)
# define TIC_EXPORT
#else
# if defined(__TIC_WINDOWS__)
# define TIC_EXPORT __declspec(dllexport)
# elif defined(__GNUC__) && __GNUC__ >= 4
# define TIC_EXPORT __attribute__ ((visibility("default")))
# endif
#endif

#ifndef TIC80_API
# if defined(TIC80_SHARED)
# if defined(__TIC_WINDOWS__)
Expand Down
22 changes: 11 additions & 11 deletions src/api/fennel.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// SOFTWARE.

#include "core/core.h"
#include "lua_api.h"
#include "luaapi.h"

#include "fennel.h"

Expand All @@ -41,12 +41,12 @@ static const char* execute_fennel_src = FENNEL_CODE(
static bool initFennel(tic_mem* tic, const char* code)
{
tic_core* core = (tic_core*)tic;
closeLua(tic);
luaapi_close(tic);

lua_State* lua = core->currentVM = luaL_newstate();
lua_open_builtins(lua);
luaapi_open(lua);

initLuaAPI(core);
luaapi_init(core);

{
lua_State* fennel = core->currentVM;
Expand Down Expand Up @@ -187,23 +187,23 @@ static const u8 DemoRom[] =
#include "../build/assets/fenneldemo.tic.dat"
};

const tic_script EXPORT_SCRIPT(Fennel) =
TIC_EXPORT const tic_script EXPORT_SCRIPT(Fennel) =
{
.id = 14,
.name = "fennel",
.fileExtension = ".fnl",
.projectComment = ";;",
{
.init = initFennel,
.close = closeLua,
.tick = callLuaTick,
.boot = callLuaBoot,
.close = luaapi_close,
.tick = luaapi_tick,
.boot = luaapi_boot,

.callback =
{
.scanline = callLuaScanline,
.border = callLuaBorder,
.menu = callLuaMenu,
.scanline = luaapi_scn,
.border = luaapi_bdr,
.menu = luaapi_menu,
},
},

Expand Down
2 changes: 1 addition & 1 deletion src/api/janet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ static const u8 MarkRom[] =
#include "../build/assets/janetmark.tic.dat"
};

JANET_API const tic_script EXPORT_SCRIPT(Janet) =
TIC_EXPORT const tic_script EXPORT_SCRIPT(Janet) =
{
.id = 18,
.name = "janet",
Expand Down
2 changes: 1 addition & 1 deletion src/api/js.c
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ static const u8 MarkRom[] =
#include "../build/assets/jsmark.tic.dat"
};

const tic_script EXPORT_SCRIPT(Js) =
TIC_EXPORT const tic_script EXPORT_SCRIPT(Js) =
{
.id = 12,
.name = "js",
Expand Down

0 comments on commit cafff38

Please sign in to comment.