aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArrigo Zanette <zanettea@gmail.com>2018-01-08 02:55:52 -0800
committerChristian Kandeler <christian.kandeler@qt.io>2018-01-08 14:00:17 +0000
commitb08481ec22ffb42f6ce36ccdee57c60724c44bf4 (patch)
treefe85249df3cd48f94a43e630f354e50e91bf270c
parent3bde712fa2c1f926720e85d20ae7fd5f9f378fef (diff)
GCC: Reorder prefixHeaders and precompiled headers
Prefix headers should follow precompiled headers on the gcc command line. Testcase added. Change-Id: I3dfba8cae9c894932acce5c0a67f16d7d072c94b Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r--share/qbs/modules/cpp/gcc.js12
-rw-r--r--tests/auto/blackbox/testdata/precompiled-and-prefix-headers/main.cpp31
-rw-r--r--tests/auto/blackbox/testdata/precompiled-and-prefix-headers/pch.h28
-rw-r--r--tests/auto/blackbox/testdata/precompiled-and-prefix-headers/precompiled-and-prefix-headers.qbs13
-rw-r--r--tests/auto/blackbox/testdata/precompiled-and-prefix-headers/prefix.h28
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp6
-rw-r--r--tests/auto/blackbox/tst_blackbox.h1
7 files changed, 113 insertions, 6 deletions
diff --git a/share/qbs/modules/cpp/gcc.js b/share/qbs/modules/cpp/gcc.js
index f638d3cb3..be0829322 100644
--- a/share/qbs/modules/cpp/gcc.js
+++ b/share/qbs/modules/cpp/gcc.js
@@ -702,12 +702,6 @@ function compilerFlags(project, product, input, output, explicitlyDependsOn) {
args.push('-fvisibility=default')
}
- var prefixHeaders = input.cpp.prefixHeaders;
- for (i in prefixHeaders) {
- args.push('-include');
- args.push(prefixHeaders[i]);
- }
-
if (compilerInfo.language)
// Only push language arguments if we have to.
Array.prototype.push.apply(args, compilerInfo.language);
@@ -728,6 +722,12 @@ function compilerFlags(project, product, input, output, explicitlyDependsOn) {
args.push('-include', pchFilePath);
}
+ var prefixHeaders = input.cpp.prefixHeaders;
+ for (i in prefixHeaders) {
+ args.push('-include');
+ args.push(prefixHeaders[i]);
+ }
+
var positionIndependentCode = input.cpp.positionIndependentCode;
if (positionIndependentCode && !product.qbs.toolchain.contains("mingw"))
args.push('-fPIC');
diff --git a/tests/auto/blackbox/testdata/precompiled-and-prefix-headers/main.cpp b/tests/auto/blackbox/testdata/precompiled-and-prefix-headers/main.cpp
new file mode 100644
index 000000000..98e7b4060
--- /dev/null
+++ b/tests/auto/blackbox/testdata/precompiled-and-prefix-headers/main.cpp
@@ -0,0 +1,31 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qbs.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+int main()
+{
+}
diff --git a/tests/auto/blackbox/testdata/precompiled-and-prefix-headers/pch.h b/tests/auto/blackbox/testdata/precompiled-and-prefix-headers/pch.h
new file mode 100644
index 000000000..f19f4b59d
--- /dev/null
+++ b/tests/auto/blackbox/testdata/precompiled-and-prefix-headers/pch.h
@@ -0,0 +1,28 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qbs.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
diff --git a/tests/auto/blackbox/testdata/precompiled-and-prefix-headers/precompiled-and-prefix-headers.qbs b/tests/auto/blackbox/testdata/precompiled-and-prefix-headers/precompiled-and-prefix-headers.qbs
new file mode 100644
index 000000000..b30f76874
--- /dev/null
+++ b/tests/auto/blackbox/testdata/precompiled-and-prefix-headers/precompiled-and-prefix-headers.qbs
@@ -0,0 +1,13 @@
+import qbs
+
+CppApplication {
+ name: "MyApp"
+ consoleApplication: true
+ cpp.includePaths: [product.buildDirectory]
+ cpp.prefixHeaders: [ "prefix.h" ]
+ Group {
+ files: ["pch.h"]
+ fileTags: ["cpp_pch_src"]
+ }
+ files: ["main.cpp"]
+}
diff --git a/tests/auto/blackbox/testdata/precompiled-and-prefix-headers/prefix.h b/tests/auto/blackbox/testdata/precompiled-and-prefix-headers/prefix.h
new file mode 100644
index 000000000..f19f4b59d
--- /dev/null
+++ b/tests/auto/blackbox/testdata/precompiled-and-prefix-headers/prefix.h
@@ -0,0 +1,28 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qbs.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index a8b82eabb..954c5cd6a 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -2386,6 +2386,12 @@ void TestBlackbox::pluginDependency()
QVERIFY(m_qbsStdout.contains("plugin4"));
}
+void TestBlackbox::precompiledAndPrefixHeaders()
+{
+ QDir::setCurrent(testDataDir + "/precompiled-and-prefix-headers");
+ QCOMPARE(runQbs(), 0);
+}
+
void TestBlackbox::probeChangeTracking()
{
QDir::setCurrent(testDataDir + "/probe-change-tracking");
diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h
index cc21c2be9..f08e1ad25 100644
--- a/tests/auto/blackbox/tst_blackbox.h
+++ b/tests/auto/blackbox/tst_blackbox.h
@@ -160,6 +160,7 @@ private slots:
void pkgConfigProbe_data();
void pkgConfigProbeSysroot();
void pluginDependency();
+ void precompiledAndPrefixHeaders();
void probeChangeTracking();
void probeProperties();
void probeInExportedModule();