diff --git a/src/_premake_main.lua b/src/_premake_main.lua index 38bdff80..f2153edc 100644 --- a/src/_premake_main.lua +++ b/src/_premake_main.lua @@ -14,18 +14,7 @@ -- Script-side program entry point. -- - function _premake_main(scriptpath) - - -- if running off the disk (in debug mode), load everything - -- listed in _manifest.lua; the list divisions make sure - -- everything gets initialized in the proper order. - - if (scriptpath) then - local scripts = dofile(scriptpath .. "/_manifest.lua") - for _,v in ipairs(scripts) do - dofile(scriptpath .. "/" .. v) - end - end + function _premake_main() -- Seed the random number generator so actions don't have to do it themselves diff --git a/src/host/premake.c b/src/host/premake.c index 59536919..b84b63d2 100755 --- a/src/host/premake.c +++ b/src/host/premake.c @@ -322,8 +322,28 @@ int load_builtin_scripts(lua_State* L) return !OKAY; } - /* run the bootstrapping script */ + /* load the manifest, which includes all the required scripts */ scripts_path = lua_tostring(L, -1); + filename = lua_pushfstring(L, "%s/_manifest.lua", scripts_path); + if (luaL_dofile(L, filename)) + { + printf(ERROR_MESSAGE, lua_tostring(L, -1)); + return !OKAY; + } + + lua_pushnil(L); + while (lua_next(L, -2)) + { + filename = lua_pushfstring(L, "%s/%s", scripts_path, lua_tostring(L, -1)); + if (luaL_dofile(L, filename)) { + printf(ERROR_MESSAGE, lua_tostring(L, -1)); + return !OKAY; + } + lua_pop(L, 2); + } + lua_pop(L, 1); + + /* run the bootstrapping script */ filename = lua_pushfstring(L, "%s/_premake_main.lua", scripts_path); if (luaL_dofile(L, filename)) { @@ -337,8 +357,7 @@ int load_builtin_scripts(lua_State* L) /* hand off control to the scripts */ lua_getglobal(L, "_premake_main"); - lua_pushstring(L, scripts_path); - if (lua_pcall(L, 1, 1, -3) != OKAY) + if (lua_pcall(L, 0, 1, -3) != OKAY) { printf(ERROR_MESSAGE, lua_tostring(L, -1)); return !OKAY;