cross-lua.lua 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. local args = { ... }
  2. local b = require "tools.build"
  3. local builder = b.new_builder( ".build/cross-lua" )
  4. local utils = b.utils
  5. local sf = string.format
  6. builder:init( args )
  7. builder:set_build_mode( builder.BUILD_DIR_LINEARIZED )
  8. local output = 'luac.cross'
  9. local cdefs = '-DLUA_CROSS_COMPILER -O2'
  10. -- Lua source files and include path
  11. local lua_files = [[
  12. lapi.c lauxlib.c lbaselib.c lcode.c ldblib.c ldebug.c ldo.c ldump.c
  13. lfunc.c lgc.c llex.c lmathlib.c lmem.c loadlib.c lobject.c lopcodes.c
  14. lparser.c lrotable.c lstate.c lstring.c lstrlib.c ltable.c ltablib.c
  15. ltm.c lundump.c lvm.c lzio.c
  16. luac_cross/luac.c luac_cross/loslib.c luac_cross/print.c
  17. ../modules/linit.c
  18. ]]
  19. lua_files = lua_files:gsub( "\n" , "" )
  20. local lua_full_files = utils.prepend_path( lua_files, "app/lua" )
  21. local local_include = "-Iapp/include -Iinclude -Iapp/lua"
  22. -- Compiler/linker options
  23. builder:set_compile_cmd( sf( "gcc -O2 %s -Wall %s -c $(FIRST) -o $(TARGET)", local_include, cdefs ) )
  24. builder:set_link_cmd( "gcc -o $(TARGET) $(DEPENDS) -lm" )
  25. -- Build everything
  26. builder:make_exe_target( output, lua_full_files )
  27. builder:build()