Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcode embed libraries #1619

Merged
merged 3 commits into from Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions modules/xcode/_preload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@
}
}

p.api.register {
name = "embed",
scope = "config",
kind = "list",
}

p.api.register {
name = "embedAndSign",
scope = "config",
kind = "list",
}

--
-- Register the Xcode exporters.
--
Expand Down
62 changes: 62 additions & 0 deletions modules/xcode/tests/test_xcode_dependencies.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,38 @@
]]
end

function suite.PBXBuildFile_ListsDependencyTargets_OnSharedLibWhenEmbedding()
kind "SharedLib"

project "MyProject"
embed { "MyProject2" }

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"
embedAndSign { "MyProject2" }

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
Expand Down Expand Up @@ -166,6 +198,35 @@
]]
end

---------------------------------------------------------------------------
-- PBXCopyFilesBuildPhaseForEmbedFrameworks tests
---------------------------------------------------------------------------

function suite.PBXCopyFilesBuildPhaseForEmbedFrameworks_ListsDependencies_OnSharedLib()
kind "SharedLib"

project "MyProject"
embed { "MyProject2" }

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
---------------------------------------------------------------------------
Expand Down Expand Up @@ -229,6 +290,7 @@
0FC4B7F6B3104128CDE10E36 /* Resources */,
7971D14D1CBD5A7F378E278D /* Sources */,
9FDD37564328C0885DF98D96 /* Frameworks */,
E1D3B542862652F4985E9B82 /* Embed Libraries */,
);
buildRules = (
);
Expand Down
122 changes: 122 additions & 0 deletions modules/xcode/tests/test_xcode_project.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,55 @@
]]
end

function suite.PBXBuildFile_ListsDylibs()
links { "../libA.dylib", "libB.dylib", "/usr/lib/libC.dylib" }
prepare()
xcode.PBXBuildFile(tr)
test.capture [[
/* Begin PBXBuildFile section */
3C98627697D9B5E86B3400B6 /* libB.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D413533EEB25EE70DB41E97E /* libB.dylib */; };
91686CDFDECB631154EA631F /* libA.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F9AE5C74A870BB9926CD407 /* libA.dylib */; };
A7E42B5676077F08FD15D196 /* libC.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CF0547FE2A469B70FDA0E63E /* libC.dylib */; };
/* End PBXBuildFile section */
]]
end

function suite.PBXBuildFile_ListsFrameworksAndDylibsForSigning()
links
{
"../libA.dylib",
"libB.dylib",
"/usr/lib/libC.dylib",
"../D.framework",
"../E.framework",
}
embedAndSign
{
"libA.dylib",
"D.framework",
}
embed
{
"libB.dylib",
"E.framework",
}
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" } }
Expand Down Expand Up @@ -378,6 +427,20 @@
end


function suite.PBXFileReference_ListDylibsCorrectly()
links { "../libA.dylib", "libB.dylib", "/usr/lib/libC.dylib" }
prepare()
xcode.PBXFileReference(tr)
test.capture [[
/* Begin PBXFileReference section */
19A5C4E61D1697189E833B26 /* MyProject */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = MyProject; path = MyProject; sourceTree = BUILT_PRODUCTS_DIR; };
5F9AE5C74A870BB9926CD407 /* libA.dylib */ = {isa = PBXFileReference; lastKnownFileType = compiled.mach-o.dylib; name = libA.dylib; path = ../libA.dylib; sourceTree = SOURCE_ROOT; };
CF0547FE2A469B70FDA0E63E /* libC.dylib */ = {isa = PBXFileReference; lastKnownFileType = compiled.mach-o.dylib; name = libC.dylib; path = /usr/lib/libC.dylib; sourceTree = "<absolute>"; };
D413533EEB25EE70DB41E97E /* libB.dylib */ = {isa = PBXFileReference; lastKnownFileType = compiled.mach-o.dylib; name = libB.dylib; path = libB.dylib; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
]]
end

function suite.PBXFileReference_leavesFrameworkLocationsAsIsWhenSupplied_pathIsSetToInput()
local inputFrameWork = 'somedir/Foo.framework'
links(inputFrameWork)
Expand Down Expand Up @@ -496,6 +559,59 @@
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",
}
embed { "libA.dylib" }
embedAndSign { "D.framework" }
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
---------------------------------------------------------------------------
Expand Down Expand Up @@ -730,6 +846,7 @@
0FC4B7F6B3104128CDE10E36 /* Resources */,
7971D14D1CBD5A7F378E278D /* Sources */,
9FDD37564328C0885DF98D96 /* Frameworks */,
E1D3B542862652F4985E9B82 /* Embed Libraries */,
);
buildRules = (
);
Expand Down Expand Up @@ -759,6 +876,7 @@
0F791C0512E9EE3794569245 /* Resources */,
7926355C7C97078EFE03AB9C /* Sources */,
9F919B65A3026D97246F11A5 /* Frameworks */,
A0315911431F7FC3D2455F51 /* Embed Libraries */,
);
buildRules = (
);
Expand Down Expand Up @@ -788,6 +906,7 @@
A1093E0F9A6F3F818E0A9C4F /* Resources */,
0AB65766041C58D8F7B7B5A6 /* Sources */,
3121BD6F2A87BEE11E231BAF /* Frameworks */,
D652259BC13E4B8D092413DB /* Embed Libraries */,
);
buildRules = (
);
Expand Down Expand Up @@ -825,6 +944,7 @@
7971D14D1CBD5A7F378E278D /* Sources */,
9607AE3510C85E7E00CD1376 /* Prelink */,
9FDD37564328C0885DF98D96 /* Frameworks */,
E1D3B542862652F4985E9B82 /* Embed Libraries */,
9607AE3710C85E8F00CD1376 /* Postbuild */,
);
buildRules = (
Expand Down Expand Up @@ -867,6 +987,7 @@
0FC4B7F6B3104128CDE10E36 /* Resources */,
7971D14D1CBD5A7F378E278D /* Sources */,
9FDD37564328C0885DF98D96 /* Frameworks */,
E1D3B542862652F4985E9B82 /* Embed Libraries */,
);
buildRules = (
);
Expand Down Expand Up @@ -910,6 +1031,7 @@
0FC4B7F6B3104128CDE10E36 /* Resources */,
7971D14D1CBD5A7F378E278D /* Sources */,
9FDD37564328C0885DF98D96 /* Frameworks */,
E1D3B542862652F4985E9B82 /* Embed Libraries */,
);
buildRules = (
);
Expand Down
Loading