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 1 commit
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
Prev Previous commit
Split xcodeembedlibraries into embed and embedAndSign
  • Loading branch information
Nick Gravelyn committed Apr 16, 2021
commit 626eedbc46ee6f14116be8cbf7b997bb5495da6f
10 changes: 8 additions & 2 deletions modules/xcode/_preload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,15 @@
}

p.api.register {
name = "xcodeembedlibraries",
name = "embed",
scope = "config",
kind = "key-string",
kind = "list",
}

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

--
Expand Down
15 changes: 3 additions & 12 deletions modules/xcode/tests/test_xcode_dependencies.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@
kind "SharedLib"

project "MyProject"
xcodeembedlibraries
{
["MyProject2"] = "embed"
}
embed { "MyProject2" }

prepare()
xcode.PBXBuildFile(tr)
Expand All @@ -92,10 +89,7 @@
kind "SharedLib"

project "MyProject"
xcodeembedlibraries
{
["MyProject2"] = "embed-and-sign"
}
embedAndSign { "MyProject2" }

prepare()
xcode.PBXBuildFile(tr)
Expand Down Expand Up @@ -212,10 +206,7 @@
kind "SharedLib"

project "MyProject"
xcodeembedlibraries
{
["MyProject2"] = "embed"
}
embed { "MyProject2" }

prepare()
xcode.PBXCopyFilesBuildPhaseForEmbedFrameworks(tr)
Expand Down
20 changes: 10 additions & 10 deletions modules/xcode/tests/test_xcode_project.lua
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,15 @@
"../D.framework",
"../E.framework",
}
xcodeembedlibraries
embedAndSign
{
["libA.dylib"] = "embed-and-sign",
["libB.dylib"] = "embed",
["D.framework"] = "embed-and-sign",
["E.framework"] = "embed",
"libA.dylib",
"D.framework",
}
embed
{
"libB.dylib",
"E.framework",
}
prepare()
xcode.PBXBuildFile(tr)
Expand Down Expand Up @@ -586,11 +589,8 @@
"../libA.dylib",
"../D.framework",
}
xcodeembedlibraries
{
["libA.dylib"] = "embed",
["D.framework"] = "embed-and-sign",
}
embed { "libA.dylib" }
embedAndSign { "D.framework" }
prepare()
xcode.PBXCopyFilesBuildPhaseForEmbedFrameworks(tr)
test.capture [[
Expand Down
42 changes: 19 additions & 23 deletions modules/xcode/xcode_common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -617,44 +617,40 @@
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
function xcode.embedListContains(list, node)
-- 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.
local entryname = node.name
if node.parent.project then
entryname = node.parent.project.name
end
return table.contains(list, entryname)
end

function xcode.shouldembed(tr, node)
if not xcode.isframeworkordylib(node.name) then
return false
end

for _, cfg in ipairs(tr.configs) do
local setting = xcode.embedsetting(cfg, node)
if setting == "embed" or setting == "embed-and-sign" then
if xcode.embedListContains(cfg.embed, node) or xcode.embedListContains(cfg.embedAndSign, node) then
return true
end
end

return false
end


function xcode.shouldembedandsign(tr, node)
if not xcode.isframeworkordylib(node.name) then
return false
end

for _, cfg in ipairs(tr.configs) do
local setting = xcode.embedsetting(cfg, node)
if setting == "embed-and-sign" then
if xcode.embedListContains(cfg.embedAndSign, node) then
return true
end
end

return false
end


Expand Down