Merge Xcode and module loading improvements
This commit is contained in:
commit
aab1e899bf
@ -1 +1 @@
|
||||
aaccdc16e9bb0b2b1a3cdc8855e0c27e7f920f1d modules/xcode
|
||||
fb55ee49710c8f9a296219e5b948a294a282af29 modules/xcode
|
||||
|
@ -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
|
||||
|
@ -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, "};")
|
||||
|
9
src/_modules.lua
Normal file
9
src/_modules.lua
Normal file
@ -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",
|
||||
}
|
@ -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.
|
||||
|
@ -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('<?xml version="1.0" encoding="utf-8"?>')
|
||||
function premake.xmlUtf8(upper)
|
||||
local encoding = iif(upper, "UTF-8", "utf-8")
|
||||
premake.w('<?xml version="1.0" encoding="%s"?>', encoding)
|
||||
end
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user