Rework --scripts handling to allow module loading

The --scripts argument should not point to the top-level Premake folder rather than its src/ folder; this allows the modules/ folder to also be referenced along that same path.
This commit is contained in:
Jason Perkins 2014-10-16 17:32:09 -04:00
parent 636f886795
commit a0ab11bda6
3 changed files with 6 additions and 14 deletions

View File

@ -90,9 +90,7 @@
-- Generate an index of the script file names. Script names are stored
-- relative to the directory containing the manifest, i.e. the main
-- Xcode script, which is at $/modules/xcode/xcode.lua is stored as
-- "xcode/xcode.lua". Core scripts currently get special treatment and
-- are stored as "base/os.lua" instead of "core/base/os.lua"; I would
-- like to treat core like just another module eventually.
-- "xcode/xcode.lua".
table.insert(result, "const char* builtin_scripts_index[] = {")
@ -105,18 +103,12 @@
for fi = 1, #files do
local filename = path.join(manifestDir, files[fi])
filename = path.getrelative(baseDir, filename)
-- core files fix-up for backward compatibility
if filename:startswith("src/") then
filename = filename:sub(5)
end
table.insert(result, '\t"' .. filename .. '",')
end
end
table.insert(result, '\t"_premake_main.lua",')
table.insert(result, '\t"_manifest.lua",')
table.insert(result, '\t"src/_premake_main.lua",')
table.insert(result, '\t"src/_manifest.lua",')
table.insert(result, "\tNULL")
table.insert(result, "};")
table.insert(result, "")

View File

@ -164,7 +164,7 @@
function p.main.moduleLoader(name)
local shortName = name .. "/" .. name .. ".lua"
local longName = "modules/" .. shortName
local chunk = loadfile(shortName) or loadfile(longName)
local chunk = loadfile(longName) or loadfile(shortName)
if chunk then
return chunk
else

View File

@ -135,7 +135,7 @@ int premake_execute(lua_State* L, int argc, const char** argv)
}
/* load the main script */
if (luaL_dofile(L, "_premake_main.lua") != OKAY) {
if (luaL_dofile(L, "src/_premake_main.lua") != OKAY) {
printf(ERROR_MESSAGE, lua_tostring(L, -1));
return !OKAY;
}
@ -312,7 +312,7 @@ int premake_load_embedded_script(lua_State* L, const char* filename)
#if !defined(NDEBUG)
if (!warned) {
warned = 1;
printf("** warning: using embedded scripts; use /scripts argument to load from files\n");
printf("** warning: using embedded script '%s'; use /scripts argument to load from files\n", filename);
}
#endif