From b59266f42e73b14074271ffdce61e861de0228aa Mon Sep 17 00:00:00 2001 From: Damien Courtois Date: Wed, 15 Apr 2015 12:21:00 +0200 Subject: [PATCH] modules are now correctly loaded in all situations --- src/_premake_main.lua | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/_premake_main.lua b/src/_premake_main.lua index e8bce7c2..470ef74b 100644 --- a/src/_premake_main.lua +++ b/src/_premake_main.lua @@ -47,17 +47,32 @@ end local full = dir .. "/" .. base .. ".lua" - local p = os.locate("modules/" .. full) or - os.locate(full) or - os.locate(name .. ".lua") - if not p then - -- try to load from the embedded script - p = "$/" .. full + -- list of paths where to look for the module + local paths = { + "modules/" .. full, + full, + name .. ".lua" + } + + -- try to locate the module + for _, p in ipairs(paths) do + local file = os.locate(p) + if file then + local chunk, err = loadfile(file) + if chunk then + return chunk + end + end end - local chunk, err = loadfile(p) - return chunk + -- didn't find the module in supported paths, try the embedded scripts + for _, p in ipairs(paths) do + local chunk, err = loadfile("$/" .. p) + if chunk then + return chunk + end + end end