diff options
| -rw-r--r-- | all_in_one.patch | 38 | ||||
| -rw-r--r-- | hardcoded.lua | 6 | ||||
| -rwxr-xr-x | init | 94 |
3 files changed, 113 insertions, 25 deletions
diff --git a/all_in_one.patch b/all_in_one.patch new file mode 100644 index 0000000..234bcb7 --- /dev/null +++ b/all_in_one.patch | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | --- "binary/all_in_one.orig" 2024-09-23 13:31:16.489277700 -0500 | ||
| 2 | +++ "binary/all_in_one" 2024-09-23 13:31:14.032152500 -0500 | ||
| 3 | @@ -406,27 +406,6 @@ | ||
| 4 | fd:write(reindent_c(table.concat(out, "\n"))) | ||
| 5 | fd:close() | ||
| 6 | |||
| 7 | - assert(deps.check_lua_incdir(cfg.variables)) | ||
| 8 | - assert(deps.check_lua_libdir(cfg.variables)) | ||
| 9 | - | ||
| 10 | - cmd = table.concat(filter_in(nonnull, { | ||
| 11 | - CC, "-o", TARGET_DIR .. "/" .. program_name .. ".exe", | ||
| 12 | - "-I", cfg.variables.LUA_INCDIR, | ||
| 13 | - if_platform("unix", "-rdynamic"), | ||
| 14 | - "-Os", | ||
| 15 | - c_filename, | ||
| 16 | - "-L", cfg.variables.LUA_LIBDIR, | ||
| 17 | - table.concat(a_files, " "), | ||
| 18 | - --if_platform("unix", cfg.variables.LUA_LIBDIR .. "/" .. cfg.variables.LUALIB:gsub("%.so.*$", ".a")), | ||
| 19 | - --if_platform("windows", "mingw/liblua.a"), -- FIXME | ||
| 20 | - cfg.variables.LUA_LIBDIR .. "/" .. cfg.variables.LUALIB:gsub("%.so.*$", ".a"), | ||
| 21 | - if_platform("unix", "-ldl"), | ||
| 22 | - if_platform("unix", "-lpthread"), | ||
| 23 | - if_platform("windows", "-mconsole -mwindows"), | ||
| 24 | - "-lm" | ||
| 25 | - }), " ") | ||
| 26 | - print(cmd) | ||
| 27 | - os.execute(cmd) | ||
| 28 | end | ||
| 29 | |||
| 30 | -------------------------------------------------------------------------------- | ||
| 31 | @@ -500,4 +479,6 @@ | ||
| 32 | generate(MAIN_PROGRAM, "src", { EXCLUDE, "^bin/?" }) | ||
| 33 | end | ||
| 34 | |||
| 35 | -main() | ||
| 36 | +cfg.init() | ||
| 37 | +fs.init() | ||
| 38 | +generate(MAIN_PROGRAM, "src", {EXCLUDE, "^bin/?"}) | ||
diff --git a/hardcoded.lua b/hardcoded.lua new file mode 100644 index 0000000..9be83d8 --- /dev/null +++ b/hardcoded.lua | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | return { | ||
| 2 | SYSTEM = "windows", | ||
| 3 | PROCESSOR = "x86", | ||
| 4 | FORCE_CONFIG = true, | ||
| 5 | IS_BINARY = true, | ||
| 6 | } | ||
| @@ -3,25 +3,32 @@ | |||
| 3 | if [ -e libluajit.a ]; then | 3 | if [ -e libluajit.a ]; then |
| 4 | mv libluajit.a liblua.a | 4 | mv libluajit.a liblua.a |
| 5 | fi | 5 | fi |
| 6 | cd luarocks/binary | 6 | tar -xvzf lua-*.tar.gz --directory="lua" --strip-components=1 |
| 7 | mkdir -p build-windows-deps-cicd/lib | 7 | mv hardcoded.lua luarocks/src/core/hardcoded.lua |
| 8 | cd build-windows-deps-cicd/lib | 8 | cd luarocks |
| 9 | cp /root/liblua.a . | 9 | mkdir build-binary |
| 10 | cp /root/libssl.a . | 10 | patch -p1 -i /root/luarocks-packaging/all_in_one.patch |
| 11 | cp /root/libz.a . | 11 | LUAROCKS_CROSS_COMPILING=1 lua5.4 binary/all_in_one |
| 12 | cp /root/libbz2.a . | ||
| 13 | cd .. | ||
| 14 | mkdir bin | ||
| 15 | cd bin | ||
| 16 | cp /root/*.exe . | ||
| 17 | |||
| 18 | mkdir -p windows-deps-cicd/lib | ||
| 19 | 12 | ||
| 20 | cd ../../.. | 13 | #cd luarocks/binary |
| 21 | LUA_BINDIR=binary/build-windows-deps-cicd/bin | 14 | # mkdir -p build-windows-deps-cicd/lib |
| 22 | ./configure --disable-incdir-check --with-lua=binary/build-windows-deps-cicd/bin --with-lua-lib=binary/build-windows-deps/lib | 15 | # cd build-windows-deps-cicd/lib |
| 23 | make -f binary/Makefile.windows BUILD_WINDOWS_DEPS_DIR= | 16 | # cp /root/liblua.a . |
| 24 | LUAROCKS_CROSS_COMPILING=1 make binary LUA_DIR=binary/build-windows-deps-cicd/bin CC=gcc NM=nm BINARY_PLATFORM=windows | 17 | # cp /root/libssl.a . |
| 18 | # cp /root/libz.a . | ||
| 19 | # cp /root/libbz2.a . | ||
| 20 | # cd .. | ||
| 21 | # mkdir bin | ||
| 22 | # cd bin | ||
| 23 | # cp /root/*.exe . | ||
| 24 | # | ||
| 25 | # mkdir -p windows-deps-cicd/lib | ||
| 26 | # | ||
| 27 | # cd ../../.. | ||
| 28 | #LUA_BINDIR=binary/build-windows-deps-cicd/bin | ||
| 29 | #./configure --disable-incdir-check --with-lua=binary/build-windows-deps-cicd/bin --with-lua-lib=binary/build-windows-deps/lib | ||
| 30 | #make -f binary/Makefile.windows BUILD_WINDOWS_DEPS_DIR= | ||
| 31 | #LUAROCKS_CROSS_COMPILING=1 make binary LUA_DIR=binary/build-windows-deps-cicd/bin CC=gcc NM=nm BINARY_PLATFORM=windows | ||
| 25 | # all_in_one generates a series of files: | 32 | # all_in_one generates a series of files: |
| 26 | # dir .. "/luarocks/core/hardcoded.lua" | 33 | # dir .. "/luarocks/core/hardcoded.lua" |
| 27 | # | 34 | # |
| @@ -50,13 +57,50 @@ LUAROCKS_CROSS_COMPILING=1 make binary LUA_DIR=binary/build-windows-deps-cicd/bi | |||
| 50 | # ---------------------- | 57 | # ---------------------- |
| 51 | # Lets modify all_in_one: delete the last line that calls main() and replace it | 58 | # Lets modify all_in_one: delete the last line that calls main() and replace it |
| 52 | # with: | 59 | # with: |
| 53 | cfg.init() | 60 | # cfg.init() |
| 54 | cfg.variables.LUA_INCDIR_OK = true | 61 | # cfg.variables.LUA_INCDIR_OK = true |
| 55 | cfg.variables.LUA_LIBDIR_OK = true | 62 | # cfg.variables.LUA_LIBDIR_OK = true |
| 56 | fs.init() | 63 | # fs.init() |
| 57 | generate(MAIN_PROGRAM, "src", {EXCLUDE, "^bin/?"}) | 64 | # generate(MAIN_PROGRAM, "src", {EXCLUDE, "^bin/?"}) |
| 58 | 65 | ||
| 59 | # Make the output directory | 66 | # Make the output directory |
| 60 | mkdir build-binary | 67 | # mkdir build-binary |
| 61 | # Then call it like: | 68 | # Then call it like: |
| 62 | LUAROCKS_CROSS_COMPILING=1 lua5.4 binary/all_in_one | 69 | # LUAROCKS_CROSS_COMPILING=1 lua5.4 binary/all_in_one |
| 70 | |||
| 71 | # Patches to make all_in_one work with lua 5.1: | ||
| 72 | # Lua 5.1 never defined LUA_OK, which all_in_one uses to check luaL_loadbuffer(), | ||
| 73 | # define it in the preamble if it doesn't already exist. | ||
| 74 | |||
| 75 | #ifndef LUA_OK | ||
| 76 | #define LUA_OK 0 | ||
| 77 | #endif | ||
| 78 | |||
| 79 | # Lua 5.1 doesn't define lua_copy or luaL_traceback, | ||
| 80 | # for lua_copy, we can rewrite with lua_replace() since we're moving the top element. | ||
| 81 | # line 137: lua_replace(L,3); | ||
| 82 | # | ||
| 83 | # Lua 5.1 doesn't define luaL_traceback(), here's what it looks like in 5.1 lua.c: | ||
| 84 | #ifndef luaL_traceback | ||
| 85 | # static inline void | ||
| 86 | # luaL_traceback(lua_State *L, lua_State *L1, const char *msg, int level){ | ||
| 87 | # lua_getfield(L, LUA_GLOBALSINDEX, "debug"); | ||
| 88 | # if(!lua_istable(L,-1)){ | ||
| 89 | # lua_pop(L,1); | ||
| 90 | # return; | ||
| 91 | # } | ||
| 92 | # lua_getfield(L, -1, "traceback"); | ||
| 93 | # if(!lua_isfunction(L,-1)){ | ||
| 94 | # lua_pop(L,2); | ||
| 95 | # return; | ||
| 96 | # } | ||
| 97 | # lua_pushthread(L1); | ||
| 98 | # lua_pushstring(L,msg); | ||
| 99 | # lua_pushnumber(L,level); | ||
| 100 | # lua_call(L,3,1); | ||
| 101 | # return; | ||
| 102 | # } | ||
| 103 | #endif | ||
| 104 | |||
| 105 | # Finally, use gcc to build: | ||
| 106 | #gcc -o build-binary/luarocks.exe -Os build-binary/luarocks.exe.c -I/root/lua/src /root/libz2.a /root/libssl.a /root/libz.a /root/liblua.a -mconsole -mwindows -lm | ||
