diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2018-05-03 11:24:26 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2018-05-14 08:35:08 +0000 |
commit | 2bda52aa3d50deb56128f42395ae9f2686af2a99 (patch) | |
tree | ec88cd206f39606aa97df9a72c05cfea5fc2f203 /share | |
parent | b9a1173d3b3677416295c4739aa53d35365fa0e1 (diff) |
Make cpp.cxxLanguageVersion a list
... and choose the highest entry. This enables different modules to
specify their requirements without introducing conflicts.
Same for cpp.cLanguageVersion.
Task-number: QBS-1225
Change-Id: I96ed6c370eb190023fdb69274dcb080d967f512d
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'share')
-rw-r--r-- | share/qbs/modules/cpp/CppModule.qbs | 2 | ||||
-rw-r--r-- | share/qbs/modules/cpp/cpp.js | 46 | ||||
-rw-r--r-- | share/qbs/modules/cpp/gcc.js | 9 | ||||
-rw-r--r-- | share/qbs/modules/cpp/msvc.js | 4 |
4 files changed, 57 insertions, 4 deletions
diff --git a/share/qbs/modules/cpp/CppModule.qbs b/share/qbs/modules/cpp/CppModule.qbs index 377b89ede..1c42169d5 100644 --- a/share/qbs/modules/cpp/CppModule.qbs +++ b/share/qbs/modules/cpp/CppModule.qbs @@ -283,7 +283,7 @@ Module { description: "The version of the C standard with which the code must comply." } - property string cxxLanguageVersion + property stringList cxxLanguageVersion PropertyOptions { name: "cxxLanguageVersion" allowedValues: ["c++98", "c++11", "c++14", "c++17"] diff --git a/share/qbs/modules/cpp/cpp.js b/share/qbs/modules/cpp/cpp.js new file mode 100644 index 000000000..0e440bdb0 --- /dev/null +++ b/share/qbs/modules/cpp/cpp.js @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** 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 http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +function languageVersion(versionArray, knownValues, lang) { + if (!versionArray) + return undefined; + var versions = [].uniqueConcat(versionArray); + if (versions.length === 1) + return versions[0]; + for (var i = 0; i < knownValues.length; ++i) { + var candidate = knownValues[i]; + if (versions.contains(candidate)) + return candidate; + } + var version = versions[0]; + console.debug("Randomly choosing '" + version + + "' from list of unknown " + lang + " version strings (" + versions + ")"); + return version; +} diff --git a/share/qbs/modules/cpp/gcc.js b/share/qbs/modules/cpp/gcc.js index ce6871c70..5ac936eb0 100644 --- a/share/qbs/modules/cpp/gcc.js +++ b/share/qbs/modules/cpp/gcc.js @@ -28,6 +28,7 @@ ** ****************************************************************************/ +var Cpp = require("cpp.js"); var File = require("qbs.File"); var FileInfo = require("qbs.FileInfo"); var DarwinTools = require("qbs.DarwinTools"); @@ -866,10 +867,14 @@ function compilerFlags(project, product, input, output, explicitlyDependsOn) { switch (tag) { case "c": case "objc": - return input.cpp.cLanguageVersion; + var knownValues = ["c11", "c99", "c90", "c89"]; + return Cpp.languageVersion(input.cpp.cLanguageVersion, knownValues, "C"); case "cpp": case "objcpp": - return input.cpp.cxxLanguageVersion; + knownValues = ["c++20", "c++2a", "c++17", "c++1z", + "c++14", "c++1y", "c++11", "c++0x", + "c++03", "c++98"]; + return Cpp.languageVersion(input.cpp.cxxLanguageVersion, knownValues, "C++"); } } diff --git a/share/qbs/modules/cpp/msvc.js b/share/qbs/modules/cpp/msvc.js index 4be20bfd1..e96b53d8f 100644 --- a/share/qbs/modules/cpp/msvc.js +++ b/share/qbs/modules/cpp/msvc.js @@ -28,6 +28,7 @@ ** ****************************************************************************/ +var Cpp = require("cpp.js"); var File = require("qbs.File"); var FileInfo = require("qbs.FileInfo"); var ModUtils = require("qbs.ModUtils"); @@ -65,7 +66,8 @@ function hasCxx17Option(input) } function addLanguageVersionFlag(input, args) { - var cxxVersion = input.cpp.cxxLanguageVersion; + var cxxVersion = Cpp.languageVersion(input.cpp.cxxLanguageVersion, + ["c++17", "c++14", "c++11", "c++98"], "C++"); if (!cxxVersion) return; |