From 901b76e8d99704c2b75c2f3e50f3a877eadf6862 Mon Sep 17 00:00:00 2001 From: icedream Date: Mon, 20 Oct 2014 11:30:04 +0200 Subject: [PATCH] I wonder if gmod allows compiled lua files to be executed... --- build.bat | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/build.bat b/build.bat index 8c3c643..9a43110 100644 --- a/build.bat +++ b/build.bat @@ -5,6 +5,44 @@ path %programfiles(x86)%\lua\5.1\;%path%;%programfiles(x86)%\Steam\SteamApps\com if not exist builds mkdir builds mkdir tmp +:: Root path +set workspace=%cd% +set workspacelentmp=%workspace% +set workspacelen=1 +:workspacelencalc +set /a workspacelen=!workspacelen!+1 +set workspace=!workspace:~1! +if "%workspace%"=="" goto compile +goto workspacelencalc + +:compileerr +echo ERROR: Compilation failed. +exit /B -1 + +:compile +echo Workspace: %workspace% (%workspacelen%) +:: Compile LUA files +pushd lua +for /r %%i in (.) do ( + set absdir=%%i + set directory=!absdir:~%workspacelen%,-2! + + echo Creating !directory!... + mkdir "..\tmp\!directory!" +) +for /r %%i in (*.lua) do ( + set absfile=%%i + set file=!absfile:~%workspacelen%! + + echo Compiling !file!... + luac52 -o "..\tmp\!file!" "!absfile!" + if %errorlevel% NEQ 0 ( + echo Could not compile !file!, only copying... + copy !absfile! "..\tmp\!file!" + ) +) +popd + :: Optimize LUA files ::set cutofflen= ::set foo=%~dp0 @@ -34,4 +72,4 @@ gmad create -folder "tmp" -out "builds\disguiser_swep.gma" :: Clean up rmdir /q /s tmp -pause +::pause