qmake: Use correct CFBundleExecutable in framework bundles

This fixes a bug where joined device and simulator builds would get
for example, QtCore_iphonesimulator as the CFBundleExecutable.

According to Apple:

"For frameworks, the value of this key is REQUIRED to be the same as
the framework name, minus the .framework extension."

This does not affect the ability to load a framework whose executable
name differs from the bundle name (as is the case for simulator builds),
as the application will be linked to the correct framework executable
at link time by specifying (for example) the linker flag:
-framework QtCore,_iphonesimulator

Change-Id: Ib7614670d0620e0235cd7e2606d42dd034a90c68
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
This commit is contained in:
Jake Petroules 2016-02-18 01:01:38 -08:00
parent f607233c7c
commit 2e3a585013
2 changed files with 23 additions and 5 deletions

View File

@ -1480,9 +1480,15 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
plist_in_text.replace(QLatin1String("@ICON@"),
(project->isEmpty("ICON") ? QString("") : project->first("ICON").toQString().section(Option::dir_sep, -1)));
if (project->first("TEMPLATE") == "app") {
plist_in_text.replace(QLatin1String("@EXECUTABLE@"), project->first("QMAKE_ORIG_TARGET").toQString());
ProString app_bundle_name = project->first("QMAKE_APPLICATION_BUNDLE_NAME");
if (app_bundle_name.isEmpty())
app_bundle_name = project->first("QMAKE_ORIG_TARGET");
plist_in_text.replace(QLatin1String("@EXECUTABLE@"), app_bundle_name.toQString());
} else {
plist_in_text.replace(QLatin1String("@LIBRARY@"), project->first("QMAKE_ORIG_TARGET").toQString());
ProString lib_bundle_name = project->first("QMAKE_FRAMEWORK_BUNDLE_NAME");
if (lib_bundle_name.isEmpty())
lib_bundle_name = project->first("QMAKE_ORIG_TARGET");
plist_in_text.replace(QLatin1String("@LIBRARY@"), lib_bundle_name.toQString());
}
QString bundlePrefix = project->first("QMAKE_TARGET_BUNDLE_PREFIX").toQString();
if (bundlePrefix.isEmpty())

View File

@ -822,14 +822,22 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
commonSedArgs << "-e \"s,@BUNDLEIDENTIFIER@," << bundleIdentifier << ",g\" ";
if (!isFramework) {
ProString app_bundle_name = var("QMAKE_APPLICATION_BUNDLE_NAME");
if (app_bundle_name.isEmpty())
app_bundle_name = var("QMAKE_ORIG_TARGET");
ProString plugin_bundle_name = var("QMAKE_PLUGIN_BUNDLE_NAME");
if (plugin_bundle_name.isEmpty())
plugin_bundle_name = var("QMAKE_ORIG_TARGET");
QString icon = fileFixify(var("ICON"));
t << "@$(DEL_FILE) " << info_plist_out << "\n\t"
<< "@sed ";
for (const ProString &arg : qAsConst(commonSedArgs))
t << arg;
t << "-e \"s,@ICON@," << icon.section(Option::dir_sep, -1) << ",g\" "
<< "-e \"s,@EXECUTABLE@," << var("QMAKE_ORIG_TARGET") << ",g\" "
<< "-e \"s,@LIBRARY@," << var("QMAKE_ORIG_TARGET") << ",g\" "
<< "-e \"s,@EXECUTABLE@," << app_bundle_name << ",g\" "
<< "-e \"s,@LIBRARY@," << plugin_bundle_name << ",g\" "
<< "-e \"s,@TYPEINFO@,"<< (project->isEmpty("QMAKE_PKGINFO_TYPEINFO") ?
QString::fromLatin1("????") : project->first("QMAKE_PKGINFO_TYPEINFO").left(4)) << ",g\" "
<< "" << info_plist << " >" << info_plist_out << endl;
@ -846,13 +854,17 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
<< "@$(COPY_FILE) " << escapeFilePath(icon) << ' ' << icon_path_f << endl;
}
} else {
ProString lib_bundle_name = var("QMAKE_FRAMEWORK_BUNDLE_NAME");
if (lib_bundle_name.isEmpty())
lib_bundle_name = var("QMAKE_ORIG_TARGET");
if (!isShallowBundle)
symlinks[bundle_dir + "Resources"] = "Versions/Current/Resources";
t << "@$(DEL_FILE) " << info_plist_out << "\n\t"
<< "@sed ";
for (const ProString &arg : qAsConst(commonSedArgs))
t << arg;
t << "-e \"s,@LIBRARY@," << var("QMAKE_ORIG_TARGET") << ",g\" "
t << "-e \"s,@LIBRARY@," << lib_bundle_name << ",g\" "
<< "-e \"s,@TYPEINFO@,"
<< (project->isEmpty("QMAKE_PKGINFO_TYPEINFO") ?
QString::fromLatin1("????") : project->first("QMAKE_PKGINFO_TYPEINFO").left(4)) << ",g\" "