Skip to content

Commit d3a4dd9

Browse files
committed
Merge pull request #60 from moteus/master
Add. Appveyor test building.
2 parents 5781896 + 7eeaeb3 commit d3a4dd9

File tree

6 files changed

+1485
-1139
lines changed

6 files changed

+1485
-1139
lines changed

.appveyor/install.bat

+215
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
@echo off
2+
3+
cd %APPVEYOR_BUILD_FOLDER%
4+
5+
:: =========================================================
6+
:: Set some defaults. Infer some variables.
7+
::
8+
:: These are set globally
9+
if not "%LUA_VER%"=="" (
10+
set LUA=lua
11+
set LUA_SHORTV=%LUA_VER:~0,3%
12+
) else if not "%LJ_VER%"=="" (
13+
set LUA=luajit
14+
set LJ_SHORTV=%LJ_VER:~0,3%
15+
set LUA_SHORTV=5.1
16+
) else (
17+
echo Can not recognize needed Lua version
18+
echo Please set LUA_VER or LJ_VER
19+
exit /B 3
20+
)
21+
22+
:: Now we declare a scope
23+
Setlocal EnableDelayedExpansion EnableExtensions
24+
25+
set LUAROCKS_SHORTV=%LUAROCKS_VER:~0,3%
26+
27+
if not defined LUAROCKS_URL set LUAROCKS_URL=http://keplerproject.github.io/luarocks/releases
28+
if not defined LUAROCKS_REPO set LUAROCKS_REPO=http://rocks.moonscript.org
29+
if not defined LUA_URL set LUA_URL=http://www.lua.org/ftp
30+
if not defined LUAJIT_GIT_REPO set LUAJIT_GIT_REPO=http://luajit.org/git/luajit-2.0.git
31+
if not defined LUAJIT_URL set LUAJIT_URL=http://luajit.org/download
32+
33+
if not defined LR_EXTERNAL set LR_EXTERNAL=c:\external
34+
if not defined LUAROCKS_INSTALL set LUAROCKS_INSTALL=%ProgramFiles(x86)%\LuaRocks
35+
if not defined LR_ROOT set LR_ROOT=%LUAROCKS_INSTALL%\%LUAROCKS_SHORTV%
36+
if not defined LR_SYSTREE set LR_SYSTREE=%LUAROCKS_INSTALL%\systree
37+
if /I "%platform%"=="x64" set LR_SYSTREE=%ProgramFiles%\LuaRocks\systree
38+
39+
if not defined SEVENZIP set SEVENZIP=7z
40+
41+
::
42+
:: =========================================================
43+
44+
:: first create some necessary directories:
45+
mkdir downloads 2>NUL
46+
47+
:: defines LUA_DIR so Cmake can find this Lua install
48+
if "%LUA%"=="luajit" (
49+
set LUA_DIR=c:\lua\lj%LJ_SHORTV%
50+
) else (
51+
set LUA_DIR=c:\lua\%LUA_VER%
52+
)
53+
54+
:: Download and compile Lua (or LuaJIT)
55+
if "%LUA%"=="luajit" (
56+
if not exist %LUA_DIR% (
57+
if "%LJ_SHORTV%"=="2.1" (
58+
:: Clone repository and checkout 2.1 branch
59+
set lj_source_folder=%APPVEYOR_BUILD_FOLDER%\downloads\luajit-%LJ_VER%
60+
if not exist !lj_source_folder! (
61+
echo Cloning git repo %LUAJIT_GIT_REPO% !lj_source_folder!
62+
git clone %LUAJIT_GIT_REPO% !lj_source_folder! || call :die "Failed to clone repository"
63+
)
64+
cd !lj_source_folder!\src
65+
git checkout v2.1 || call :die
66+
) else (
67+
set lj_source_folder=%APPVEYOR_BUILD_FOLDER%\downloads\luajit-%LJ_VER%
68+
if not exist !lj_source_folder! (
69+
echo Downloading... %LUAJIT_URL%/LuaJIT-%LJ_VER%.tar.gz
70+
curl --silent --fail --max-time 120 --connect-timeout 30 %LUAJIT_URL%/LuaJIT-%LJ_VER%.tar.gz | %SEVENZIP% x -si -so -tgzip | %SEVENZIP% x -si -ttar -aoa -odownloads
71+
)
72+
cd !lj_source_folder!\src
73+
)
74+
:: Compiles LuaJIT
75+
call msvcbuild.bat
76+
77+
mkdir %LUA_DIR% 2> NUL
78+
for %%a in (bin include lib) do ( mkdir "%LUA_DIR%\%%a" )
79+
80+
for %%a in (luajit.exe lua51.dll) do ( move "!lj_source_folder!\src\%%a" "%LUA_DIR%\bin" )
81+
82+
move "!lj_source_folder!\src\lua51.lib" "%LUA_DIR%\lib"
83+
for %%a in (lauxlib.h lua.h lua.hpp luaconf.h lualib.h luajit.h) do (
84+
copy "!lj_source_folder!\src\%%a" "%LUA_DIR%\include"
85+
)
86+
87+
) else (
88+
echo LuaJIT %LJ_VER% already installed at %LUA_DIR%
89+
)
90+
) else (
91+
if not exist %LUA_DIR% (
92+
:: Download and compile Lua
93+
if not exist downloads\lua-%LUA_VER% (
94+
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
95+
)
96+
97+
mkdir downloads\lua-%LUA_VER%\etc 2> NUL
98+
if not exist downloads\lua-%LUA_VER%\etc\winmake.bat (
99+
curl --silent --location --insecure --fail --max-time 120 --connect-timeout 30 https://github.com/Tieske/luawinmake/archive/master.tar.gz | %SEVENZIP% x -si -so -tgzip | %SEVENZIP% e -si -ttar -aoa -odownloads\lua-%LUA_VER%\etc luawinmake-master\etc\winmake.bat
100+
)
101+
102+
cd downloads\lua-%LUA_VER%
103+
call etc\winmake
104+
call etc\winmake install %LUA_DIR%
105+
) else (
106+
echo Lua %LUA_VER% already installed at %LUA_DIR%
107+
)
108+
)
109+
110+
if not exist %LUA_DIR%\bin\%LUA%.exe (
111+
echo Missing Lua interpreter
112+
exit /B 1
113+
)
114+
115+
set PATH=%LUA_DIR%\bin;%PATH%
116+
call %LUA% -v
117+
118+
:: =========================================================
119+
:: LuaRocks
120+
:: =========================================================
121+
122+
if not exist "%LR_ROOT%" (
123+
:: Downloads and installs LuaRocks
124+
cd %APPVEYOR_BUILD_FOLDER%
125+
126+
if not exist downloads\luarocks-%LUAROCKS_VER%-win32.zip (
127+
echo Downloading LuaRocks...
128+
curl --silent --fail --max-time 120 --connect-timeout 30 --output downloads\luarocks-%LUAROCKS_VER%-win32.zip %LUAROCKS_URL%/luarocks-%LUAROCKS_VER%-win32.zip
129+
%SEVENZIP% x -aoa -odownloads downloads\luarocks-%LUAROCKS_VER%-win32.zip
130+
)
131+
132+
cd downloads\luarocks-%LUAROCKS_VER%-win32
133+
call install.bat /LUA %LUA_DIR% /Q /LV %LUA_SHORTV% /P "%LUAROCKS_INSTALL%"
134+
)
135+
136+
if not exist "%LR_ROOT%" (
137+
echo LuaRocks installation failed.
138+
exit /B 2
139+
)
140+
141+
set PATH=%LR_ROOT%;%LR_SYSTREE%\bin;%PATH%
142+
143+
:: Lua will use just the system rocks
144+
set LUA_PATH=%LR_ROOT%\lua\?.lua;%LR_ROOT%\lua\?\init.lua
145+
set LUA_PATH=%LUA_PATH%;%LR_SYSTREE%\share\lua\%LUA_SHORTV%\?.lua
146+
set LUA_PATH=%LUA_PATH%;%LR_SYSTREE%\share\lua\%LUA_SHORTV%\?\init.lua
147+
set LUA_CPATH=%LR_SYSTREE%\lib\lua\%LUA_SHORTV%\?.dll
148+
149+
call luarocks --version || call :die "Error with LuaRocks installation"
150+
call luarocks list
151+
152+
if not exist "%LR_EXTERNAL%" (
153+
mkdir "%LR_EXTERNAL%"
154+
mkdir "%LR_EXTERNAL%\lib"
155+
mkdir "%LR_EXTERNAL%\include"
156+
)
157+
158+
set PATH=%LR_EXTERNAL%;%PATH%
159+
160+
:: Exports the following variables:
161+
:: (beware of whitespace between & and ^ below)
162+
endlocal & set PATH=%PATH%&^
163+
set LUA_DIR=%LUA_DIR%&^
164+
set LR_SYSTREE=%LR_SYSTREE%&^
165+
set LUA_PATH=%LUA_PATH%&^
166+
set LUA_CPATH=%LUA_CPATH%&^
167+
set LR_EXTERNAL=%LR_EXTERNAL%
168+
169+
echo ======================================================
170+
if "%LUA%"=="luajit" (
171+
echo Installation of LuaJIT %LJ_VER% and LuaRocks %LUAROCKS_VER% done.
172+
) else (
173+
echo Installation of Lua %LUA_VER% and LuaRocks %LUAROCKS_VER% done.
174+
)
175+
echo Platform - %platform%
176+
echo LUA - %LUA%
177+
echo LUA_SHORTV - %LUA_SHORTV%
178+
echo LJ_SHORTV - %LJ_SHORTV%
179+
echo LUA_PATH - %LUA_PATH%
180+
echo LUA_CPATH - %LUA_CPATH%
181+
echo
182+
echo LR_EXTERNAL - %LR_EXTERNAL%
183+
echo ======================================================
184+
185+
goto :eof
186+
187+
188+
189+
190+
191+
192+
193+
194+
195+
196+
197+
198+
199+
200+
201+
202+
203+
204+
:: This blank space is intentional. If you see errors like "The system cannot find the batch label specified 'foo'"
205+
:: then try adding or removing blank lines lines above.
206+
:: Yes, really.
207+
:: http://stackoverflow.com/questions/232651/why-the-system-cannot-find-the-batch-label-specified-is-thrown-even-if-label-e
208+
209+
:: helper functions:
210+
211+
:: for bailing out when an error occurred
212+
:die %1
213+
echo %1
214+
exit 1
215+
goto :eof

.appveyor/install_curl.bat

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
SETLOCAL
2+
3+
set PLAT_NAME=Win32
4+
set CURL_PLAT=Win32
5+
set CURL_URL=http://curl.haxx.se/download
6+
set CURL_CFG=DLL Release - DLL Windows SSPI
7+
8+
if /I "%platform%" == "x64" (
9+
set PLAT_NAME=Win64
10+
set CURL_PLAT=x64
11+
)
12+
13+
cd %APPVEYOR_BUILD_FOLDER%
14+
15+
echo =========================================
16+
echo External library path: %LR_EXTERNAL%
17+
echo =========================================
18+
19+
if not exist %LR_EXTERNAL%\libcurl.dll (
20+
@echo Download %CURL_URL%/curl-%CURL_VER%.zip ...
21+
22+
appveyor DownloadFile %CURL_URL%/curl-%CURL_VER%.zip
23+
7z x curl-%CURL_VER%.zip
24+
cd curl-%CURL_VER%
25+
26+
@echo Build curl %CURL_CFG% / %PLAT_NAME% ...
27+
28+
if exist projects\Windows\VC12\curl.sln (
29+
msbuild projects\Windows\VC12\curl.sln /p:Configuration="%CURL_CFG%" /p:Platform=%CURL_PLAT%
30+
) else (
31+
msbuild projects\Windows\VC12\curl-all.sln /p:Configuration="%CURL_CFG%" /p:Platform=%CURL_PLAT%
32+
)
33+
34+
@echo Build curl done
35+
36+
if not exist %LR_EXTERNAL%\include\curl mkdir %LR_EXTERNAL%\include\curl
37+
copy "include\curl\*.h" %LR_EXTERNAL%\include\curl
38+
copy "build\%PLAT_NAME%\VC12\%CURL_CFG%\libcurl.lib" %LR_EXTERNAL%\lib\libcurl.lib
39+
copy "build\%PLAT_NAME%\VC12\%CURL_CFG%\libcurl.dll" %LR_EXTERNAL%\libcurl.dll
40+
)
41+
42+
if not exist %LR_EXTERNAL%\libcurl.dll (
43+
exit /B 1
44+
)
45+
46+
appveyor PushArtifact %LR_EXTERNAL%\libcurl.dll -DeploymentName ext-deps
47+
48+
cd %APPVEYOR_BUILD_FOLDER%

.appveyor/pack_artifact.bat

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@setlocal
2+
3+
@for /f "delims=" %%A in ('luarocks pack %1') do @set "rock_name=%%A"
4+
5+
@set rock_name=%rock_name:Packed: =%
6+
7+
@echo make rock file as artifact: %rock_name%
8+
9+
@appveyor PushArtifact %rock_name% -DeploymentName %2
10+
11+
@endlocal
12+

appveyor.yml

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
version: 0.3.2.{build}
2+
3+
os:
4+
- Windows Server 2012 R2
5+
6+
shallow_clone: true
7+
8+
environment:
9+
LUAROCKS_VER: 2.2.1
10+
CURL_VER: 7.41.0
11+
12+
matrix:
13+
- LUA_VER: 5.1.5
14+
# - LUA_VER: 5.2.4
15+
# - LUA_VER: 5.3.0
16+
# - LJ_VER: 2.0.3
17+
# - LJ_VER: 2.1
18+
19+
platform:
20+
- x64
21+
- x86
22+
23+
cache:
24+
- c:\lua -> appveyor.yml
25+
- c:\external -> appveyor.yml
26+
- C:\Program Files (x86)\LuaRocks -> appveyor.yml
27+
- C:\Program Files\LuaRocks -> appveyor.yml
28+
29+
init:
30+
- call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" %platform%
31+
32+
install:
33+
# Setup Lua development/build environment
34+
- call .appveyor\install.bat
35+
36+
before_build:
37+
# external deps
38+
- call .appveyor\install_curl.bat
39+
40+
build_script:
41+
- set LUA_CURL_VER=scm-0
42+
- if "%APPVEYOR_REPO_TAG%" == "true" set set LUA_CURL_VER=%APPVEYOR_REPO_TAG_NAME:~1%-1
43+
- echo "Making lua-curl-%LUA_CURL_VER% ..."
44+
- luarocks make rockspecs/lua-curl-%LUA_CURL_VER%.rockspec
45+
46+
before_test:
47+
# test deps
48+
- luarocks install lunitx
49+
- luarocks install dkjson
50+
- luarocks install luafilesystem
51+
- if "%LUA_SHORTV%"=="5.1" luarocks install bit32
52+
- luarocks install lua-path
53+
54+
test_script:
55+
- echo "Testing..."
56+
- cd %APPVEYOR_BUILD_FOLDER%\test
57+
- lua test_easy.lua
58+
- lua test_safe.lua
59+
- lua test_form.lua
60+
- lua test_pause02.c.lua
61+
- lua test_curl.lua
62+
63+
after_test:
64+
- cd %APPVEYOR_BUILD_FOLDER%
65+
- .appveyor\pack_artifact.bat lua-curl bin-rock

0 commit comments

Comments
 (0)