summaryrefslogtreecommitdiffstats
path: root/qmake
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 /qmake
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>
Diffstat (limited to 'qmake')
-rw-r--r--qmake/generators/mac/pbuilder_pbx.cpp46
1 files changed, 46 insertions, 0 deletions
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;