WIP: Auios' version - Do not merge. Only here for comparison #9

Draft
Auios wants to merge 28 commits from Auios/BlockLua:master into master
4 changed files with 95 additions and 12 deletions
Showing only changes of commit 93a47d54be - Show all commits

1
.gitignore vendored
View File

@@ -1 +1,2 @@
build/
.cache/

23
.vscode/settings.json vendored
View File

@@ -1,12 +1,11 @@
{
"Lua.diagnostics.globals": [
"_bllua_ts",
"_bllua_requiresecure",
"_bllua_on_unload"
],
"Lua.runtime.version": "Lua 5.1",
"Lua.diagnostics.disable": [
"lowercase-global",
"undefined-global"
]
}
{
"Lua.diagnostics.globals": [
"_bllua_ts",
"_bllua_requiresecure",
"_bllua_on_unload"
],
"Lua.runtime.version": "Lua 5.1",
"Lua.diagnostics.disable": ["lowercase-global", "undefined-global"],
"C_Cpp.default.compileCommands": "${workspaceFolder}/build/compile_commands.json",
"C_Cpp.default.compilerPath": "C:/msys64/mingw32/bin/g++.exe"
}

56
CMakeLists.txt Normal file
View File

@@ -0,0 +1,56 @@
cmake_minimum_required(VERSION 3.10)
project(BlockLua CXX)
# Export compile_commands.json for VSCode IntelliSense
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Output directories to mirror compile.bat's build folder
set(OUTPUT_DIR ${CMAKE_SOURCE_DIR}/build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_DIR})
# Global compile options to mirror compile.bat
add_compile_options(
-Wall
-Werror
-m32
-static-libgcc
-static-libstdc++
)
# Include paths
include_directories(
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/inc/tsfuncs
${CMAKE_SOURCE_DIR}/inc/lua
)
# Link directories (for -L.) and libraries from compile.bat
link_directories(
${CMAKE_SOURCE_DIR}
)
# Safe DLL
add_library(BlockLua SHARED src/bllua4.cpp)
# Ensure output name matches compile.bat
set_target_properties(BlockLua PROPERTIES OUTPUT_NAME "BlockLua")
# Linker flags and libraries
if(MSVC)
# Not expected with mingw, but keep placeholder
else()
target_link_libraries(BlockLua PRIVATE psapi lua5.1)
endif()
# Unsafe DLL (with BLLUA_UNSAFE definition)
add_library(BlockLuaUnsafe SHARED src/bllua4.cpp)
set_target_properties(BlockLuaUnsafe PROPERTIES OUTPUT_NAME "BlockLua-Unsafe")
target_compile_definitions(BlockLuaUnsafe PRIVATE BLLUA_UNSAFE)
if(MSVC)
# Not expected with mingw, but keep placeholder
else()
target_link_libraries(BlockLuaUnsafe PRIVATE psapi lua5.1)
endif()

27
make.bat Normal file
View File

@@ -0,0 +1,27 @@
@echo off
cd /d %~dp0
REM Ensure MinGW32 toolchain is first in PATH (matches compile.bat)
set "PATH=C:\msys64\mingw32\bin;%PATH%"
REM Configure CMake (generate into build/)
cmake -S . -B build -G "MinGW Makefiles"
if errorlevel 1 goto :error
REM Build (Release by default)
cmake --build build --config Release -j
if errorlevel 1 goto :error
echo.
echo Build completed.
echo Outputs in .\build :
echo - BlockLua.dll
echo - BlockLua-Unsafe.dll
exit /b 0
:error
echo.
echo Build failed. See errors above.
exit /b 1