From 10611038900842061bfef8516b1a994b7ac05877 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Mon, 22 Jul 2019 21:24:19 +0300 Subject: qmake: Use a simple response file for ar on mingw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- qmake/generators/win32/mingw_make.cpp | 36 +++++++++-------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) (limited to 'qmake/generators/win32') 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); -- cgit v1.2.3