Ported build configurations

This commit is contained in:
starkos 2009-11-09 21:16:34 +00:00
parent 382aed3e93
commit 0273520f02
5 changed files with 323 additions and 306 deletions

View File

@ -331,6 +331,135 @@
end
function xcode.PBXVariantGroup(tr)
_p('/* Begin PBXVariantGroup section */')
tree.traverse(tr, {
onbranch = function(node)
if node.kind == "vgroup" then
_p(2,'%s /* %s */ = {', node.id, node.name)
_p(3,'isa = PBXVariantGroup;')
_p(3,'children = (')
for _, lang in ipairs(node.children) do
_p(4,'%s /* %s */,', lang.id, lang.name)
end
_p(3,');')
_p(3,'name = %s;', node.name)
_p(3,'sourceTree = "<group>";')
_p(2,'};')
end
end
})
_p('/* End PBXVariantGroup section */')
_p('')
end
function xcode.XCBuildConfigurationBlock(tr, target, cfg)
_p(2,'%s /* %s */ = {', target.configids[cfg.name], cfg.name)
_p(3,'isa = XCBuildConfiguration;')
_p(3,'buildSettings = {')
_p(4,'ALWAYS_SEARCH_USER_PATHS = NO;')
local outdir = path.getdirectory(cfg.buildtarget.bundlepath)
if outdir ~= "." then
_p(4,'CONFIGURATION_BUILD_DIR = %s;', outdir)
end
if cfg.flags.Symbols then
_p(4,'COPY_PHASE_STRIP = NO;')
end
_p(4,'GCC_DYNAMIC_NO_PIC = NO;')
if cfg.flags.Symbols then
_p(4,'GCC_ENABLE_FIX_AND_CONTINUE = YES;')
end
_p(4,'GCC_MODEL_TUNING = G5;')
if #cfg.defines > 0 then
_p(4,'GCC_PREPROCESSOR_DEFINITIONS = (')
_p(table.implode(cfg.defines, "\t\t\t\t", ",\n"))
_p(4,');')
end
if tr.infoplist then
_p(4,'INFOPLIST_FILE = %s;', tr.infoplist.path)
end
_p(4,'PRODUCT_NAME = %s;', cfg.buildtarget.basename)
_p(4,'SYMROOT = %s;', cfg.objectsdir)
_p(3,'};')
_p(3,'name = %s;', cfg.name)
_p(2,'};')
end
function xcode.XCBuildConfigurationDefault(tr, cfg)
_p(2,'%s /* %s */ = {', tr.configids[cfg.name], cfg.name)
_p(3,'isa = XCBuildConfiguration;')
_p(3,'buildSettings = {')
_p(4,'ARCHS = "$(ARCHS_STANDARD_32_BIT)";')
_p(4,'GCC_C_LANGUAGE_STANDARD = c99;')
_p(4,'GCC_WARN_ABOUT_RETURN_TYPE = YES;')
_p(4,'GCC_WARN_UNUSED_VARIABLE = YES;')
_p(4,'ONLY_ACTIVE_ARCH = YES;')
_p(4,'PREBINDING = NO;')
_p(4,'SDKROOT = macosx10.5;')
_p(4,'SYMROOT = %s;', cfg.objectsdir)
_p(3,'};')
_p(3,'name = %s;', cfg.name)
_p(2,'};')
end
function xcode.XCBuildConfiguration(tr)
_p('/* Begin XCBuildConfiguration section */')
for _, target in ipairs(tr.products.children) do
for cfg in premake.eachconfig(tr.project) do
xcode.XCBuildConfigurationBlock(tr, target, cfg)
end
end
for cfg in premake.eachconfig(tr.project) do
xcode.XCBuildConfigurationDefault(tr, cfg)
end
_p('/* End XCBuildConfiguration section */')
_p('')
end
function xcode.XCBuildConfigurationList(tr)
local sln = tr.project.solution
_p('/* Begin XCConfigurationList section */')
for _, target in ipairs(tr.products.children) do
_p(2,'%s /* Build configuration list for PBXNativeTarget "%s" */ = {', target.cfgsection, target.name)
_p(3,'isa = XCConfigurationList;')
_p(3,'buildConfigurations = (')
for _, cfgname in ipairs(sln.configurations) do
_p(4,'%s /* %s */,', target.configids[cfgname], cfgname)
end
_p(3,');')
_p(3,'defaultConfigurationIsVisible = 0;')
_p(3,'defaultConfigurationName = %s;', sln.configurations[1])
_p(2,'};')
end
_p(2,'1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "%s" */ = {', tr.name)
_p(3,'isa = XCConfigurationList;')
_p(3,'buildConfigurations = (')
for _, cfgname in ipairs(sln.configurations) do
_p(4,'%s /* %s */,', tr.configids[cfgname], cfgname)
end
_p(3,');')
_p(3,'defaultConfigurationIsVisible = 0;')
_p(3,'defaultConfigurationName = %s;', sln.configurations[1])
_p(2,'};')
_p('/* End XCConfigurationList section */')
_p('')
end
function xcode.Footer()
_p(1,'};')
_p('\trootObject = 08FB7793FE84155DC02AAC07 /* Project object */;')

View File

@ -206,136 +206,6 @@
function xcode.PBXVariantGroup(tr)
_p('/* Begin PBXVariantGroup section */')
tree.traverse(tr, {
onbranch = function(node)
if node.kind == "vgroup" then
_p(2,'%s /* %s */ = {', node.id, node.name)
_p(3,'isa = PBXVariantGroup;')
_p(3,'children = (')
for _, lang in ipairs(node.children) do
_p(4,'%s /* %s */,', lang.id, lang.name)
end
_p(3,');')
_p(3,'name = %s;', node.name)
_p(3,'sourceTree = "<group>";')
_p(2,'};')
end
end
})
_p('/* End PBXVariantGroup section */')
_p('')
end
function xcode.XCBuildConfigurationBlock(target, cfg)
local prj = target.prjnode.project
_p(2,'%s /* %s */ = {', target.configids[cfg.name], cfg.name)
_p(3,'isa = XCBuildConfiguration;')
_p(3,'buildSettings = {')
_p(4,'ALWAYS_SEARCH_USER_PATHS = NO;')
_p(4,'CONFIGURATION_BUILD_DIR = %s;', xcode.rebase(prj, path.getdirectory(cfg.buildtarget.bundlepath)))
if cfg.flags.Symbols then
_p(4,'COPY_PHASE_STRIP = NO;')
end
_p(4,'GCC_DYNAMIC_NO_PIC = NO;')
if cfg.flags.Symbols then
_p(4,'GCC_ENABLE_FIX_AND_CONTINUE = YES;')
end
_p(4,'GCC_MODEL_TUNING = G5;')
if #cfg.defines > 0 then
_p(4,'GCC_PREPROCESSOR_DEFINITIONS = (')
_p(table.implode(cfg.defines, "\t\t\t\t", ",\n"))
_p(4,');')
end
if target.prjnode.infoplist then
_p(4,'INFOPLIST_FILE = %s;', target.prjnode.infoplist.path)
end
_p(4,'PRODUCT_NAME = %s;', cfg.buildtarget.basename)
_p(4,'SYMROOT = %s;', xcode.rebase(prj, cfg.objectsdir))
_p(3,'};')
_p(3,'name = %s;', cfg.name)
_p(2,'};')
end
function xcode.XCBuildConfigurationDefault(tr, cfgname)
_p(2,'%s /* %s */ = {', tr.configids[cfgname], cfgname)
_p(3,'isa = XCBuildConfiguration;')
_p(3,'buildSettings = {')
_p(4,'ARCHS = "$(ARCHS_STANDARD_32_BIT)";')
_p(4,'GCC_C_LANGUAGE_STANDARD = c99;')
_p(4,'GCC_WARN_ABOUT_RETURN_TYPE = YES;')
_p(4,'GCC_WARN_UNUSED_VARIABLE = YES;')
_p(4,'ONLY_ACTIVE_ARCH = YES;')
_p(4,'PREBINDING = NO;')
_p(4,'SDKROOT = macosx10.5;')
-- I don't have any concept of a solution-level objdir; use the first target cfg
local target = tr.products.children[1]
local prj = target.prjnode.project
local cfg = premake.getconfig(prj, cfgname)
_p(4,'SYMROOT = %s;', xcode.rebase(prj, cfg.objectsdir))
_p(3,'};')
_p(3,'name = %s;', cfgname)
_p(2,'};')
end
function xcode.XCBuildConfiguration(tr)
_p('/* Begin XCBuildConfiguration section */')
for _, target in ipairs(tr.products.children) do
for cfg in premake.eachconfig(target.prjnode.project) do
xcode.XCBuildConfigurationBlock(target, cfg)
end
end
for _, cfgname in ipairs(tr.solution.configurations) do
xcode.XCBuildConfigurationDefault(tr, cfgname)
end
_p('/* End XCBuildConfiguration section */')
_p('')
end
function xcode.XCBuildConfigurationList(tr)
_p('/* Begin XCConfigurationList section */')
for _, target in ipairs(tr.products.children) do
_p(2,'%s /* Build configuration list for PBXNativeTarget "%s" */ = {', target.cfgsection, target.name)
_p(3,'isa = XCConfigurationList;')
_p(3,'buildConfigurations = (')
for _, cfgname in ipairs(tr.solution.configurations) do
_p(4,'%s /* %s */,', target.configids[cfgname], cfgname)
end
_p(3,');')
_p(3,'defaultConfigurationIsVisible = 0;')
_p(3,'defaultConfigurationName = %s;', tr.solution.configurations[1])
_p(2,'};')
end
_p(2,'1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "%s" */ = {', tr.name)
_p(3,'isa = XCConfigurationList;')
_p(3,'buildConfigurations = (')
for _, cfgname in ipairs(tr.solution.configurations) do
_p(4,'%s /* %s */,', tr.configids[cfgname], cfgname)
end
_p(3,');')
_p(3,'defaultConfigurationIsVisible = 0;')
_p(3,'defaultConfigurationName = %s;', tr.solution.configurations[1])
_p(2,'};')
_p('/* End XCConfigurationList section */')
_p('')
end
---------------------------------------------------------------------------
-- Xcode project generator function

View File

@ -89,6 +89,12 @@
end
end
-- also assign configuration IDs
tr.configids = {}
for _, cfgname in ipairs(prj.solution.configurations) do
tr.configids[cfgname] = xcode.newid(tr, cfgname)
end
-- Final setup
tree.traverse(tr, {
onnode = function(node)
@ -99,6 +105,11 @@
if xcode.getbuildcategory(node) then
node.buildid = xcode.newid(node, "build")
end
-- remember key files that are needed elsewhere
if node.name == "Info.plist" then
tr.infoplist = node
end
end
}, true)
@ -124,5 +135,8 @@
xcode.PBXProject(tr)
xcode.PBXResourcesBuildPhase(tr)
xcode.PBXSourcesBuildPhase(tr)
xcode.PBXVariantGroup(tr)
xcode.XCBuildConfiguration(tr)
xcode.XCBuildConfigurationList(tr)
xcode.Footer(tr)
end

View File

@ -28,181 +28,5 @@
---------------------------------------------------------------------------
-- PBXVariantGroup tests
---------------------------------------------------------------------------
function T.xcode3.PBXVariantGroup_OnNoGroups()
prepare()
xcode.PBXVariantGroup(tr)
test.capture [[
/* Begin PBXVariantGroup section */
/* End PBXVariantGroup section */
]]
end
function T.xcode3.PBXVariantGroup_OnNoResourceGroups()
files { "English.lproj/MainMenu.xib", "French.lproj/MainMenu.xib" }
prepare()
xcode.PBXVariantGroup(tr)
test.capture [[
/* Begin PBXVariantGroup section */
[MainMenu.xib] /* MainMenu.xib */ = {
isa = PBXVariantGroup;
children = (
[English] /* English */,
[French] /* French */,
);
name = MainMenu.xib;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
]]
end
---------------------------------------------------------------------------
-- XCBuildConfiguration tests
---------------------------------------------------------------------------
local function Call_XCBuildConfigurationBlock()
prepare()
local target = tr.products.children[1]
local config = premake.getconfig(target.prjnode.project, "Debug")
xcode.XCBuildConfigurationBlock(target, config)
end
function T.xcode3.XCBuildConfigurationDefault_OnDefaults()
prepare()
xcode.XCBuildConfigurationDefault(tr, "Debug")
test.capture [[
[MyProject:Debug(2)] /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
SDKROOT = macosx10.5;
SYMROOT = obj/Debug;
};
name = Debug;
};
]]
end
function T.xcode3.XCBuildConfigurationBlock_OnConsoleAppDefaults()
Call_XCBuildConfigurationBlock()
test.capture [[
[MyProject:Debug] /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CONFIGURATION_BUILD_DIR = .;
GCC_DYNAMIC_NO_PIC = NO;
GCC_MODEL_TUNING = G5;
PRODUCT_NAME = MyProject;
SYMROOT = obj/Debug;
};
name = Debug;
};
]]
end
function T.xcode3.XCBuildConfigurationBlock_OnStaticLibDefaults()
kind "StaticLib"
Call_XCBuildConfigurationBlock()
test.capture [[
[libMyProject.a:Debug] /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CONFIGURATION_BUILD_DIR = .;
GCC_DYNAMIC_NO_PIC = NO;
GCC_MODEL_TUNING = G5;
PRODUCT_NAME = MyProject;
SYMROOT = obj/Debug;
};
name = Debug;
};
]]
end
function T.xcode3.XCBuildConfigurationBlock_OnInfoPlist()
files { "Info.plist" }
Call_XCBuildConfigurationBlock()
test.capture [[
[MyProject:Debug] /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CONFIGURATION_BUILD_DIR = .;
GCC_DYNAMIC_NO_PIC = NO;
GCC_MODEL_TUNING = G5;
INFOPLIST_FILE = Info.plist;
PRODUCT_NAME = MyProject;
SYMROOT = obj/Debug;
};
name = Debug;
};
]]
end
function T.xcode3.XCBuildConfigurationBlock_SetsWindowedAppOutputDir()
kind "WindowedApp"
Call_XCBuildConfigurationBlock()
test.capture [[
[MyProject.app:Debug] /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CONFIGURATION_BUILD_DIR = .;
GCC_DYNAMIC_NO_PIC = NO;
GCC_MODEL_TUNING = G5;
PRODUCT_NAME = MyProject;
SYMROOT = obj/Debug;
};
name = Debug;
};
]]
end
---------------------------------------------------------------------------
-- XCBuildConfigurationList tests
---------------------------------------------------------------------------
function T.xcode3.XCBuildConfigurationList_OnSingleProject()
prepare()
xcode.XCBuildConfigurationList(tr)
test.capture [[
/* Begin XCConfigurationList section */
[MyProject:cfg] /* Build configuration list for PBXNativeTarget "MyProject" */ = {
isa = XCConfigurationList;
buildConfigurations = (
[MyProject:Debug] /* Debug */,
[MyProject:Release] /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Debug;
};
1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "MyProject" */ = {
isa = XCConfigurationList;
buildConfigurations = (
[MyProject:Debug(2)] /* Debug */,
[MyProject:Release(2)] /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Debug;
};
/* End XCConfigurationList section */
]]
end

View File

@ -513,3 +513,183 @@
/* End PBXSourcesBuildPhase section */
]]
end
---------------------------------------------------------------------------
-- PBXVariantGroup tests
---------------------------------------------------------------------------
function suite.PBXVariantGroup_OnNoGroups()
prepare()
xcode.PBXVariantGroup(tr)
test.capture [[
/* Begin PBXVariantGroup section */
/* End PBXVariantGroup section */
]]
end
function suite.PBXVariantGroup_OnNoResourceGroups()
files { "English.lproj/MainMenu.xib", "French.lproj/MainMenu.xib" }
prepare()
xcode.PBXVariantGroup(tr)
test.capture [[
/* Begin PBXVariantGroup section */
[MainMenu.xib] /* MainMenu.xib */ = {
isa = PBXVariantGroup;
children = (
[English] /* English */,
[French] /* French */,
);
name = MainMenu.xib;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
]]
end
---------------------------------------------------------------------------
-- XCBuildConfiguration tests
---------------------------------------------------------------------------
local function Call_XCBuildConfigurationBlock()
prepare()
local target = tr.products.children[1]
local config = premake.getconfig(target.project, "Debug")
xcode.XCBuildConfigurationBlock(target, config)
end
function suite.XCBuildConfigurationDefault_OnDefaults()
prepare()
xcode.XCBuildConfigurationDefault(tr, premake.getconfig(tr.project, "Debug"))
test.capture [[
[MyProject:Debug(2)] /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
SDKROOT = macosx10.5;
SYMROOT = obj/Debug;
};
name = Debug;
};
]]
end
function suite.XCBuildConfigurationBlock_OnConsoleAppDefaults()
prepare()
xcode.XCBuildConfigurationBlock(tr, tr.products.children[1], premake.getconfig(tr.project, "Debug"))
test.capture [[
[MyProject:Debug] /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_MODEL_TUNING = G5;
PRODUCT_NAME = MyProject;
SYMROOT = obj/Debug;
};
name = Debug;
};
]]
end
function suite.XCBuildConfigurationBlock_OnStaticLibDefaults()
kind "StaticLib"
prepare()
xcode.XCBuildConfigurationBlock(tr, tr.products.children[1], premake.getconfig(tr.project, "Debug"))
test.capture [[
[libMyProject.a:Debug] /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_MODEL_TUNING = G5;
PRODUCT_NAME = MyProject;
SYMROOT = obj/Debug;
};
name = Debug;
};
]]
end
function suite.XCBuildConfigurationBlock_OnInfoPlist()
files { "Info.plist" }
prepare()
xcode.XCBuildConfigurationBlock(tr, tr.products.children[1], premake.getconfig(tr.project, "Debug"))
test.capture [[
[MyProject:Debug] /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_MODEL_TUNING = G5;
INFOPLIST_FILE = Info.plist;
PRODUCT_NAME = MyProject;
SYMROOT = obj/Debug;
};
name = Debug;
};
]]
end
function suite.XCBuildConfigurationBlock_SetsWindowedAppOutputDir()
kind "WindowedApp"
prepare()
xcode.XCBuildConfigurationBlock(tr, tr.products.children[1], premake.getconfig(tr.project, "Debug"))
test.capture [[
[MyProject.app:Debug] /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_MODEL_TUNING = G5;
PRODUCT_NAME = MyProject;
SYMROOT = obj/Debug;
};
name = Debug;
};
]]
end
---------------------------------------------------------------------------
-- XCBuildConfigurationList tests
---------------------------------------------------------------------------
function suite.XCBuildConfigurationList_OnSingleProject()
prepare()
xcode.XCBuildConfigurationList(tr)
test.capture [[
/* Begin XCConfigurationList section */
[MyProject:cfg] /* Build configuration list for PBXNativeTarget "MyProject" */ = {
isa = XCConfigurationList;
buildConfigurations = (
[MyProject:Debug] /* Debug */,
[MyProject:Release] /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Debug;
};
1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "MyProject" */ = {
isa = XCConfigurationList;
buildConfigurations = (
[MyProject:Debug(2)] /* Debug */,
[MyProject:Release(2)] /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Debug;
};
/* End XCConfigurationList section */
]]
end