all: setenv.sh lua libraries install-lua bin-libraries compiler compile-libraries
endif
-install-lua: lua
- mkdir -p $(TARGET_BIN_PATH)
+install-lua: lua target-dirs
cp $(LUA_VM_DIR)/$(RUN) $(LUA_VM_DIR)/$(COMPILE) $(TARGET_BIN_PATH)/
-setenv.sh: config
- mkdir -p $(TARGET_BIN_PATH)
- mkdir -p $(TARGET_LUA_PATH)
- mkdir -p $(TARGET_LUA_CPATH)
+setenv.sh: config target-dirs
echo '#!/bin/bash' > $@
echo 'export LUA_PATH="$(LUA_PATH)"' >> $@
echo 'export LUA_CPATH="$(LUA_CPATH)"' >> $@
echo 'export PATH=$(TARGET_BIN_PATH):$$PATH' >> $@
chmod a+x $@
+
+copy-libraries: lib/ target-dirs
+
copy-libraries: lib/
mkdir -p $(TARGET_LUA_PATH)
cp -Rp lib/* $(TARGET_LUA_PATH)/
done
compiler: copy-libraries bin-libraries
- $(MAKE) -C $@ $(PLATFORM)
+ LUA_PATH="$(LUA_PATH)" LUA_CPATH="$(LUA_CPATH)" LUA_MPATH="$(LUA_MPATH)" $(MAKE) -C $@ $(PLATFORM)
bin-libraries:
$(MAKE) -C binlibs $(PLATFORM) install
lua: $@
- $(MAKE) -C $@ $(PLATFORM)
+ $(MAKE) -C $@ $(PLATFORM)
clean:
$(MAKE) -C compiler clean
$(MAKE) -C binlibs clean
+target-dirs: $(TARGET_BIN_PATH) $(TARGET_LUA_PATH) $(TARGET_LUA_CPATH)
+
+$(TARGET_BIN_PATH) $(TARGET_LUA_PATH) $(TARGET_LUA_CPATH):
+ mkdir -p $@
+
.PHONY: all libraries lua bin-libraries copy-libraries compile-libraries compiler
mkdir -p $(TARGET_LUA_CPATH)
cp $(LIBS) $(TARGET_LUA_CPATH)
+# TODO [EVE] there is still a question, how to remove dlls,
+# cause clean knows nothing about platform
clean:
-rm *.o *.$(LIBEXT)
local src_file = io.open (src_filename, 'r')
local src = src_file:read '*a'; src_file:close()
local ast = mlc.ast_of_luastring (src)
- local proto = bytecode.metalua_compile (ast)
+ local proto = bytecode.metalua_compile (ast, src_filename)
local dump = bytecode.dump_string (proto)
local dst_filename = src_filename:gsub ("%.mlua$", ".luac")
local dst_file = io.open (dst_filename, 'wb')
if a then
debugf ("[L:%i K:%i T:%s %q]", a.line or -1, a.char or -1,
a.tag or '<none>', a[1])
- self.lastline = a.lineinfo.last
- end
+ end
+ self.lastline = a.lineinfo.last
end
return a or eof_token
end
st, ast = spring_pcall('mlc.ast_of_luafile', f, '@'..f)
-- Isolate each file in a separate fenv
ast = +{ function (...) -{ast} end (...) }
+ ast.source = '@'..f -- TODO [EVE]
+ code.source = '@'..f -- TODO [EVE]
last_file = ast
end
if not st then os.exit (AST_COMPILE_ERROR_NUMBER) end
-- The last file returns the whole chunk's result
if last_file then
local c = table.shallow_copy(last_file)
- last_file <- `Return{ origin = c.origin, c }
+ last_file <- `Return{ source = c.source, c }
end
-------------------------------------------------------------------
if cfg['print-ast'] then
verb_print "Resulting AST:"
for x in values(code) do
--- [[ Get rid of fenv isolation cruft
- match x with
- | +{stat: return function(...) -{ast} end (...) }
- | +{expr: function(...) -{ast} end (...) } -> x=ast
- | _ ->
- end
---]]
- printf("--- AST From %s: ---", table.tostring(x.origin, 'nohash'))
+ printf("--- AST From %s: ---", table.tostring(x.source, 'nohash'))
--if x.origin.tag=='File' then x=x[1][2][1] end
table.print(x, 80, 'nohash')
end
return nil
end
+ if x then x.source = name end -- TODO [EVE] store debug info in the special part of ast
+
POINT 'ast', 'table' -- x is the AST
- x = bytecode.metalua_compile(x)
- x.source = name
+ x = bytecode.metalua_compile(x, name or x.source)
POINT 'proto', 'table'
x = bytecode.dump_string (x)
POINT 'luacstring', 'string' -- normally x is a bytecode dump
# Platforms currently supported: mingw, macosx.
# Feel welcome to contribute additional ones! :)
-PLATFORM = none
+PLATFORM = linux
PLATFORMS = macosx mingw linux
ifeq ($(PLATFORM), mingw)
LIBEXT = dll
MKLIB = gcc -shared
- LUA_BINARIES = $(COMPILE).exe $(RUN).exe metalua.dll
+ LUALIB = ../lua/lua51.dll
+ LDFLAGS = $(LUALIB)
+ LUA_BINARIES = $(COMPILE).exe $(RUN).exe lua51.dll
endif
ifeq ($(PLATFORM), linux)
$(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \
"AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \
"MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe
- $(MAKE) "LUAC_T=luac.exe" luac.exe
+ $(MAKE) "LUA_A=lua51.dll" "LUAC_T=luac.exe" "MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" luac.exe
posix:
$(MAKE) all MYCFLAGS=-DLUA_USE_POSIX
# define LUAI_FUNC LUA_API
# define LUAI_DATA LUA_API
#else /* Metalua: Original version, disabled */
-#if defined(luaall_c)
-#define LUAI_FUNC static
-#define LUAI_DATA /* empty */
-
-#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
- defined(__ELF__)
-#define LUAI_FUNC __attribute__((visibility("hidden"))) extern
-#define LUAI_DATA LUAI_FUNC
-
-#else
-#define LUAI_FUNC extern
-#define LUAI_DATA extern
-#endif
+# if defined(luaall_c)
+# define LUAI_FUNC static
+# define LUAI_DATA /* empty */
+# elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
+ defined(__ELF__)
+# define LUAI_FUNC __attribute__((visibility("hidden"))) extern
+# define LUAI_DATA LUAI_FUNC
+# else
+# define LUAI_FUNC extern
+# define LUAI_DATA extern
+# endif
#endif