mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Improve the docs, set up LuaJIT, and try to figure out why we can't build a DLL as an external projcet target with LuaJIT...
This commit is contained in:
parent
dbaabcdf6a
commit
1a64ba0fe5
44
.travis.yml
44
.travis.yml
|
@ -47,69 +47,111 @@ matrix:
|
||||||
- env:
|
- env:
|
||||||
- LUA_VERSION=5.3.4
|
- LUA_VERSION=5.3.4
|
||||||
GCC_VERSION=4.9
|
GCC_VERSION=4.9
|
||||||
|
platform=x64
|
||||||
CI=true
|
CI=true
|
||||||
|
|
||||||
- env:
|
- env:
|
||||||
- LUA_VERSION=5.3.4
|
- LUA_VERSION=5.3.4
|
||||||
GCC_VERSION=5
|
GCC_VERSION=5
|
||||||
CI=true
|
CI=true
|
||||||
|
platform=x64
|
||||||
|
|
||||||
- env:
|
- env:
|
||||||
- LUA_VERSION=5.3.4
|
- LUA_VERSION=5.3.4
|
||||||
GCC_VERSION=6
|
GCC_VERSION=6
|
||||||
|
platform=x64
|
||||||
CI=true
|
CI=true
|
||||||
|
|
||||||
- env:
|
- env:
|
||||||
- LUA_VERSION=5.3.4
|
- LUA_VERSION=5.3.4
|
||||||
GCC_VERSION=7
|
GCC_VERSION=7
|
||||||
|
platform=x64
|
||||||
CI=true
|
CI=true
|
||||||
|
|
||||||
# LLVM 3.6.x -> 5.0.x
|
# LLVM 3.6.x -> 5.0.x
|
||||||
- env:
|
- env:
|
||||||
- LUA_VERSION=5.3.4
|
- LUA_VERSION=5.3.4
|
||||||
LLVM_VERSION=3.6.2
|
LLVM_VERSION=3.6.2
|
||||||
|
platform=x64
|
||||||
CI=true
|
CI=true
|
||||||
ALLOW_FAILURE=true
|
ALLOW_FAILURE=true
|
||||||
|
|
||||||
- env:
|
- env:
|
||||||
- LUA_VERSION=5.3.4
|
- LUA_VERSION=5.3.4
|
||||||
LLVM_VERSION=3.7.1
|
LLVM_VERSION=3.7.1
|
||||||
|
platform=x64
|
||||||
CI=true
|
CI=true
|
||||||
ALLOW_FAILURE=true
|
ALLOW_FAILURE=true
|
||||||
|
|
||||||
- env:
|
- env:
|
||||||
- LUA_VERSION=5.3.4
|
- LUA_VERSION=5.3.4
|
||||||
LLVM_VERSION=3.8.1
|
LLVM_VERSION=3.8.1
|
||||||
|
platform=x64
|
||||||
CI=true
|
CI=true
|
||||||
ALLOW_FAILURE=true
|
ALLOW_FAILURE=true
|
||||||
|
|
||||||
- env:
|
- env:
|
||||||
- LUA_VERSION=5.3.4
|
- LUA_VERSION=5.3.4
|
||||||
LLVM_VERSION=3.9.1
|
LLVM_VERSION=3.9.1
|
||||||
|
platform=x64
|
||||||
CI=true
|
CI=true
|
||||||
ALLOW_FAILURE=true
|
ALLOW_FAILURE=true
|
||||||
|
|
||||||
- env:
|
- env:
|
||||||
- LUA_VERSION=5.3.4
|
- LUA_VERSION=5.3.4
|
||||||
LLVM_VERSION=4.0.1
|
LLVM_VERSION=4.0.1
|
||||||
|
platform=x64
|
||||||
CI=true
|
CI=true
|
||||||
ALLOW_FAILURE=true
|
ALLOW_FAILURE=true
|
||||||
|
|
||||||
- env:
|
- env:
|
||||||
- LUA_VERSION=5.3.4
|
- LUA_VERSION=5.3.4
|
||||||
LLVM_VERSION=5.0.1
|
LLVM_VERSION=5.0.1
|
||||||
|
platform=x64
|
||||||
CI=true
|
CI=true
|
||||||
ALLOW_FAILURE=true
|
ALLOW_FAILURE=true
|
||||||
|
|
||||||
# Lua Versions 5.2.4, 5.1.5, and maybe LuaJIT (as well as x86)
|
# Lua Versions 5.2.4, 5.1.5, and LuaJIT (as well as x86)
|
||||||
- env:
|
- env:
|
||||||
- LUA_VERSION=5.2.4
|
- LUA_VERSION=5.2.4
|
||||||
GCC_VERSION=7
|
GCC_VERSION=7
|
||||||
|
platform=x64
|
||||||
CI=true
|
CI=true
|
||||||
|
|
||||||
- env:
|
- env:
|
||||||
- LUA_VERSION=5.1.5
|
- LUA_VERSION=5.1.5
|
||||||
GCC_VERSION=7
|
GCC_VERSION=7
|
||||||
|
platform=x64
|
||||||
|
CI=true
|
||||||
|
|
||||||
|
- env:
|
||||||
|
- LUA_VERSION=luajit-2.0.4
|
||||||
|
GCC_VERSION=7
|
||||||
|
platform=x64
|
||||||
|
CI=true
|
||||||
|
|
||||||
|
- env:
|
||||||
|
- LUA_VERSION=luajit-2.0.5
|
||||||
|
GCC_VERSION=7
|
||||||
|
platform=x64
|
||||||
|
CI=true
|
||||||
|
|
||||||
|
- env:
|
||||||
|
- LUA_VERSION=luajit-2.1.0-beta3
|
||||||
|
GCC_VERSION=7
|
||||||
|
platform=x64
|
||||||
|
CI=true
|
||||||
|
|
||||||
|
- env:
|
||||||
|
- LUA_VERSION=luajit-2.0.5
|
||||||
|
GCC_VERSION=7
|
||||||
|
platform=x86
|
||||||
|
CI=true
|
||||||
|
|
||||||
|
- env:
|
||||||
|
- LUA_VERSION=luajit-2.1.0-beta3
|
||||||
|
GCC_VERSION=7
|
||||||
|
platform=x86
|
||||||
CI=true
|
CI=true
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
|
|
|
@ -60,16 +60,15 @@ if (MSVC)
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
add_compile_options(-Wno-unknown-warning -Wno-unknown-warning-option -Wall -Wextra -Wpedantic -pedantic -pedantic-errors)
|
add_compile_options(-Wno-unknown-warning -Wno-unknown-warning-option -Wall -Wextra -Wpedantic -pedantic -pedantic-errors)
|
||||||
#if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
||||||
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++")
|
|
||||||
# add_compile_options("$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:-stdlib=libc++>")
|
|
||||||
#endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (CI)
|
if (CI)
|
||||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
#if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
include_directories("$ENV{CLANG_PREFIX}/include/c++/v1")
|
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++")
|
||||||
endif()
|
# add_compile_options("$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:-stdlib=libc++>")
|
||||||
|
# LIST(APPEND CMAKE_LIBRARY_PATH_FLAG "$$ENV{CLANG_PREFIX}/lib")
|
||||||
|
# include_directories("$ENV{CLANG_PREFIX}/include/c++/v1")
|
||||||
|
#endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# # # General project output locations
|
# # # General project output locations
|
||||||
|
@ -110,7 +109,7 @@ CMAKE_DEPENDENT_OPTION(TESTS_SINGLE "Enable build of tests using the generated s
|
||||||
CMAKE_DEPENDENT_OPTION(EXAMPLES_SINGLE "Enable build of examples using the generated single headers" OFF
|
CMAKE_DEPENDENT_OPTION(EXAMPLES_SINGLE "Enable build of examples using the generated single headers" OFF
|
||||||
"SINGLE;EXAMPLES" OFF)
|
"SINGLE;EXAMPLES" OFF)
|
||||||
CMAKE_DEPENDENT_OPTION(TESTS_EXAMPLES "Enable build of examples as tests" ON
|
CMAKE_DEPENDENT_OPTION(TESTS_EXAMPLES "Enable build of examples as tests" ON
|
||||||
"TESTS;EXAMPLES" OFF)
|
"EXAMPLES" OFF)
|
||||||
|
|
||||||
|
|
||||||
# # # sol2 Library
|
# # # sol2 Library
|
||||||
|
@ -161,6 +160,8 @@ source_group(headers FILES ${SOL2_SINGLE_HEADER_SOURCES})
|
||||||
# Find Python3 for single header / forward header generation
|
# Find Python3 for single header / forward header generation
|
||||||
find_package(PythonInterp 3)
|
find_package(PythonInterp 3)
|
||||||
set(SOL2_SINGLE_HEADER_FOUND FALSE)
|
set(SOL2_SINGLE_HEADER_FOUND FALSE)
|
||||||
|
set(SOL2_SINGLE_FOUND FALSE)
|
||||||
|
set(SOL2_DOCS_FOUND FALSE)
|
||||||
if (PYTHONINTERP_FOUND)
|
if (PYTHONINTERP_FOUND)
|
||||||
if (SINGLE)
|
if (SINGLE)
|
||||||
set(SOL2_SINGLE_FOUND TRUE)
|
set(SOL2_SINGLE_FOUND TRUE)
|
||||||
|
@ -185,20 +186,16 @@ if (PYTHONINTERP_FOUND)
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
if (SINGLE)
|
if (SINGLE)
|
||||||
set(SOL2_SINGLE_FOUND FALSE)
|
message(STATUS "sol2 single_header cannot be generated as python 3 has not been found.")
|
||||||
message(STATUS "single_header cannot be generated as python 3 has not been found.")
|
|
||||||
endif()
|
|
||||||
if (DOCS)
|
|
||||||
set(SOL2_DOCS_FOUND FALSE)
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (CI)
|
if (CI)
|
||||||
message(STATUS "Contiguous Integration is on")
|
message(STATUS "sol2 Contiguous Integration is on")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# # # Tests, Examples and other CI suites that come with sol2
|
# # # Tests, Examples and other CI suites that come with sol2
|
||||||
if (TESTS OR TESTS_SINGLE OR EXAMPLES OR TESTS_EXAMPLES)
|
if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES OR EXAMPLES OR EXAMPLES_SINGLE)
|
||||||
# # # Libraries
|
# # # Libraries
|
||||||
# Here, we pull in all the necessary libraries for building examples and tests
|
# Here, we pull in all the necessary libraries for building examples and tests
|
||||||
# Find threading library
|
# Find threading library
|
||||||
|
@ -227,28 +224,30 @@ if (TESTS OR TESTS_SINGLE OR EXAMPLES OR TESTS_EXAMPLES)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT LUA_FOUND)
|
if (NOT LUA_FOUND)
|
||||||
message(FATAL_ERROR "Lua ${LUA_VERSION} not found and could not be targeted for building.")
|
message(FATAL_ERROR "sol2 Lua \"${LUA_VERSION}\" not found and could not be targeted for building.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# # # Tests
|
# # Enable test harness for regular, example or single tests
|
||||||
# # Enable test harness for regular or single tests
|
|
||||||
if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES)
|
if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES)
|
||||||
# enable ctest
|
# enable ctest
|
||||||
message(STATUS "Testing enabled...")
|
message(STATUS "sol2 testing enabled")
|
||||||
enable_testing()
|
enable_testing()
|
||||||
endif()
|
endif()
|
||||||
# # Add tests here
|
|
||||||
if (TESTS OR TESTS_SINGLE)
|
|
||||||
# add subdir to get going
|
|
||||||
message(STATUS "Adding sol2 tests...")
|
|
||||||
add_subdirectory(tests "${CMAKE_BINARY_DIR}/tests")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# # # Examples
|
# # # Examples
|
||||||
# # Enable examples to be built against the library
|
# # Enable examples to be built against the library
|
||||||
if (EXAMPLES OR TESTS_EXAMPLES)
|
if (EXAMPLES OR TESTS_EXAMPLES OR EXAMPLES_SINGLE)
|
||||||
# NOTE: will also add to tests if TESTS is defined
|
# NOTE: will also add to tests if TESTS is defined
|
||||||
message(STATUS "Adding sol2 examples...")
|
message(STATUS "sol2 adding examples...")
|
||||||
add_subdirectory(examples "${CMAKE_BINARY_DIR}/examples")
|
add_subdirectory(examples "${CMAKE_BINARY_DIR}/examples")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# # # Tests
|
||||||
|
# # Add tests here
|
||||||
|
if (TESTS OR TESTS_SINGLE)
|
||||||
|
# add subdir to get going
|
||||||
|
message(STATUS "sol2 adding tests...")
|
||||||
|
add_subdirectory(tests "${CMAKE_BINARY_DIR}/tests")
|
||||||
|
endif()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -49,9 +49,15 @@ environment:
|
||||||
# LLVM_VERSION: 4.0.0
|
# LLVM_VERSION: 4.0.0
|
||||||
- LUA_VERSION: 5.3.4
|
- LUA_VERSION: 5.3.4
|
||||||
MINGW_VERSION: 6.3.0
|
MINGW_VERSION: 6.3.0
|
||||||
|
- LUA_VERSION: luajit-2.0.5
|
||||||
|
MINGW_VERSION: 6.3.0
|
||||||
|
- LUA_VERSION: luajit-2.1.0-beta3
|
||||||
|
MINGW_VERSION: 6.3.0
|
||||||
- LUA_VERSION: 5.3.4
|
- LUA_VERSION: 5.3.4
|
||||||
- LUA_VERSION: 5.2.4
|
- LUA_VERSION: 5.2.4
|
||||||
- LUA_VERSION: 5.1.5
|
- LUA_VERSION: 5.1.5
|
||||||
|
#- LUA_VERSION: luajit-2.0.5
|
||||||
|
#- LUA_VERSION: luajit-2.1.0-beta3
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
|
@ -72,8 +78,6 @@ matrix:
|
||||||
- platform: x86
|
- platform: x86
|
||||||
LLVM_VERSION: 4.0.0
|
LLVM_VERSION: 4.0.0
|
||||||
# Get rid of x86 builds
|
# Get rid of x86 builds
|
||||||
- platform: x86
|
|
||||||
image: Visual Studio 2015
|
|
||||||
- platform: x86
|
- platform: x86
|
||||||
LUA_VERSION: 5.2.4
|
LUA_VERSION: 5.2.4
|
||||||
- platform: x86
|
- platform: x86
|
||||||
|
|
|
@ -25,11 +25,11 @@
|
||||||
string(TOLOWER ${LUA_VERSION} LUA_BUILD_NORMALIZED_LUA_VERSION)
|
string(TOLOWER ${LUA_VERSION} LUA_BUILD_NORMALIZED_LUA_VERSION)
|
||||||
if (LUA_BUILD_NORMALIZED_LUA_VERSION MATCHES "luajit")
|
if (LUA_BUILD_NORMALIZED_LUA_VERSION MATCHES "luajit")
|
||||||
set(LUA_BUILD_LIBNAME ${LUA_VERSION})
|
set(LUA_BUILD_LIBNAME ${LUA_VERSION})
|
||||||
elseif (LUAJIT_BUILD)
|
elseif (BUILD_LUAJIT)
|
||||||
set(LUA_BUILD_LIBNAME luajit-${LUA_VERSION})
|
set(LUA_BUILD_LIBNAME luajit-${LUA_VERSION})
|
||||||
elseif (LUA_BUILD_NORMALIZED_LUA_VERSION MATCHES "lua")
|
elseif (LUA_BUILD_NORMALIZED_LUA_VERSION MATCHES "lua")
|
||||||
set(LUA_BUILD_LIBNAME ${LUA_VERSION})
|
set(LUA_BUILD_LIBNAME ${LUA_VERSION})
|
||||||
elseif (LUA_BUILD)
|
elseif (BUILD_LUA)
|
||||||
set(LUA_BUILD_LIBNAME lua-${LUA_VERSION})
|
set(LUA_BUILD_LIBNAME lua-${LUA_VERSION})
|
||||||
else()
|
else()
|
||||||
set(LUA_BUILD_LIBNAME lua-${LUA_VERSION})
|
set(LUA_BUILD_LIBNAME lua-${LUA_VERSION})
|
||||||
|
@ -50,18 +50,17 @@ endif()
|
||||||
|
|
||||||
|
|
||||||
# # # Options
|
# # # Options
|
||||||
set(LUA_INCLUDE_DIR "${LUA_BUILD_INSTALL_DIR}/include" CACHE PATH "Directory with lua include files")
|
|
||||||
set(LUA_LIB_DIR "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}" CACHE PATH "Directory with lua library files")
|
|
||||||
set(LUA_BIN_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" CACHE PATH "Directory with lua executable and dynamic library files")
|
|
||||||
option(BUILD_LUA_AS_DLL ${LUA_BUILD_BUILD_DLL_DEFAULT} "Build Lua or LuaJIT as a Shared/Dynamic Link Library")
|
option(BUILD_LUA_AS_DLL ${LUA_BUILD_BUILD_DLL_DEFAULT} "Build Lua or LuaJIT as a Shared/Dynamic Link Library")
|
||||||
|
|
||||||
STRING(TOLOWER ${LUA_BUILD_LIBNAME} LUA_BUILD_NORMALIZED_LIBNAME)
|
STRING(TOLOWER ${LUA_BUILD_LIBNAME} LUA_BUILD_NORMALIZED_LIBNAME)
|
||||||
if (LUA_BUILD_NORMALIZED_LIBNAME MATCHES "luajit")
|
if (NOT LUA_LIBRARY_NAME)
|
||||||
set(LUA_LIBRARY luajit
|
if (LUA_BUILD_NORMALIZED_LIBNAME MATCHES "luajit")
|
||||||
CACHE STRING
|
set(LUA_LIBRARY luajit)
|
||||||
${LUA_BUILD_LIBRARY_DESCRIPTION})
|
else()
|
||||||
|
set(LUA_LIBRARY ${LUA_BUILD_LIBNAME})
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
set(LUA_LIBRARY ${LUA_BUILD_LIBNAME}
|
set(LUA_LIBRARY_NAME ${LUA_LIBRARY_NAME}
|
||||||
CACHE STRING
|
CACHE STRING
|
||||||
${LUA_BUILD_LIBRARY_DESCRIPTION})
|
${LUA_BUILD_LIBRARY_DESCRIPTION})
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -23,67 +23,75 @@
|
||||||
# import necessary standard modules
|
# import necessary standard modules
|
||||||
include(ExternalProject)
|
include(ExternalProject)
|
||||||
|
|
||||||
|
# protect from multiple inclusion
|
||||||
|
if(lua_jit_build_included)
|
||||||
|
return()
|
||||||
|
endif(lua_jit_build_included)
|
||||||
|
set(lua_jit_build_included true)
|
||||||
|
|
||||||
# Latest iterations for specific sub-versions of LuaJIT
|
# Latest iterations for specific sub-versions of LuaJIT
|
||||||
set(LUA_JIT_2.0_LATEST_VERSION 2.0.5)
|
set(LUA_JIT_2.0_LATEST_VERSION 2.0.5)
|
||||||
|
set(LUA_JIT_${LUA_JIT_2.0_LATEST_VERSION}_COMMIT c88602f080dcafea6ba222a2f7cc1ea0e41ef3cc)
|
||||||
set(LUA_JIT_2.1_LATEST_VERSION 2.1.0-beta3)
|
set(LUA_JIT_2.1_LATEST_VERSION 2.1.0-beta3)
|
||||||
|
set(LUA_JIT_${LUA_JIT_2.1_LATEST_VERSION}_COMMIT 80aaaeee99d7f7b06c9e75ed3a457c49d86fc4db)
|
||||||
|
|
||||||
# MD5 hashes taken off of LuaJIT's website
|
# MD5 hashes taken off of LuaJIT's website
|
||||||
# must be updated whenever a new version appears
|
# must be updated whenever a new version appears
|
||||||
set(LUA_JIT_MD5_2.1.0-beta3 eae40bc29d06ee5e3078f9444fcea39b)
|
set(LUA_JIT_MD5_2.1.0-beta3.tar.gz eae40bc29d06ee5e3078f9444fcea39b)
|
||||||
set(LUA_JIT_MD5_2.1.0-beta3 58d0480e1af0811e7ecee45498d62e2d)
|
set(LUA_JIT_MD5_2.1.0-beta3.zip 58d0480e1af0811e7ecee45498d62e2d)
|
||||||
set(LUA_JIT_MD5_2.1.0-beta2 fa14598d0d775a7ffefb138a606e0d7b)
|
set(LUA_JIT_MD5_2.1.0-beta2.tar.gz fa14598d0d775a7ffefb138a606e0d7b)
|
||||||
set(LUA_JIT_MD5_2.1.0-beta2 b5d943c0174ca217736e2ddc2d9721c3)
|
set(LUA_JIT_MD5_2.1.0-beta2.zip b5d943c0174ca217736e2ddc2d9721c3)
|
||||||
set(LUA_JIT_MD5_2.1.0-beta1 5a5bf71666e77cf6e7a1ae851127b834)
|
set(LUA_JIT_MD5_2.1.0-beta1.tar.gz 5a5bf71666e77cf6e7a1ae851127b834)
|
||||||
set(LUA_JIT_MD5_2.1.0-beta1 4b5c2c9aef0e7c0b622b09e7c84d566b)
|
set(LUA_JIT_MD5_2.1.0-beta1.zip 4b5c2c9aef0e7c0b622b09e7c84d566b)
|
||||||
set(LUA_JIT_MD5_2.0.5 48353202cbcacab84ee41a5a70ea0a2c)
|
set(LUA_JIT_MD5_2.0.5.tar.gz 48353202cbcacab84ee41a5a70ea0a2c)
|
||||||
set(LUA_JIT_MD5_2.0.5 f7cf52a049d74aee4e624bdc1160b80d)
|
set(LUA_JIT_MD5_2.0.5.zip f7cf52a049d74aee4e624bdc1160b80d)
|
||||||
set(LUA_JIT_MD5_2.0.4 dd9c38307f2223a504cbfb96e477eca0)
|
set(LUA_JIT_MD5_2.0.4.tar.gz dd9c38307f2223a504cbfb96e477eca0)
|
||||||
set(LUA_JIT_MD5_2.0.4 ed1f0caf3d390171f423f6f1b5c57aac)
|
set(LUA_JIT_MD5_2.0.4.zip ed1f0caf3d390171f423f6f1b5c57aac)
|
||||||
set(LUA_JIT_MD5_2.0.3 f14e9104be513913810cd59c8c658dc0)
|
set(LUA_JIT_MD5_2.0.3.tar.gz f14e9104be513913810cd59c8c658dc0)
|
||||||
set(LUA_JIT_MD5_2.0.3 6c0f6958d5e1f67734fb1ff514ec4c84)
|
set(LUA_JIT_MD5_2.0.3.zip 6c0f6958d5e1f67734fb1ff514ec4c84)
|
||||||
set(LUA_JIT_MD5_2.0.2 112dfb82548b03377fbefbba2e0e3a5b)
|
set(LUA_JIT_MD5_2.0.2.tar.gz 112dfb82548b03377fbefbba2e0e3a5b)
|
||||||
set(LUA_JIT_MD5_2.0.2 a57c7d1b8eaf46559303dcfd56404045)
|
set(LUA_JIT_MD5_2.0.2.zip a57c7d1b8eaf46559303dcfd56404045)
|
||||||
set(LUA_JIT_MD5_2.0.1 85e406e8829602988eb1233a82e29f1f)
|
set(LUA_JIT_MD5_2.0.1.tar.gz 85e406e8829602988eb1233a82e29f1f)
|
||||||
set(LUA_JIT_MD5_2.0.1 cf4aee0e40b220054ee3cffbe0cd6ed5)
|
set(LUA_JIT_MD5_2.0.1.zip cf4aee0e40b220054ee3cffbe0cd6ed5)
|
||||||
set(LUA_JIT_MD5_2.0.0 97a2b87cc0490784f54b64cfb3b8f5ad)
|
set(LUA_JIT_MD5_2.0.0.tar.gz 97a2b87cc0490784f54b64cfb3b8f5ad)
|
||||||
set(LUA_JIT_MD5_2.0.0 467f4f531f7e08ee252f5030ecada7ed)
|
set(LUA_JIT_MD5_2.0.0.zip 467f4f531f7e08ee252f5030ecada7ed)
|
||||||
set(LUA_JIT_MD5_2.0.0-beta11 824aa2684a11e3cc3abe87350a7b6139)
|
set(LUA_JIT_MD5_2.0.0-beta11.tar.gz 824aa2684a11e3cc3abe87350a7b6139)
|
||||||
set(LUA_JIT_MD5_2.0.0-beta11 8629401437048e477c94bd791b0a823a)
|
set(LUA_JIT_MD5_2.0.0-beta11.zip 8629401437048e477c94bd791b0a823a)
|
||||||
set(LUA_JIT_MD5_2.0.0-beta10 ed66689b96f7ad7bfeffe0b4ff2d63d4)
|
set(LUA_JIT_MD5_2.0.0-beta10.tar.gz ed66689b96f7ad7bfeffe0b4ff2d63d4)
|
||||||
set(LUA_JIT_MD5_2.0.0-beta10 f6bbd472726b761b29438c4a06b5ab3c)
|
set(LUA_JIT_MD5_2.0.0-beta10.zip f6bbd472726b761b29438c4a06b5ab3c)
|
||||||
set(LUA_JIT_MD5_2.0.0-beta9 e7e03e67e2550817358bc28b44270c6d)
|
set(LUA_JIT_MD5_2.0.0-beta9.tar.gz e7e03e67e2550817358bc28b44270c6d)
|
||||||
set(LUA_JIT_MD5_2.0.0-beta9 3f9ca0309f26e789c6c3246c83696f84)
|
set(LUA_JIT_MD5_2.0.0-beta9.zip 3f9ca0309f26e789c6c3246c83696f84)
|
||||||
set(LUA_JIT_MD5_2.0.0-beta8 f0748a73ae268d49b1d01f56c4fe3e61)
|
set(LUA_JIT_MD5_2.0.0-beta8.tar.gz f0748a73ae268d49b1d01f56c4fe3e61)
|
||||||
set(LUA_JIT_MD5_2.0.0-beta8 fb096a90c9e799c8922f32095ef3d93c)
|
set(LUA_JIT_MD5_2.0.0-beta8.zip fb096a90c9e799c8922f32095ef3d93c)
|
||||||
set(LUA_JIT_MD5_2.0.0-beta7 b845dec15dd9eba2fd17d865601a52e5)
|
set(LUA_JIT_MD5_2.0.0-beta7.tar.gz b845dec15dd9eba2fd17d865601a52e5)
|
||||||
set(LUA_JIT_MD5_2.0.0-beta7 e10fc2b19de52d8770cdf24f1791dd77)
|
set(LUA_JIT_MD5_2.0.0-beta7.zip e10fc2b19de52d8770cdf24f1791dd77)
|
||||||
set(LUA_JIT_MD5_2.0.0-beta6 bfcbe2a11162cfa84d5a1693b442c8bf)
|
set(LUA_JIT_MD5_2.0.0-beta6.tar.gz bfcbe2a11162cfa84d5a1693b442c8bf)
|
||||||
set(LUA_JIT_MD5_2.0.0-beta6 f64945c5ecaf3ea71a829fdbb5cb196c)
|
set(LUA_JIT_MD5_2.0.0-beta6.zip f64945c5ecaf3ea71a829fdbb5cb196c)
|
||||||
set(LUA_JIT_MD5_2.0.0-beta5 7e0dfa03a140148149a1021d4ffd5c57)
|
set(LUA_JIT_MD5_2.0.0-beta5.tar.gz 7e0dfa03a140148149a1021d4ffd5c57)
|
||||||
set(LUA_JIT_MD5_2.0.0-beta5 be8087fcb576c30ffbb6368ebc284498)
|
set(LUA_JIT_MD5_2.0.0-beta5.zip be8087fcb576c30ffbb6368ebc284498)
|
||||||
set(LUA_JIT_MD5_2.0.0-beta4 5c5a9305b3e06765e1dae138e1a95c3a)
|
set(LUA_JIT_MD5_2.0.0-beta4.tar.gz 5c5a9305b3e06765e1dae138e1a95c3a)
|
||||||
set(LUA_JIT_MD5_2.0.0-beta4 d0b241be6207fa7d97b6afc41368e05f)
|
set(LUA_JIT_MD5_2.0.0-beta4.zip d0b241be6207fa7d97b6afc41368e05f)
|
||||||
set(LUA_JIT_MD5_2.0.0-beta3 313b6f164e93e1bbac7bf87abb58d4a1)
|
set(LUA_JIT_MD5_2.0.0-beta3.tar.gz 313b6f164e93e1bbac7bf87abb58d4a1)
|
||||||
set(LUA_JIT_MD5_2.0.0-beta3 bea9c7bcd5084f98830e31956f276ff6)
|
set(LUA_JIT_MD5_2.0.0-beta3.zip bea9c7bcd5084f98830e31956f276ff6)
|
||||||
set(LUA_JIT_MD5_2.0.0-beta2 2ebcc38fa1d9756dc2e341f191701120)
|
set(LUA_JIT_MD5_2.0.0-beta2.tar.gz 2ebcc38fa1d9756dc2e341f191701120)
|
||||||
set(LUA_JIT_MD5_2.0.0-beta2 94086f99f647d46a8360adeb11851d66)
|
set(LUA_JIT_MD5_2.0.0-beta2.zip 94086f99f647d46a8360adeb11851d66)
|
||||||
set(LUA_JIT_MD5_2.0.0-beta1 9ed7646d03580a1cec4abeb74ca44843)
|
set(LUA_JIT_MD5_2.0.0-beta1.tar.gz 9ed7646d03580a1cec4abeb74ca44843)
|
||||||
set(LUA_JIT_MD5_2.0.0-beta1 19d5bac616fa739343c7158d9d99a3f3)
|
set(LUA_JIT_MD5_2.0.0-beta1.zip 19d5bac616fa739343c7158d9d99a3f3)
|
||||||
set(LUA_JIT_MD5_1.1.8 ad0e319483fa235e3979537a748631e9)
|
set(LUA_JIT_MD5_1.1.8.tar.gz ad0e319483fa235e3979537a748631e9)
|
||||||
set(LUA_JIT_MD5_1.1.8 92870c80f504c34c9b7547cd6c5562d0)
|
set(LUA_JIT_MD5_1.1.8.zip 92870c80f504c34c9b7547cd6c5562d0)
|
||||||
set(LUA_JIT_MD5_1.1.7 3aed0795f7c8725d3613269cd56f8e5a)
|
set(LUA_JIT_MD5_1.1.7.tar.gz 3aed0795f7c8725d3613269cd56f8e5a)
|
||||||
set(LUA_JIT_MD5_1.1.7 40a8dbc214306bb4b9849fcf026c4ee0)
|
set(LUA_JIT_MD5_1.1.7.zip 40a8dbc214306bb4b9849fcf026c4ee0)
|
||||||
set(LUA_JIT_MD5_1.1.6 1a1320e09d0cd5b793014556fb7d64c9)
|
set(LUA_JIT_MD5_1.1.6.tar.gz 1a1320e09d0cd5b793014556fb7d64c9)
|
||||||
set(LUA_JIT_MD5_1.1.6 350d7b9230637056fbd6158b95e8fa11)
|
set(LUA_JIT_MD5_1.1.6.zip 350d7b9230637056fbd6158b95e8fa11)
|
||||||
set(LUA_JIT_MD5_1.1.5 b99d244ba4fc1979946ae1025368fc5c)
|
set(LUA_JIT_MD5_1.1.5.tar.gz b99d244ba4fc1979946ae1025368fc5c)
|
||||||
set(LUA_JIT_MD5_1.1.5 d3ffbae3bfcd5914b02dc00b1118a59d)
|
set(LUA_JIT_MD5_1.1.5.zip d3ffbae3bfcd5914b02dc00b1118a59d)
|
||||||
set(LUA_JIT_MD5_1.1.4 9fe29cfb8126bc9c4302701c06965f1c)
|
set(LUA_JIT_MD5_1.1.4.tar.gz 9fe29cfb8126bc9c4302701c06965f1c)
|
||||||
set(LUA_JIT_MD5_1.1.4 30d318e3287000ecf4c93b29e8783183)
|
set(LUA_JIT_MD5_1.1.4.zip 30d318e3287000ecf4c93b29e8783183)
|
||||||
set(LUA_JIT_MD5_1.1.3 f5db1a147ed3d34677ad1ef310c56da7)
|
set(LUA_JIT_MD5_1.1.3.tar.gz f5db1a147ed3d34677ad1ef310c56da7)
|
||||||
set(LUA_JIT_MD5_1.1.3 5949e7bce9d97c37c282e1cbe85aa378)
|
set(LUA_JIT_MD5_1.1.3.zip 5949e7bce9d97c37c282e1cbe85aa378)
|
||||||
set(LUA_JIT_MD5_1.1.2 4ae25ce7e3f301d1fcf0b713016edab0)
|
set(LUA_JIT_MD5_1.1.2.tar.gz 4ae25ce7e3f301d1fcf0b713016edab0)
|
||||||
set(LUA_JIT_MD5_1.1.0 16d880a98a1ff6608ac1039c802233db)
|
set(LUA_JIT_MD5_1.1.0.tar.gz 16d880a98a1ff6608ac1039c802233db)
|
||||||
set(LUA_JIT_MD5_1.0.3 d0a63d5394cca549889bd820a05b32d2)
|
set(LUA_JIT_MD5_1.0.3.tar.gz d0a63d5394cca549889bd820a05b32d2)
|
||||||
|
|
||||||
# Clean up some variables
|
# Clean up some variables
|
||||||
string(TOLOWER ${LUA_VERSION} LUA_JIT_NORMALIZED_LUA_VERSION)
|
string(TOLOWER ${LUA_VERSION} LUA_JIT_NORMALIZED_LUA_VERSION)
|
||||||
|
@ -103,16 +111,24 @@ elseif (LUA_JIT_NORMALIZED_LUA_VERSION MATCHES "([0-9]+\\.[0-9]+)")
|
||||||
# Just pick a default version and roll with it
|
# Just pick a default version and roll with it
|
||||||
set(LUA_JIT_VERSION ${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.0)
|
set(LUA_JIT_VERSION ${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.0)
|
||||||
endif()
|
endif()
|
||||||
|
elseif (LUA_JIT_NORMALIZED_LUA_VERSION MATCHES "latest")
|
||||||
|
set(LUA_JIT_VERSION ${LUA_JIT_2.1_LATEST_VERSION})
|
||||||
else()
|
else()
|
||||||
message(FATAL "Cannot deduce LuaJIT version from ${LUA_VERSION}")
|
MESSAGE(FATAL "Cannot deduce LuaJIT version from ${LUA_VERSION}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message(STATUS "Selecting LuaJIT ${LUA_JIT_VERSION}")
|
MESSAGE(STATUS "Selecting LuaJIT ${LUA_JIT_VERSION} from '${LUA_VERSION}' and building a ${LUA_BUILD_LIBRARY_TYPE} library...")
|
||||||
|
|
||||||
# Get hashes for the build
|
# Get hashes for the build
|
||||||
# LuaJIT unfortunately does not give us SHA1 hashes as well
|
# LuaJIT unfortunately does not give us SHA1 hashes as well
|
||||||
# set(LUA_JIT_SHA1 ${LUA_JIT_SHA1_${LUA_JIT_VERSION}})
|
# set(LUA_JIT_SHA1 ${LUA_JIT_SHA1_${LUA_JIT_VERSION}})
|
||||||
set(LUA_JIT_MD5 ${LUA_JIT_MD5_${LUA_JIT_VERSION}})
|
if (WIN32)
|
||||||
|
set(LUA_JIT_MD5 ${LUA_JIT_MD5_${LUA_JIT_VERSION}.zip})
|
||||||
|
set(LUA_JIT_DOWNLOAD_URI http://luajit.org/download/LuaJIT-${LUA_JIT_VERSION}.zip)
|
||||||
|
else()
|
||||||
|
set(LUA_JIT_MD5 ${LUA_JIT_MD5_${LUA_JIT_VERSION}.tar.gz})
|
||||||
|
set(LUA_JIT_DOWNLOAD_URI http://luajit.org/download/LuaJIT-${LUA_JIT_VERSION}.tar.gz)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (LUA_JIT_MD5)
|
if (LUA_JIT_MD5)
|
||||||
set(LUA_JIT_DOWNLOAD_MD5_COMMAND URL_MD5 ${LUA_JIT_MD5})
|
set(LUA_JIT_DOWNLOAD_MD5_COMMAND URL_MD5 ${LUA_JIT_MD5})
|
||||||
|
@ -125,61 +141,207 @@ else ()
|
||||||
set(LUA_JIT_DOWNLOAD_SHA1_COMMAND "")
|
set(LUA_JIT_DOWNLOAD_SHA1_COMMAND "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(LUA_JIT_SOURCE_DIR "${LUA_BUILD_TOPLEVEL}/src")
|
||||||
|
set(LUA_JIT_INSTALL_DIR "${LUA_BUILD_TOPLEVEL}/install")
|
||||||
|
file(MAKE_DIRECTORY ${LUA_JIT_SOURCE_DIR})
|
||||||
|
file(MAKE_DIRECTORY ${LUA_JIT_INSTALL_DIR})
|
||||||
|
|
||||||
|
set(LUA_JIT_LIB_FILENAME "${CMAKE_STATIC_LIBRARY_PREFIX}${LUA_BUILD_LIBNAME}${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||||
|
set(LUA_JIT_IMP_LIB_FILENAME "${CMAKE_IMPORT_LIBRARY_PREFIX}${LUA_BUILD_LIBNAME}${CMAKE_IMPORT_LIBRARY_SUFFIX}")
|
||||||
|
set(LUA_JIT_LIB_EXP_FILENAME "${LUA_BUILD_LIBNAME}.exp")
|
||||||
|
set(LUA_JIT_DLL_FILENAME "${CMAKE_SHARED_LIBRARY_PREFIX}${LUA_BUILD_LIBNAME}${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||||
|
set(LUA_JIT_EXE_FILENAME "${LUA_BUILD_LIBNAME}${CMAKE_EXECUTABLE_SUFFIX}")
|
||||||
|
|
||||||
|
set(LUA_JIT_LIB_FILE "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${LUA_JIT_LIB_FILENAME}")
|
||||||
|
set(LUA_JIT_IMP_LIB_FILE "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${LUA_JIT_IMP_LIB_FILENAME}")
|
||||||
|
set(LUA_JIT_LIB_EXP_FILE "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${LUA_JIT_LIB_EXP_FILENAME}")
|
||||||
|
set(LUA_JIT_DLL_FILE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${LUA_JIT_DLL_FILENAME}")
|
||||||
|
|
||||||
# # # Do the build
|
# # # Do the build
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
# Visual C++ is predicated off running msvcbuild.bat
|
# Visual C++ is predicated off running msvcbuild.bat
|
||||||
# which requires a Visual Studio Command Prompt
|
# which requires a Visual Studio Command Prompt
|
||||||
|
if (BUILD_LUA_AS_DLL)
|
||||||
|
set(LUA_JIT_BUILD_COMMAND cd src && msvcbuild.bat)
|
||||||
|
else()
|
||||||
|
set(LUA_JIT_BUILD_COMMAND cd src && msvcbuild.bat static)
|
||||||
|
endif()
|
||||||
|
set(LUA_JIT_PREBUILT_LIB "lua51.lib")
|
||||||
|
set(LUA_JIT_PREBUILT_IMP_LIB "lua51.lib")
|
||||||
|
set(LUA_JIT_PREBUILT_DLL "lua51.dll")
|
||||||
|
set(LUA_JIT_PREBUILT_EXP "lua51.exp")
|
||||||
else ()
|
else ()
|
||||||
|
# get the make command we need for this system
|
||||||
|
find_program(MAKE_PROGRAM NAMES make mingw32-make mingw64-make)
|
||||||
|
if (MAKE_PROGRAM MATCHES "MAKE_PROGRAM-NOTFOUND")
|
||||||
|
MESSAGE(FATAL_ERROR "Cannot find 'make' program or similar needed to build LuaJIT ${LUA_VERSION} (perhaps place it in the PATH environment variable if it is not already?)")
|
||||||
|
endif()
|
||||||
|
|
||||||
# we can simply reuse the makefile here
|
# we can simply reuse the makefile here
|
||||||
# so define it as an external project and then just have the proper
|
# so define it as an external project and then just have the proper
|
||||||
# build/install/test commands
|
# build/install/test commands
|
||||||
|
# make sure to apply -pagezero_size 10000 -image_base 100000000
|
||||||
set(LUA_JIT_BUILD_COMMAND make)
|
set(LUA_JIT_MAKE_BUILD_MODIFICATIONS "LUAJIT_T=${LUA_JIT_EXE_FILENAME}")
|
||||||
set(LUA_JIT_INSTALL_COMMAND make install PREFIX=${LUA_LIB_DIR})
|
list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "LUAJIT_A=${LUA_JIT_LIB_FILENAME}")
|
||||||
set(LUA_JIT_TEST_COMMAND make test)
|
|
||||||
set(LUA_JIT_LIB_FILE "${LUA_LIB_DIR}/${LUA_LIBRARY}")
|
|
||||||
set(LUA_JIT_DLL_FILE "${LUA_BIN_DIR}/${LUA_DYNAMIC_LIBRARY}")
|
|
||||||
if (BUILD_LUA_AS_DLL)
|
if (BUILD_LUA_AS_DLL)
|
||||||
set(LUA_JIT_BYPRODUCTS ${LUA_JIT_LIB_FILE} ${LUA_JIT_DLL_FILE})
|
list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "LUAJIT_SO=${LUA_JIT_DLL_FILENAME}" "TARGET_SONAME=${LUA_JIT_DLL_FILENAME}" "TARGET_DYLIBNAME=${LUA_JIT_DLL_FILENAME}" "TARGET_DLLNAME=${LUA_JIT_DLL_FILENAME}")
|
||||||
|
list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "BUILDMODE=dynamic")
|
||||||
else()
|
else()
|
||||||
set(LUA_JIT_BYPRODUCTS ${LUA_JIT_LIB_FILE})
|
list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "BUILDMODE=static")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(LUA_JIT_PREBUILT_DLL ${LUA_JIT_DLL_FILENAME})
|
||||||
|
set(LUA_JIT_PREBUILT_LIB ${LUA_JIT_LIB_FILENAME})
|
||||||
|
set(LUA_JIT_PREBUILT_IMP_LIB ${LUA_JIT_IMP_LIB_FILENAME})
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
list(APPEND LUA_JIT_MAKE_BUILD_MODIFICATIONS "HOST_SYS=Windows" "TARGET_SYS=Windows")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(LUA_JIT_BUILD_COMMAND BUILD_COMMAND "${MAKE_PROGRAM}" ${LUA_JIT_MAKE_BUILD_MODIFICATIONS})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(lualib luajitlib_${LUA_JIT_VERSION})
|
||||||
|
|
||||||
|
file(TO_NATIVE_PATH "${LUA_JIT_SOURCE_DIR}/${LUA_JIT_PREBUILT_LIB}" LUA_JIT_SOURCE_LUA_LIB)
|
||||||
|
file(TO_NATIVE_PATH "${LUA_JIT_LIB_FILE}" LUA_JIT_DESTINATION_LUA_LIB)
|
||||||
|
file(TO_NATIVE_PATH "${LUA_JIT_SOURCE_DIR}/${LUA_JIT_PREBUILT_IMP_LIB}" LUA_JIT_SOURCE_LUA_IMP_LIB)
|
||||||
|
file(TO_NATIVE_PATH "${LUA_JIT_IMP_LIB_FILE}" LUA_JIT_DESTINATION_LUA_IMP_LIB)
|
||||||
|
file(TO_NATIVE_PATH "${LUA_JIT_SOURCE_DIR}/${LUA_JIT_PREBUILT_DLL}" LUA_JIT_SOURCE_LUA_DLL)
|
||||||
|
file(TO_NATIVE_PATH "${LUA_JIT_DLL_FILE}" LUA_JIT_DESTINATION_LUA_DLL)
|
||||||
|
file(TO_NATIVE_PATH "${LUA_JIT_SOURCE_DIR}/${LUA_JIT_PREBUILT_EXP}" LUA_JIT_SOURCE_LUA_LIB_EXP)
|
||||||
|
file(TO_NATIVE_PATH "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${LUA_JIT_LIB_EXP_FILENAME}" LUA_JIT_DESTINATION_LUA_LIB_EXP)
|
||||||
|
|
||||||
|
if (WIN32 AND NOT MSVC)
|
||||||
|
string(COMPARE EQUAL ${LUA_JIT_VERSION} ${LUA_JIT_2.0_LATEST_VERSION} lua_jit_same_version_20)
|
||||||
|
string(COMPARE EQUAL ${LUA_JIT_VERSION} ${LUA_JIT_2.1_LATEST_VERSION} lua_jit_same_version_21)
|
||||||
|
if (lua_jit_same_version_20 OR lua_jit_same_version_21)
|
||||||
|
#set (LUA_JIT_GIT_COMMIT ${LUA_JIT_${LUA_JIT_VERSION}_COMMIT})
|
||||||
|
#set(LUA_JIT_GIT_TAG GIT_TAG ${LUA_JIT_GIT_COMMIT})
|
||||||
|
endif()
|
||||||
|
elseif(LUA_JIT_NORMALIZED_LUA_VERSION MATCHES "latest")
|
||||||
|
set(LUA_JIT_PULL_LATEST TRUE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (LUA_JIT_GIT_COMMIT OR LUA_JIT_PULL_LATEST)
|
||||||
|
if (LUA_JIT_PULL_LATEST)
|
||||||
|
MESSAGE(STATUS "Latest LuaJIT has been requested: pulling from git...")
|
||||||
|
elseif (LUA_JIT_GIT_COMMIT)
|
||||||
|
MESSAGE(STATUS "LuaJIT '${LUA_VERSION}' requested has broken static library builds: using git '${LUA_JIT_GIT_COMMIT}'...")
|
||||||
|
endif()
|
||||||
ExternalProject_Add(LUA_JIT
|
ExternalProject_Add(LUA_JIT
|
||||||
BUILD_IN_SOURCE TRUE
|
BUILD_IN_SOURCE TRUE
|
||||||
BUILD_ALWAYS TRUE
|
BUILD_ALWAYS TRUE
|
||||||
# LuaJIT does not offer a TLS/SSL port
|
# LuaJIT does not offer a TLS/SSL port
|
||||||
# TLS_VERIFY TRUE
|
# TLS_VERIFY TRUE
|
||||||
PREFIX ${LUA_BUILD_TOPLEVEL}
|
PREFIX "${LUA_BUILD_TOPLEVEL}"
|
||||||
SOURCE_DIR ${LUA_BUILD_TOPLEVEL}
|
SOURCE_DIR "${LUA_BUILD_TOPLEVEL}"
|
||||||
DOWNLOAD_DIR ${LUA_BUILD_TOPLEVEL}
|
DOWNLOAD_DIR "${LUA_BUILD_TOPLEVEL}"
|
||||||
TMP_DIR "${LUA_BUILD_TOPLEVEL}-tmp"
|
TMP_DIR "${LUA_BUILD_TOPLEVEL}-tmp"
|
||||||
STAMP_DIR "${LUA_BUILD_TOPLEVEL}-stamp"
|
STAMP_DIR "${LUA_BUILD_TOPLEVEL}-stamp"
|
||||||
INSTALL_DIR "${LUA_BUILD_INSTALL_DIR}"
|
INSTALL_DIR "${LUA_BUILD_INSTALL_DIR}"
|
||||||
URL http://luajit.org/download/LuaJIT-${LUA_JIT_VERSION}.tar.gz
|
GIT_REPOSITORY https://github.com/LuaJIT/LuaJIT.git
|
||||||
|
GIT_REMOTE_NAME origin
|
||||||
|
${LUA_JIT_GIT_TAG}
|
||||||
|
GIT_SHALLOW TRUE
|
||||||
|
CONFIGURE_COMMAND ""
|
||||||
|
${LUA_JIT_BUILD_COMMAND}
|
||||||
|
INSTALL_COMMAND ""
|
||||||
|
TEST_COMMAND ""
|
||||||
|
BUILD_BYPRODUCTS "${LUA_JIT_DESTINATION_LUA_LIB}" "${LUA_JIT_DESTINATION_LUA_LIB_EXP}"
|
||||||
|
"${LUA_JIT_DESTINATION_LUA_DLL}" "${LUA_JIT_DESTINATION_LUA_IMP_LIB}")
|
||||||
|
else()
|
||||||
|
ExternalProject_Add(LUA_JIT
|
||||||
|
BUILD_IN_SOURCE TRUE
|
||||||
|
BUILD_ALWAYS TRUE
|
||||||
|
# LuaJIT does not offer a TLS/SSL port
|
||||||
|
# TLS_VERIFY TRUE
|
||||||
|
PREFIX "${LUA_BUILD_TOPLEVEL}"
|
||||||
|
SOURCE_DIR "${LUA_BUILD_TOPLEVEL}"
|
||||||
|
DOWNLOAD_DIR "${LUA_BUILD_TOPLEVEL}"
|
||||||
|
TMP_DIR "${LUA_BUILD_TOPLEVEL}-tmp"
|
||||||
|
STAMP_DIR "${LUA_BUILD_TOPLEVEL}-stamp"
|
||||||
|
INSTALL_DIR "${LUA_BUILD_INSTALL_DIR}"
|
||||||
|
URL "${LUA_JIT_DOWNLOAD_URI}"
|
||||||
${LUA_JIT_DOWNLOAD_MD5_COMMAND}
|
${LUA_JIT_DOWNLOAD_MD5_COMMAND}
|
||||||
${LUA_JIT_DOWNLOAD_SHA1_COMMAND}
|
${LUA_JIT_DOWNLOAD_SHA1_COMMAND}
|
||||||
CONFIGURE_COMMAND ""
|
CONFIGURE_COMMAND ""
|
||||||
BUILD_COMMAND ${LUA_JIT_BUILD_COMMAND}
|
${LUA_JIT_BUILD_COMMAND}
|
||||||
INSTALL_COMMAND ${LUA_JIT_INSTALL_COMMAND}
|
INSTALL_COMMAND ""
|
||||||
TEST_COMMAND ${LUA_JIT_TEST_COMMAND}
|
TEST_COMMAND ""
|
||||||
BUILD_BYPRODUCTS ${LUA_JIT_BYPRODUCTS})
|
BUILD_BYPRODUCTS "${LUA_JIT_DESTINATION_LUA_LIB}" "${LUA_JIT_DESTINATION_LUA_LIB_EXP}"
|
||||||
|
"${LUA_JIT_DESTINATION_LUA_DLL}" "${LUA_JIT_DESTINATION_LUA_IMP_LIB}")
|
||||||
# TODO: SHARED not fully supported yet, stock makefiles do not build
|
|
||||||
# dynamic libs on linux out of the box...
|
|
||||||
add_library(lualib_${LUA_JIT_VERSION} ${LUA_BUILD_LIBRARY_TYPE} IMPORTED)
|
|
||||||
set_target_properties(lualib_${LUA_JIT_VERSION}
|
|
||||||
PROPERTIES
|
|
||||||
LANGUAGE C
|
|
||||||
LINKER_LANGUAGE C
|
|
||||||
INCLUDE_DIRECTORIES ${LUA_INCLUDE_DIR}
|
|
||||||
IMPORTED_LOCATION ${LUA_JIT_LIB_FILE}
|
|
||||||
IMPORTED_SONAME ${LUA_JIT_DLL_FILE})
|
|
||||||
|
|
||||||
# make sure the library we export really does depend on Lua
|
|
||||||
add_dependencies(lualib_${LUA_JIT_VERSION} LUA_JIT)
|
|
||||||
|
|
||||||
# set externally-visible target indicator
|
|
||||||
set(LUA_LIBRARIES lualib_${LUA_JIT_VERSION})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# # Post-Build moving steps for necessary items
|
||||||
|
# Add post-step to move library afterwards
|
||||||
|
if (MSVC)
|
||||||
|
ExternalProject_Add_Step(LUA_JIT
|
||||||
|
postbuild.exp
|
||||||
|
DEPENDEES build
|
||||||
|
COMMENT "Libray - Moving \"${LUA_JIT_SOURCE_LUA_LIB_EXP}\" to \"${LUA_JIT_DESTINATION_LUA_LIB_EXP}\"..."
|
||||||
|
COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_LIB_EXP}" "${LUA_JIT_DESTINATION_LUA_LIB_EXP}" && echo "Successfully moved!")
|
||||||
|
endif()
|
||||||
|
if (BUILD_LUA_AS_DLL)
|
||||||
|
if (MSVC)
|
||||||
|
MESSAGE(STATUS ${LUA_JIT_SOURCE_LUA_IMP_LIB})
|
||||||
|
MESSAGE(STATUS ${LUA_JIT_DESTINATION_LUA_IMP_LIB})
|
||||||
|
ExternalProject_Add_Step(LUA_JIT
|
||||||
|
postbuild.import.lib
|
||||||
|
DEPENDEES build
|
||||||
|
COMMENT "Libray - Moving \"${LUA_JIT_SOURCE_LUA_IMP_LIB}\" to \"${LUA_JIT_DESTINATION_LUA_IMP_LIB}\"..."
|
||||||
|
COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_IMP_LIB}" "${LUA_JIT_DESTINATION_LUA_IMP_LIB}"
|
||||||
|
COMMAND echo "Successfully moved!")
|
||||||
|
endif()
|
||||||
|
MESSAGE(STATUS ${LUA_JIT_SOURCE_LUA_DLL})
|
||||||
|
MESSAGE(STATUS ${LUA_JIT_DESTINATION_LUA_DLL})
|
||||||
|
MESSAGE(STATUS ${LUA_JIT_DLL_FILE})
|
||||||
|
ExternalProject_Add_Step(LUA_JIT
|
||||||
|
postbuild.dll
|
||||||
|
DEPENDEES build
|
||||||
|
COMMENT "Dynamic Library - Moving \"${LUA_JIT_SOURCE_LUA_DLL}\" to \"${LUA_JIT_DESTINATION_LUA_DLL}\"..."
|
||||||
|
COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_DLL}" "${LUA_JIT_DESTINATION_LUA_DLL}" && echo "Successfully moved!")
|
||||||
|
else()
|
||||||
|
ExternalProject_Add_Step(LUA_JIT
|
||||||
|
postbuild.lib
|
||||||
|
DEPENDEES build
|
||||||
|
COMMENT "Library - Moving \"${LUA_JIT_SOURCE_LUA_LIB}\" to \"${LUA_JIT_DESTINATION_LUA_LIB}\"..."
|
||||||
|
COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_LIB}" "${LUA_JIT_DESTINATION_LUA_LIB}" && echo "Successfully moved!")
|
||||||
|
endif()
|
||||||
|
# # TODO:
|
||||||
|
# Add additional post-build step to move all necessary headers/lua files
|
||||||
|
# for now, we just point directly to the `src` directory...
|
||||||
|
|
||||||
|
add_library(${lualib} ${LUA_BUILD_LIBRARY_TYPE} IMPORTED)
|
||||||
|
# make sure the library we export really does depend on Lua JIT's external project
|
||||||
|
add_dependencies(${lualib} LUA_JIT)
|
||||||
|
if (BUILD_LUA_AS_DLL)
|
||||||
|
if (MSVC)
|
||||||
|
set_target_properties(${lualib}
|
||||||
|
PROPERTIES
|
||||||
|
IMPORTED_IMPLIB "${LUA_JIT_IMP_LIB_FILE}")
|
||||||
|
endif()
|
||||||
|
MESSAGE(STATUS "${LUA_JIT_DLL_FILE}")
|
||||||
|
MESSAGE(STATUS "${LUA_JIT_DESTINATION_LUA_DLL}")
|
||||||
|
set_target_properties(${lualib}
|
||||||
|
PROPERTIES
|
||||||
|
#IMPORTED_SONAME "${LUA_BUILD_LIBNAME}"
|
||||||
|
IMPORTED_LOCATION "${LUA_JIT_DLL_FILE}")
|
||||||
|
else ()
|
||||||
|
set_target_properties(${lualib}
|
||||||
|
PROPERTIES
|
||||||
|
IMPORTED_LOCATION "${LUA_JIT_LIB_FILE}")
|
||||||
|
endif()
|
||||||
|
set_target_properties(${lualib}
|
||||||
|
PROPERTIES
|
||||||
|
IMPORTED_LINK_INTERFACE_LANGUAGES C
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${LUA_JIT_SOURCE_DIR}")
|
||||||
|
if (XCODE)
|
||||||
|
target_compile_options(${lualib}
|
||||||
|
PUBLIC -pagezero_size 10000 -image_base 100000000)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# set externally-visible target indicator
|
||||||
|
set(LUA_LIBRARIES ${lualib})
|
||||||
|
set(LUAJIT_FOUND TRUE)
|
||||||
|
set(LUA_FOUND TRUE)
|
||||||
|
|
|
@ -23,6 +23,12 @@
|
||||||
# import necessary standard modules
|
# import necessary standard modules
|
||||||
include(ExternalProject)
|
include(ExternalProject)
|
||||||
|
|
||||||
|
if(lua_build_included)
|
||||||
|
return()
|
||||||
|
endif(lua_build_included)
|
||||||
|
set(lua_build_included true)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Latest versions for specific sub-versions of Lua
|
# Latest versions for specific sub-versions of Lua
|
||||||
set(LUA_VANILLA_5.1_LATEST_VERSION 5.1.5)
|
set(LUA_VANILLA_5.1_LATEST_VERSION 5.1.5)
|
||||||
|
@ -201,17 +207,10 @@ else()
|
||||||
set(LUA_VANILLA_GENERATE_LUA_HPP false)
|
set(LUA_VANILLA_GENERATE_LUA_HPP false)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (BUILD_LUA_AS_DLL)
|
|
||||||
set(LUA_VANILLA_LUAC_SOURCES ${LUA_VANILLA_LUAC_SOURCES} ${LUA_VANILLA_LIB_SOURCES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(LUA_VANILLA_SOURCE_DIR "${LUA_BUILD_TOPLEVEL}/src")
|
set(LUA_VANILLA_SOURCE_DIR "${LUA_BUILD_TOPLEVEL}/src")
|
||||||
prepend(LUA_VANILLA_LIB_SOURCES "${LUA_VANILLA_SOURCE_DIR}/" ${LUA_VANILLA_LIB_SOURCES})
|
prepend(LUA_VANILLA_LIB_SOURCES "${LUA_VANILLA_SOURCE_DIR}/" ${LUA_VANILLA_LIB_SOURCES})
|
||||||
prepend(LUA_VANILLA_LUA_SOURCES "${LUA_VANILLA_SOURCE_DIR}/" ${LUA_VANILLA_LUA_SOURCES})
|
prepend(LUA_VANILLA_LUA_SOURCES "${LUA_VANILLA_SOURCE_DIR}/" ${LUA_VANILLA_LUA_SOURCES})
|
||||||
prepend(LUA_VANILLA_LUAC_SOURCES "${LUA_VANILLA_SOURCE_DIR}/" ${LUA_VANILLA_LUAC_SOURCES})
|
prepend(LUA_VANILLA_LUAC_SOURCES "${LUA_VANILLA_SOURCE_DIR}/" ${LUA_VANILLA_LUAC_SOURCES})
|
||||||
STRING(REGEX REPLACE "\\.c" ${LUA_BUILD_OBJECT_FILE_SUFFIX} LUA_VANILLA_LIB_OBJECTS ${LUA_VANILLA_LIB_SOURCES})
|
|
||||||
STRING(REGEX REPLACE "\\.c" ${LUA_BUILD_OBJECT_FILE_SUFFIX} LUA_VANILLA_LUA_OBJECTS ${LUA_VANILLA_LUA_SOURCES})
|
|
||||||
STRING(REGEX REPLACE "\\.c" ${LUA_BUILD_OBJECT_FILE_SUFFIX} LUA_VANILLA_LUAC_OBJECTS ${LUA_VANILLA_LUAC_SOURCES})
|
|
||||||
|
|
||||||
# download, just for the sake of download + extract
|
# download, just for the sake of download + extract
|
||||||
# have to use 2 different commands just to have an empty command
|
# have to use 2 different commands just to have an empty command
|
||||||
|
@ -260,7 +259,7 @@ extern \"C\" {
|
||||||
# after download, before build
|
# after download, before build
|
||||||
DEPENDEES download
|
DEPENDEES download
|
||||||
DEPENDERS build
|
DEPENDERS build
|
||||||
BYPRODUCTS "${LUA_VANILLA_TARGET_LUA_HPP}"
|
BYPRODUCTS "${LUA_VANILLA_DESTINATION_LUA_HPP}"
|
||||||
COMMENT "Moving \"${LUA_VANILLA_SOURCE_LUA_HPP}\" to \"${LUA_VANILLA_DESTINATION_LUA_HPP}\"..."
|
COMMENT "Moving \"${LUA_VANILLA_SOURCE_LUA_HPP}\" to \"${LUA_VANILLA_DESTINATION_LUA_HPP}\"..."
|
||||||
COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_VANILLA_SOURCE_LUA_HPP}" "${LUA_VANILLA_DESTINATION_LUA_HPP}")
|
COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_VANILLA_SOURCE_LUA_HPP}" "${LUA_VANILLA_DESTINATION_LUA_HPP}")
|
||||||
endif()
|
endif()
|
||||||
|
@ -288,9 +287,6 @@ set_target_properties(${liblua}
|
||||||
C_EXTENSIONS TRUE
|
C_EXTENSIONS TRUE
|
||||||
POSITION_INDEPENDENT_CODE TRUE
|
POSITION_INDEPENDENT_CODE TRUE
|
||||||
INCLUDE_DIRECTORIES ${LUA_VANILLA_SOURCE_DIR}
|
INCLUDE_DIRECTORIES ${LUA_VANILLA_SOURCE_DIR}
|
||||||
RUNTIME_OUTPUT_DIRECTORY ${LUA_BIN_DIR}
|
|
||||||
LIBRARY_OUTPUT_DIRECTORY ${LUA_BIN_DIR}
|
|
||||||
ARCHIVE_OUTPUT_DIRECTORY ${LUA_LIB_DIR}
|
|
||||||
OUTPUT_NAME ${LUA_BUILD_LIBNAME}
|
OUTPUT_NAME ${LUA_BUILD_LIBNAME}
|
||||||
RUNTIME_OUTPUT_NAME ${LUA_BUILD_LIBNAME}
|
RUNTIME_OUTPUT_NAME ${LUA_BUILD_LIBNAME}
|
||||||
LIBRARY_OUTPUT_NAME ${LUA_BUILD_LIBNAME}
|
LIBRARY_OUTPUT_NAME ${LUA_BUILD_LIBNAME}
|
||||||
|
@ -363,6 +359,10 @@ endif()
|
||||||
|
|
||||||
# LuaC Compiler
|
# LuaC Compiler
|
||||||
add_executable(${luacompiler} ${LUA_VANILLA_LUAC_SOURCES})
|
add_executable(${luacompiler} ${LUA_VANILLA_LUAC_SOURCES})
|
||||||
|
if (BUILD_LUA_AS_DLL)
|
||||||
|
# TODO: figure out how to make DLL internal symbols for lua public so we don't have to do this
|
||||||
|
target_sources(${luacompiler} PRIVATE ${LUA_VANILLA_LIB_SOURCES})
|
||||||
|
endif()
|
||||||
set_target_properties(${luacompiler}
|
set_target_properties(${luacompiler}
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
LANGUAGE C
|
LANGUAGE C
|
||||||
|
|
|
@ -24,9 +24,15 @@
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/sol2-targets.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/sol2-targets.cmake")
|
||||||
|
|
||||||
get_target_property(
|
MESSAGE(STATUS ${CMAKE_CURRENT_LIST_DIR})
|
||||||
SOL_INCLUDE_DIRS
|
|
||||||
|
get_target_property(SOL_INCLUDE_DIRS
|
||||||
sol2 INTERFACE_INCLUDE_DIRECTORIES)
|
sol2 INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
|
|
||||||
|
get_target_property(SOL_SINGLE_INCLUDE_DIRS
|
||||||
|
sol2_single INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
|
|
||||||
set_and_check(SOL2_INCLUDE_DIRS "${SOL2_INCLUDE_DIRS}")
|
set_and_check(SOL2_INCLUDE_DIRS "${SOL2_INCLUDE_DIRS}")
|
||||||
|
set_and_check(SOL2_INCLUDE_DIRS "${SOL2_SINGLE_INCLUDE_DIRS}")
|
||||||
set(SOL2_LIBRARIES sol2)
|
set(SOL2_LIBRARIES sol2)
|
||||||
|
set(SOL2_LIBRARIES_SINGLE sol2_single)
|
||||||
|
|
|
@ -3,17 +3,26 @@ tutorial: quick 'n' dirty
|
||||||
|
|
||||||
These are all the things. Use your browser's search to find things you want.
|
These are all the things. Use your browser's search to find things you want.
|
||||||
|
|
||||||
You'll need to ``#include <sol.hpp>``/``#include "sol.hpp"`` somewhere in your code. Sol is header-only, so you don't need to compile anything.
|
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
After you learn the basics of sol, it is usually advised that if you think something can work, you should TRY IT. It will probably work!
|
After you learn the basics of sol, it is usually advised that if you think something can work, you should TRY IT. It will probably work!
|
||||||
|
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
All of the code below is available at the `sol2 tutorial examples`_.
|
All of the code below is available at the `sol2 tutorial examples`_.
|
||||||
|
|
||||||
|
asserts / prerequisites
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
You'll need to ``#include <sol.hpp>``/``#include "sol.hpp"`` somewhere in your code. Sol is header-only, so you don't need to compile anything. However, **Lua must be compiled and available**. See the :doc:`getting started tutorial<getting-started>` for more details.
|
||||||
|
|
||||||
|
The implementation for ``assert.hpp`` with ``c_assert`` looks like so:
|
||||||
|
|
||||||
|
.. literalinclude:: ../../../examples/assert.hpp
|
||||||
|
:linenos:
|
||||||
|
|
||||||
|
This is the assert used in the quick code below.
|
||||||
|
|
||||||
opening a state
|
opening a state
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
|
@ -23,8 +32,8 @@ opening a state
|
||||||
|
|
||||||
.. _sol-state-on-lua-state:
|
.. _sol-state-on-lua-state:
|
||||||
|
|
||||||
using sol2 on a lua_State*
|
using sol2 on a lua_State\*
|
||||||
--------------------------
|
---------------------------
|
||||||
|
|
||||||
For your system/game that already has Lua or uses an in-house or pre-rolled Lua system (LuaBridge, kaguya, Luwra, etc.), but you'd still like sol2 and nice things:
|
For your system/game that already has Lua or uses an in-house or pre-rolled Lua system (LuaBridge, kaguya, Luwra, etc.), but you'd still like sol2 and nice things:
|
||||||
|
|
||||||
|
@ -32,6 +41,7 @@ For your system/game that already has Lua or uses an in-house or pre-rolled Lua
|
||||||
.. literalinclude:: ../../../examples/tutorials/quick_n_dirty/opening_state_on_raw_lua.cpp
|
.. literalinclude:: ../../../examples/tutorials/quick_n_dirty/opening_state_on_raw_lua.cpp
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
|
.. _running-lua-code:
|
||||||
|
|
||||||
running lua code
|
running lua code
|
||||||
----------------
|
----------------
|
||||||
|
@ -44,9 +54,23 @@ To run Lua code but have an error handler in case things go wrong:
|
||||||
|
|
||||||
.. literalinclude:: ../../../examples/tutorials/quick_n_dirty/running_lua_code.cpp
|
.. literalinclude:: ../../../examples/tutorials/quick_n_dirty/running_lua_code.cpp
|
||||||
:linenos:
|
:linenos:
|
||||||
:lines: 28-
|
:lines: 28-40
|
||||||
|
|
||||||
|
|
||||||
|
running lua code (low-level)
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
You can use the individual load and function call operator to load, check, and then subsequently run and check code.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
|
||||||
|
This is ONLY if you need some sort of fine-grained control: for 99% of cases, :ref:`running lua code<running-lua-code>` is preferred and avoids pitfalls in not understanding the difference between script/load and needing to run a chunk after loading it.
|
||||||
|
|
||||||
|
|
||||||
|
.. literalinclude:: ../../../examples/tutorials/quick_n_dirty/running_lua_code_low_level.cpp
|
||||||
|
:linenos:
|
||||||
|
:lines: 1-10, 16-41
|
||||||
|
|
||||||
set and get variables
|
set and get variables
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
|
@ -90,85 +114,32 @@ Note that if its a :doc:`userdata/usertype<../api/usertype>` for a C++ type, the
|
||||||
tables
|
tables
|
||||||
------
|
------
|
||||||
|
|
||||||
:doc:`sol::state<../api/state>` is a table too.
|
Tables can be manipulated using accessor-syntax. Note that :doc:`sol::state<../api/state>` is a table and all the methods shown here work with ``sol::state``, too.
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. literalinclude:: ../../../examples/tutorials/quick_n_dirty/tables_and_nesting.cpp
|
||||||
|
:linenos:
|
||||||
sol::state lua;
|
:lines: 1-34
|
||||||
|
|
||||||
// Raw string literal for easy multiline
|
|
||||||
lua.script( R"(
|
|
||||||
abc = { [0] = 24 }
|
|
||||||
def = {
|
|
||||||
ghi = {
|
|
||||||
bark = 50,
|
|
||||||
woof = abc
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)"
|
|
||||||
);
|
|
||||||
|
|
||||||
sol::table abc = lua["abc"];
|
|
||||||
sol::table def = lua["def"];
|
|
||||||
sol::table ghi = lua["def"]["ghi"];
|
|
||||||
|
|
||||||
int bark1 = def["ghi"]["bark"];
|
|
||||||
int bark2 = lua["def"]["ghi"]["bark"];
|
|
||||||
// bark1 == bark2 == 50
|
|
||||||
|
|
||||||
int abcval1 = abc[0];
|
|
||||||
int abcval2 = ghi["woof"][0];
|
|
||||||
// abcval1 == abcval2 == 24
|
|
||||||
|
|
||||||
If you're going deep, be safe:
|
If you're going deep, be safe:
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. literalinclude:: ../../../examples/tutorials/quick_n_dirty/tables_and_nesting.cpp
|
||||||
|
:linenos:
|
||||||
sol::state lua;
|
:lines: 35-
|
||||||
|
|
||||||
sol::optional<int> will_not_error = lua["abc"]["DOESNOTEXIST"]["ghi"];
|
|
||||||
// will_not_error == sol::nullopt
|
|
||||||
int also_will_not_error = lua["abc"]["def"]["ghi"]["jklm"].get_or(25);
|
|
||||||
// is 25
|
|
||||||
|
|
||||||
// if you don't go safe,
|
|
||||||
// will throw (or do at_panic if no exceptions)
|
|
||||||
int aaaahhh = lua["boom"]["the_dynamite"];
|
|
||||||
|
|
||||||
|
|
||||||
make tables
|
make tables
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
Make some:
|
There are many ways to make a table. Here's an easy way for simple ones:
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. literalinclude:: ../../../examples/tutorials/quick_n_dirty/make_tables.cpp
|
||||||
|
:linenos:
|
||||||
|
:lines: 1-21
|
||||||
|
|
||||||
sol::state lua;
|
Equivalent Lua code, and check that they're equivalent:
|
||||||
|
|
||||||
lua["abc"] = lua.create_table_with(
|
|
||||||
0, 24
|
|
||||||
);
|
|
||||||
|
|
||||||
lua.create_named_table("def",
|
|
||||||
"ghi", lua.create_table_with(
|
|
||||||
"bark", 50,
|
|
||||||
// can reference other existing stuff too
|
|
||||||
"woof", lua["abc"]
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
Equivalent Lua code:
|
|
||||||
|
|
||||||
.. code-block:: lua
|
|
||||||
|
|
||||||
abc = { [0] = 24 }
|
|
||||||
def = {
|
|
||||||
ghi = {
|
|
||||||
bark = 50,
|
|
||||||
woof = abc
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
.. literalinclude:: ../../../examples/tutorials/quick_n_dirty/make_tables.cpp
|
||||||
|
:linenos:
|
||||||
|
:lines: 22-
|
||||||
|
|
||||||
You can put anything you want in tables as values or keys, including strings, numbers, functions, other tables.
|
You can put anything you want in tables as values or keys, including strings, numbers, functions, other tables.
|
||||||
|
|
||||||
|
@ -178,190 +149,53 @@ Note that this idea that things can be nested is important and will help later w
|
||||||
functions
|
functions
|
||||||
---------
|
---------
|
||||||
|
|
||||||
They're great. Use them:
|
They're easy to use, from Lua and from C++:
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. literalinclude:: ../../../examples/tutorials/quick_n_dirty/functions_easy.cpp
|
||||||
|
:linenos:
|
||||||
|
:lines: 1-
|
||||||
|
|
||||||
sol::state lua;
|
If you need to protect against errors and parser problems and you're not ready to deal with Lua's ``longjmp`` problems (if you compiled with C), use :doc:`sol::protected_function<../api/protected_function>`.
|
||||||
|
|
||||||
lua.script("function f (a, b, c, d) return 1 end");
|
|
||||||
lua.script("function g (a, b) return a + b end");
|
|
||||||
|
|
||||||
// sol::function is often easier:
|
|
||||||
// takes a variable number/types of arguments...
|
|
||||||
sol::function fx = lua["f"];
|
|
||||||
// fixed signature std::function<...>
|
|
||||||
// can be used to tie a sol::function down
|
|
||||||
std::function<int(int, double, int, std::string)> stdfx = fx;
|
|
||||||
|
|
||||||
int is_one = stdfx(1, 34.5, 3, "bark");
|
|
||||||
int is_also_one = fx(1, "boop", 3, "bark");
|
|
||||||
|
|
||||||
// call through operator[]
|
|
||||||
int is_three = lua["g"](1, 2);
|
|
||||||
// is_three == 3
|
|
||||||
double is_4_8 = lua["g"](2.4, 2.4);
|
|
||||||
// is_4_8 == 4.8
|
|
||||||
|
|
||||||
If you need to protect against errors and parser problems and you're not ready to deal with Lua's `longjmp` problems (if you compiled with C), use :doc:`sol::protected_function<../api/protected_function>`.
|
|
||||||
|
|
||||||
You can bind member variables as functions too, as well as all KINDS of function-like things:
|
You can bind member variables as functions too, as well as all KINDS of function-like things:
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. literalinclude:: ../../../examples/tutorials/quick_n_dirty/functions_all.cpp
|
||||||
|
:linenos:
|
||||||
void some_function () {
|
:lines: 1-50
|
||||||
std::cout << "some function!" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void some_other_function () {
|
|
||||||
std::cout << "some other function!" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct some_class {
|
|
||||||
int variable = 30;
|
|
||||||
|
|
||||||
double member_function () {
|
|
||||||
return 24.5;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
sol::state lua;
|
|
||||||
lua.open_libraries(sol::lib::base);
|
|
||||||
|
|
||||||
// put an instance of "some_class" into lua
|
|
||||||
// (we'll go into more detail about this later
|
|
||||||
// just know here that it works and is
|
|
||||||
// put into lua as a userdata
|
|
||||||
lua.set("sc", some_class());
|
|
||||||
|
|
||||||
// binds a plain function
|
|
||||||
lua["f1"] = some_function;
|
|
||||||
lua.set_function("f2", &some_other_function);
|
|
||||||
|
|
||||||
// binds just the member function
|
|
||||||
lua["m1"] = &some_class::member_function;
|
|
||||||
|
|
||||||
// binds the class to the type
|
|
||||||
lua.set_function("m2", &some_class::member_function, some_class{});
|
|
||||||
|
|
||||||
// binds just the member variable as a function
|
|
||||||
lua["v1"] = &some_class::variable;
|
|
||||||
|
|
||||||
// binds class with member variable as function
|
|
||||||
lua.set_function("v2", &some_class::variable, some_class{});
|
|
||||||
|
|
||||||
The lua code to call these things is:
|
The lua code to call these things is:
|
||||||
|
|
||||||
.. code-block:: lua
|
.. literalinclude:: ../../../examples/tutorials/quick_n_dirty/functions_all.cpp
|
||||||
|
:linenos:
|
||||||
|
:lines: 51-
|
||||||
|
|
||||||
f1() -- some function!
|
You can use ``sol::readonly( &some_class::variable )`` to make a variable readonly and error if someone tries to write to it.
|
||||||
f2() -- some other function!
|
|
||||||
|
|
||||||
-- need class instance if you don't bind it with the function
|
|
||||||
print(m1(sc)) -- 24.5
|
|
||||||
-- does not need class instance: was bound to lua with one
|
|
||||||
print(m2()) -- 24.5
|
|
||||||
|
|
||||||
-- need class instance if you
|
|
||||||
-- don't bind it with the function
|
|
||||||
print(v1(sc)) -- 30
|
|
||||||
-- does not need class instance:
|
|
||||||
-- it was bound with one
|
|
||||||
print(v2()) -- 30
|
|
||||||
|
|
||||||
-- can set, still
|
|
||||||
-- requires instance
|
|
||||||
v1(sc, 212)
|
|
||||||
-- can set, does not need
|
|
||||||
-- class instance: was bound with one
|
|
||||||
v2(254)
|
|
||||||
|
|
||||||
print(v1(sc)) -- 212
|
|
||||||
print(v2()) -- 254
|
|
||||||
|
|
||||||
Can use ``sol::readonly( &some_class::variable )`` to make a variable readonly and error if someone tries to write to it.
|
|
||||||
|
|
||||||
|
|
||||||
self call
|
self call
|
||||||
---------
|
---------
|
||||||
|
|
||||||
You can pass the 'self' argument through C++ to emulate 'member function' calls in Lua.
|
You can pass the ``self`` argument through C++ to emulate 'member function' calls in Lua.
|
||||||
|
|
||||||
.. code-block:: cpp
|
|
||||||
|
|
||||||
sol::state lua;
|
|
||||||
|
|
||||||
lua.open_libraries(sol::lib::base, sol::lib::package, sol::lib::table);
|
|
||||||
|
|
||||||
// a small script using 'self' syntax
|
|
||||||
lua.script(R"(
|
|
||||||
some_table = { some_val = 100 }
|
|
||||||
|
|
||||||
function some_table:add_to_some_val(value)
|
|
||||||
self.some_val = self.some_val + value
|
|
||||||
end
|
|
||||||
|
|
||||||
function print_some_val()
|
|
||||||
print("some_table.some_val = " .. some_table.some_val)
|
|
||||||
end
|
|
||||||
)");
|
|
||||||
|
|
||||||
// do some printing
|
|
||||||
lua["print_some_val"]();
|
|
||||||
// 100
|
|
||||||
|
|
||||||
sol::table self = lua["some_table"];
|
|
||||||
self["add_to_some_val"](self, 10);
|
|
||||||
lua["print_some_val"]();
|
|
||||||
|
|
||||||
|
.. literalinclude:: ../../../examples/tutorials/quick_n_dirty/self_call.cpp
|
||||||
|
:linenos:
|
||||||
|
:lines: 1-
|
||||||
|
|
||||||
|
|
||||||
multiple returns from lua
|
multiple returns from lua
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. literalinclude:: ../../../examples/tutorials/quick_n_dirty/multiple_returns_from_lua.cpp
|
||||||
|
:linenos:
|
||||||
sol::state lua;
|
:lines: 1-
|
||||||
|
|
||||||
lua.script("function f (a, b, c) return a, b, c end");
|
|
||||||
|
|
||||||
std::tuple<int, int, int> result;
|
|
||||||
result = lua["f"](100, 200, 300);
|
|
||||||
// result == { 100, 200, 300 }
|
|
||||||
int a;
|
|
||||||
int b;
|
|
||||||
std::string c;
|
|
||||||
sol::tie( a, b, c ) = lua["f"](100, 200, "bark");
|
|
||||||
// a == 100
|
|
||||||
// b == 200
|
|
||||||
// c == "bark"
|
|
||||||
|
|
||||||
|
|
||||||
multiple returns to lua
|
multiple returns to lua
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. literalinclude:: ../../../examples/tutorials/quick_n_dirty/multiple_returns_to_lua.cpp
|
||||||
|
:linenos:
|
||||||
sol::state lua;
|
:lines: 1-
|
||||||
|
|
||||||
lua["f"] = [](int a, int b, sol::object c) {
|
|
||||||
// sol::object can be anything here: just pass it through
|
|
||||||
return std::make_tuple( a, b, c );
|
|
||||||
};
|
|
||||||
|
|
||||||
std::tuple<int, int, int> result = lua["f"](100, 200, 300);
|
|
||||||
// result == { 100, 200, 300 }
|
|
||||||
|
|
||||||
std::tuple<int, int, std::string> result2;
|
|
||||||
result2 = lua["f"](100, 200, "BARK BARK BARK!");
|
|
||||||
// result2 == { 100, 200, "BARK BARK BARK!" }
|
|
||||||
|
|
||||||
int a, b;
|
|
||||||
std::string c;
|
|
||||||
sol::tie( a, b, c ) = lua["f"](100, 200, "bark");
|
|
||||||
// a == 100
|
|
||||||
// b == 200
|
|
||||||
// c == "bark"
|
|
||||||
|
|
||||||
|
|
||||||
C++ classes from C++
|
C++ classes from C++
|
||||||
|
|
|
@ -36,7 +36,7 @@ Or using your favorite IDE / tool after setting up your include paths and librar
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
If you get an avalanche of errors (particularly referring to ``auto``), you may not have enabled C++14 / C++17 mode for your compiler. Add one of ``std=c++14``, ``std=c++1z`` OR ``std=c++1y`` to your compiler options. By default, this is always-on for VC++ compilers in Visual Studio and friends, but g++ and clang++ require a flag (unless you're on `GCC 6.0`_).
|
If you get an avalanche of errors (particularly referring to ``auto``), you may not have enabled C++14 / C++17 mode for your compiler. Add one of ``std=c++14``, ``std=c++1z`` OR ``std=c++1y`` to your compiler options. By default, this is always-on for VC++ compilers in Visual Studio and friends, but g++ and clang++ require a flag (unless you're on `GCC 6.0`_ or better).
|
||||||
|
|
||||||
If this works, you're ready to start! The first line creates the ``lua_State`` and will hold onto it for the duration of the scope its declared in (e.g., from the opening ``{`` to the closing ``}``). It will automatically close / cleanup that lua state when it gets destructed.
|
If this works, you're ready to start! The first line creates the ``lua_State`` and will hold onto it for the duration of the scope its declared in (e.g., from the opening ``{`` to the closing ``}``). It will automatically close / cleanup that lua state when it gets destructed.
|
||||||
|
|
||||||
|
|
|
@ -26,11 +26,6 @@ file(GLOB EXAMPLES_SRC *.cpp tutorials/quick_n_dirty/*.cpp)
|
||||||
source_group(examples FILES ${EXAMPLES_SRC})
|
source_group(examples FILES ${EXAMPLES_SRC})
|
||||||
|
|
||||||
function (MAKE_EXAMPLE example_source_file is_single)
|
function (MAKE_EXAMPLE example_source_file is_single)
|
||||||
if (is_single)
|
|
||||||
set(header_files ${SOL2_SINGLE_HEADER_SOURCES})
|
|
||||||
else()
|
|
||||||
set(header_files ${SOL2_HEADER_SOURCES})
|
|
||||||
endif()
|
|
||||||
get_filename_component(example_name ${example_source_file} NAME_WE)
|
get_filename_component(example_name ${example_source_file} NAME_WE)
|
||||||
file(RELATIVE_PATH example_source_file_relative ${CMAKE_SOURCE_DIR} ${example_source_file})
|
file(RELATIVE_PATH example_source_file_relative ${CMAKE_SOURCE_DIR} ${example_source_file})
|
||||||
get_filename_component(example_output_relative_dir ${example_source_file_relative} DIRECTORY)
|
get_filename_component(example_output_relative_dir ${example_source_file_relative} DIRECTORY)
|
||||||
|
@ -45,7 +40,7 @@ function (MAKE_EXAMPLE example_source_file is_single)
|
||||||
set(example_output_name "${example_output_relative_dir_name}.${example_name}")
|
set(example_output_name "${example_output_relative_dir_name}.${example_name}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(${example_name} ${example_source_file} ${header_files})
|
add_executable(${example_name} ${example_source_file})
|
||||||
set_target_properties(${example_name}
|
set_target_properties(${example_name}
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
OUTPUT_NAME "${example_output_name}")
|
OUTPUT_NAME "${example_output_name}")
|
||||||
|
|
|
@ -8,12 +8,16 @@ int main(int, char* []) {
|
||||||
lua.open_libraries(sol::lib::base);
|
lua.open_libraries(sol::lib::base);
|
||||||
|
|
||||||
lua["abc_sol2"] = lua.create_table_with(
|
lua["abc_sol2"] = lua.create_table_with(
|
||||||
0, 24);
|
0, 24
|
||||||
|
);
|
||||||
|
|
||||||
lua.create_named_table("def_sol2",
|
sol::table inner_table = lua.create_table_with("bark", 50,
|
||||||
"ghi", lua.create_table_with("bark", 50,
|
|
||||||
// can reference other existing stuff too
|
// can reference other existing stuff too
|
||||||
"woof", lua["abc"]));
|
"woof", lua["abc_sol2"]
|
||||||
|
);
|
||||||
|
lua.create_named_table("def_sol2",
|
||||||
|
"ghi", inner_table
|
||||||
|
);
|
||||||
|
|
||||||
std::string code = R"(
|
std::string code = R"(
|
||||||
abc = { [0] = 24 }
|
abc = { [0] = 24 }
|
||||||
|
|
|
@ -73,7 +73,7 @@ then
|
||||||
apt-get -y install xz-utils clang
|
apt-get -y install xz-utils clang
|
||||||
wget http://llvm.org/releases/$LLVM_VERSION/clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-ubuntu-${download_version}.tar.xz -O ${LLVM_ARCHIVE_PATH}
|
wget http://llvm.org/releases/$LLVM_VERSION/clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-ubuntu-${download_version}.tar.xz -O ${LLVM_ARCHIVE_PATH}
|
||||||
mkdir -p "${CLANG_PREFIX}"
|
mkdir -p "${CLANG_PREFIX}"
|
||||||
tar xf "${LLVM_ARCHIVE_PATH}" -C "${CLANG_PREFIX}" --strip-components 1
|
tar xf "${LLVM_ARCHIE_PATH}" -C "${CLANG_PREFIX}" --strip-components 1
|
||||||
# make sure a clang(++) of major/minor exists
|
# make sure a clang(++) of major/minor exists
|
||||||
# use || true to ignore potential failures
|
# use || true to ignore potential failures
|
||||||
ln -s "clang-${major}.${minor}" "${CLANG_PREFIX}/bin/clang-${major}.${minor}" || true
|
ln -s "clang-${major}.${minor}" "${CLANG_PREFIX}/bin/clang-${major}.${minor}" || true
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
# # This script runs the actual project
|
||||||
|
|
||||||
echo -en "travis_fold:start:build_preparation.1\r"
|
echo -en "travis_fold:start:build_preparation.1\r"
|
||||||
if [ -z "${SOL2_DIR}" ]
|
if [ -z "${SOL2_DIR}" ]
|
||||||
then
|
then
|
||||||
|
@ -48,7 +50,6 @@ echo -en "travis_fold:start:build_preparation.1\r"
|
||||||
source ./sol2.compiler.vars
|
source ./sol2.compiler.vars
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# This script runs the actual project
|
|
||||||
mkdir -p Debug Release
|
mkdir -p Debug Release
|
||||||
|
|
||||||
export build_type_cc=-DCMAKE_C_COMPILER\=${CC}
|
export build_type_cc=-DCMAKE_C_COMPILER\=${CC}
|
||||||
|
|
|
@ -619,7 +619,7 @@ namespace sol {
|
||||||
#ifdef SOL_NO_EXCEPTIONS
|
#ifdef SOL_NO_EXCEPTIONS
|
||||||
// we can't abort here
|
// we can't abort here
|
||||||
// because there's no constexpr abort
|
// because there's no constexpr abort
|
||||||
: *(T*)nullptr;
|
: *static_cast<T*>(nullptr);
|
||||||
#else
|
#else
|
||||||
: (throw bad_optional_access("bad optional access"), contained_val());
|
: (throw bad_optional_access("bad optional access"), contained_val());
|
||||||
#endif
|
#endif
|
||||||
|
@ -628,7 +628,7 @@ namespace sol {
|
||||||
OPTIONAL_MUTABLE_CONSTEXPR T& value() & {
|
OPTIONAL_MUTABLE_CONSTEXPR T& value() & {
|
||||||
return initialized() ? contained_val()
|
return initialized() ? contained_val()
|
||||||
#ifdef SOL_NO_EXCEPTIONS
|
#ifdef SOL_NO_EXCEPTIONS
|
||||||
: *(T*)nullptr;
|
: *static_cast<T*>(nullptr);
|
||||||
#else
|
#else
|
||||||
: (throw bad_optional_access("bad optional access"), contained_val());
|
: (throw bad_optional_access("bad optional access"), contained_val());
|
||||||
#endif
|
#endif
|
||||||
|
@ -639,7 +639,7 @@ namespace sol {
|
||||||
#ifdef SOL_NO_EXCEPTIONS
|
#ifdef SOL_NO_EXCEPTIONS
|
||||||
// we can't abort here
|
// we can't abort here
|
||||||
// because there's no constexpr abort
|
// because there's no constexpr abort
|
||||||
: std::move(*(T*)nullptr);
|
: std::move(*static_cast<T*>(nullptr));
|
||||||
#else
|
#else
|
||||||
: (throw bad_optional_access("bad optional access"), contained_val());
|
: (throw bad_optional_access("bad optional access"), contained_val());
|
||||||
#endif
|
#endif
|
||||||
|
@ -666,7 +666,7 @@ namespace sol {
|
||||||
#ifdef SOL_NO_EXCEPTIONS
|
#ifdef SOL_NO_EXCEPTIONS
|
||||||
// we can't abort here
|
// we can't abort here
|
||||||
// because there's no constexpr abort
|
// because there's no constexpr abort
|
||||||
: *(T*)nullptr;
|
: *static_cast<T*>(nullptr);
|
||||||
#else
|
#else
|
||||||
: (throw bad_optional_access("bad optional access"), contained_val());
|
: (throw bad_optional_access("bad optional access"), contained_val());
|
||||||
#endif
|
#endif
|
||||||
|
@ -677,7 +677,7 @@ namespace sol {
|
||||||
#ifdef SOL_NO_EXCEPTIONS
|
#ifdef SOL_NO_EXCEPTIONS
|
||||||
// we can abort here
|
// we can abort here
|
||||||
// but the others are constexpr, so we can't...
|
// but the others are constexpr, so we can't...
|
||||||
: (std::abort(), *(T*)nullptr);
|
: (std::abort(), *static_cast<T*>(nullptr));
|
||||||
#else
|
#else
|
||||||
: (throw bad_optional_access("bad optional access"), contained_val());
|
: (throw bad_optional_access("bad optional access"), contained_val());
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -326,8 +326,8 @@ namespace sol {
|
||||||
|
|
||||||
static_assert(sizeof(void*) <= sizeof(detail::inheritance_check_function), "The size of this data pointer is too small to fit the inheritance checking function: Please file a bug report.");
|
static_assert(sizeof(void*) <= sizeof(detail::inheritance_check_function), "The size of this data pointer is too small to fit the inheritance checking function: Please file a bug report.");
|
||||||
static_assert(sizeof(void*) <= sizeof(detail::inheritance_cast_function), "The size of this data pointer is too small to fit the inheritance checking function: Please file a bug report.");
|
static_assert(sizeof(void*) <= sizeof(detail::inheritance_cast_function), "The size of this data pointer is too small to fit the inheritance checking function: Please file a bug report.");
|
||||||
baseclasscheck = (void*)&detail::inheritance<T, Bases...>::type_check;
|
baseclasscheck = reinterpret_cast<void*>(&detail::inheritance<T, Bases...>::type_check);
|
||||||
baseclasscast = (void*)&detail::inheritance<T, Bases...>::type_cast;
|
baseclasscast = reinterpret_cast<void*>(&detail::inheritance<T, Bases...>::type_cast);
|
||||||
indexbaseclasspropogation = usertype_detail::walk_all_bases<true, Bases...>;
|
indexbaseclasspropogation = usertype_detail::walk_all_bases<true, Bases...>;
|
||||||
newindexbaseclasspropogation = usertype_detail::walk_all_bases<false, Bases...>;
|
newindexbaseclasspropogation = usertype_detail::walk_all_bases<false, Bases...>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -455,7 +455,7 @@ namespace stack {
|
||||||
lua_rawget(L, metatableindex);
|
lua_rawget(L, metatableindex);
|
||||||
if (type_of(L, -1) != type::lua_nil) {
|
if (type_of(L, -1) != type::lua_nil) {
|
||||||
void* basecastdata = lua_touserdata(L, -1);
|
void* basecastdata = lua_touserdata(L, -1);
|
||||||
detail::inheritance_check_function ic = (detail::inheritance_check_function)basecastdata;
|
detail::inheritance_check_function ic = reinterpret_cast<detail::inheritance_check_function>(basecastdata);
|
||||||
success = ic(detail::id_for<T>::value);
|
success = ic(detail::id_for<T>::value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -662,7 +662,7 @@ namespace stack {
|
||||||
static T* get_no_lua_nil_from(lua_State* L, void* udata, int index, record&) {
|
static T* get_no_lua_nil_from(lua_State* L, void* udata, int index, record&) {
|
||||||
if (detail::has_derived<T>::value && luaL_getmetafield(L, index, &detail::base_class_cast_key()[0]) != 0) {
|
if (detail::has_derived<T>::value && luaL_getmetafield(L, index, &detail::base_class_cast_key()[0]) != 0) {
|
||||||
void* basecastdata = lua_touserdata(L, -1);
|
void* basecastdata = lua_touserdata(L, -1);
|
||||||
detail::inheritance_cast_function ic = (detail::inheritance_cast_function)basecastdata;
|
detail::inheritance_cast_function ic = reinterpret_cast<detail::inheritance_cast_function>(basecastdata);
|
||||||
// use the casting function to properly adjust the pointer for the desired T
|
// use the casting function to properly adjust the pointer for the desired T
|
||||||
udata = ic(udata, detail::id_for<T>::value);
|
udata = ic(udata, detail::id_for<T>::value);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user