Skip to content

Commit

Permalink
Merge branch 'luvit:master' into docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilal2453 authored Jan 19, 2025
2 parents e7cc5ad + 12c8642 commit 401d41b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 3 deletions.
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ if (WithSharedLibluv)
find_package(Libuv REQUIRED)
include_directories(${LIBUV_INCLUDE_DIRS})

include(CheckCSourceCompiles)

set(CMAKE_REQUIRED_INCLUDES ${LUAJIT_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${LUAJIT_LIBRARIES})
check_c_source_compiles("
#include <luajit.h>
int main() {
LUAJIT_VERSION_SYM();
return 0;
}" LUAJIT_HAS_VERSION_SYM)
if (NOT LUAJIT_HAS_VERSION_SYM)
add_compile_definitions(LUAJIT_MISSING_VERSION_SYM)
endif ()

list(APPEND LUVI_LIBRARIES ${LUV_LIBRARIES} ${LUAJIT_LIBRARIES} ${LIBUV_LIBRARIES})
else (WithSharedLibluv)
# Build luv as static library instead of as module
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ endif #### End of gmake ####
###############################################################################

CONFIGURE_FLAGS = \
-Wno-dev \
-DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) \
-DWITH_AMALG=$(WITH_AMALG) \
-DWITH_LUA_ENGINE=$(WITH_LUA_ENGINE) \
Expand Down
21 changes: 18 additions & 3 deletions deps/openssl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,18 @@ if (WithSharedOpenSSL)
else (WithSharedOpenSSL)
message("Enabling Static OpenSSL")

set(OPENSSL_CONFIG_OPTIONS no-unit-test no-shared no-stdio no-idea no-mdc2 no-rc5 --prefix=${CMAKE_BINARY_DIR})
execute_process(
COMMAND openssl info -configdir
OUTPUT_VARIABLE OPENSSL_CONFIG_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)

set(OPENSSL_CONFIG_OPTIONS no-tests no-shared no-pinshared no-makedepend --prefix=${CMAKE_BINARY_DIR})
if (OPENSSL_CONFIG_DIR)
message("Using existing OpenSSL configuration directory: ${OPENSSL_CONFIG_DIR}")
set(OPENSSL_CONFIG_OPTIONS ${OPENSSL_CONFIG_OPTIONS} --openssldir=${OPENSSL_CONFIG_DIR})
endif ()

if (WithOpenSSLASM)
enable_language(ASM)
if (MSVC)
Expand Down Expand Up @@ -45,8 +56,8 @@ else (WithSharedOpenSSL)
include(FetchContent)

FetchContent_Declare(openssl
URL https://github.com/openssl/openssl/releases/download/openssl-3.0.14/openssl-3.0.14.tar.gz
URL_HASH SHA256=eeca035d4dd4e84fc25846d952da6297484afa0650a6f84c682e39df3a4123ca
URL https://github.com/openssl/openssl/releases/download/openssl-3.4.0/openssl-3.4.0.tar.gz
URL_HASH SHA256=e15dda82fe2fe8139dc2ac21a36d4ca01d5313c75f99f46c4e8a27709b7294bf
)

FetchContent_MakeAvailable(openssl)
Expand Down Expand Up @@ -101,6 +112,10 @@ else (WithSharedOpenSSL)
set(OPENSSL_INCLUDE_DIR ${OPENSSL_ROOT_DIR}/include)
set(OPENSSL_LIBRARIES openssl_ssl openssl_crypto)

if (WIN32)
set(OPENSSL_LIBRARIES ${OPENSSL_LIBRARIES} crypt32)
endif ()

message("OPENSSL_INCLUDE_DIR: ${OPENSSL_INCLUDE_DIR}")
message("OPENSSL_LIBRARIES: ${OPENSSL_LIBRARIES}")
endif (WithSharedOpenSSL)
3 changes: 3 additions & 0 deletions src/luvi.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#include "lauxlib.h"
#include "uv.h"
#include "luv.h"
#ifndef WITH_PLAIN_LUA
#include "luajit.h"
#endif

#include <string.h>
#include <stdlib.h>
Expand Down
11 changes: 11 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ static lua_State* vm_acquire(){
if (L == NULL)
return L;

// Ensure that the version of lua interpreter is compatible with the version luvi was compiled with.
#ifdef WITH_PLAIN_LUA
#if (LUA_VERSION_NUM >= 502)
luaL_checkversion(L);
#endif
#else
#ifndef LUAJIT_MISSING_VERSION_SYM // debian patches luajit to remove this symbol, so we can't check it.
LUAJIT_VERSION_SYM();
#endif
#endif

// Add in the lua standard and compat libraries
luvi_openlibs(L);

Expand Down

0 comments on commit 401d41b

Please sign in to comment.