From 3ed9e2788e8e8d682484f55eb2e5538d48097b72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 20 Sep 2010 12:37:20 +0200 Subject: qmake: Make smart library merge architecture-aware Qmake's smart library merge would not take Xarch into account, so lines like -Xarch_i386 -foo -Xarch_ppc -foo would be reduced to -Xarch_i386 -Xarch_ppc -foo, due to the "duplicate" -foo. The explicit addition of the -Xarch option for each entry of the architecture specific options is intentional, to make cases like "-Xarch_i386 -framework Foo" magically work. Reviewed-by: Simon Hausmann --- qmake/generators/unix/unixmake.cpp | 51 +++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp index db5b957..da4bbb7 100644 --- a/qmake/generators/unix/unixmake.cpp +++ b/qmake/generators/unix/unixmake.cpp @@ -622,31 +622,42 @@ UnixMakefileGenerator::processPrlFiles() //merge them into a logical order if(!project->isActiveConfig("no_smart_library_merge") && !project->isActiveConfig("no_lflags_merge")) { - QStringList lflags; + QHash lflags; for(int lit = 0; lit < l.size(); ++lit) { + QString arch("default"); QString opt = l.at(lit).trimmed(); if(opt.startsWith("-")) { + if (Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-Xarch")) { + if (opt.length() > 7) { + arch = opt.mid(7); + opt = l.at(++lit); + } + } + if(opt.startsWith("-L") || (Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-F"))) { - if(lit == 0 || l.lastIndexOf(opt, lit-1) == -1) - lflags.append(opt); + if(lit == 0 || !lflags[arch].contains(opt)) + lflags[arch].append(opt); } else if(opt.startsWith("-l")) { - if(lit == l.size()-1 || l.indexOf(opt, lit+1) == -1) - lflags.append(opt); + if(lit == l.size()-1 || !lflags[arch].contains(opt)) + lflags[arch].append(opt); } else if(Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-framework")) { if(opt.length() > 11) opt = opt.mid(11); - else + else { opt = l.at(++lit); + if (Option::target_mode == Option::TARG_MACX_MODE && opt.startsWith("-Xarch")) + opt = l.at(++lit); // The user has done the right thing and prefixed each part + } bool found = false; - for(int x = lit+1; x < l.size(); ++x) { - QString xf = l.at(x); + for(int x = 0; x < lflags[arch].size(); ++x) { + QString xf = lflags[arch].at(x); if(xf.startsWith("-framework")) { QString framework; if(xf.length() > 11) framework = xf.mid(11); else - framework = l.at(++x); + framework = lflags[arch].at(++x); if(framework == opt) { found = true; break; @@ -654,18 +665,30 @@ UnixMakefileGenerator::processPrlFiles() } } if(!found) { - lflags.append("-framework"); - lflags.append(opt); + lflags[arch].append("-framework"); + lflags[arch].append(opt); } } else { - lflags.append(opt); + lflags[arch].append(opt); } } else if(!opt.isNull()) { if(lit == 0 || l.lastIndexOf(opt, lit-1) == -1) - lflags.append(opt); + lflags[arch].append(opt); + } + } + + l = lflags.take("default"); + + // Process architecture specific options (Xarch) + QHash::const_iterator archIterator = lflags.constBegin(); + while (archIterator != lflags.constEnd()) { + const QStringList archOptions = archIterator.value(); + for (int i = 0; i < archOptions.size(); ++i) { + l.append(QLatin1String("-Xarch_") + archIterator.key()); + l.append(archOptions.at(i)); } + ++archIterator; } - l = lflags; } } } -- cgit v0.12