From 64ca2cfde9dc4857e338c3953cfee1138f3c4fb2 Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Wed, 3 Aug 2016 00:01:50 +0200 Subject: [PATCH] Add bam 0.5.0 support while retaining 0.4.0 compatiblity --- bam.lua | 1 - configure.lua | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/bam.lua b/bam.lua index cee7d2a38..8b0ee603f 100644 --- a/bam.lua +++ b/bam.lua @@ -1,4 +1,3 @@ -CheckVersion("0.4") target_family = os.getenv("TARGET_FAMILY") if target_family then diff --git a/configure.lua b/configure.lua index f06b77d5a..de16fe587 100644 --- a/configure.lua +++ b/configure.lua @@ -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.