diff --git a/.hgsubstate b/.hgsubstate index 4ce0b665..cf2e15a4 100644 --- a/.hgsubstate +++ b/.hgsubstate @@ -1 +1 @@ -aaccdc16e9bb0b2b1a3cdc8855e0c27e7f920f1d modules/xcode +fb55ee49710c8f9a296219e5b948a294a282af29 modules/xcode diff --git a/CHANGES.txt b/CHANGES.txt index fadc1e9d..1c763e2f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -14,3 +14,5 @@ Since 5.0-alpha1: * Configuration baking and validation now skipped for execute only actions * os.findlib() now accepts paths to search as argument * Visual Studio .user files are now only generated if not empty +* Xcode4 exporter is now available +* Modules may now be loaded on demand where feasible diff --git a/scripts/embed.lua b/scripts/embed.lua index 23c61b65..9746ea61 100644 --- a/scripts/embed.lua +++ b/scripts/embed.lua @@ -110,6 +110,7 @@ table.insert(result, '\t"src/_premake_main.lua",') table.insert(result, '\t"src/_manifest.lua",') + table.insert(result, '\t"src/_modules.lua",') table.insert(result, "\tNULL") table.insert(result, "};") table.insert(result, "") @@ -134,6 +135,7 @@ appendScript(result, loadScript(path.join(_SCRIPT_DIR, "../src/_premake_main.lua"))) appendScript(result, loadScript(path.join(_SCRIPT_DIR, "../src/_manifest.lua"))) + appendScript(result, loadScript(path.join(_SCRIPT_DIR, "../src/_modules.lua"))) table.insert(result, "\tNULL") table.insert(result, "};") diff --git a/src/_modules.lua b/src/_modules.lua new file mode 100644 index 00000000..90730c36 --- /dev/null +++ b/src/_modules.lua @@ -0,0 +1,9 @@ +-- +-- _modules.lua +-- The list of core modules to preload on startup +-- Copyright (c) 2015 Jason Perkins and the Premake project +-- + + return { + "xcode", + } diff --git a/src/_premake_main.lua b/src/_premake_main.lua index 059b632d..24b9e63f 100644 --- a/src/_premake_main.lua +++ b/src/_premake_main.lua @@ -10,6 +10,7 @@ -- Load the collection of core scripts, required for everything else to work + local modules = dofile("_modules.lua") local manifest = dofile("_manifest.lua") for i = 1, #manifest do dofile(manifest[i]) @@ -32,6 +33,7 @@ return { m.installModuleLoader, m.prepareEnvironment, + m.preloadModules, m.runSystemScript, m.locateUserScript, m.prepareAction, @@ -62,9 +64,6 @@ function m.installModuleLoader() table.insert(package.loaders, 2, m.moduleLoader) - - -- TEMPORARY: I'm working on a different solution for this - require("xcode") end function m.moduleLoader(name) @@ -77,28 +76,20 @@ dir = base end - local function tryLoad(filename) - local chunk, err = loadfile(filename) - if not chunk and not err:startswith("No such file") then - error(err, 0) - end - return chunk - end + local full = dir .. "/" .. base .. ".lua" + local p = os.locate("modules/" .. full) or + os.locate(full) or + os.locate(name .. ".lua") - -- Premake standard is moduleName/moduleName.lua - local relPath = dir .. "/" .. base .. ".lua" - local chunk = tryLoad("modules/" .. relPath) - if not chunk then - chunk = tryLoad(relPath) - end - if not chunk then - chunk = tryLoad(name .. ".lua") - end - - if not chunk then + if not p then return "\n\tno file " .. name .. " on module paths" end + local chunk, err = loadfile(p) + if not chunk then + error(err, 0) + end + return chunk end @@ -115,6 +106,26 @@ end +--- +-- Load the required core modules that are shipped as part of Premake +-- and expected to be present at startup. +--- + + function m.preloadModules() + for i = 1, #modules do + local name = modules[i] + local preload = name .. "/_preload.lua" + local fn = os.locate("modules/" .. preload) or os.locate(preload) + + if fn then + include(fn) + else + require(name) + end + end + end + + --- -- Look for and run the system-wide configuration script; make sure any -- configuration scoping gets cleared before continuing. diff --git a/src/base/premake.lua b/src/base/premake.lua index 7f011d48..5b0c2f29 100644 --- a/src/base/premake.lua +++ b/src/base/premake.lua @@ -339,10 +339,14 @@ end -- Write a opening XML element for a UTF-8 encoded file. Used by -- several different files for different actions, so makes sense -- to have a common call for it. +-- +-- @param upper +-- If true, the encoding is written in uppercase. --- - function premake.xmlUtf8() - premake.outln('') + function premake.xmlUtf8(upper) + local encoding = iif(upper, "UTF-8", "utf-8") + premake.w('', encoding) end diff --git a/tests/testfx.lua b/tests/testfx.lua index 5024bc76..ed999133 100644 --- a/tests/testfx.lua +++ b/tests/testfx.lua @@ -266,16 +266,20 @@ end - function test.getproject(sln, i) + function test.getsolution(sln) premake.oven.bake() - sln = premake.global.getSolution(sln.name) + return premake.global.getSolution(sln.name) + end + + + function test.getproject(sln, i) + sln = test.getsolution(sln) return premake.solution.getproject(sln, i or 1) end function test.getconfig(prj, buildcfg, platform) - premake.oven.bake() - local sln = premake.global.getSolution(prj.solution.name) + sln = test.getsolution(prj.solution) prj = premake.solution.getproject(sln, prj.name) return premake.project.getconfig(prj, buildcfg, platform) end