This commit is contained in:
2025-10-06 11:47:11 -04:00
parent 87e199ea5c
commit 93a47d54be
4 changed files with 95 additions and 12 deletions

1
.gitignore vendored
View File

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

23
.vscode/settings.json vendored
View File

@@ -1,12 +1,11 @@
{ {
"Lua.diagnostics.globals": [ "Lua.diagnostics.globals": [
"_bllua_ts", "_bllua_ts",
"_bllua_requiresecure", "_bllua_requiresecure",
"_bllua_on_unload" "_bllua_on_unload"
], ],
"Lua.runtime.version": "Lua 5.1", "Lua.runtime.version": "Lua 5.1",
"Lua.diagnostics.disable": [ "Lua.diagnostics.disable": ["lowercase-global", "undefined-global"],
"lowercase-global", "C_Cpp.default.compileCommands": "${workspaceFolder}/build/compile_commands.json",
"undefined-global" "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