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

Add support & tests for XCTest sharedlibtype #1218

Merged
merged 1 commit into from
Jan 9, 2019
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
44 changes: 44 additions & 0 deletions modules/xcode/tests/test_xcode_project.lua
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,30 @@
]]
end

function suite.PBXFileReference_ListsXCTestTarget()
kind "SharedLib"
sharedlibtype "XCTest"
prepare()
xcode.PBXFileReference(tr)
test.capture [[
/* Begin PBXFileReference section */
[MyProject.xctest:product] /* MyProject.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; name = MyProject.xctest; path = MyProject.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
]]
end

function suite.PBXFileReference_ListsIOSXCTestTarget()
_TARGET_OS = "ios"
kind "SharedLib"
sharedlibtype "XCTest"
prepare()
xcode.PBXFileReference(tr)
test.capture [[
/* Begin PBXFileReference section */
[MyProject.xctest:product] /* MyProject.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; name = MyProject.xctest; path = MyProject.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
]]
end

function suite.PBXFileReference_ListsOSXFrameworkTarget()
kind "SharedLib"
Expand Down Expand Up @@ -1294,6 +1318,26 @@
]]
end

function suite.XCBuildConfigurationTarget_OnXCTest()
kind "SharedLib"
sharedlibtype "XCTest"
prepare()
xcode.XCBuildConfiguration_Target(tr, tr.products.children[1], tr.configs[1])
test.capture [[
[MyProject.xctest:Debug] /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CONFIGURATION_BUILD_DIR = bin/Debug;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_DYNAMIC_NO_PIC = NO;
PRODUCT_NAME = MyProject;
};
name = Debug;
};
]]
end


function suite.XCBuildConfigurationTarget_OnOSXFramework()
kind "SharedLib"
Expand Down
3 changes: 3 additions & 0 deletions modules/xcode/xcode_common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@
SharedLib = "com.apple.product-type.library.dynamic",
OSXBundle = "com.apple.product-type.bundle",
OSXFramework = "com.apple.product-type.framework",
XCTest = "com.apple.product-type.bundle.unit-test",
}
return types[iif(node.cfg.kind == "SharedLib" and node.cfg.sharedlibtype, node.cfg.sharedlibtype, node.cfg.kind)]
end
Expand All @@ -290,6 +291,7 @@
SharedLib = "\"compiled.mach-o.dylib\"",
OSXBundle = "wrapper.cfbundle",
OSXFramework = "wrapper.framework",
XCTest = "wrapper.cfbundle",
}
return types[iif(node.cfg.kind == "SharedLib" and node.cfg.sharedlibtype, node.cfg.sharedlibtype, node.cfg.kind)]
end
Expand Down Expand Up @@ -1125,6 +1127,7 @@
StaticLib = "a",
OSXBundle = "bundle",
OSXFramework = "framework",
XCTest = "xctest",
}
local ext = cfg.buildtarget.extension:sub(2)
if ext ~= exts[iif(cfg.kind == "SharedLib" and cfg.sharedlibtype, cfg.sharedlibtype, cfg.kind)] then
Expand Down
5 changes: 5 additions & 0 deletions src/_premake_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@
allowed = {
"OSXBundle",
"OSXFramework",
"XCTest",
},
}

Expand Down Expand Up @@ -1778,6 +1779,10 @@
targetprefix ""
targetextension ".framework"

filter { "system:darwin", "kind:SharedLib", "sharedlibtype:XCTest" }
targetprefix ""
targetextension ".xctest"

-- Windows and friends.

filter { "system:Windows or language:C# or language:F#", "kind:ConsoleApp or WindowedApp" }
Expand Down
2 changes: 2 additions & 0 deletions src/tools/gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@
if table.contains(os.getSystemTags(cfg.system), "darwin") then
if cfg.sharedlibtype == "OSXBundle" then
return "-bundle"
elseif cfg.sharedlibtype == "XCTest" then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably could have been an or on the previous line, but the consistency is good. 👍

return "-bundle"
elseif cfg.sharedlibtype == "OSXFramework" then
return "-framework"
else
Expand Down
12 changes: 12 additions & 0 deletions tests/config/test_targetinfo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,18 @@
test.isequal("bin/Debug/MyProject.bundle/Contents/MacOS", path.getrelative(os.getcwd(), i.bundlepath))
end

--
-- Bundle path should be set for macOS/iOS cocoa unit test bundle.
--

function suite.bundlepathSet_onMacSharedLibXCTest()
kind "SharedLib"
sharedlibtype "XCTest"
system "macosx"
i = prepare()
test.isequal("bin/Debug/MyProject.xctest/Contents/MacOS", path.getrelative(os.getcwd(), i.bundlepath))
end


--
-- Bundle path should be set for macOS/iOS framework.
Expand Down
8 changes: 8 additions & 0 deletions tests/tools/test_gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,14 @@
test.contains({ "-Wl,-x", "-bundle" }, gcc.getldflags(cfg))
end

function suite.ldflags_onMacOSXXCTest()
system "MacOSX"
kind "SharedLib"
sharedlibtype "XCTest"
prepare()
test.contains({ "-Wl,-x", "-bundle" }, gcc.getldflags(cfg))
end

function suite.ldflags_onMacOSXFramework()
system "MacOSX"
kind "SharedLib"
Expand Down