]> git.lizzy.rs Git - metalua.git/blob - src/make.bat
rewrote the build and install system, tested on linux and windows
[metalua.git] / src / make.bat
1 @CLS
2
3 @REM *** Settings ***
4
5 @REM BASE        = root directory of metalua sources
6 @REM DISTRIB_BIN = metalua executables target directory
7 @REM DISTRIB_LIB = metalua libraries target directory, can be an existing path referenced in LUA_PATH
8 @REM LUA, LUAC   = Lua executables, provided by metalua by default.
9
10 @REM --- BEGINNING OF USER-EDITABLE PART ---
11
12 @set BASE=%CD%
13 @set DISTRIB=%BASE%\..\distrib
14 @set DISTRIB_BIN=%DISTRIB%\bin
15 @set DISTRIB_LIB=%DISTRIB%\lib
16 @set LUA=%DISTRIB_BIN%\lua
17 @set LUAC=%DISTRIB_BIN%\luac
18
19 @REM --- END OF USER-EDITABLE PART ---
20
21
22 @REM *** Create the distribution directories, populate them with lib sources ***
23
24 mkdir %DISTRIB%
25 mkdir %DISTRIB_BIN%
26 mkdir %DISTRIB_LIB%
27 xcopy /y /s lib %DISTRIB_LIB%
28 xcopy /y /s bin %DISTRIB_BIN%
29
30 @REM *** Generate a callable batch metalua.bat script ***
31
32 echo @set LUA_PATH=?.luac;?.lua;%DISTRIB_LIB%\?.luac;%DISTRIB_LIB%\?.lua > %DISTRIB_BIN%\metalua.bat
33 echo @set LUA_MPATH=?.mlua;%DISTRIB_LIB%\?.mlua >> %DISTRIB_BIN%\metalua.bat
34 echo @%LUA% %DISTRIB_LIB%\metalua.luac %%* >> %DISTRIB_BIN%\metalua.bat
35
36
37 @REM *** Compiling the parts of the compiler written in plain Lua ***
38
39 cd compiler
40 %LUAC% -o %DISTRIB_LIB%\metalua\bytecode.luac lopcodes.lua lcode.lua ldump.lua compile.lua
41 %LUAC% -o %DISTRIB_LIB%\metalua\mlp.luac lexer.lua gg.lua mlp_lexer.lua mlp_misc.lua mlp_table.lua mlp_meta.lua mlp_expr.lua mlp_stat.lua mlp_ext.lua
42 cd ..
43
44 @REM *** Bootstrap the parts of the compiler written in metalua ***
45
46 %LUA% %BASE%\build-utils\bootstrap.lua %BASE%\compiler\mlc.mlua output=%DISTRIB_LIB%\metalua\mlc.luac
47 %LUA% %BASE%\build-utils\bootstrap.lua %BASE%\compiler\metalua.mlua output=%DISTRIB_LIB%\metalua.luac
48
49 @REM *** Finish the bootstrap: recompile the metalua parts of the compiler with itself ***
50
51 call %DISTRIB_BIN%\metalua -vb -f compiler\mlc.mlua     -o %DISTRIB_LIB%\metalua\mlc.luac
52 call %DISTRIB_BIN%\metalua -vb -f compiler\metalua.mlua -o %DISTRIB_LIB%\metalua.luac
53
54 @REM *** Precompile metalua libraries ***
55 %LUA% %BASE%\build-utils\precompile.lua directory=%DISTRIB_LIB% command=%DISTRIB_BIN%\metalua