From df6cab229adf20369b898517a68efdc18b264d1f Mon Sep 17 00:00:00 2001 From: Polite Kiwi Date: Fri, 26 Feb 2021 02:06:57 -0500 Subject: [PATCH] Did the following - Matched style of build.mingw.bat to build.msvs.bat - Fixed up build system to reflect new lib prefix in build.msvs.bat - Added CWD prefix to missed path in build.mingw.bat --- build.mingw.bat | 2 +- build.msvs.bat | 270 ++++++++++++++++++++++++++---------------------- 2 files changed, 149 insertions(+), 123 deletions(-) diff --git a/build.mingw.bat b/build.mingw.bat index bb9124b..fca0145 100644 --- a/build.mingw.bat +++ b/build.mingw.bat @@ -167,7 +167,7 @@ setlocal call :build_luajit IF NOT EXIST "%root%\jit" ( mkdir %root%\jit - xcopy /E /Y luajit-2.0\src\jit\* %root%\jit + xcopy /E /Y %CWD%\luajit-2.0\src\jit\* %root%\jit ) ) ELSE ( IF NOT EXIST "%CWD%\lua-all\%2" ( diff --git a/build.msvs.bat b/build.msvs.bat index 1057c22..fe53be8 100644 --- a/build.msvs.bat +++ b/build.msvs.bat @@ -26,10 +26,16 @@ REM MSVS Build File setlocal - REM Default env vars + + REM - Basic Variables -------------------------------------------------- + + IF NOT DEFINED debug set debug=0 - REM Basic help switches + + REM - Basic Switches --------------------------------------------------- + + IF [] == [%1] ( goto help ) @@ -44,109 +50,124 @@ setlocal ) - REM -------------------------------------------------------------------- + REM - Basic Dependencies Checking -------------------------------------- + + + REM -- TODO: add in executable checking + + + REM - Basic Innerworking Variables ------------------------------------- + + + set "CWD=%cd%" + + + REM - Basic Cleaner ---------------------------------------------------- - REM Cleans the build directory... IF [clean] == [%1] ( - echo Cleaning build directory... - del include\*.h - del dll\*.dll - del dll\*.lib - del dll\*.exp - del obj\*.obj - rmdir /S /Q bin\Release - rmdir /S /Q bin\Debug + echo Cleaning build directory %CWD% ... + echo Remove %CWD%\include\*.h + del %CWD%\include\*.h + echo Remove %CWD%\dll\*.dll + del %CWD%\dll\*.dll + echo Remove %CWD%\dll\*.lib + del %CWD%\dll\*.lib + echo Remove %CWD%\dll\*.exp + del %CWD%\dll\*.exp + echo Remove %CWD%\obj\*.obj + del %CWD%\obj\*.obj + rmdir /S /Q %CWD%\bin echo Done. exit /b 0 ) - REM -------------------------------------------------------------------- + REM - Basic Installer -------------------------------------------------- - REM Installs to a directory IF [install] == [%1] ( IF [] == [%2] ( - echo Please specify where to install to. + echo please specify where to install to goto failure ) - - echo Installing to directory %2... IF NOT EXIST "%2" ( - echo Please create the destination folder first. + echo please create the destination folder first goto failure ) - xcopy /Y bin\Release\* %2 + echo Installing to directory %2 ... + xcopy /Y %CWD%\bin\Release\* %2 echo Done. exit /b 0 ) - REM -------------------------------------------------------------------- + REM - Basic MSVS Setup ------------------------------------------------- - IF NOT EXIST "lua-all" ( - echo Please run prereqs.bat to get lua-all - goto failure + IF [%debug%] EQU [0] ( + set attrib=/O2 + set root=%CWD%\bin\Release + ) ELSE ( + set attrib=/Od + set root=%CWD%\bin\Debug ) - IF NOT EXIST "luajit-2.0" ( - echo Please run prereqs.bat to get luajit - goto failure - ) + set objdir=%CWD%\obj + set libdir=%CWD%\lib + set resdir=%CWD%\res + set rootdir=%CWD%\root + set dlldir=%CWD%\dll + set srcdir=%CWD%\src + set incdir=%CWD%\include + set dirs=/I%srcdir% /I%libdir% /I%incdir% /I%dlldir% - REM -------------------------------------------------------------------- + REM - Basic Cache Checking --------------------------------------------- - REM MSVS setup - IF [%debug%] EQU [0] ( - set attrib=/O2 - set root=bin\Release - ) ELSE ( - set attrib=/Od - set root=bin\Debug - ) - set objdir=obj - set libdir=lib - set resdir=res - set rootdir=root - set dlldir=dll - set srcdir=src - set incdir=include + IF NOT EXIST "%CWD%\lua-all" ( + echo please run prereqs.bat download to get lua-all + goto failure + ) - set dirs=/I%srcdir% /I%incdir% + IF NOT EXIST "%CWD%\luajit-2.0" ( + echo please run prereqs.bat download to get luajit + goto failure + ) REM -------------------------------------------------------------------- IF [%1] == [driver] ( - echo Cleaning workspace... + echo Cleaning workspace %CWD% ... + REM Resets bin IF EXIST "%root%" rmdir /S /Q %root% REM Resets dll - del %dlldir%\*.dll - del %dlldir%\*.lib - del %dlldir%\*.exp + del %dlldir%\*.dll %dlldir%\*.lib %dlldir%\*.exp REM Output build structure mkdir %root%\res + mkdir %root%\dll + mkdir %root%\lang REM Build dependencies IF [%2] == [luajit] ( call :build_luajit - mkdir %root%\jit - xcopy /E /Y luajit-2.0\src\jit\* %root%\jit + IF NOT EXIST "%root%\jit" ( + mkdir %root%\jit + xcopy /E /Y %CWD%\luajit-2.0\src\jit\* %root%\jit + ) ) ELSE ( - IF NOT EXIST "lua-all\%2" ( - echo Not a valid lua version! + IF NOT EXIST "%CWD%\lua-all\%2" ( + echo supplied argument %2 is not a valid lua version in lua-all goto failure ) call :build_lua %2 @@ -173,23 +194,24 @@ setlocal REM Force driver to be built IF NOT EXIST "%root%\luaw.exe" ( - echo Please build the driver first. + echo please run build.mingw.bat driver lua-5.x.x first goto failure ) echo Cleaning workspace... + REM Resets dll - del %dlldir%\*.dll - del %dlldir%\*.lib - del %dlldir%\*.exp + del %dlldir%\*.dll %dlldir%\*.lib %dlldir%\*.exp IF [%2] == [luajit] ( call :build_luajit - mkdir %root%\jit - xcopy /E /Y luajit-2.0\src\jit\* %root%\jit + IF NOT EXIST "%root%\jit" ( + mkdir %root%\jit + xcopy /E /Y %CWD%\luajit-2.0\src\jit\* %root%\jit + ) ) ELSE ( - IF NOT EXIST "lua-all\%2" ( - echo Not a valid lua version! + IF NOT EXIST "%CWD%\lua-all\%2" ( + echo supplied argument %2 is not a valid lua version in lua-all goto failure ) call :build_lua %2 @@ -215,54 +237,61 @@ setlocal :build_luajit setlocal - echo Building luajit... + echo Locally building luajit %CWD%\luajit-2.0 ... - pushd luajit-2.0\src - IF NOT EXIST "lua51.dll" ( - msvcbuild.bat + pushd %CWD%\luajit-2.0\src + IF NOT EXIST "msvs_lua51.lib" ( + call msvcbuild.bat ) ELSE ( - echo luajit already cached. + echo msvs_lua51.lib already cached. ) - echo Installing... - xcopy /Y lua.h ..\..\include - xcopy /Y luaconf.h ..\..\include - xcopy /Y lualib.h ..\..\include - xcopy /Y lauxlib.h ..\..\include - xcopy /Y luajit.h ..\..\include - xcopy /Y lua51.dll ..\..\dll - xcopy /Y lua51.lib ..\..\dll - xcopy /Y lua51.exp ..\..\dll + echo Locally installing luajit %CWD% ... + move lua51.lib msvs_lua51.lib + move lua51.dll msvs_lua51.dll + move lua51.exp msvs_lua51.exp + xcopy /Y lua.h %incdir% + xcopy /Y luaconf.h %incdir% + xcopy /Y lualib.h %incdir% + xcopy /Y lauxlib.h %incdir% + xcopy /Y luajit.h %incdir% + xcopy /Y msvs_lua51.dll %dlldir%\libluajit.dll + xcopy /Y msvs_lua51.lib %dlldir%\libluajit.lib + xcopy /Y msvs_lua51.exp %dlldir%\libluajit.exp popd - echo Finished installing luajit. + echo Finished locally building / installing luajit. goto :EOF endlocal :build_lua setlocal - echo "Building %1..." + echo Locally building lua %CWD%\lua-all\%1 ... - pushd lua-all\%1 - IF NOT EXIST "*.lib" ( - echo Building %1... + pushd %CWD%\lua-all\%1 + IF EXIST "msvs_lib%1.lib" ( + echo msvs_lib%1.lib already cached. + ) ELSE ( + echo Building %1 ... + REM TODO: upright deleting lua.c is bad IF EXIST "lua.c" del lua.c - REM IF EXIST "luac.c" del luac.c - cl.exe /O2 /D_USRDLL /D_WINDLL /DLUA_BUILD_AS_DLL *.c /link /DLL /EXPORT:luac_main=main /OUT:%1.dll - ) ELSE ( - echo %1 already cached. + REM TODO: I don't know if LUA_BUILD_AS_DLL is necessary + cl.exe /O2 /D_USRDLL /D_WINDLL /DLUA_BUILD_AS_DLL *.c /link /DLL /EXPORT:luac_main=main /OUT:lib%1.dll ) - echo Installing... - xcopy /Y lua.h ..\..\include - xcopy /Y luaconf.h ..\..\include - xcopy /Y lualib.h ..\..\include - xcopy /Y lauxlib.h ..\..\include - xcopy /Y %1.dll ..\..\dll - xcopy /Y %1.lib ..\..\dll - xcopy /Y %1.exp ..\..\dll + echo Locally installing %CWD% ... + move lib%1.dll msvs_lib%1.dll + move lib%1.lib msvs_lib%1.lib + move lib%1.exp msvs_lib%1.exp + xcopy /Y lua.h %incdir% + xcopy /Y luaconf.h %incdir% + xcopy /Y lualib.h %incdir% + xcopy /Y lauxlib.h %incdir% + xcopy /Y msvs_lib%1.dll %dlldir%\lib%1.dll + xcopy /Y msvs_lib%1.lib %dlldir%\lib%1.lib + xcopy /Y msvs_lib%1.exp %dlldir%\lib%1.exp popd echo Finished installing %1. @@ -271,36 +300,37 @@ setlocal :build_install setlocal + echo Migrating %1 to %root%... + move /Y *.obj %objdir% - IF [%1] == [luajit] ( - copy /Y %dlldir%\lua51.dll %root% - copy /Y %dlldir%\lua51.lib %root% + IF [luajit] == [%1] ( + copy /Y %dlldir%\libluajit.dll %root% + copy /Y %dlldir%\libluajit.lib %root% ) ELSE ( - copy /Y %dlldir%\%1.dll %root% - copy /Y %dlldir%\%1.lib %root% + copy /Y %dlldir%\lib%1.dll %root% + copy /Y %dlldir%\lib%1.lib %root% ) - copy lc%1.dll %dlldir% - move lc%1.dll %root% - move lc%1.lib %dlldir% - move lc%1.exp %dlldir% - + move liblc%1.dll %root% + move liblc%1.lib %dlldir% + move liblc%1.exp %dlldir% - echo Finished installing %1. + echo Finished migrating %1 to %root%. goto :EOF endlocal :build_package setlocal - echo Building luaw driver package %1... IF [%1] == [luajit] ( set luaverdef=/DLUA_JIT_51 - set luaverout=%dlldir%\lua51.lib + set luaverout=%dlldir%\libluajit.lib ) ELSE ( - set luaverout=%dlldir%\%1.lib + set luaverout=%dlldir%\lib%1.lib ) - cl.exe %attrib% %dirs% %luaverdef% /D_USRDLL /D_WINDLL /DLC_LD_DLL %srcdir%\ldata.c %srcdir%\jitsupport.c %luaverout% /link /DLL /OUT:lc%1.dll + echo Building luaw driver package %1... + cl.exe %attrib% %dirs% %luaverdef% /D_USRDLL /D_WINDLL /DLC_LD_DLL %srcdir%\ldata.c %srcdir%\jitsupport.c %luaverout% /link /DLL /OUT:liblc%1.dll + echo Finished building driver package %1. goto :EOF endlocal @@ -308,8 +338,9 @@ setlocal setlocal echo Building luaw driver... - cl.exe %attrib% %dirs% /DDEFAULT_LUA=\"lc%1.dll\" %srcdir%\luadriver.c /link /OUT:luaw.exe + cl.exe %attrib% %dirs% /DDEFAULT_LUA=\"liblc%1.dll\" %srcdir%\luadriver.c /link /OUT:luaw.exe + echo Building default lua package %1... call :build_package %1 echo Finished building driver %1. @@ -323,24 +354,19 @@ REM Simplex help message :help echo Usage: echo. - echo build.bat build lua-x.x.x Builds the driver with a default package - echo build.bat package lua-x.x.x Creates packages for the driver - echo build.bat clean Cleans the environment of built files - echo build.bat install [directory] Installs to a pre-created directory - echo build.bat -? /? --help Shows this help message + echo build build lua-x.x.x Builds the driver with a default package + echo build package lua-x.x.x Creates packages for the driver + echo build clean Cleans the environment of built files + echo build install [directory] Installs to a pre-created directory + echo build -? /? --help Shows this help message echo. - echo Notes: - echo Uses `debug` for debug binaries - echo Uses `debug_coverage` for coverage enabling - echo Uses `GCC` for specifying GCC executable - echo Uses `AR` for specifying AR executable - echo Uses `MAKE` for specifying MAKE executable - echo Uses `GCC_VER` for specifying lua gcc version for building lua dlls + echo build and package accepts: + echo luajit, lua-5.1, lua-5.1.5, lua-5.2.0, etc echo. - echo Configure above notes with set: - echo debug, debug_coverage, GCC, AR, MAKE, GCC_VER + echo Listens to these variables: + echo debug echo. - echo Specify luajit if you want to use luajit + echo debug - 0, 1 Default: 0 echo. exit /b 0