forked from redo/BlockLua
		
	Compare commits
	
		
			5 Commits
		
	
	
		
			1a4c7bfefc
			...
			f447c039c7
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| f447c039c7 | |||
| 30fa81f513 | |||
| 1144504ac3 | |||
| ce3f7c8b3f | |||
| 4d74df209e | 
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,2 +1,3 @@ | ||||
| .* | ||||
| !.gitignore | ||||
| build/ | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								BlockLua.dll
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								BlockLua.dll
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -1,16 +1,19 @@ | ||||
| @echo off | ||||
| cd /d %~dp0 | ||||
|  | ||||
| rem ensure build directory exists | ||||
| if not exist build mkdir build | ||||
|  | ||||
| set buildargs=-Wall -Werror -m32 -shared -Isrc -Iinc/tsfuncs -Iinc/lua -lpsapi -L. -llua5.1 -static-libgcc -static-libstdc++ | ||||
|  | ||||
| echo on | ||||
|  | ||||
| g++ src/bllua4.cpp %buildargs% -o BlockLua.dll | ||||
| g++ src/bllua4.cpp %buildargs% -o build\BlockLua.dll | ||||
| @rem g++ -DBLLUA_UNSAFE src/bllua4.cpp %buildargs% -o BlockLua-Unsafe.dll | ||||
|  | ||||
| @echo off | ||||
|  | ||||
| rem objdump -d BlockLua.dll > BlockLua.dll.dump.txt | ||||
| rem objdump -d BlockLua-Unsafe.dll > BlockLua-Unsafe.dll.dump.txt | ||||
| rem objdump -d build\BlockLua.dll > build\BlockLua.dll.dump.txt | ||||
| rem objdump -d build\BlockLua-Unsafe.dll > build\BlockLua-Unsafe.dll.dump.txt | ||||
|  | ||||
| pause | ||||
|   | ||||
							
								
								
									
										52
									
								
								compiling.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								compiling.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,52 @@ | ||||
| ## Compiling on Windows with MSYS2 (32-bit) | ||||
|  | ||||
| Follow these steps to build `BlockLua.dll` for 32-bit Windows using MSYS2's MinGW-w64 i686 toolchain. | ||||
|  | ||||
| ### 1) Install MSYS2 | ||||
|  | ||||
| - Download and install MSYS2 from `https://www.msys2.org/`. | ||||
| - After installing, open the "MSYS2 MSYS" terminal once and update the package database if prompted. | ||||
|  | ||||
| ### 2) Install required packages (i686 / 32-bit) | ||||
|  | ||||
| Run this in the "MSYS2 MSYS" or "MSYS2 MinGW 32-bit" terminal: | ||||
|  | ||||
| ```bash | ||||
| pacman -Sy --needed mingw-w64-i686-toolchain mingw-w64-i686-binutils mingw-w64-i686-lua51 | ||||
| ``` | ||||
|  | ||||
| What these packages are for: | ||||
|  | ||||
| - mingw-w64-i686-toolchain: 32-bit C/C++ compiler suite (g++, libstdc++, runtime libs) to build Windows binaries. | ||||
| - mingw-w64-i686-binutils: Linker and binary utilities (ld, as, objdump) used by the compiler and for optional inspection. | ||||
| - mingw-w64-i686-lua51: Lua 5.1 development files for 32-bit (import library). We use its import library to link; at runtime you can use the provided `lua5.1.dll`. | ||||
|  | ||||
| ### 3) Build (PowerShell, recommended) | ||||
|  | ||||
| - Open PowerShell in the repo root. | ||||
| - Run the script: | ||||
|  | ||||
| ```powershell | ||||
| msys_compile.bat | ||||
| ``` | ||||
|  | ||||
| What the script does: | ||||
|  | ||||
| - Temporarily prepends `C:\\msys64\\mingw32\\bin` to PATH so the 32-bit toolchain is used. | ||||
| - Compiles the project with `-m32` and links against `lua5.1`. | ||||
| - Produces `build\BlockLua.dll` and `build\BlockLua-Unsafe.dll`. | ||||
|  | ||||
| ### 4) Optional: Verify 32-bit output | ||||
|  | ||||
| If you installed binutils, you can check the architecture: | ||||
|  | ||||
| ```powershell | ||||
| objdump -f build\BlockLua.dll | Select-String i386 | ||||
| ``` | ||||
|  | ||||
| You should see `architecture: i386` in the output. | ||||
|  | ||||
| ### Notes | ||||
|  | ||||
| - Ensure you installed the i686 (32-bit) variants of the packages; x86_64 packages won’t work for a 32-bit build. | ||||
| - If the linker cannot find `-llua5.1`, confirm `mingw-w64-i686-lua51` is installed and you are using the `mingw32` toolchain (not `x86_64`). | ||||
							
								
								
									
										13
									
								
								msys_compile.bat
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								msys_compile.bat
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| @echo off | ||||
| cd /d %~dp0 | ||||
|  | ||||
| set "PATH=C:\msys64\mingw32\bin;%PATH%" | ||||
|  | ||||
| if not exist build mkdir build | ||||
|  | ||||
| set buildargs=-Wall -Werror -m32 -shared -Isrc -Iinc/tsfuncs -Iinc/lua -lpsapi -L. -llua5.1 -static-libgcc -static-libstdc++ | ||||
|  | ||||
| echo on | ||||
| g++ src/bllua4.cpp %buildargs% -o build\BlockLua.dll | ||||
| g++ -DBLLUA_UNSAFE src/bllua4.cpp %buildargs% -o build\BlockLua-Unsafe.dll | ||||
| @echo off | ||||
| @@ -7,7 +7,9 @@ ts = _bllua_ts | ||||
|  | ||||
| -- Provide limited OS functions | ||||
| os = os or {} | ||||
| ---@diagnostic disable-next-line: duplicate-set-field | ||||
| function os.time() return math.floor(tonumber(_bllua_ts.call('getSimTime'))/1000) end | ||||
| ---@diagnostic disable-next-line: duplicate-set-field | ||||
| function os.clock() return tonumber(_bllua_ts.call('getSimTime'))/1000 end | ||||
|  | ||||
| -- Virtual file class, emulating a file object as returned by io.open | ||||
| @@ -106,6 +108,7 @@ local function io_open_absolute(fn, mode) | ||||
| end | ||||
|  | ||||
| io = io or {} | ||||
| ---@diagnostic disable-next-line: duplicate-set-field | ||||
| function io.open(fn, mode, errn) | ||||
| 	errn = errn or 1 | ||||
| 	 | ||||
| @@ -126,13 +129,17 @@ function io.open(fn, mode, errn) | ||||
| 		return fi, err, fn | ||||
| 	end | ||||
| end | ||||
| ---@diagnostic disable-next-line: duplicate-set-field | ||||
| function io.lines(fn) | ||||
| 	local fi, err, fn2 = io.open(fn, nil, 2) | ||||
| 	if not fi then error('Error opening file \''..fn2..'\': '..err, 2) end | ||||
| 	return fi:lines() | ||||
| end | ||||
| ---@diagnostic disable-next-line: duplicate-set-field | ||||
| function io.type(f) | ||||
| ---@diagnostic disable-next-line: undefined-field | ||||
| 	if type(f)=='table' and f._is_file then | ||||
| ---@diagnostic disable-next-line: undefined-field | ||||
| 		return f._is_open and 'file' or 'closed file' | ||||
| 	else | ||||
| 		return _bllua_io_type(f) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user