diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2017-04-21 09:57:19 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2017-04-28 11:08:05 +0000 |
commit | b4aa71223c18599302d600b079e20fc0fb51009a (patch) | |
tree | 70243969c32958fe89489cb45948599c2a1309eb | |
parent | 9503948fd9195f0d07456e66e4dbf7c781f82ef8 (diff) |
Support command files in cpp.{static,dynamic}Libraries
We will make use of that in a follow-up patch.
Change-Id: I1fb6ca0938bbcc6f53bd0046761023a1b8563949
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r-- | share/qbs/modules/cpp/gcc.js | 2 | ||||
-rw-r--r-- | share/qbs/modules/cpp/msvc.js | 2 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/processcommandexecutor.cpp | 13 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/command-file/command-file.qbs | 17 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/command-file/lib.cpp | 1 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/command-file/list.gcc | 1 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/command-file/list.msvc | 1 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/command-file/main.cpp | 6 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.cpp | 9 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.h | 1 |
10 files changed, 50 insertions, 3 deletions
diff --git a/share/qbs/modules/cpp/gcc.js b/share/qbs/modules/cpp/gcc.js index def8d6c76..70c1c0874 100644 --- a/share/qbs/modules/cpp/gcc.js +++ b/share/qbs/modules/cpp/gcc.js @@ -365,7 +365,7 @@ function linkerFlags(project, product, inputs, output) { } args = args.concat(libraryDependencies.libraries.map(function(lib) { - return FileInfo.isAbsolutePath(lib) + return FileInfo.isAbsolutePath(lib) || lib.startsWith('@') ? lib : '-l' + lib; })); diff --git a/share/qbs/modules/cpp/msvc.js b/share/qbs/modules/cpp/msvc.js index 92b37bfb5..b1f9686e0 100644 --- a/share/qbs/modules/cpp/msvc.js +++ b/share/qbs/modules/cpp/msvc.js @@ -230,7 +230,7 @@ function collectLibraryDependencies(product) { ModUtils.sanitizedModuleProperty(obj, "cpp", "staticLibraries"), ModUtils.sanitizedModuleProperty(obj, "cpp", "dynamicLibraries")); externalLibs.forEach(function (libName) { - if (!libName.match(/\.lib$/i)) + if (!libName.match(/\.lib$/i) && !libName.startsWith('@')) libName += ".lib"; addFilePath(libName); }); diff --git a/src/lib/corelib/buildgraph/processcommandexecutor.cpp b/src/lib/corelib/buildgraph/processcommandexecutor.cpp index 3efcc2653..25a80f5be 100644 --- a/src/lib/corelib/buildgraph/processcommandexecutor.cpp +++ b/src/lib/corelib/buildgraph/processcommandexecutor.cpp @@ -144,7 +144,18 @@ void ProcessCommandExecutor::doStart() return; } for (int i = cmd->responseFileArgumentIndex(); i < cmd->arguments().count(); ++i) { - responseFile.write(qbs::Internal::shellQuote(cmd->arguments().at(i)).toLocal8Bit()); + const QString arg = cmd->arguments().at(i); + if (arg.startsWith(cmd->responseFileUsagePrefix())) { + QFile f(arg.mid(cmd->responseFileUsagePrefix().count())); + if (!f.open(QIODevice::ReadOnly)) { + emit finished(ErrorInfo(Tr::tr("Cannot open command file '%1'.") + .arg(QDir::toNativeSeparators(f.fileName())))); + return; + } + responseFile.write(f.readAll()); + } else { + responseFile.write(qbs::Internal::shellQuote(arg).toLocal8Bit()); + } responseFile.write("\n"); } responseFile.close(); diff --git a/tests/auto/blackbox/testdata/command-file/command-file.qbs b/tests/auto/blackbox/testdata/command-file/command-file.qbs new file mode 100644 index 000000000..09823b152 --- /dev/null +++ b/tests/auto/blackbox/testdata/command-file/command-file.qbs @@ -0,0 +1,17 @@ +import qbs + +Project { + StaticLibrary { + name: "theLib" + destinationDirectory: project.buildDirectory + Depends { name: "cpp" } + files: ["lib.cpp"] + } + CppApplication { + name: "theApp" + cpp.libraryPaths: project.buildDirectory + files: ["main.cpp"] + cpp.staticLibraries: ['@' + sourceDirectory + '/' + + (qbs.toolchain.contains("msvc") ? "list.msvc" : "list.gcc")] + } +} diff --git a/tests/auto/blackbox/testdata/command-file/lib.cpp b/tests/auto/blackbox/testdata/command-file/lib.cpp new file mode 100644 index 000000000..8101b05dc --- /dev/null +++ b/tests/auto/blackbox/testdata/command-file/lib.cpp @@ -0,0 +1 @@ +void f() { } diff --git a/tests/auto/blackbox/testdata/command-file/list.gcc b/tests/auto/blackbox/testdata/command-file/list.gcc new file mode 100644 index 000000000..2bb6dae62 --- /dev/null +++ b/tests/auto/blackbox/testdata/command-file/list.gcc @@ -0,0 +1 @@ +-ltheLib diff --git a/tests/auto/blackbox/testdata/command-file/list.msvc b/tests/auto/blackbox/testdata/command-file/list.msvc new file mode 100644 index 000000000..6f7a50ca2 --- /dev/null +++ b/tests/auto/blackbox/testdata/command-file/list.msvc @@ -0,0 +1 @@ +theLib.lib diff --git a/tests/auto/blackbox/testdata/command-file/main.cpp b/tests/auto/blackbox/testdata/command-file/main.cpp new file mode 100644 index 000000000..6a0bac9f1 --- /dev/null +++ b/tests/auto/blackbox/testdata/command-file/main.cpp @@ -0,0 +1,6 @@ +void f(); + +int main() +{ + f(); +} diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index e541bacc8..84d490999 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -3043,6 +3043,15 @@ void TestBlackbox::combinedSources() QVERIFY(m_qbsStdout.contains("compiling amalgamated_theapp.cpp")); } +void TestBlackbox::commandFile() +{ + QDir::setCurrent(testDataDir + "/command-file"); + QbsRunParameters params(QStringList() << "-p" << "theLib"); + QCOMPARE(runQbs(params), 0); + params.arguments = QStringList() << "-p" << "theApp"; + QCOMPARE(runQbs(params), 0); +} + void TestBlackbox::jsExtensionsFile() { QDir::setCurrent(testDataDir + "/jsextensions-file"); diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index 7a4a0cb67..c73855696 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -59,6 +59,7 @@ private slots: void cli(); void combinedMoc(); void combinedSources(); + void commandFile(); void concurrentExecutor(); void conditionalExport(); void conditionalFileTagger(); |