Skip to content
This repository has been archived by the owner on Jun 2, 2019. It is now read-only.

xcode project dependencies #25

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions _manifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ return {
"xcode4_workspace.lua",
"xcode_common.lua",
"xcode_project.lua",
"xcode_scheme.lua",
}
1 change: 1 addition & 0 deletions _preload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

onProject = function(prj)
p.generate(prj, ".xcodeproj/project.pbxproj", p.modules.xcode.generateProject)
p.generate(prj, ".xcodeproj/xcshareddata/xcschemes/" .. prj.name .. ".xcscheme", p.modules.xcode.scheme.generate)
end,
}

Expand Down
1 change: 1 addition & 0 deletions tests/_tests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ return {
"test_xcode4_workspace.lua",
"test_xcode_dependencies.lua",
"test_xcode_project.lua",
"test_xcode_scheme.lua",
}
64 changes: 56 additions & 8 deletions tests/test_xcode_dependencies.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,31 @@
end

function suite.setup()
_ACTION = "xcode4"
premake.action.set("xcode4")
xcode.used_ids = { } -- reset the list of generated IDs

wks, prj = test.createWorkspace()
links { "MyProject2" }
dependson { "MyProject3" }

prj2 = test.createproject(wks)
kind "StaticLib"
configuration "Debug"
targetsuffix "-d"
configuration {}

local prj3 = test.createproject(wks)
kind "SharedLib"
links { "MyProject2" }
configuration "Debug"
targetsuffix "-d"
configuration {}
end

local function prepare()
wks = premake.oven.bakeWorkspace(wks)
xcode.prepareWorkspace(wks)
local prj3 = premake.workspace.getproject(wks, 1)
--prj2 = test.getproject(wks, 2)
tr = xcode.buildprjtree(prj3)
local prj1 = test.getproject(wks, 1)
tr = xcode.buildprjtree(prj1)
end


Expand All @@ -58,7 +65,7 @@
end

function suite.PBXBuildFile_ListsDependencyTargets_OnSharedLib()
kind "SharedLib"
prj2.kind = "SharedLib"
prepare()
xcode.PBXBuildFile(tr)
test.capture [[
Expand Down Expand Up @@ -92,6 +99,20 @@
remoteGlobalIDString = [libMyProject2-d.a:target];
remoteInfo = "libMyProject2-d.a";
};
[MyProject3.xcodeproj:prodprox] /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = [MyProject3.xcodeproj] /* MyProject3.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = [libMyProject3-d.dylib:product];
remoteInfo = "libMyProject3-d.dylib";
};
[MyProject3.xcodeproj:targprox] /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = [MyProject3.xcodeproj] /* MyProject3.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = [libMyProject3-d.dylib:target];
remoteInfo = "libMyProject3-d.dylib";
};
/* End PBXContainerItemProxy section */
]]
end
Expand All @@ -107,19 +128,20 @@
test.capture [[
/* Begin PBXFileReference section */
[MyProject2.xcodeproj] /* libMyProject2-d.a */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "MyProject2.xcodeproj"; path = MyProject2.xcodeproj; sourceTree = SOURCE_ROOT; };
[MyProject3.xcodeproj] /* libMyProject3-d.dylib */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "MyProject3.xcodeproj"; path = MyProject3.xcodeproj; sourceTree = SOURCE_ROOT; };
[MyProject:product] /* MyProject */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = MyProject; path = MyProject; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
]]
end

function suite.PBXFileReference_UsesRelativePaths()
prj.location = "MyProject"
prj2.location = "MyProject2"
prepare()
xcode.PBXFileReference(tr)
test.capture [[
/* Begin PBXFileReference section */
[MyProject2.xcodeproj] /* libMyProject2-d.a */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "MyProject2.xcodeproj"; path = ../MyProject2.xcodeproj; sourceTree = SOURCE_ROOT; };
[MyProject3.xcodeproj] /* libMyProject3-d.dylib */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "MyProject3.xcodeproj"; path = ../MyProject3.xcodeproj; sourceTree = SOURCE_ROOT; };
[MyProject:product] /* MyProject */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = MyProject; path = MyProject; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
]]
Expand Down Expand Up @@ -148,7 +170,7 @@
end

function suite.PBXFrameworksBuildPhase_ListsDependencies_OnSharedLib()
kind "SharedLib"
prj2.kind="SharedLib"
prepare()
xcode.PBXFrameworksBuildPhase(tr)
test.capture [[
Expand Down Expand Up @@ -182,6 +204,14 @@
name = Products;
sourceTree = "<group>";
};
[MyProject3.xcodeproj:prodgrp] /* Products */ = {
isa = PBXGroup;
children = (
[libMyProject3-d.dylib] /* libMyProject3-d.dylib */,
);
name = Products;
sourceTree = "<group>";
};
[MyProject] /* MyProject */ = {
isa = PBXGroup;
children = (
Expand All @@ -203,6 +233,7 @@
isa = PBXGroup;
children = (
[MyProject2.xcodeproj] /* MyProject2.xcodeproj */,
[MyProject3.xcodeproj] /* MyProject3.xcodeproj */,
);
name = Projects;
sourceTree = "<group>";
Expand Down Expand Up @@ -233,6 +264,7 @@
);
dependencies = (
[MyProject2.xcodeproj:targdep] /* PBXTargetDependency */,
[MyProject3.xcodeproj:targdep] /* PBXTargetDependency */,
);
name = MyProject;
productInstallPath = "$(HOME)/bin";
Expand Down Expand Up @@ -266,6 +298,10 @@
ProductGroup = [MyProject2.xcodeproj:prodgrp] /* Products */;
ProjectRef = [MyProject2.xcodeproj] /* MyProject2.xcodeproj */;
},
{
ProductGroup = [MyProject3.xcodeproj:prodgrp] /* Products */;
ProjectRef = [MyProject3.xcodeproj] /* MyProject3.xcodeproj */;
},
);
projectRoot = "";
targets = (
Expand Down Expand Up @@ -293,6 +329,13 @@
remoteRef = [MyProject2.xcodeproj:prodprox] /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
[libMyProject3-d.dylib] /* libMyProject3-d.dylib */ = {
isa = PBXReferenceProxy;
fileType = "compiled.mach-o.dylib";
path = "libMyProject3-d.dylib";
remoteRef = [MyProject3.xcodeproj:prodprox] /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
]]
end
Expand All @@ -312,6 +355,11 @@
name = "libMyProject2-d.a";
targetProxy = [MyProject2.xcodeproj:targprox] /* PBXContainerItemProxy */;
};
[MyProject3.xcodeproj:targdep] /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = "libMyProject3-d.dylib";
targetProxy = [MyProject3.xcodeproj:targprox] /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
]]
end
210 changes: 210 additions & 0 deletions tests/test_xcode_scheme.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
---
-- tests/test_xcode_scheme.lua
-- Automated test suite for Xcode scheme generation.
-- Copyright (c) 2011-2016 Jason Perkins and the Premake project
---


local suite = test.declare("xcode4_scheme")
local xcode = premake.modules.xcode
local scheme = xcode.scheme

---------------------------------------------------------------------------
-- Setup/Teardown
---------------------------------------------------------------------------

local wks, prj

function suite.teardown()
wks = nil
prj = nil
end

function suite.setup()
_ACTION = "xcode4"
xcode.used_ids = { } -- reset the list of generated IDs

wks = test.createWorkspace()
end

local function prepare()
wks = premake.oven.bakeWorkspace(wks)
xcode.prepareWorkspace(wks)
prj = premake.workspace.getproject(wks, 1)
local tr = xcode.buildprjtree(prj)
end

---------------------------------------------------------------------------
-- Header
---------------------------------------------------------------------------

function suite.scheme_header()
prepare()
scheme.Header(prj)
test.capture [[
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
version = "1.3">
]]
end

---------------------------------------------------------------------------
-- Footer
---------------------------------------------------------------------------

function suite.scheme_footer()
prepare()
scheme.Footer(prj)
test.capture [[
</Scheme>
]]
end

---------------------------------------------------------------------------
-- Build
---------------------------------------------------------------------------

function suite.scheme_build()
prepare()
scheme.build(prj)
test.capture [[
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "[MyProject:target]"
BuildableName = "MyProject"
BlueprintName = "MyProject"
ReferencedContainer = "container:MyProject.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
]]
end

---------------------------------------------------------------------------
-- Test
---------------------------------------------------------------------------

function suite.scheme_test()
prepare()
scheme.test(prj)
test.capture [[
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "[MyProject:target]"
BuildableName = "MyProject"
BlueprintName = "MyProject"
ReferencedContainer = "container:MyProject.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
]]
end

---------------------------------------------------------------------------
-- Launch
---------------------------------------------------------------------------

function suite.scheme_launch()
prepare()
scheme.launch(prj)
test.capture [[
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "NO"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "[MyProject:target]"
BuildableName = "MyProject"
BlueprintName = "MyProject"
ReferencedContainer = "container:MyProject.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
]]
end

---------------------------------------------------------------------------
-- Profile
---------------------------------------------------------------------------

function suite.scheme_profile()
prepare()
scheme.profile(prj)
test.capture [[
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "NO">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "[MyProject:target]"
BuildableName = "MyProject"
BlueprintName = "MyProject"
ReferencedContainer = "container:MyProject.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
]]
end

---------------------------------------------------------------------------
-- Analyze
---------------------------------------------------------------------------

function suite.scheme_analyze()
prepare()
scheme.analyze(prj)
test.capture [[
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
]]
end

---------------------------------------------------------------------------
-- Archive
---------------------------------------------------------------------------

function suite.scheme_archive()
prepare()
scheme.archive(prj)
test.capture [[
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
]]
end

Loading