From c897f9d13594061fb75274246d6288a717faca93 Mon Sep 17 00:00:00 2001 From: Atirut Wattanamongkol Date: Sat, 17 Apr 2021 20:58:10 +0700 Subject: [PATCH] Update make_release.lua Still have to be tested on Linux and optimized --- make_release.lua | 83 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 75 insertions(+), 8 deletions(-) diff --git a/make_release.lua b/make_release.lua index a3577c1..0b3862a 100644 --- a/make_release.lua +++ b/make_release.lua @@ -1,3 +1,17 @@ +print("INFO: Static builds may not be usable due to unfinished strings bug. Normal builds require argparse.") +local luaToUse = "lua53" + +-- Clear the build directory. +if os.getenv("OS") == "Windows_NT" then + os.execute("rmdir build /s /q") + os.execute("mkdir build") + os.execute("mkdir build\\linux") +else + os.execute("rm -rf build") + os.execute("mkdir build") + os.execute("mkdir build/inux") +end + local luaexec = { "5.4", "5.3", @@ -5,14 +19,67 @@ local luaexec = { "5.1", "jit" } +local luaCompPath = ({...})[1] or "" +local isLuaCompInstalled = true -os.execute("rm -rf build") -os.execute("mkdir build") -for i=1, #luaexec do - os.execute("luacomp -xlua"..luaexec[i].." -mluamin -O build/luacomp-"..luaexec[i].." src/init.lua") - os.execute("luacomp -xlua"..luaexec[i].." -mnone -O build/luacomp-static-"..luaexec[i].." src/staticinit.lua") - os.execute("chmod +x build/luacomp-"..luaexec[i]) - os.execute("chmod +x build/luacomp-static-"..luaexec[i]) +-- Check for LuaComp installation. +if os.getenv("OS") == "Windows_NT" then + if luaCompPath == "" then + print("LuaComp path not set. This is required for Windows") + print("To set the path to LuaComp, supply it as an argument to this program.") + os.exit() + end + isLuaCompInstalled = false +else + if (not io.open("/bin/luacomp", "r")) and luaCompPath == "" then + print("No existing installation of LuaComp found and LuaComp path is not set. Either make sure you have LuaComp installed or set the LuaComp path.") + print("To set the path to LuaComp, supply it as an argument to this program.") + os.exit() + elseif not io.open("/bin/luacomp", "r") then + isLuaCompInstalled = false + end end -os.execute("cp -v build/luacomp-".._VERSION:sub(5).." luacomp") \ No newline at end of file +-- Build Windows versions +if os.getenv("OS") == "Windows_NT" then + os.execute(luaToUse .. " " .. luaCompPath .. " ./src/init.lua -O ./build/luacomp.lua") + os.execute(luaToUse .. " " .. luaCompPath .. " ./src/staticinit.lua -O ./build/luacomp-static.lua") +else + if isLuaCompInstalled == true then + os.execute("luacomp ./src/init.lua -O ./build/luacomp.lua") + os.execute("luacomp ./src/staticinit.lua -O ./build/luacomp-static.lua") + else + os.execute(luaToUse .. " " .. luaCompPath .. " ./src/init.lua -O ./build/luacomp.lua") + os.execute(luaToUse .. " " .. luaCompPath .. " ./src/staticinit.lua -O ./build/luacomp-static.lua") + end +end + +-- Build Linux versions that are directly executable. +for _,version in ipairs(luaexec) do + print("Making release for Lua " .. version) + if os.getenv("OS") == "Windows_NT" then + os.execute(luaToUse .. " " .. luaCompPath .. " ./src/init.lua -O ./build/linux/luacomp-" .. version .. " --executable " .. version) + os.execute(luaToUse .. " " .. luaCompPath .. " ./src/staticinit.lua -O ./build/linux/luacomp-static-" .. version .. " --executable " .. version) + else + if isLuaCompInstalled == true then + os.execute("luacomp ./src/init.lua -O ./build/linux/luacomp-" .. version .. " --executable " .. version) + os.execute("luacomp ./src/staticinit.lua -O ./build/linux/luacomp-static-" .. version .. " --executable " .. version) + else + os.execute(luaToUse .. " " .. luaCompPath .. " ./src/init.lua -O ./build/linux/luacomp-" .. version .. " --executable " .. version) + os.execute(luaToUse .. " " .. luaCompPath .. " ./src/staticinit.lua -O ./build/linux/luacomp-static-" .. version .. " --executable " .. version) + end + end +end + +-- Original script for reference. + +-- os.execute("rm -rf build") +-- os.execute("mkdir build") +-- for i=1, #luaexec do +-- os.execute("luacomp -xlua"..luaexec[i].." -mluamin -O build/luacomp-"..luaexec[i].." src/init.lua") +-- os.execute("luacomp -xlua"..luaexec[i].." -mnone -O build/luacomp-static-"..luaexec[i].." src/staticinit.lua") +-- os.execute("chmod +x build/luacomp-"..luaexec[i]) +-- os.execute("chmod +x build/luacomp-static-"..luaexec[i]) +-- end + +-- os.execute("cp -v build/luacomp-".._VERSION:sub(5).." luacomp") \ No newline at end of file