Skip to content

Commit

Permalink
build fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nesbox committed May 2, 2024
1 parent 73b68f4 commit 6d02479
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
18 changes: 10 additions & 8 deletions cmake/core.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
# TIC-80 core
################################

if(WIN32)
add_library(dlfcn STATIC ${THIRDPARTY_DIR}/dlfcn/src/dlfcn.c)

target_include_directories(dlfcn
INTERFACE
${THIRDPARTY_DIR}/dirent/include
${THIRDPARTY_DIR}/dlfcn/src)
endif()

macro(MACRO_CORE SCRIPT DEFINE BUILD_DEPRECATED)

set(TIC80CORE_DIR ${CMAKE_SOURCE_DIR}/src)
Expand Down Expand Up @@ -30,16 +39,9 @@ macro(MACRO_CORE SCRIPT DEFINE BUILD_DEPRECATED)
endif()

if(WIN32)
add_library(dlfcn STATIC ${THIRDPARTY_DIR}/dlfcn/src/dlfcn.c)

target_include_directories(dlfcn
INTERFACE
${THIRDPARTY_DIR}/dirent/include
${THIRDPARTY_DIR}/dlfcn/src)

target_link_libraries(tic80core${SCRIPT} PUBLIC dlfcn)
endif()

target_include_directories(tic80core${SCRIPT}
PRIVATE
${THIRDPARTY_DIR}/moonscript
Expand Down
7 changes: 4 additions & 3 deletions include/tic80_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,24 @@
// # ifndef TARGET_OS_IPHONE
# undef __TIC_MACOSX__
# define __TIC_MACOSX__ 1
# define MODULE_EXT ".dylib"
# define TIC_MODULE_EXT ".dylib"
// # endif /* TARGET_OS_IPHONE */
#endif /* defined(__APPLE__) */

#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
# undef __TIC_WINDOWS__
# define __TIC_WINDOWS__ 1
# define MODULE_EXT ".dll"
# define TIC_MODULE_EXT ".dll"
#endif

#if defined(ANDROID) || defined(__ANDROID__)
# undef __TIC_ANDROID__
# define __TIC_ANDROID__ 1
# define TIC_MODULE_EXT ".so"
#elif (defined(linux) || defined(__linux) || defined(__linux__))
# undef __TIC_LINUX__
# define __TIC_LINUX__ 1
# define MODULE_EXT ".so"
# define TIC_MODULE_EXT ".so"
#endif

#ifndef TIC80_API
Expand Down
2 changes: 1 addition & 1 deletion src/studio/studio.c
Original file line number Diff line number Diff line change
Expand Up @@ -2447,7 +2447,7 @@ bool studio_alive(Studio* studio)

static bool onEnumModule(const char* name, const char* title, const char* hash, s32 id, void* data, bool dir)
{
if(strstr(name, MODULE_EXT))
if(strstr(name, TIC_MODULE_EXT))
{
void* module = dlopen(name, RTLD_NOW | RTLD_LOCAL);

Expand Down
2 changes: 1 addition & 1 deletion src/tic.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ TIC80_API void tic80_load(tic80* tic, void* cart, s32 size)
{
const char* tag = tic_tool_metatag(mem->cart.code.data, "script", NULL);
char name[128];
sprintf(name, "%s" MODULE_EXT, tag);
sprintf(name, "%s" TIC_MODULE_EXT, tag);

void* module = dlopen(name, RTLD_NOW | RTLD_LOCAL);

Expand Down

0 comments on commit 6d02479

Please sign in to comment.