Add xcodeembedlibraries command
This commit is contained in:
parent
0e93130442
commit
4ed74246b5
@ -46,6 +46,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
p.api.register {
|
||||
name = "xcodeembedlibraries",
|
||||
scope = "config",
|
||||
kind = "key-string",
|
||||
}
|
||||
|
||||
--
|
||||
-- Register the Xcode exporters.
|
||||
--
|
||||
|
@ -69,6 +69,44 @@
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.PBXBuildFile_ListsDependencyTargets_OnSharedLibWhenEmbedding()
|
||||
kind "SharedLib"
|
||||
|
||||
project "MyProject"
|
||||
xcodeembedlibraries
|
||||
{
|
||||
["MyProject2"] = "embed"
|
||||
}
|
||||
|
||||
prepare()
|
||||
xcode.PBXBuildFile(tr)
|
||||
test.capture [[
|
||||
/* Begin PBXBuildFile section */
|
||||
1BC538B0FA67D422AF49D6F0 /* libMyProject2-d.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 107168B810144BEA4A68FEF8 /* libMyProject2-d.dylib */; };
|
||||
6514841E8D4F3CD074EACA5E /* libMyProject2-d.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = 107168B810144BEA4A68FEF8 /* libMyProject2-d.dylib */; };
|
||||
/* End PBXBuildFile section */
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.PBXBuildFile_ListsDependencyTargets_OnSharedLibWhenEmbeddingAndSigning()
|
||||
kind "SharedLib"
|
||||
|
||||
project "MyProject"
|
||||
xcodeembedlibraries
|
||||
{
|
||||
["MyProject2"] = "embed-and-sign"
|
||||
}
|
||||
|
||||
prepare()
|
||||
xcode.PBXBuildFile(tr)
|
||||
test.capture [[
|
||||
/* Begin PBXBuildFile section */
|
||||
1BC538B0FA67D422AF49D6F0 /* libMyProject2-d.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 107168B810144BEA4A68FEF8 /* libMyProject2-d.dylib */; };
|
||||
6514841E8D4F3CD074EACA5E /* libMyProject2-d.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = 107168B810144BEA4A68FEF8 /* libMyProject2-d.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
/* End PBXBuildFile section */
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- PBXContainerItemProxy tests
|
||||
@ -166,6 +204,38 @@
|
||||
]]
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- PBXCopyFilesBuildPhaseForEmbedFrameworks tests
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
function suite.PBXCopyFilesBuildPhaseForEmbedFrameworks_ListsDependencies_OnSharedLib()
|
||||
kind "SharedLib"
|
||||
|
||||
project "MyProject"
|
||||
xcodeembedlibraries
|
||||
{
|
||||
["MyProject2"] = "embed"
|
||||
}
|
||||
|
||||
prepare()
|
||||
xcode.PBXCopyFilesBuildPhaseForEmbedFrameworks(tr)
|
||||
test.capture [[
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
E1D3B542862652F4985E9B82 /* Embed Libraries */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
6514841E8D4F3CD074EACA5E /* MyProject2 in Projects */,
|
||||
);
|
||||
name = "Embed Libraries";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
]]
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- PBXGroup tests
|
||||
---------------------------------------------------------------------------
|
||||
@ -229,6 +299,7 @@
|
||||
0FC4B7F6B3104128CDE10E36 /* Resources */,
|
||||
7971D14D1CBD5A7F378E278D /* Sources */,
|
||||
9FDD37564328C0885DF98D96 /* Frameworks */,
|
||||
E1D3B542862652F4985E9B82 /* Embed Libraries */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
|
@ -119,6 +119,39 @@
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.PBXBuildFile_ListsFrameworksAndDylibsForSigning()
|
||||
links
|
||||
{
|
||||
"../libA.dylib",
|
||||
"libB.dylib",
|
||||
"/usr/lib/libC.dylib",
|
||||
"../D.framework",
|
||||
"../E.framework",
|
||||
}
|
||||
xcodeembedlibraries
|
||||
{
|
||||
["libA.dylib"] = "embed-and-sign",
|
||||
["libB.dylib"] = "embed",
|
||||
["D.framework"] = "embed-and-sign",
|
||||
["E.framework"] = "embed",
|
||||
}
|
||||
prepare()
|
||||
xcode.PBXBuildFile(tr)
|
||||
test.capture [[
|
||||
/* Begin PBXBuildFile section */
|
||||
12F1B82D44EB02DFBECA3E6D /* E.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A817AE35FEA518A7D71E2C75 /* E.framework */; };
|
||||
6557012668C7D358EA347766 /* E.framework in Embed Libraries */ = {isa = PBXBuildFile; fileRef = A817AE35FEA518A7D71E2C75 /* E.framework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
3C98627697D9B5E86B3400B6 /* libB.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D413533EEB25EE70DB41E97E /* libB.dylib */; };
|
||||
AC7C2020DB2274123463CE60 /* libB.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = D413533EEB25EE70DB41E97E /* libB.dylib */; };
|
||||
91686CDFDECB631154EA631F /* libA.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F9AE5C74A870BB9926CD407 /* libA.dylib */; };
|
||||
E054F1BF0EFB45B1683C9FFF /* libA.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = 5F9AE5C74A870BB9926CD407 /* libA.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
A7E42B5676077F08FD15D196 /* libC.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CF0547FE2A469B70FDA0E63E /* libC.dylib */; };
|
||||
F56B754B2764BFFDA143FB8B /* D.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F3987C734A25E6E5229EFAB3 /* D.framework */; };
|
||||
966D8A4599DE5C771B4B0085 /* D.framework in Embed Libraries */ = {isa = PBXBuildFile; fileRef = F3987C734A25E6E5229EFAB3 /* D.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
/* End PBXBuildFile section */
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.PBXBuildFile_IgnoresVpaths()
|
||||
files { "source.h", "source.c", "source.cpp", "Info.plist" }
|
||||
vpaths { ["Source Files"] = { "**.c", "**.cpp" } }
|
||||
@ -523,6 +556,62 @@
|
||||
end
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- PBXCopyFilesBuildPhaseForEmbedFrameworks tests
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
function suite.PBXCopyFilesBuildPhaseForEmbedFrameworks_OnNoFiles()
|
||||
prepare()
|
||||
xcode.PBXCopyFilesBuildPhaseForEmbedFrameworks(tr)
|
||||
test.capture [[
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
E1D3B542862652F4985E9B82 /* Embed Libraries */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
);
|
||||
name = "Embed Libraries";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
function suite.PBXCopyFilesBuildPhaseForEmbedFrameworks_ListsEmbeddedLibrariesCorrectly()
|
||||
links
|
||||
{
|
||||
"../libA.dylib",
|
||||
"../D.framework",
|
||||
}
|
||||
xcodeembedlibraries
|
||||
{
|
||||
["libA.dylib"] = "embed",
|
||||
["D.framework"] = "embed-and-sign",
|
||||
}
|
||||
prepare()
|
||||
xcode.PBXCopyFilesBuildPhaseForEmbedFrameworks(tr)
|
||||
test.capture [[
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
E1D3B542862652F4985E9B82 /* Embed Libraries */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
E054F1BF0EFB45B1683C9FFF /* libA.dylib in Frameworks */,
|
||||
966D8A4599DE5C771B4B0085 /* D.framework in Frameworks */,
|
||||
);
|
||||
name = "Embed Libraries";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- PBXGroup tests
|
||||
---------------------------------------------------------------------------
|
||||
@ -757,6 +846,7 @@
|
||||
0FC4B7F6B3104128CDE10E36 /* Resources */,
|
||||
7971D14D1CBD5A7F378E278D /* Sources */,
|
||||
9FDD37564328C0885DF98D96 /* Frameworks */,
|
||||
E1D3B542862652F4985E9B82 /* Embed Libraries */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@ -786,6 +876,7 @@
|
||||
0F791C0512E9EE3794569245 /* Resources */,
|
||||
7926355C7C97078EFE03AB9C /* Sources */,
|
||||
9F919B65A3026D97246F11A5 /* Frameworks */,
|
||||
A0315911431F7FC3D2455F51 /* Embed Libraries */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@ -815,6 +906,7 @@
|
||||
A1093E0F9A6F3F818E0A9C4F /* Resources */,
|
||||
0AB65766041C58D8F7B7B5A6 /* Sources */,
|
||||
3121BD6F2A87BEE11E231BAF /* Frameworks */,
|
||||
D652259BC13E4B8D092413DB /* Embed Libraries */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@ -852,6 +944,7 @@
|
||||
7971D14D1CBD5A7F378E278D /* Sources */,
|
||||
9607AE3510C85E7E00CD1376 /* Prelink */,
|
||||
9FDD37564328C0885DF98D96 /* Frameworks */,
|
||||
E1D3B542862652F4985E9B82 /* Embed Libraries */,
|
||||
9607AE3710C85E8F00CD1376 /* Postbuild */,
|
||||
);
|
||||
buildRules = (
|
||||
@ -894,6 +987,7 @@
|
||||
0FC4B7F6B3104128CDE10E36 /* Resources */,
|
||||
7971D14D1CBD5A7F378E278D /* Sources */,
|
||||
9FDD37564328C0885DF98D96 /* Frameworks */,
|
||||
E1D3B542862652F4985E9B82 /* Embed Libraries */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@ -937,6 +1031,7 @@
|
||||
0FC4B7F6B3104128CDE10E36 /* Resources */,
|
||||
7971D14D1CBD5A7F378E278D /* Sources */,
|
||||
9FDD37564328C0885DF98D96 /* Frameworks */,
|
||||
E1D3B542862652F4985E9B82 /* Embed Libraries */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
|
@ -410,6 +410,25 @@
|
||||
settings[node.buildid] = function(level)
|
||||
_p(level,'%s /* %s in %s */ = {isa = PBXBuildFile; fileRef = %s /* %s */; };',
|
||||
node.buildid, node.name, xcode.getbuildcategory(node), node.id, node.name)
|
||||
|
||||
if node.embedid then
|
||||
local attrs = ""
|
||||
|
||||
if xcode.shouldembedandsign(tr, node) then
|
||||
attrs = attrs .. "CodeSignOnCopy, "
|
||||
end
|
||||
|
||||
if xcode.isframework(node.name) then
|
||||
attrs = attrs .. "RemoveHeadersOnCopy, "
|
||||
end
|
||||
|
||||
if attrs ~= "" then
|
||||
attrs = " settings = {ATTRIBUTES = (" .. attrs .. "); };"
|
||||
end
|
||||
|
||||
_p(level,'%s /* %s in Embed Libraries */ = {isa = PBXBuildFile; fileRef = %s /* %s */;%s };',
|
||||
node.embedid, node.name, node.id, node.name, attrs)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -598,6 +617,83 @@
|
||||
end
|
||||
|
||||
|
||||
function xcode.embedsetting(cfg, node)
|
||||
if type(cfg.xcodeembedlibraries) == 'table' then
|
||||
-- Frameworks and dylibs referenced by path are expected
|
||||
-- to provide the file name (but not path). Project
|
||||
-- references are expected to provide the project name.
|
||||
if xcode.isframeworkordylib(node.name) then
|
||||
local tablekey = node.name
|
||||
if node.parent.project then
|
||||
tablekey = node.parent.project.name
|
||||
end
|
||||
return cfg.xcodeembedlibraries[tablekey]
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
function xcode.shouldembed(tr, node)
|
||||
for _, cfg in ipairs(tr.configs) do
|
||||
local setting = xcode.embedsetting(cfg, node)
|
||||
if setting == "embed" or setting == "embed-and-sign" then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
function xcode.shouldembedandsign(tr, node)
|
||||
for _, cfg in ipairs(tr.configs) do
|
||||
local setting = xcode.embedsetting(cfg, node)
|
||||
if setting == "embed-and-sign" then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
function xcode.PBXCopyFilesBuildPhaseForEmbedFrameworks(tr)
|
||||
_p('/* Begin PBXCopyFilesBuildPhase section */')
|
||||
_p(2,'%s /* Embed Libraries */ = {', tr.products.children[1].embedstageid)
|
||||
_p(3,'isa = PBXCopyFilesBuildPhase;')
|
||||
_p(3,'buildActionMask = 2147483647;')
|
||||
_p(3,'dstPath = "";')
|
||||
_p(3,'dstSubfolderSpec = 10;')
|
||||
_p(3,'files = (')
|
||||
|
||||
-- write out library dependencies
|
||||
tree.traverse(tr.frameworks, {
|
||||
onleaf = function(node)
|
||||
if node.embedid then
|
||||
_p(4,'%s /* %s in Frameworks */,', node.embedid, node.name)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
-- write out project dependencies
|
||||
tree.traverse(tr.projects, {
|
||||
onleaf = function(node)
|
||||
if node.embedid then
|
||||
_p(4,'%s /* %s in Projects */,', node.embedid, node.parent.project.name)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
_p(3,');')
|
||||
_p(3,'name = "Embed Libraries";')
|
||||
_p(3,'runOnlyForDeploymentPostprocessing = 0;')
|
||||
_p(2,'};')
|
||||
_p('/* End PBXCopyFilesBuildPhase section */')
|
||||
_p('')
|
||||
end
|
||||
|
||||
|
||||
function xcode.PBXGroup(tr)
|
||||
local settings = {}
|
||||
|
||||
@ -786,6 +882,7 @@
|
||||
end
|
||||
if pbxTargetName == "Native" then
|
||||
_p(4,'%s /* Frameworks */,', node.fxstageid)
|
||||
_p(4,'%s /* Embed Libraries */,', node.embedstageid)
|
||||
end
|
||||
if hasBuildCommands('postbuildcommands') then
|
||||
_p(4,'9607AE3710C85E8F00CD1376 /* Postbuild */,')
|
||||
|
@ -159,6 +159,10 @@
|
||||
-- assign build IDs to buildable files
|
||||
if xcode.getbuildcategory(node) and not node.excludefrombuild and not xcode.mustExcludeFromTarget(node, tr.project) then
|
||||
node.buildid = xcode.newid(node.name, "build", nodePath)
|
||||
|
||||
if xcode.shouldembed(tr, node) then
|
||||
node.embedid = xcode.newid(node.name, "embed", nodepath)
|
||||
end
|
||||
end
|
||||
|
||||
-- remember key files that are needed elsewhere
|
||||
@ -174,10 +178,11 @@
|
||||
node = tree.insert(tr.products, prj.xcode.projectnode)
|
||||
node.kind = "product"
|
||||
node.path = node.cfg.buildtarget.fullpath
|
||||
node.cfgsection = xcode.newid(node.name, "cfg")
|
||||
node.resstageid = xcode.newid(node.name, "rez")
|
||||
node.sourcesid = xcode.newid(node.name, "src")
|
||||
node.fxstageid = xcode.newid(node.name, "fxs")
|
||||
node.cfgsection = xcode.newid(node.name, "cfg")
|
||||
node.resstageid = xcode.newid(node.name, "rez")
|
||||
node.sourcesid = xcode.newid(node.name, "src")
|
||||
node.fxstageid = xcode.newid(node.name, "fxs")
|
||||
node.embedstageid = xcode.newid(node.name, "embed")
|
||||
|
||||
return tr
|
||||
end
|
||||
@ -224,6 +229,7 @@
|
||||
xcode.PBXContainerItemProxy(tr)
|
||||
xcode.PBXFileReference(tr)
|
||||
xcode.PBXFrameworksBuildPhase(tr)
|
||||
xcode.PBXCopyFilesBuildPhaseForEmbedFrameworks(tr)
|
||||
xcode.PBXGroup(tr)
|
||||
xcode.PBXNativeTarget(tr)
|
||||
xcode.PBXAggregateTarget(tr)
|
||||
|
Loading…
Reference in New Issue
Block a user