Add bam 0.5.0 support while retaining 0.4.0 compatiblity

This commit is contained in:
heinrich5991 2016-08-03 00:01:50 +02:00
parent 3341e18d13
commit 64ca2cfde9
2 changed files with 13 additions and 4 deletions

View file

@ -1,4 +1,3 @@
CheckVersion("0.4")
target_family = os.getenv("TARGET_FAMILY")
if target_family then

View file

@ -1,4 +1,15 @@
function loadfile_(filename, env)
local file
if _VERSION == "Lua 5.1" then
file = loadfile(filename)
setfenv(file, env)
else
file = loadfile(filename, nil, env)
end
return file
end
--[[@GROUP Configuration@END]]--
--[[@FUNCTION
@ -72,13 +83,13 @@ function NewConfig(on_configured_callback)
end
config.Load = function(self, filename)
local options_func = loadfile(filename)
local options_table = {}
local options_func = loadfile_(filename, options_table)
if not options_func then
print("auto configuration")
self:Config(filename)
options_func = loadfile(filename)
options_func = loadfile_(filename, options_table)
end
if options_func then
@ -86,7 +97,6 @@ function NewConfig(on_configured_callback)
for k,v in pairs(self.options) do
options_table[v.name] = {}
end
setfenv(options_func, options_table)
-- this is to make sure that we get nice error messages when
-- someone sets an option that isn't valid.