summaryrefslogtreecommitdiffstats
path: root/qmake/generators/win32
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2019-07-22 21:24:19 +0300
committerOrgad Shaneh <orgads@gmail.com>2019-07-29 08:41:27 +0000
commit10611038900842061bfef8516b1a994b7ac05877 (patch)
tree5e8d7ea063acd173e950ed078ea0d3947cfb9992 /qmake/generators/win32
parentfe8cd567dd3499d144f46ebba1a82a4ff85ff408 (diff)
qmake: Use a simple response file for ar on mingw
This change allows using custom flags for ar. For instance, it is now possible to create a thin archive by setting QMAKE_LIB += -T. This uses and extends commit d92c25b1b4ac0423a824715a08b2db2def4b6e25 which served a similar purpose for the linker. Change-Id: Ie1d6a0b957dc4809957726de00911c8d91647fab Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'qmake/generators/win32')
-rw-r--r--qmake/generators/win32/mingw_make.cpp36
1 files changed, 9 insertions, 27 deletions
diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp
index 746f3e9008..2175841264 100644
--- a/qmake/generators/win32/mingw_make.cpp
+++ b/qmake/generators/win32/mingw_make.cpp
@@ -131,7 +131,7 @@ QString MingwMakefileGenerator::installRoot() const
return QStringLiteral("$(INSTALL_ROOT:@msyshack@%=%)");
}
-void createLdResponseFile(const QString &fileName, const ProStringList &objList)
+static void createResponseFile(const QString &fileName, const ProStringList &objList)
{
QString filePath = Option::output_dir + QDir::separator() + fileName;
QFile file(filePath);
@@ -155,23 +155,6 @@ void createLdResponseFile(const QString &fileName, const ProStringList &objList)
}
}
-void createArObjectScriptFile(const QString &fileName, const QString &target, const ProStringList &objList)
-{
- QString filePath = Option::output_dir + QDir::separator() + fileName;
- QFile file(filePath);
- if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
- QTextStream t(&file);
- // ### quoting?
- t << "CREATE " << target << endl;
- for (ProStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) {
- t << "ADDMOD " << *it << endl;
- }
- t << "SAVE\n";
- t.flush();
- file.close();
- }
-}
-
void MingwMakefileGenerator::writeMingwParts(QTextStream &t)
{
writeStandardParts(t);
@@ -298,26 +281,25 @@ void MingwMakefileGenerator::writeObjectsPart(QTextStream &t)
if (objmax.isEmpty() || project->values("OBJECTS").count() < objmax.toInt()) {
objectsLinkLine = "$(OBJECTS)";
} else if (project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
- QString ar_script_file = var("QMAKE_LINK_OBJECT_SCRIPT") + "." + var("TARGET");
+ QString ar_response_file = var("QMAKE_LINK_OBJECT_SCRIPT") + "." + var("TARGET");
if (!var("BUILD_NAME").isEmpty()) {
- ar_script_file += "." + var("BUILD_NAME");
+ ar_response_file += "." + var("BUILD_NAME");
}
if (!var("MAKEFILE").isEmpty())
- ar_script_file += "." + var("MAKEFILE");
+ ar_response_file += "." + var("MAKEFILE");
// QMAKE_LIB is used for win32, including mingw, whereas QMAKE_AR is used on Unix.
- // Strip off any options since the ar commands will be read from file.
- QString ar_cmd = var("QMAKE_LIB").section(" ", 0, 0);
+ QString ar_cmd = var("QMAKE_LIB");
if (ar_cmd.isEmpty())
- ar_cmd = "ar";
- createArObjectScriptFile(ar_script_file, var("DEST_TARGET"), project->values("OBJECTS"));
- objectsLinkLine = ar_cmd + " -M < " + escapeFilePath(ar_script_file);
+ ar_cmd = "ar -rc";
+ createResponseFile(ar_response_file, project->values("OBJECTS"));
+ objectsLinkLine = ar_cmd + ' ' + var("DEST_TARGET") + " @" + escapeFilePath(ar_response_file);
} else {
QString ld_response_file = var("QMAKE_LINK_OBJECT_SCRIPT") + "." + var("TARGET");
if (!var("BUILD_NAME").isEmpty())
ld_response_file += "." + var("BUILD_NAME");
if (!var("MAKEFILE").isEmpty())
ld_response_file += "." + var("MAKEFILE");
- createLdResponseFile(ld_response_file, project->values("OBJECTS"));
+ createResponseFile(ld_response_file, project->values("OBJECTS"));
objectsLinkLine = "@" + escapeFilePath(ld_response_file);
}
Win32MakefileGenerator::writeObjectsPart(t);