diff options
author | Jake Petroules <jake.petroules@qt.io> | 2017-03-13 17:31:44 -0700 |
---|---|---|
committer | Jake Petroules <jake.petroules@qt.io> | 2017-03-22 20:12:56 +0000 |
commit | 6909d0dd1ce59d93071ce24ebd12c7c6436b93d1 (patch) | |
tree | 1156298a1075d101b1ba1cb340b952aab4fe323a | |
parent | 6ca71e5b61c5b1e4ec4c931665a2f3f34709cc23 (diff) |
Add support for QNX and the QCC toolchain
[ChangeLog] Added support for QNX and the QCC toolchain
Change-Id: Id5b1c451d3ca7c3a1445f2481af3bc4caf90798f
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r-- | share/qbs/modules/cpp/gcc.js | 16 | ||||
-rw-r--r-- | share/qbs/modules/cpp/genericunix-gcc.qbs | 2 | ||||
-rw-r--r-- | share/qbs/modules/cpp/qnx-qcc.qbs | 92 | ||||
-rw-r--r-- | share/qbs/modules/qbs/common.qbs | 6 | ||||
-rw-r--r-- | share/qbs/modules/qnx/qnx.qbs | 106 | ||||
-rw-r--r-- | src/lib/corelib/tools/architectures.cpp | 18 |
6 files changed, 231 insertions, 9 deletions
diff --git a/share/qbs/modules/cpp/gcc.js b/share/qbs/modules/cpp/gcc.js index 178541cde..fbcca23b0 100644 --- a/share/qbs/modules/cpp/gcc.js +++ b/share/qbs/modules/cpp/gcc.js @@ -248,7 +248,9 @@ function linkerFlags(project, product, inputs, output) { var sysroot = product.cpp.sysroot; if (sysroot) { - if (isDarwin) + if (product.qbs.toolchain.contains("qcc")) + args = args.concat(escapeLinkerFlags(product, inputs, ["--sysroot=" + sysroot])); + else if (isDarwin) args = args.concat(escapeLinkerFlags(product, inputs, ["-syslibroot", sysroot])); else args.push("--sysroot=" + sysroot); // do not escape, compiler-as-linker also needs it @@ -480,7 +482,9 @@ function compilerFlags(project, product, input, output) { var sysroot = product.cpp.sysroot; if (sysroot) { - if (product.qbs.targetOS.contains("darwin")) + if (product.qbs.toolchain.contains("qcc")) + args.push("-I" + FileInfo.joinPaths(sysroot, "usr", "include")); + else if (product.qbs.targetOS.contains("darwin")) args.push("-isysroot", sysroot); else args.push("--sysroot=" + sysroot); @@ -507,7 +511,9 @@ function compilerFlags(project, product, input, output) { args.push('-Werror'); args = args.concat(configFlags(input)); - args.push('-pipe'); + + if (!input.qbs.toolchain.contains("qcc")) + args.push('-pipe'); if (input.cpp.enableReproducibleBuilds) { var toolchain = product.qbs.toolchain; @@ -1064,7 +1070,9 @@ function dumpMacros(env, compilerFilePath, args, nullDevice) { p.setEnv("LC_ALL", "C"); for (var key in env) p.setEnv(key, env[key]); - p.exec(compilerFilePath, (args || []).concat(["-dM", "-E", "-x", "c", nullDevice]), true); + // qcc NEEDS the explicit -Wp, prefix to -dM; clang and gcc do not but all three accept it + p.exec(compilerFilePath, + (args || []).concat(["-Wp,-dM", "-E", "-x", "c", nullDevice]), true); var map = {}; p.readStdOut().trim().split("\n").map(function (line) { var parts = line.split(" ", 3); diff --git a/share/qbs/modules/cpp/genericunix-gcc.qbs b/share/qbs/modules/cpp/genericunix-gcc.qbs index b4c4fcccb..fa43a3c79 100644 --- a/share/qbs/modules/cpp/genericunix-gcc.qbs +++ b/share/qbs/modules/cpp/genericunix-gcc.qbs @@ -31,6 +31,6 @@ import qbs 1.0 UnixGCC { - condition: qbs.targetOS && !qbs.targetOS.containsAny(['darwin', 'freebsd', 'linux']) && + condition: qbs.targetOS && !qbs.targetOS.containsAny(['darwin', 'freebsd', 'linux', 'qnx']) && qbs.toolchain && qbs.toolchain.contains('gcc') && !qbs.toolchain.contains('mingw') } diff --git a/share/qbs/modules/cpp/qnx-qcc.qbs b/share/qbs/modules/cpp/qnx-qcc.qbs new file mode 100644 index 000000000..ed9d1571f --- /dev/null +++ b/share/qbs/modules/cpp/qnx-qcc.qbs @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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. +** +****************************************************************************/ + +import qbs +import qbs.FileInfo + +UnixGCC { + Depends { name: "qnx" } + + condition: qbs.targetOS.contains("qnx") && + qbs.toolchain && qbs.toolchain.contains("qcc") + + distributionIncludePaths: FileInfo.joinPaths(qnx.targetDir, "usr", "include") + + toolchainInstallPath: FileInfo.joinPaths(qnx.hostDir, "usr", "bin") + + sysroot: qnx.targetDir + + cCompilerName: "qcc" + compilerExtension + cxxCompilerName: "q++" + compilerExtension + + targetDriverFlags: qnxTarget ? ["-V" + qnxTarget] : [] + + property string qnxTarget: qbs.architecture + ? qnx.compilerName + "_" + targetSystem + qnxTargetArchName + : undefined + + property string qnxTargetArchName: { + switch (qbs.architecture) { + case "arm64": + return "aarch64le"; + case "armv7a": + return "armv7le"; + case "x86": + case "x86_64": + return qbs.architecture; + } + } + + // QNX doesn't support Objective-C or Objective-C++ and qcc/q++ don't use toolchainPrefix + compilerPath: FileInfo.joinPaths(toolchainInstallPath, compilerName) + compilerPathByLanguage: ({ + "c": FileInfo.joinPaths(toolchainInstallPath, cCompilerName), + "cpp": FileInfo.joinPaths(toolchainInstallPath, cxxCompilerName), + "objc": undefined, + "objcpp": undefined, + "asm_cpp": FileInfo.joinPaths(toolchainInstallPath, cCompilerName) + }) + + toolchainPrefix: target + "-" + + targetVendor: ["x86", "x86_64"].contains(qbs.architecture) ? "pc" : base + targetSystem: "nto" + targetAbi: "qnx" + qnx.version + (qnxTargetArchName === "armv7le" ? "eabi" : "") + + buildEnv: qnx.buildEnv + + setupBuildEnvironment: { + for (var key in buildEnv) { + v = new ModUtils.EnvironmentVariable(key); + v.value = buildEnv[key]; + v.set(); + } + } +} diff --git a/share/qbs/modules/qbs/common.qbs b/share/qbs/modules/qbs/common.qbs index 44fc02bf9..541e26940 100644 --- a/share/qbs/modules/qbs/common.qbs +++ b/share/qbs/modules/qbs/common.qbs @@ -86,8 +86,12 @@ Module { tc = hostOS.contains("windows") ? "msvc" : "mingw"; else if (targetOS.contains("darwin")) tc = hostOS.contains("macos") ? "xcode" : "clang"; + else if (targetOS.contains("freebsd")) + tc = "clang"; + else if (targetOS.contains("qnx")) + tc = "qcc"; else - tc = targetOS.contains("freebsd") ? "clang" : "gcc"; + tc = "gcc"; return Utilities.canonicalToolchain(tc); } property string architecture diff --git a/share/qbs/modules/qnx/qnx.qbs b/share/qbs/modules/qnx/qnx.qbs new file mode 100644 index 000000000..c84119e96 --- /dev/null +++ b/share/qbs/modules/qnx/qnx.qbs @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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. +** +****************************************************************************/ + +import qbs +import qbs.Environment +import qbs.File +import qbs.FileInfo +import qbs.ModUtils +import qbs.Probes + +Module { + Probes.PathProbe { + id: qnxSdkProbe + names: ["qnx700", "qnx660", "qnx650"] + pathPrefixes: [Environment.getEnv("HOME"), "/opt"] + } + + Probe { + id: qnxTargetOsProbe + property string qnxSdkDir: sdkDir + property stringList targets: [] + configure: { + if (qnxSdkDir) { + var validEntries = []; + var entries = File.directoryEntries( + FileInfo.joinPaths(qnxSdkDir, "target"), + File.Dirs | File.NoDotAndDotDot); + for (var i = 0; i < entries.length; ++i) { + if (/^qnx[0-9]$/.test(entries[i])) + validEntries.push(entries[i]); + } + validEntries.sort(); + validEntries.reverse(); + targets = validEntries; + found = targets.length > 0; + } else { + found = false; + } + } + } + + version: qnxSdkProbe.found ? qnxSdkProbe.fileName.substr(3, 3).split("").join(".") : undefined + + property string sdkDir: qnxSdkProbe.filePath + + property string hostArch: "x86_64" + + property string hostOs: { + if (qbs.hostOS.contains("linux")) + return "linux"; + if (qbs.hostOS.contains("macos")) + return "darwin"; + if (qbs.hostOS.contains("windows")) + return "win64"; + } + + property string targetOs: qnxTargetOsProbe.targets[0] + + property string compilerName: "gcc" + + property string configurationDir: FileInfo.joinPaths(Environment.getEnv("HOME"), ".qnx") + property string hostDir: FileInfo.joinPaths(sdkDir, "host", hostOs, hostArch) + property string targetDir: FileInfo.joinPaths(sdkDir, "target", targetOs) + + property var buildEnv: ({ + "QNX_HOST": hostDir, + "QNX_TARGET": targetDir, + "QNX_CONFIGURATION": configurationDir + }) + + validate: { + var validator = new ModUtils.PropertyValidator("qnx"); + validator.setRequiredProperty("sdkDir", sdkDir); + validator.setRequiredProperty("hostArch", hostArch); + validator.setRequiredProperty("hostOs", hostOs); + validator.setRequiredProperty("targetOs", targetOs); + return validator.validate(); + } +} diff --git a/src/lib/corelib/tools/architectures.cpp b/src/lib/corelib/tools/architectures.cpp index b2ef2d20a..ce9a0f28f 100644 --- a/src/lib/corelib/tools/architectures.cpp +++ b/src/lib/corelib/tools/architectures.cpp @@ -58,12 +58,24 @@ QString canonicalTargetArchitecture(const QString &architecture, || system == QStringLiteral("tvos") || system == QStringLiteral("watchos") || abi == QStringLiteral("macho")); + const bool isQnx = (system == QStringLiteral("nto") + || abi.startsWith(QStringLiteral("qnx"))); + + if (arch == QStringLiteral("armv7a")) { + if (isApple) + return QStringLiteral("armv7"); + if (isQnx) + return QStringLiteral("arm"); + } - if (arch == QStringLiteral("armv7a") && isApple) - return QStringLiteral("armv7"); + if (arch == QStringLiteral("arm64") && isQnx) + return QStringLiteral("aarch64"); - if (arch == QStringLiteral("x86")) + if (arch == QStringLiteral("x86")) { + if (isQnx) + return QStringLiteral("i586"); return QStringLiteral("i386"); + } return arch; } |