Fixed bug 3262 - Premake scripts are not compatible with "Genie" (premake fork) jfverdon Genie (https://github.com/bkaradzic/genie) is a well known premake fork which uses internally Lua 5.3 (as opposed to version 5.1 used in premake4). As there is some Lua's API breaks in Lua 5.2, SDL premake scripts do not works with premake. The two incompatibilities I noticed were: * unhandle modes "rt" and "wt" for io.open. Has io.open opens files in text mode by default, the "t" flag is not needed (this flag is not supported in Genie). * os.execute signature change, the return value is a tuple from Lua 5.2, before it was just the called program exit code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
diff --git a/premake/premake4.lua b/premake/premake4.lua
index 1202c0e..a9e1b92 100755
--- a/premake/premake4.lua
+++ b/premake/premake4.lua
@@ -121,7 +121,7 @@ if _OPTIONS["help"] == nil then
end
local genFile = baseLoc .. "/SDL-gen.lua"
- local file = fileopen(genFile, "wt")
+ local file = fileopen(genFile, "w")
print("Generating " .. genFile .. "...")
-- begin generating the config header file
startGeneration(premakeConfigHeader, premakeTemplateHeader)
diff --git a/premake/util/sdl_check_compile.lua b/premake/util/sdl_check_compile.lua
index c373335..41205c6 100755
--- a/premake/util/sdl_check_compile.lua
+++ b/premake/util/sdl_check_compile.lua
@@ -101,6 +101,18 @@ local function cleanup_build()
os.remove("./premakecheck.stdout")
end
+local function os_execute(cmd)
+ if _ENV then
+ -- Lua 5.2 or greater
+ local cmdSuccess, textStatus, returnCode = os.execute(cmd)
+ return returnCode
+ else
+ -- Lua 5.1 or lesser
+ local returnCode = os.execute(cmd)
+ return returnCode
+ end
+end
+
-- Check if a source builds, links, and or/runs, where running depends on
-- linking and linking depends on building. The return from this function is
-- a triple, where the first is a boolean value indicating if it successfully
@@ -108,10 +120,10 @@ end
-- linked, and the third represents nil if it was not run or run correctly, or
-- the output from the program executed (may be empty for no output).
local function check_build_source(source, link, run)
- local file = fileopen("./premakecheck.c", "wt")
+ local file = fileopen("./premakecheck.c", "w")
file:write(source)
file:close()
- local result = os.execute(build_compile_line())
+ local result = os_execute(build_compile_line())
if not link then
cleanup_build()
if result == 0 then
@@ -125,13 +137,13 @@ local function check_build_source(source, link, run)
cleanup_build()
return false, false, nil -- no compile, no link, no run
end
- result = os.execute(build_link_line())
+ result = os_execute(build_link_line())
if not run or result ~= 0 then -- have to link to run
cleanup_build()
return true, result == 0, nil -- compile, maybe link, no run
end
- result = os.execute(build_run_line())
- local output = readfile("./premakecheck.stdout", "rt")
+ result = os_execute(build_run_line())
+ local output = readfile("./premakecheck.stdout", "r")
cleanup_build()
return true, true, output -- compile, link, ran
end
diff --git a/premake/util/sdl_gen_config.lua b/premake/util/sdl_gen_config.lua
index f0873e5..ec4eded 100755
--- a/premake/util/sdl_gen_config.lua
+++ b/premake/util/sdl_gen_config.lua
@@ -33,8 +33,8 @@ local insertLocation
-- This function begins config header generation given the name of the generated
-- file and the name of the template file to use.
function startGeneration(file, template)
- configFile = fileopen(file, "wt")
- templateFileContents = readfile(template, "rt")
+ configFile = fileopen(file, "w")
+ templateFileContents = readfile(template, "r")
insertLocation = templateFileContents:find(searchKey)
if insertLocation then
configFile:write(templateFileContents:sub(1, insertLocation - 1))