Skip to content
This repository was archived by the owner on Nov 20, 2020. It is now read-only.

Commit e9a0cca

Browse files
committed
Finished CMake based build
1 parent f7bab74 commit e9a0cca

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
lines changed

CMakeLists.txt

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,39 +16,49 @@ set ( SRC ${CMAKE_CURRENT_SOURCE_DIR}/src )
1616
set ( BIN ${CMAKE_CURRENT_BINARY_DIR})
1717
set ( LIB ${BIN}/lib )
1818

19-
message ( STATUS "Compiling metalua" )
19+
message ( STATUS "Preparing the metalua libraries" )
2020

2121
file ( COPY ${SRC}/lib/ DESTINATION ${LIB} PATTERN ".in" EXCLUDE )
2222
configure_file ( ${SRC}/lib/metalua/package2.lua.in ${LIB}/metalua/package2.lua )
23-
configure_file ( ${SRC}/compiler/metalua.mlua.in ${BIN}/metalua.mlua )
23+
configure_file ( ${SRC}/compiler/metalua.mlua.in ${LIB}/metalua.mlua )
24+
25+
message ( STATUS "Compiling the parts of the compiler written in plain Lua" )
2426

2527
execute_process (
2628
COMMAND ${LUAC} -o ${LIB}/metalua/bytecode.luac
2729
lopcodes.lua lcode.lua ldump.lua compile.lua
28-
WORKING_DIRECTORY ${SRC}/compiler )
29-
30-
execute_process (
3130
COMMAND ${LUAC} -o ${LIB}/metalua/mlp.luac
3231
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
3332
WORKING_DIRECTORY ${SRC}/compiler )
3433

34+
message ( STATUS "Bootstrap the parts of the compiler written in metalua" )
35+
3536
execute_process (
36-
COMMAND ${LUA} ${SRC}/build-utils/bootstrap.lua
37-
${SRC}/compiler/mlc.mlua output=${LIB}/metalua/mlc.luac
38-
WORKING_DIRECTORY ${SRC}/lib )
37+
COMMAND ${LUA} ${SRC}/build-utils/bootstrap.lua ${SRC}/compiler/mlc.mlua output=${LIB}/metalua/mlc.luac
38+
COMMAND ${LUA} ${SRC}/build-utils/bootstrap.lua ${LIB}/metalua.mlua output=${LIB}/metalua.luac
39+
WORKING_DIRECTORY ${LIB} )
3940

41+
message ( STATUS "Finish the bootstrap: recompile the metalua parts of the compiler with itself" )
42+
4043
execute_process (
41-
COMMAND ${LUA} ${SRC}/build-utils/bootstrap.lua
42-
${BIN}/metalua.mlua output=${LIB}/metalua.luac
43-
WORKING_DIRECTORY ${SRC}/lib )
44+
COMMAND ${LUA} ${LIB}/metalua.luac -vb -f ${SRC}/compiler/mlc.mlua -o ${LIB}/metalua/mlc.luac
45+
COMMAND ${LUA} ${LIB}/metalua.luac -vb -f ${LIB}/metalua.mlua -o ${LIB}/metalua.luac
46+
WORKING_DIRECTORY ${LIB} )
47+
48+
message ( STATUS "Precompile metalua libraries" )
4449

45-
# TODO:
46-
#call %DISTRIB_BIN%\metalua -vb -f compiler\mlc.mlua -o %DISTRIB_LIB%\metalua\mlc.luac
47-
#call %DISTRIB_BIN%\metalua -vb -f compiler\metalua.mlua -o %DISTRIB_LIB%\metalua.luac
48-
#%LUA% %BASE%\build-utils\precompile.lua directory=%DISTRIB_LIB% command=%DISTRIB_BIN%\metalua
50+
file ( GLOB_RECURSE SRCS RELATIVE ${LIB} "${LIB}/*.mlua")
51+
foreach ( S ${SRCS} )
52+
get_filename_component ( P ${S} PATH )
53+
get_filename_component ( D ${S} NAME_WE )
54+
message ( STATUS "Compiling ${S} to ${P}/${D}.luac" )
55+
execute_process (
56+
COMMAND ${LUA} ${LIB}/metalua.luac ${S} -o ${P}/${D}.luac
57+
WORKING_DIRECTORY ${LIB} )
58+
endforeach ( S )
4959

60+
install_lua_executable ( metalua ${LIB}/metalua.luac )
5061
install ( DIRECTORY ${LIB}/ DESTINATION ${INSTALL_LMOD} PATTERN "*.in" EXCLUDE)
51-
install_lua_executable ( metalua ${BIN}/lib/metalua.luac )
5262
install_doc ( doc/ )
5363
install_foo ( junk/ )
5464
install_data ( INSTALL.TXT README.TXT LICENSE )

src/compiler/metalua.mlua.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--*-lua-*- Set as a metalua file because it requires some metalua libs
22

3-
package.path = './?.luac;'..(_PROGDIR or "") .. "/@INSTALL_LMOD@/?.luac;"..package.path
3+
package.path = './?.luac;'..(_PROGDIR or "") .. "/../@INSTALL_LMOD@/?.luac;"..package.path
44

55
--require 'verbose_require'
66

0 commit comments

Comments
 (0)