mirror of
https://github.com/lunarmodules/luafilesystem.git
synced 2026-07-22 02:53:06 +00:00
Adds AppVeyor integration
This commit is contained in:
270
.appveyor/install.bat
Normal file
270
.appveyor/install.bat
Normal file
@@ -0,0 +1,270 @@
|
||||
@echo off
|
||||
|
||||
cd %APPVEYOR_BUILD_FOLDER%
|
||||
|
||||
:: =========================================================
|
||||
:: Set some defaults. Infer some variables.
|
||||
::
|
||||
:: These are set globally
|
||||
if "%LUA_VER%" NEQ "" (
|
||||
set LUA=lua
|
||||
set LUA_SHORTV=%LUA_VER:~0,3%
|
||||
) else (
|
||||
set LUA=luajit
|
||||
set LJ_SHORTV=%LJ_VER:~0,3%
|
||||
set LUA_SHORTV=5.1
|
||||
)
|
||||
|
||||
:: defines LUA_DIR so Cmake can find this Lua install
|
||||
if "%LUA%"=="luajit" (
|
||||
set LUA_DIR=c:\lua\%platform%\lj%LJ_SHORTV%
|
||||
) else (
|
||||
set LUA_DIR=c:\lua\%platform%\%LUA_VER%
|
||||
)
|
||||
|
||||
:: Now we declare a scope
|
||||
Setlocal EnableDelayedExpansion EnableExtensions
|
||||
|
||||
if not defined LUAROCKS_URL set LUAROCKS_URL=http://keplerproject.github.io/luarocks/releases
|
||||
if not defined LUAROCKS_REPO set LUAROCKS_REPO=https://luarocks.org
|
||||
if not defined LUA_URL set LUA_URL=http://www.lua.org/ftp
|
||||
if defined NOCOMPAT (
|
||||
set COMPATFLAG=--nocompat
|
||||
) else (
|
||||
set COMPATFLAG=
|
||||
)
|
||||
if not defined LUAJIT_GIT_REPO set LUAJIT_GIT_REPO=https://github.com/LuaJIT/LuaJIT.git
|
||||
if not defined LUAJIT_URL set LUAJIT_URL=https://github.com/LuaJIT/LuaJIT/archive
|
||||
|
||||
if not defined LR_EXTERNAL set LR_EXTERNAL=c:\external
|
||||
if not defined LUAROCKS_INSTALL set LUAROCKS_INSTALL=%LUA_DIR%\LuaRocks
|
||||
|
||||
|
||||
:: LuaRocks <= 2.2.2 used a versioned directory
|
||||
:: HEAD and newer versions do not, so act accordingly.
|
||||
if defined LR_ROOT goto :skiplrver
|
||||
|
||||
if "%LUAROCKS_VER%" EQU "HEAD" (
|
||||
set LR_ROOT=%LUAROCKS_INSTALL%
|
||||
goto :skiplrver
|
||||
)
|
||||
set LR_ROOT=%LUAROCKS_INSTALL%
|
||||
if %LUAROCKS_VER:~0,1% LEQ 2 (
|
||||
if %LUAROCKS_VER:~2,1% LEQ 2 (
|
||||
if %LUAROCKS_VER:~4,1% LEQ 3 (
|
||||
set LR_ROOT=%LUAROCKS_INSTALL%\!LUAROCKS_VER:~0,3!
|
||||
)
|
||||
)
|
||||
)
|
||||
:skiplrver
|
||||
|
||||
if not defined LR_SYSTREE set LR_SYSTREE=%LUAROCKS_INSTALL%\systree
|
||||
|
||||
if not defined SEVENZIP set SEVENZIP=7z
|
||||
::
|
||||
:: =========================================================
|
||||
|
||||
:: first create some necessary directories:
|
||||
mkdir downloads 2>NUL
|
||||
|
||||
:: Download and compile Lua (or LuaJIT)
|
||||
if "%LUA%"=="luajit" (
|
||||
if not exist %LUA_DIR% (
|
||||
if "%LJ_SHORTV%"=="2.1" (
|
||||
:: Clone repository and checkout 2.1 branch
|
||||
set lj_source_folder=%APPVEYOR_BUILD_FOLDER%\downloads\luajit-%LJ_VER%
|
||||
if not exist !lj_source_folder! (
|
||||
echo Cloning git repo %LUAJIT_GIT_REPO% !lj_source_folder!
|
||||
git clone %LUAJIT_GIT_REPO% !lj_source_folder! || call :die "Failed to clone repository"
|
||||
) else (
|
||||
cd !lj_source_folder!
|
||||
git pull || call :die "Failed to update repository"
|
||||
)
|
||||
cd !lj_source_folder!\src
|
||||
git checkout v2.1 || call :die
|
||||
) else (
|
||||
set lj_source_folder=%APPVEYOR_BUILD_FOLDER%\downloads\luajit-%LJ_VER%
|
||||
if not exist !lj_source_folder! (
|
||||
echo Downloading... %LUAJIT_URL%/v%LJ_VER%.tar.gz
|
||||
curl --location --silent --fail --max-time 120 --connect-timeout 30 %LUAJIT_URL%/v%LJ_VER%.tar.gz | %SEVENZIP% x -si -so -tgzip | %SEVENZIP% x -si -ttar -aoa -odownloads
|
||||
)
|
||||
cd !lj_source_folder!\src
|
||||
)
|
||||
:: Compiles LuaJIT
|
||||
if "%Configuration%"=="MinGW" (
|
||||
call mingw32-make
|
||||
) else (
|
||||
call msvcbuild.bat
|
||||
)
|
||||
|
||||
mkdir %LUA_DIR% 2> NUL
|
||||
for %%a in (bin bin\lua bin\lua\jit include lib) do ( mkdir "%LUA_DIR%\%%a" )
|
||||
|
||||
for %%a in (luajit.exe lua51.dll) do ( move "!lj_source_folder!\src\%%a" "%LUA_DIR%\bin" )
|
||||
copy "%LUA_DIR%\bin\luajit.exe" "%LUA_DIR%\bin\lua.exe"
|
||||
|
||||
move "!lj_source_folder!\src\lua51.lib" "%LUA_DIR%\lib"
|
||||
for %%a in (lauxlib.h lua.h lua.hpp luaconf.h lualib.h luajit.h) do (
|
||||
copy "!lj_source_folder!\src\%%a" "%LUA_DIR%\include"
|
||||
)
|
||||
|
||||
copy "!lj_source_folder!\src\jit\*.lua" "%LUA_DIR%\bin\lua\jit"
|
||||
|
||||
) else (
|
||||
echo LuaJIT %LJ_VER% already installed at %LUA_DIR%
|
||||
)
|
||||
) else (
|
||||
if not exist %LUA_DIR% (
|
||||
:: Download and compile Lua
|
||||
if not exist downloads\lua-%LUA_VER% (
|
||||
curl --silent --fail --max-time 120 --connect-timeout 30 %LUA_URL%/lua-%LUA_VER%.tar.gz | %SEVENZIP% x -si -so -tgzip | %SEVENZIP% x -si -ttar -aoa -odownloads
|
||||
)
|
||||
|
||||
mkdir downloads\lua-%LUA_VER%\etc 2> NUL
|
||||
copy %~dp0\winmake.bat downloads\lua-%LUA_VER%\etc\winmake.bat
|
||||
|
||||
cd downloads\lua-%LUA_VER%
|
||||
call etc\winmake %COMPATFLAG%
|
||||
call etc\winmake install %LUA_DIR%
|
||||
) else (
|
||||
echo Lua %LUA_VER% already installed at %LUA_DIR%
|
||||
)
|
||||
)
|
||||
|
||||
if not exist %LUA_DIR%\bin\%LUA%.exe call :die "Missing Lua interpreter at %LUA_DIR%\bin\%LUA%.exe"
|
||||
|
||||
set PATH=%LUA_DIR%\bin;%PATH%
|
||||
call !LUA! -v
|
||||
|
||||
|
||||
|
||||
:: ==========================================================
|
||||
:: LuaRocks
|
||||
:: ==========================================================
|
||||
|
||||
if not exist "%LR_ROOT%" (
|
||||
:: Downloads and installs LuaRocks
|
||||
cd %APPVEYOR_BUILD_FOLDER%
|
||||
|
||||
if %LUAROCKS_VER%==HEAD (
|
||||
set lr_source_folder=%APPVEYOR_BUILD_FOLDER%\downloads\luarocks-%LUAROCKS_VER%-win32
|
||||
if not exist !lr_source_folder! (
|
||||
git clone https://github.com/keplerproject/luarocks.git --single-branch --depth 1 !lr_source_folder! || call :die "Failed to clone LuaRocks repository"
|
||||
) else (
|
||||
cd !lr_source_folder!
|
||||
git pull || call :die "Failed to update LuaRocks repository"
|
||||
)
|
||||
) else (
|
||||
if not exist downloads\luarocks-%LUAROCKS_VER%-win32.zip (
|
||||
echo Downloading LuaRocks...
|
||||
curl --silent --fail --max-time 120 --connect-timeout 30 --output downloads\luarocks-%LUAROCKS_VER%-win32.zip %LUAROCKS_URL%/luarocks-%LUAROCKS_VER%-win32.zip
|
||||
%SEVENZIP% x -aoa -odownloads downloads\luarocks-%LUAROCKS_VER%-win32.zip
|
||||
)
|
||||
)
|
||||
|
||||
cd downloads\luarocks-%LUAROCKS_VER%-win32
|
||||
if "%Configuration%"=="MinGW" (
|
||||
call install.bat /LUA %LUA_DIR% /Q /LV %LUA_SHORTV% /P "%LUAROCKS_INSTALL%" /TREE "%LR_SYSTREE%" /MW
|
||||
) else (
|
||||
call install.bat /LUA %LUA_DIR% /Q /LV %LUA_SHORTV% /P "%LUAROCKS_INSTALL%" /TREE "%LR_SYSTREE%"
|
||||
)
|
||||
|
||||
:: Configures LuaRocks to instruct CMake the correct generator to use. Else, CMake will pick the highest
|
||||
:: Visual Studio version installed
|
||||
if "%Configuration%"=="MinGW" (
|
||||
echo cmake_generator = "MinGW Makefiles" >> %LUAROCKS_INSTALL%\config-%LUA_SHORTV%.lua
|
||||
) else (
|
||||
set MSVS_GENERATORS[2008]=Visual Studio 9 2008
|
||||
set MSVS_GENERATORS[2010]=Visual Studio 10 2010
|
||||
set MSVS_GENERATORS[2012]=Visual Studio 11 2012
|
||||
set MSVS_GENERATORS[2013]=Visual Studio 12 2013
|
||||
set MSVS_GENERATORS[2015]=Visual Studio 14 2015
|
||||
|
||||
set CMAKE_GENERATOR=!MSVS_GENERATORS[%Configuration%]!
|
||||
if "%platform%" EQU "x64" (set CMAKE_GENERATOR=!CMAKE_GENERATOR! Win64)
|
||||
|
||||
echo cmake_generator = "!CMAKE_GENERATOR!" >> %LUAROCKS_INSTALL%\config-%LUA_SHORTV%.lua
|
||||
)
|
||||
)
|
||||
|
||||
if not exist "%LR_ROOT%" call :die "LuaRocks not found at %LR_ROOT%"
|
||||
|
||||
set PATH=%LR_ROOT%;%LR_SYSTREE%\bin;%PATH%
|
||||
|
||||
:: Lua will use just the system rocks
|
||||
set LUA_PATH=%LR_ROOT%\lua\?.lua;%LR_ROOT%\lua\?\init.lua
|
||||
set LUA_PATH=%LUA_PATH%;%LR_SYSTREE%\share\lua\%LUA_SHORTV%\?.lua
|
||||
set LUA_PATH=%LUA_PATH%;%LR_SYSTREE%\share\lua\%LUA_SHORTV%\?\init.lua
|
||||
set LUA_PATH=%LUA_PATH%;.\?.lua;.\?\init.lua
|
||||
set LUA_CPATH=%LR_SYSTREE%\lib\lua\%LUA_SHORTV%\?.dll;.\?.dll
|
||||
|
||||
call luarocks --version || call :die "Error with LuaRocks installation"
|
||||
call luarocks list
|
||||
|
||||
|
||||
if not exist "%LR_EXTERNAL%" (
|
||||
mkdir "%LR_EXTERNAL%"
|
||||
mkdir "%LR_EXTERNAL%\lib"
|
||||
mkdir "%LR_EXTERNAL%\include"
|
||||
)
|
||||
|
||||
set PATH=%LR_EXTERNAL%;%PATH%
|
||||
|
||||
:: Exports the following variables:
|
||||
:: (beware of whitespace between & and ^ below)
|
||||
endlocal & set PATH=%PATH%&^
|
||||
set LR_SYSTREE=%LR_SYSTREE%&^
|
||||
set LUA_PATH=%LUA_PATH%&^
|
||||
set LUA_CPATH=%LUA_CPATH%&^
|
||||
set LR_EXTERNAL=%LR_EXTERNAL%
|
||||
|
||||
echo.
|
||||
echo ======================================================
|
||||
if "%LUA%"=="luajit" (
|
||||
echo Installation of LuaJIT %LJ_VER% and LuaRocks %LUAROCKS_VER% done.
|
||||
) else (
|
||||
echo Installation of Lua %LUA_VER% and LuaRocks %LUAROCKS_VER% done.
|
||||
if defined NOCOMPAT echo Lua was built with compatibility flags disabled.
|
||||
)
|
||||
echo Platform - %platform%
|
||||
echo LUA - %LUA%
|
||||
echo LUA_SHORTV - %LUA_SHORTV%
|
||||
echo LJ_SHORTV - %LJ_SHORTV%
|
||||
echo LUA_PATH - %LUA_PATH%
|
||||
echo LUA_CPATH - %LUA_CPATH%
|
||||
echo.
|
||||
echo LR_EXTERNAL - %LR_EXTERNAL%
|
||||
echo ======================================================
|
||||
echo.
|
||||
|
||||
goto :eof
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
:: This blank space is intentional. If you see errors like "The system cannot find the batch label specified 'foo'"
|
||||
:: then try adding or removing blank lines lines above.
|
||||
:: Yes, really.
|
||||
:: http://stackoverflow.com/questions/232651/why-the-system-cannot-find-the-batch-label-specified-is-thrown-even-if-label-e
|
||||
|
||||
:: helper functions:
|
||||
|
||||
:: for bailing out when an error occurred
|
||||
:die %1
|
||||
echo %1
|
||||
exit /B 1
|
||||
goto :eof
|
||||
40
.appveyor/set_compiler_env.bat
Normal file
40
.appveyor/set_compiler_env.bat
Normal file
@@ -0,0 +1,40 @@
|
||||
@echo off
|
||||
|
||||
:: Now we declare a scope
|
||||
Setlocal EnableDelayedExpansion EnableExtensions
|
||||
|
||||
if not defined Configuration set Configuration=2015
|
||||
|
||||
if "%Configuration%"=="MinGW" ( goto :mingw )
|
||||
|
||||
set arch=x86
|
||||
|
||||
if "%platform%" EQU "x64" ( set arch=x86_amd64 )
|
||||
|
||||
if "%Configuration%"=="2015" (
|
||||
set SET_VS_ENV="C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
|
||||
)
|
||||
|
||||
if "%Configuration%"=="2013" (
|
||||
set SET_VS_ENV="C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"
|
||||
)
|
||||
|
||||
if "%Configuration%"=="2012" (
|
||||
set SET_VS_ENV="C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat"
|
||||
)
|
||||
|
||||
if "%Configuration%"=="2010" (
|
||||
set SET_VS_ENV="C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
|
||||
)
|
||||
|
||||
if "%Configuration%"=="2008" (
|
||||
set SET_VS_ENV="C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"
|
||||
)
|
||||
|
||||
:: Visual Studio detected
|
||||
endlocal & call %SET_VS_ENV% %arch%
|
||||
goto :eof
|
||||
|
||||
:: MinGW detected
|
||||
:mingw
|
||||
endlocal & set PATH=c:\mingw\bin;%PATH%
|
||||
457
.appveyor/winmake.bat
Normal file
457
.appveyor/winmake.bat
Normal file
@@ -0,0 +1,457 @@
|
||||
@ECHO OFF
|
||||
SETLOCAL ENABLEDELAYEDEXPANSION
|
||||
|
||||
REM *****************************
|
||||
REM * Customization section *
|
||||
REM *****************************
|
||||
|
||||
REM use the /help option for generic usage information
|
||||
|
||||
REM Where is the source code located (the unpacked Lua source archive, toplevel dir)
|
||||
SET SOURCETREE=.\
|
||||
|
||||
REM set the toolchain to either MS or GCC (allcaps), leave blank to autodetect
|
||||
SET TOOLCHAIN=
|
||||
|
||||
REM set the compatibility flags, defaults to empty for 5.1, -DLUA_COMPAT_ALL for 5.2,
|
||||
REM and -DLUA_COMPAT_5_2 for 5.3, which are the same as the unix make files
|
||||
REM This setting can be overridden with the --nocompat flag
|
||||
SET COMPATFLAG=
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
REM **********************************
|
||||
REM * Nothing to customize below *
|
||||
REM **********************************
|
||||
|
||||
SET BATCHNAME=%~n0
|
||||
SET SOURCE=%SOURCETREE%src\
|
||||
SET LUA_H=%SOURCE%lua.h
|
||||
SET CURDIR=%CD%
|
||||
|
||||
REM the following line ends with a TAB. DO NOT REMOVE IT!
|
||||
SET TABCHAR=
|
||||
REM Define LF to contain a linefeed character
|
||||
set ^"LFCHAR=^
|
||||
|
||||
^" The above empty line is critical. DO NOT REMOVE
|
||||
|
||||
|
||||
REM Supported toolchains (allcaps)
|
||||
SET TOOLCHAINS=MS GCC
|
||||
REM Commands which, if exiting without error, indicate presence of the toolchain
|
||||
SET CHECK_GCC=gcc --version
|
||||
SET CHECK_MS=cl
|
||||
|
||||
REM **********************************
|
||||
REM * Check for help request *
|
||||
REM **********************************
|
||||
|
||||
SET HELPCMDS=help -help --help /help ? -? /?
|
||||
for %%L in ("!LFCHAR!") do for /f %%a in ("!HELPCMDS: =%%~L!") do (
|
||||
if "%%a"=="%~1" (
|
||||
echo.
|
||||
echo Builds a standalone Lua installation. Supports Lua version 5.1, 5.2 and 5.3.
|
||||
echo Your compiler must be in the system path, and this "%BATCHNAME%.bat" file must be located
|
||||
echo in ".\etc\" in the unpacked Lua source archive.
|
||||
echo.
|
||||
echo USAGE etc\%BATCHNAME% [FLAG] [COMMAND] [...]
|
||||
echo ^(execute from the root of the unpacked archive^)
|
||||
echo.
|
||||
echo Commands;
|
||||
echo clean : cleans the source tree of build ^(intermediate^) files
|
||||
echo install [path] : installs the build results into "path"
|
||||
echo local : installs into ".\local\" in the unpacked Lua source structure
|
||||
echo [toolchain] : uses a specific toolchain to build. If not provided then supported
|
||||
echo toolchains will be tested and the first available will be picked.
|
||||
echo Supported toolchains are: "%TOOLCHAINS%" ^(must use ALLCAPS^)
|
||||
echo.
|
||||
echo Flags;
|
||||
echo --nocompat : Specifies that no compatibility flags should be set when building.
|
||||
echo If not specified, the default compatibility flags will be used.
|
||||
echo.
|
||||
echo Example use;
|
||||
echo set PATH=C:\path\to\your\compiler\;%%PATH%%
|
||||
echo etc\%BATCHNAME% clean
|
||||
echo etc\%BATCHNAME%
|
||||
echo etc\%BATCHNAME% --nocompat GCC
|
||||
echo etc\%BATCHNAME% install "C:\Program Files\Lua"
|
||||
echo.
|
||||
goto :EXITOK
|
||||
)
|
||||
)
|
||||
|
||||
REM **********************************
|
||||
REM * Check commandline *
|
||||
REM **********************************
|
||||
|
||||
SET CMDOK=FALSE
|
||||
if "%~1"=="" (
|
||||
SET CMDOK=TRUE
|
||||
)
|
||||
for %%a in (local install clean) do (
|
||||
if "%%a"=="%~1" (
|
||||
SET CMDOK=TRUE
|
||||
)
|
||||
)
|
||||
for %%a in (--nocompat) do (
|
||||
if "%%a"=="%~1" (
|
||||
SET NOCOMPAT=TRUE
|
||||
if "%~2"=="" (
|
||||
SET CMDOK=TRUE
|
||||
)
|
||||
SHIFT
|
||||
)
|
||||
)
|
||||
for %%a in (%TOOLCHAINS%) do (
|
||||
if "%%a"=="%~1" (
|
||||
SET CMDOK=TRUE
|
||||
SET TOOLCHAIN=%~1
|
||||
)
|
||||
)
|
||||
if NOT %CMDOK%==TRUE (
|
||||
echo.
|
||||
echo Unknown command or toolchain specified.
|
||||
goto :EXITERROR
|
||||
)
|
||||
|
||||
REM **************************************
|
||||
REM * Check for cleaning *
|
||||
REM **************************************
|
||||
|
||||
if "%1"=="clean" (
|
||||
if NOT [%2]==[] (
|
||||
echo.
|
||||
echo ERROR: The clean command does not take extra parameters.
|
||||
) else (
|
||||
echo Cleaning...
|
||||
if exist "%SOURCE%*.exe" del "%SOURCE%*.exe"
|
||||
if exist "%SOURCE%*.dll" del "%SOURCE%*.dll"
|
||||
if exist "%SOURCE%*.o" del "%SOURCE%*.o"
|
||||
if exist "%SOURCE%*.a" del "%SOURCE%*.a"
|
||||
if exist "%SOURCE%*.obj" del "%SOURCE%*.obj"
|
||||
if exist "%SOURCE%*.manifest" del "%SOURCE%*.manifest"
|
||||
if exist "%SOURCE%*.lib" del "%SOURCE%*.lib"
|
||||
echo Done.
|
||||
)
|
||||
goto :EXITOK
|
||||
)
|
||||
|
||||
REM **************************************************
|
||||
REM * Fetch the Lua version from the source code *
|
||||
REM **************************************************
|
||||
|
||||
Echo.
|
||||
Echo Checking source code to extract Lua version...
|
||||
IF NOT EXIST %LUA_H% (
|
||||
Echo Cannot locate Lua header file; %LUA_H%
|
||||
goto :EXITERROR
|
||||
)
|
||||
|
||||
findstr /R /C:"#define[ %TABCHAR%][ %TABCHAR%]*LUA_VERSION_MAJOR" %LUA_H% > NUL
|
||||
if NOT %ERRORLEVEL%==0 (
|
||||
rem ECHO We've got a Lua version 5.1
|
||||
rem findstr /R /C:"#define[ %TABCHAR%][ %TABCHAR%]*LUA_VERSION[ %TABCHAR%]" %LUA_H%
|
||||
SET LUA_VER=5.1
|
||||
) else (
|
||||
rem ECHO We've got a Lua version 5.2+
|
||||
rem findstr /R /C:"#define[ %TABCHAR%][ %TABCHAR%]*LUA_VERSION_MAJOR[ %TABCHAR%]" %LUA_H%
|
||||
rem findstr /R /C:"#define[ %TABCHAR%][ %TABCHAR%]*LUA_VERSION_MINOR[ %TABCHAR%]" %LUA_H%
|
||||
|
||||
for /F "delims=" %%a in ('findstr /R /C:"#define[ %TABCHAR%][ %TABCHAR%]*LUA_VERSION_MAJOR[ %TABCHAR%]" %LUA_H%') do set LUA_MAJOR=%%a
|
||||
SET LUA_MAJOR=!LUA_MAJOR:#define=!
|
||||
SET LUA_MAJOR=!LUA_MAJOR:LUA_VERSION_MAJOR=!
|
||||
SET LUA_MAJOR=!LUA_MAJOR: =!
|
||||
SET LUA_MAJOR=!LUA_MAJOR:%TABCHAR%=!
|
||||
SET LUA_MAJOR=!LUA_MAJOR:"=!
|
||||
SET LUA_MAJOR=!LUA_MAJOR:~0,1!
|
||||
|
||||
for /F "delims=" %%a in ('findstr /R /C:"#define[ %TABCHAR%][ %TABCHAR%]*LUA_VERSION_MINOR[ %TABCHAR%]" %LUA_H%') do set LUA_MINOR=%%a
|
||||
SET LUA_MINOR=!LUA_MINOR:#define=!
|
||||
SET LUA_MINOR=!LUA_MINOR:LUA_VERSION_MINOR=!
|
||||
SET LUA_MINOR=!LUA_MINOR: =!
|
||||
SET LUA_MINOR=!LUA_MINOR:%TABCHAR%=!
|
||||
SET LUA_MINOR=!LUA_MINOR:"=!
|
||||
SET LUA_MINOR=!LUA_MINOR:~0,1!
|
||||
|
||||
SET LUA_VER=!LUA_MAJOR!.!LUA_MINOR!
|
||||
)
|
||||
SET LUA_SVER=!LUA_VER:.=!
|
||||
|
||||
Echo Lua version found: %LUA_VER%
|
||||
Echo.
|
||||
|
||||
REM **************************************
|
||||
REM * Set some Lua version specifics *
|
||||
REM **************************************
|
||||
|
||||
REM FILES_CORE; files for Lua core (+lauxlib, needed for Luac)
|
||||
REM FILES_LIB; files for Lua standard libraries
|
||||
REM FILES_DLL; vm files to be build with dll option
|
||||
REM FILES_OTH; vm files to be build without dll, for static linking
|
||||
|
||||
if %LUA_SVER%==51 (
|
||||
set FILES_CORE=lapi lcode ldebug ldo ldump lfunc lgc llex lmem lobject lopcodes lparser lstate lstring ltable ltm lundump lvm lzio lauxlib
|
||||
set FILES_LIB=lbaselib ldblib liolib lmathlib loslib ltablib lstrlib loadlib linit
|
||||
set FILES_DLL=lua
|
||||
set FILES_OTH=luac print
|
||||
set INSTALL_H=lauxlib.h lua.h luaconf.h lualib.h ..\etc\lua.hpp
|
||||
)
|
||||
if %LUA_SVER%==52 (
|
||||
set FILES_CORE=lapi lcode lctype ldebug ldo ldump lfunc lgc llex lmem lobject lopcodes lparser lstate lstring ltable ltm lundump lvm lzio lauxlib
|
||||
set FILES_LIB=lbaselib lbitlib lcorolib ldblib liolib lmathlib loslib lstrlib ltablib loadlib linit
|
||||
set FILES_DLL=lua
|
||||
set FILES_OTH=luac
|
||||
set INSTALL_H=lauxlib.h lua.h lua.hpp luaconf.h lualib.h
|
||||
if "%COMPATFLAG%"=="" (
|
||||
set COMPATFLAG=-DLUA_COMPAT_ALL
|
||||
)
|
||||
)
|
||||
if %LUA_SVER%==53 (
|
||||
set FILES_CORE=lapi lcode lctype ldebug ldo ldump lfunc lgc llex lmem lobject lopcodes lparser lstate lstring ltable ltm lundump lvm lzio lauxlib
|
||||
set FILES_LIB=lbaselib lbitlib lcorolib ldblib liolib lmathlib loslib lstrlib ltablib lutf8lib loadlib linit
|
||||
set FILES_DLL=lua
|
||||
set FILES_OTH=luac
|
||||
set INSTALL_H=lauxlib.h lua.h lua.hpp luaconf.h lualib.h
|
||||
if "%COMPATFLAG%"=="" (
|
||||
set COMPATFLAG=-DLUA_COMPAT_5_2
|
||||
)
|
||||
)
|
||||
|
||||
if "%NOCOMPAT%"=="TRUE" (
|
||||
set COMPATFLAG=
|
||||
)
|
||||
|
||||
SET FILES_BASE=%FILES_DLL% %FILES_CORE% %FILES_LIB%
|
||||
|
||||
if "%FILES_BASE%"=="" (
|
||||
Echo Unknown Lua version; %LUA_VER%
|
||||
goto :EXITERROR
|
||||
)
|
||||
|
||||
REM *********************************
|
||||
REM * Check available toolchain *
|
||||
REM *********************************
|
||||
|
||||
if [%TOOLCHAIN%]==[] (
|
||||
Echo Testing for MS...
|
||||
%CHECK_MS%
|
||||
IF !ERRORLEVEL!==0 SET TOOLCHAIN=MS
|
||||
)
|
||||
if [%TOOLCHAIN%]==[] (
|
||||
Echo Testing for GCC...
|
||||
%CHECK_GCC%
|
||||
IF !ERRORLEVEL!==0 SET TOOLCHAIN=GCC
|
||||
)
|
||||
if [%TOOLCHAIN%]==[] (
|
||||
Echo No supported toolchain found ^(please make sure it is in the system path^)
|
||||
goto :EXITERROR
|
||||
)
|
||||
|
||||
REM ***************************
|
||||
REM * Configure toolchain *
|
||||
REM ***************************
|
||||
|
||||
if %TOOLCHAIN%==GCC (
|
||||
echo Using GCC toolchain...
|
||||
SET OBJEXT=o
|
||||
SET LIBFILE=liblua%LUA_SVER%.a
|
||||
)
|
||||
if %TOOLCHAIN%==MS (
|
||||
echo Using Microsoft toolchain...
|
||||
SET OBJEXT=obj
|
||||
SET LIBFILE=lua%LUA_SVER%.lib
|
||||
)
|
||||
echo.
|
||||
|
||||
REM **************************************
|
||||
REM * Check for installing *
|
||||
REM **************************************
|
||||
|
||||
if "%1"=="install" (
|
||||
if "%~2"=="" (
|
||||
echo.
|
||||
echo ERROR: The install command requires a path where to install to.
|
||||
goto :EXITERROR
|
||||
)
|
||||
SET TARGETPATH=%~2
|
||||
)
|
||||
if "%1"=="local" (
|
||||
if NOT "%~2"=="" (
|
||||
echo.
|
||||
echo ERROR: The local command does not take extra parameters.
|
||||
goto :EXITERROR
|
||||
)
|
||||
SET TARGETPATH=%SOURCETREE%local
|
||||
)
|
||||
if NOT "%TARGETPATH%"=="" (
|
||||
mkdir "%TARGETPATH%\bin"
|
||||
mkdir "%TARGETPATH%\include"
|
||||
mkdir "%TARGETPATH%\lib\lua\%LUA_VER%"
|
||||
mkdir "%TARGETPATH%\man\man1"
|
||||
mkdir "%TARGETPATH%\share\lua\%LUA_VER%"
|
||||
copy "%SOURCE%lua.exe" "%TARGETPATH%\bin"
|
||||
copy "%SOURCE%luac.exe" "%TARGETPATH%\bin"
|
||||
copy "%SOURCE%lua%LUA_SVER%.dll" "%TARGETPATH%\bin"
|
||||
for %%a in (%INSTALL_H%) do ( copy "%SOURCE%%%a" "%TARGETPATH%\include" )
|
||||
copy "%SOURCE%%LIBFILE%" "%TARGETPATH%\lib"
|
||||
copy "%SOURCETREE%doc\lua.1" "%TARGETPATH%\man\man1"
|
||||
copy "%SOURCETREE%doc\luac.1" "%TARGETPATH%\man\man1"
|
||||
|
||||
echo Installation completed in "%TARGETPATH%".
|
||||
goto :EXITOK
|
||||
)
|
||||
|
||||
REM ***********************
|
||||
REM * Compile sources *
|
||||
REM ***********************
|
||||
goto :after_compile_function
|
||||
:compile_function
|
||||
REM Params: %1 is filelist (must be quoted)
|
||||
REM Return: same list, with the object file extension included, will be stored in global OBJLIST
|
||||
|
||||
for %%a in (%~1) do (
|
||||
SET FILENAME=%%a
|
||||
if %TOOLCHAIN%==GCC (
|
||||
SET COMPCMD=gcc -O2 -Wall !EXTRAFLAG! !COMPATFLAG! -c -o !FILENAME!.%OBJEXT% !FILENAME!.c
|
||||
)
|
||||
if %TOOLCHAIN%==MS (
|
||||
SET COMPCMD=cl /nologo /MD /O2 /W3 /c /D_CRT_SECURE_NO_DEPRECATE !COMPATFLAG! !EXTRAFLAG! !FILENAME!.c
|
||||
)
|
||||
echo !COMPCMD!
|
||||
!COMPCMD!
|
||||
SET OBJLIST=!OBJLIST! !FILENAME!.%OBJEXT%
|
||||
)
|
||||
|
||||
goto :eof
|
||||
:after_compile_function
|
||||
|
||||
CD %SOURCE%
|
||||
REM Traverse the 4 lists of source files
|
||||
|
||||
for %%b in (CORE LIB DLL OTH) do (
|
||||
SET LTYPE=%%b
|
||||
SET OBJLIST=
|
||||
if !LTYPE!==OTH (
|
||||
REM OTH is the only list of files build without DLL option
|
||||
SET EXTRAFLAG=
|
||||
) else (
|
||||
SET EXTRAFLAG=-DLUA_BUILD_AS_DLL
|
||||
)
|
||||
if !LTYPE!==CORE SET FILELIST=%FILES_CORE%
|
||||
if !LTYPE!==LIB SET FILELIST=%FILES_LIB%
|
||||
if !LTYPE!==DLL SET FILELIST=%FILES_DLL%
|
||||
if !LTYPE!==OTH SET FILELIST=%FILES_OTH%
|
||||
|
||||
echo Now compiling !LTYPE! file set...
|
||||
call:compile_function "!FILELIST!"
|
||||
|
||||
if !LTYPE!==CORE SET FILES_CORE_O=!OBJLIST!
|
||||
if !LTYPE!==LIB SET FILES_LIB_O=!OBJLIST!
|
||||
if !LTYPE!==DLL SET FILES_DLL_O=!OBJLIST!
|
||||
if !LTYPE!==OTH SET FILES_OTH_O=!OBJLIST!
|
||||
)
|
||||
|
||||
|
||||
REM ****************************
|
||||
REM * Link GCC based files *
|
||||
REM ****************************
|
||||
|
||||
if %TOOLCHAIN%==GCC (
|
||||
REM Link the LuaXX.dll file
|
||||
SET LINKCMD=gcc -shared -o lua%LUA_SVER%.dll %FILES_CORE_O% %FILES_LIB_O%
|
||||
echo !LINKCMD!
|
||||
!LINKCMD!
|
||||
|
||||
REM strip from LuaXX.dll
|
||||
SET RANCMD=strip --strip-unneeded lua%LUA_SVER%.dll
|
||||
echo !RANCMD!
|
||||
!RANCMD!
|
||||
|
||||
REM Link the Lua.exe file
|
||||
SET LINKCMD=gcc -o lua.exe -s lua.%OBJEXT% lua%LUA_SVER%.dll -lm
|
||||
echo !LINKCMD!
|
||||
!LINKCMD!
|
||||
|
||||
REM create lib archive
|
||||
SET LIBCMD=ar rcu liblua%LUA_SVER%.a %FILES_CORE_O% %FILES_LIB_O%
|
||||
echo !LIBCMD!
|
||||
!LIBCMD!
|
||||
|
||||
REM Speedup index using ranlib
|
||||
SET RANCMD=ranlib liblua%LUA_SVER%.a
|
||||
echo !RANCMD!
|
||||
!RANCMD!
|
||||
|
||||
REM Link Luac.exe file
|
||||
SET LINKCMD=gcc -o luac.exe %FILES_OTH_O% liblua%LUA_SVER%.a -lm
|
||||
echo !LINKCMD!
|
||||
!LINKCMD!
|
||||
|
||||
)
|
||||
|
||||
|
||||
REM ****************************
|
||||
REM * Link MS based files *
|
||||
REM ****************************
|
||||
|
||||
if %TOOLCHAIN%==MS (
|
||||
REM Link the LuaXX.dll file, and LuaXX.obj
|
||||
SET LINKCMD=link /nologo /DLL /out:lua%LUA_SVER%.dll %FILES_CORE_O% %FILES_LIB_O%
|
||||
echo !LINKCMD!
|
||||
!LINKCMD!
|
||||
|
||||
REM handle dll manifest
|
||||
if exist lua%LUA_SVER%.dll.manifest (
|
||||
SET MANICMD=mt /nologo -manifest lua%LUA_SVER%.dll.manifest -outputresource:lua%LUA_SVER%.dll;2
|
||||
echo !MANICMD!
|
||||
!MANICMD!
|
||||
)
|
||||
|
||||
REM Link Lua.exe
|
||||
SET LINKCMD=link /nologo /out:lua.exe lua.%OBJEXT% lua%LUA_SVER%.lib
|
||||
echo !LINKCMD!
|
||||
!LINKCMD!
|
||||
|
||||
REM handle manifest
|
||||
if exist lua.exe.manifest (
|
||||
SET MANICMD=mt /nologo -manifest lua.exe.manifest -outputresource:lua.exe
|
||||
echo !MANICMD!
|
||||
!MANICMD!
|
||||
)
|
||||
|
||||
REM Link Luac.exe
|
||||
SET LINKCMD=link /nologo /out:luac.exe %FILES_OTH_O% %FILES_CORE_O%
|
||||
echo !LINKCMD!
|
||||
!LINKCMD!
|
||||
|
||||
REM handle manifest
|
||||
if exist luac.exe.manifest (
|
||||
SET MANICMD=mt /nologo -manifest luac.exe.manifest -outputresource:luac.exe
|
||||
echo !MANICMD!
|
||||
!MANICMD!
|
||||
)
|
||||
)
|
||||
|
||||
CD %CURDIR%
|
||||
|
||||
REM ****************************
|
||||
REM * Finished building *
|
||||
REM ****************************
|
||||
|
||||
echo.
|
||||
echo Build completed.
|
||||
goto :EXITOK
|
||||
|
||||
:EXITOK
|
||||
exit /B 0
|
||||
|
||||
:EXITERROR
|
||||
echo For help try; etc\%BATCHNAME% /help
|
||||
exit /B 1
|
||||
64
appveyor.yml
Normal file
64
appveyor.yml
Normal file
@@ -0,0 +1,64 @@
|
||||
version: 0.0.1.{build}-test
|
||||
|
||||
# Use default image unless needed
|
||||
#os:
|
||||
#- Windows Server 2012 R2
|
||||
|
||||
shallow_clone: true
|
||||
|
||||
environment:
|
||||
LUAROCKS_VER: 2.3.0
|
||||
matrix:
|
||||
- LUA_VER: 5.1.5
|
||||
- LUA_VER: 5.2.4
|
||||
NOCOMPAT: true
|
||||
- LUA_VER: 5.3.2 # Lua 5.3.2 with compatibility flags disabled.
|
||||
NOCOMPAT: true
|
||||
- LJ_VER: 2.0.4
|
||||
- LJ_VER: 2.1
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- configuration: MinGW
|
||||
platform: x64
|
||||
|
||||
# Abuse this section so we can have a matrix with different Compiler versions
|
||||
configuration:
|
||||
- 2015
|
||||
- MinGW
|
||||
|
||||
platform:
|
||||
- x86
|
||||
- x64
|
||||
|
||||
cache:
|
||||
- c:\lua -> appveyor.yml
|
||||
- c:\external -> appveyor.yml
|
||||
|
||||
# Skip unsupported combinations (ie, VS2008 for x64 is not supported)
|
||||
init:
|
||||
- if "%platform%" EQU "x64" ( for %%a in (2008 2010 MinGW) do ( if "%Configuration%"=="%%a" (echo "Skipping unsupported configuration" && exit /b 1 ) ) )
|
||||
|
||||
|
||||
install:
|
||||
# Make compiler command line tools available
|
||||
- call .appveyor\set_compiler_env.bat
|
||||
# Setup Lua development/build environment
|
||||
- call .appveyor\install.bat
|
||||
|
||||
before_build:
|
||||
# @todo
|
||||
- echo "Installing external deps"
|
||||
|
||||
build_script:
|
||||
- luarocks make rockspecs/luafilesystem-cvs-3.rockspec
|
||||
|
||||
before_test:
|
||||
|
||||
test_script:
|
||||
- echo "Testing..."
|
||||
- cd %APPVEYOR_BUILD_FOLDER%\tests
|
||||
- lua test.lua
|
||||
|
||||
after_test:
|
||||
# @todo
|
||||
Reference in New Issue
Block a user