summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2015-02-09 15:01:30 +0100
committerTor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>2015-03-06 19:01:43 +0000
commit08f6af608a8269dfa7d3e2f58be45ee0df72b925 (patch)
treed03d29f89012d505b415fdaa956cd2635561d87b
parent91828af6c508c5bb9c0c819d1fe18cc2273f1810 (diff)
Xcode: Generate scheme manually, instead of letting Xcode do it
A scheme is required to be able to run tests through Xcode, even from the command line, but Xcode doesn't auto-generate the schemes until launched as an application. Xcode also auto-generates schemes for all our targets, but we only need one for the primary application target. Change-Id: Ia42f3825aba3ffde3be93be55e165d6284434853 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
-rw-r--r--mkspecs/macx-xcode/WorkspaceSettings.xcsettings8
-rw-r--r--mkspecs/macx-xcode/default.xcscheme96
-rw-r--r--mkspecs/macx-xcode/qmake.conf2
-rw-r--r--qmake/generators/mac/pbuilder_pbx.cpp46
4 files changed, 152 insertions, 0 deletions
diff --git a/mkspecs/macx-xcode/WorkspaceSettings.xcsettings b/mkspecs/macx-xcode/WorkspaceSettings.xcsettings
new file mode 100644
index 0000000000..08de0be8d3
--- /dev/null
+++ b/mkspecs/macx-xcode/WorkspaceSettings.xcsettings
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
+ <false/>
+</dict>
+</plist>
diff --git a/mkspecs/macx-xcode/default.xcscheme b/mkspecs/macx-xcode/default.xcscheme
new file mode 100644
index 0000000000..53c736cc15
--- /dev/null
+++ b/mkspecs/macx-xcode/default.xcscheme
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "0610"
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ <BuildActionEntries>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "YES"
+ buildForArchiving = "YES"
+ buildForAnalyzing = "YES">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "@TARGET_PBX_KEY@"
+ BuildableName = "@QMAKE_ORIG_TARGET@"
+ BlueprintName = "@QMAKE_ORIG_TARGET@"
+ ReferencedContainer = "container:@QMAKE_ORIG_TARGET@.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ </BuildActionEntries>
+ </BuildAction>
+ <TestAction
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ buildConfiguration = "Debug">
+ <Testables>
+ <TestableReference
+ skipped = "NO">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "@TARGET_PBX_KEY@"
+ BuildableName = "@QMAKE_ORIG_TARGET@"
+ BlueprintName = "@QMAKE_ORIG_TARGET@"
+ ReferencedContainer = "container:@QMAKE_ORIG_TARGET@.xcodeproj">
+ </BuildableReference>
+ </TestableReference>
+ </Testables>
+ <MacroExpansion>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "@TARGET_PBX_KEY@"
+ BuildableName = "@QMAKE_ORIG_TARGET@"
+ BlueprintName = "@QMAKE_ORIG_TARGET@"
+ ReferencedContainer = "container:@QMAKE_ORIG_TARGET@.xcodeproj">
+ </BuildableReference>
+ </MacroExpansion>
+ </TestAction>
+ <LaunchAction
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ buildConfiguration = "Debug"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ allowLocationSimulation = "YES">
+ <BuildableProductRunnable>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "@TARGET_PBX_KEY@"
+ BuildableName = "@QMAKE_ORIG_TARGET@"
+ BlueprintName = "@QMAKE_ORIG_TARGET@"
+ ReferencedContainer = "container:@QMAKE_ORIG_TARGET@.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ buildConfiguration = "Release"
+ debugDocumentVersioning = "YES">
+ <BuildableProductRunnable>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "@TARGET_PBX_KEY@"
+ BuildableName = "@QMAKE_ORIG_TARGET@"
+ BlueprintName = "@QMAKE_ORIG_TARGET@"
+ ReferencedContainer = "container:@QMAKE_ORIG_TARGET@.xcodeproj">
+ </BuildableReference>
+ </BuildableProductRunnable>
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
diff --git a/mkspecs/macx-xcode/qmake.conf b/mkspecs/macx-xcode/qmake.conf
index fde682b64b..6fc6160ec7 100644
--- a/mkspecs/macx-xcode/qmake.conf
+++ b/mkspecs/macx-xcode/qmake.conf
@@ -6,6 +6,8 @@
QMAKESPEC = $$dirname(PWD)/$$[QMAKE_XSPEC]
+QMAKE_XCODE_SPECDIR = $$PWD
+
include($$QMAKESPEC/qmake.conf)
MAKEFILE_GENERATOR = XCODE
diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp
index 36ec6ef742..e2b5f5f90b 100644
--- a/qmake/generators/mac/pbuilder_pbx.cpp
+++ b/qmake/generators/mac/pbuilder_pbx.cpp
@@ -1573,6 +1573,52 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
}
}
+ // Scheme
+ {
+ QString xcodeSpecDir = project->first("QMAKE_XCODE_SPECDIR").toQString();
+
+ bool wroteCustomScheme = false;
+
+ QString projectSharedSchemesPath = pbx_dir + "/xcshareddata/xcschemes";
+ if (mkdir(projectSharedSchemesPath)) {
+ QString target = project->first("QMAKE_ORIG_TARGET").toQString();
+
+ QFile defaultSchemeFile(xcodeSpecDir + "/default.xcscheme");
+ QFile outputSchemeFile(projectSharedSchemesPath + Option::dir_sep + target + ".xcscheme");
+
+ if (defaultSchemeFile.open(QIODevice::ReadOnly)
+ && outputSchemeFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
+
+ QTextStream defaultSchemeStream(&defaultSchemeFile);
+ QString schemeData = defaultSchemeStream.readAll();
+
+ schemeData.replace("@QMAKE_ORIG_TARGET@", target);
+ schemeData.replace("@TARGET_PBX_KEY@", keyFor(pbx_dir + "QMAKE_PBX_TARGET"));
+
+ QTextStream outputSchemeStream(&outputSchemeFile);
+ outputSchemeStream << schemeData;
+
+ wroteCustomScheme = true;
+ }
+ }
+
+ if (wroteCustomScheme) {
+ // Prevent Xcode from auto-generating schemes
+ QString workspaceSettingsFilename("WorkspaceSettings.xcsettings");
+ QString workspaceSharedDataPath = pbx_dir + "/project.xcworkspace/xcshareddata";
+ if (mkdir(workspaceSharedDataPath)) {
+ QFile::copy(xcodeSpecDir + Option::dir_sep + workspaceSettingsFilename,
+ workspaceSharedDataPath + Option::dir_sep + workspaceSettingsFilename);
+ } else {
+ wroteCustomScheme = false;
+ }
+ }
+
+ if (!wroteCustomScheme)
+ warn_msg(WarnLogic, "Failed to generate schemes in '%s', " \
+ "falling back to Xcode auto-generated schemes", qPrintable(projectSharedSchemesPath));
+ }
+
qmake_setpwd(input_dir);
return true;