diff options
author | Tor Arne Vestbø <tor.arne.vestbo@nokia.com> | 2010-09-20 10:37:20 (GMT) |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@nokia.com> | 2010-09-20 14:24:33 (GMT) |
commit | 3ed9e2788e8e8d682484f55eb2e5538d48097b72 (patch) | |
tree | 438c15c71f0fb661be6d080ae6b72fe0881e0155 | |
parent | b579058afa6759b1b293fa5a3ddf7c345b6e4a3c (diff) | |
download | Qt-3ed9e2788e8e8d682484f55eb2e5538d48097b72.zip Qt-3ed9e2788e8e8d682484f55eb2e5538d48097b72.tar.gz Qt-3ed9e2788e8e8d682484f55eb2e5538d48097b72.tar.bz2 |
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 <simon.hausmann@nokia.com>
-rw-r--r-- | qmake/generators/unix/unixmake.cpp | 51 |
1 files 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<QString, QStringList> 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<QString, QStringList>::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; } } } |