Merge pull request #1668 from starkos/v6-bootstrapping

Fix v6 bootstrapping from v5
This commit is contained in:
starkos 2021-07-15 07:59:52 -04:00 committed by GitHub
commit 64f1b3494a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 5 deletions

View File

@ -68,6 +68,12 @@
name .. ".lua"
}
-- If this module is being requested by an embedded script, favor embedded modules.
-- This helps prevent local scripts from interfering with release build bootstrapping.
if string.startswith(_SCRIPT_DIR, '$/') then
table.insert(paths, 1, '$/' .. full)
end
-- try to locate the module
for _, p in ipairs(paths) do
local file = os.locate(p)
@ -118,8 +124,9 @@
local preloader = name .. "/_preload.lua"
preloader = os.locate("modules/" .. preloader) or os.locate(preloader)
if preloader then
m._preloaded[name] = include(preloader)
if not m._preloaded[name] then
local modulePath = path.getdirectory(preloader)
m._preloaded[modulePath] = include(preloader)
if not m._preloaded[modulePath] then
p.warn("module '%s' should return function from _preload.lua", name)
end
else
@ -306,9 +313,11 @@
end
-- any modules need to load to support this project?
for module, func in pairs(m._preloaded) do
if not package.loaded[module] and shouldLoad(func) then
require(module)
for modulePath, func in pairs(m._preloaded) do
local moduleName = path.getbasename(modulePath)
if not package.loaded[moduleName] and shouldLoad(func) then
_SCRIPT_DIR = modulePath
require(moduleName)
end
end
end

View File

@ -36,6 +36,12 @@ int os_locate(lua_State* L)
for (i = 1; i <= nArgs; ++i) {
const char* name = lua_tostring(L, i);
/* Direct path to an embedded file? */
if (name[0] == '$' && name[1] == '/' && premake_find_embedded_script(name + 2)) {
lua_pushvalue(L, i);
return 1;
}
/* Direct path to file? Return as absolute path */
if (do_isfile(L, name)) {
lua_pushcfunction(L, path_getabsolute);