aboutsummaryrefslogtreecommitdiff
path: root/.appveyor/install.bat
diff options
context:
space:
mode:
Diffstat (limited to '.appveyor/install.bat')
-rw-r--r--.appveyor/install.bat151
1 files changed, 151 insertions, 0 deletions
diff --git a/.appveyor/install.bat b/.appveyor/install.bat
new file mode 100644
index 00000000..db4800f9
--- /dev/null
+++ b/.appveyor/install.bat
@@ -0,0 +1,151 @@
1@echo off
2
3cd %APPVEYOR_BUILD_FOLDER%
4
5:: =========================================================
6:: Set some defaults. Infer some variables.
7::
8:: These are set globally
9if "%LUA_VER%" NEQ "" (
10 set LUA=lua
11 set LUA_SHORTV=%LUA_VER:~0,3%
12) else (
13 set LUA=luajit
14 set LJ_SHORTV=%LJ_VER:~0,3%
15 set LUA_SHORTV=5.1
16)
17
18:: defines LUA_DIR so Cmake can find this Lua install
19if "%LUA%"=="luajit" (
20 set LUA_DIR=c:\lua\%platform%\lj%LJ_SHORTV%
21) else (
22 set LUA_DIR=c:\lua\%platform%\%LUA_VER%
23)
24
25:: Now we declare a scope
26Setlocal EnableDelayedExpansion EnableExtensions
27
28if not defined LUA_URL set LUA_URL=http://www.lua.org/ftp
29if not defined LUAJIT_GIT_REPO set LUAJIT_GIT_REPO=http://luajit.org/git/luajit-2.0.git
30if not defined LUAJIT_URL set LUAJIT_URL=http://luajit.org/download
31
32if not defined SEVENZIP set SEVENZIP=7z
33::
34:: =========================================================
35
36:: first create some necessary directories:
37mkdir downloads 2>NUL
38
39:: Download and compile Lua (or LuaJIT)
40if "%LUA%"=="luajit" (
41 if not exist %LUA_DIR% (
42 if "%LJ_SHORTV%"=="2.1" (
43 :: Clone repository and checkout 2.1 branch
44 set lj_source_folder=%APPVEYOR_BUILD_FOLDER%\downloads\luajit-%LJ_VER%
45 if not exist !lj_source_folder! (
46 echo Cloning git repo %LUAJIT_GIT_REPO% !lj_source_folder!
47 git clone %LUAJIT_GIT_REPO% !lj_source_folder! || call :die "Failed to clone repository"
48 )
49 cd !lj_source_folder!\src
50 git checkout v2.1 || call :die
51 ) else (
52 set lj_source_folder=%APPVEYOR_BUILD_FOLDER%\downloads\luajit-%LJ_VER%
53 if not exist !lj_source_folder! (
54 echo Downloading... %LUAJIT_URL%/LuaJIT-%LJ_VER%.tar.gz
55 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
56 )
57 cd !lj_source_folder!\src
58 )
59 :: Compiles LuaJIT
60 call msvcbuild.bat
61
62 mkdir %LUA_DIR% 2> NUL
63 for %%a in (bin include lib) do ( mkdir "%LUA_DIR%\%%a" )
64
65 for %%a in (luajit.exe lua51.dll) do ( move "!lj_source_folder!\src\%%a" "%LUA_DIR%\bin" )
66
67 move "!lj_source_folder!\src\lua51.lib" "%LUA_DIR%\lib"
68 for %%a in (lauxlib.h lua.h lua.hpp luaconf.h lualib.h luajit.h) do (
69 copy "!lj_source_folder!\src\%%a" "%LUA_DIR%\include"
70 )
71
72 ) else (
73 echo LuaJIT %LJ_VER% already installed at %LUA_DIR%
74 )
75) else (
76 if not exist %LUA_DIR% (
77 :: Download and compile Lua
78 if not exist downloads\lua-%LUA_VER% (
79 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
80 )
81
82 mkdir downloads\lua-%LUA_VER%\etc 2> NUL
83 if not exist downloads\lua-%LUA_VER%\etc\winmake.bat (
84 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
85 )
86
87 cd downloads\lua-%LUA_VER%
88 call etc\winmake
89 call etc\winmake install %LUA_DIR%
90 ) else (
91 echo Lua %LUA_VER% already installed at %LUA_DIR%
92 )
93)
94
95if not exist %LUA_DIR%\bin\%LUA%.exe call :die "Missing Lua interpreter at %LUA_DIR%\bin\%LUA%.exe"
96
97set PATH=%LUA_DIR%\bin;%PATH%
98call %LUA% -v
99
100
101
102:: Exports the following variables:
103endlocal & set PATH=%PATH%
104
105echo.
106echo ======================================================
107if "%LUA%"=="luajit" (
108 echo Installation of LuaJIT %LJ_VER% done.
109) else (
110 echo Installation of Lua %LUA_VER% done.
111)
112echo Platform - %platform%
113echo LUA - %LUA%
114echo LUA_SHORTV - %LUA_SHORTV%
115echo LJ_SHORTV - %LJ_SHORTV%
116echo.
117echo ======================================================
118echo.
119
120goto :eof
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139:: This blank space is intentional. If you see errors like "The system cannot find the batch label specified 'foo'"
140:: then try adding or removing blank lines lines above.
141:: Yes, really.
142:: http://stackoverflow.com/questions/232651/why-the-system-cannot-find-the-batch-label-specified-is-thrown-even-if-label-e
143
144:: helper functions:
145
146:: for bailing out when an error occurred
147:die %1
148echo %1
149exit /B 1
150goto :eof
151