From 8cef809b16aac9d4c4163ff2e2e831adf70133c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 2 Jan 2018 22:49:08 +0200 Subject: qmake: Handle QMAKE_LINK_OBJECT_MAX being unset for static libraries This was missed in 8bebded9. Task-number: QTBUG-63637 Change-Id: I6be472430a9aa8f533def4fd6c14c8dbfe8b6f70 Reviewed-by: Oswald Buddenhagen --- qmake/generators/win32/mingw_make.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'qmake') diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp index 792ffb1997..d6d6b04148 100644 --- a/qmake/generators/win32/mingw_make.cpp +++ b/qmake/generators/win32/mingw_make.cpp @@ -324,7 +324,8 @@ void MingwMakefileGenerator::writeBuildRulesPart(QTextStream &t) t << "\n\t" <isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") { t << "\n\t-$(DEL_FILE) $(DESTDIR_TARGET) 2>" << var("QMAKE_SHELL_NULL_DEVICE"); - if (project->values("OBJECTS").count() < var("QMAKE_LINK_OBJECT_MAX").toInt()) { + const ProString &objmax = project->first("QMAKE_LINK_OBJECT_MAX"); + if (objmax.isEmpty() || project->values("OBJECTS").count() < objmax.toInt()) { t << "\n\t$(LIB) $(DESTDIR_TARGET) " << objectsLinkLine << " " ; } else { t << "\n\t" << objectsLinkLine << " " ; -- cgit v1.2.3 From fe72571da885499739f723e054e1ba5433fb36e8 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 4 Jan 2018 23:45:42 -0800 Subject: qmake: replace invalid characters in generated bundle identifiers This problem does not affect the Xcode generator. Task-number: QTBUG-65477 Change-Id: I6194edc5b679edad9ae1a25e35b71e5df9bd4c95 Reviewed-by: Oswald Buddenhagen --- qmake/generators/unix/unixmake2.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'qmake') diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp index f7097e58dc..6b08a2dd28 100644 --- a/qmake/generators/unix/unixmake2.cpp +++ b/qmake/generators/unix/unixmake2.cpp @@ -155,6 +155,20 @@ UnixMakefileGenerator::writeSubTargets(QTextStream &t, QList= '0' && c <= '9') || (c >= 'A' && c <= 'Z') + || (c >= 'a' && c <= 'z') || c == '-' || c == '.'; + if (!okChar) + ch = QChar::fromLatin1('-'); + } + return s; +} + void UnixMakefileGenerator::writeMakeParts(QTextStream &t) { @@ -826,7 +840,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) if (bundleIdentifier.endsWith(".framework")) bundleIdentifier.chop(10); // replace invalid bundle id characters - bundleIdentifier.replace('_', '-'); + bundleIdentifier = rfc1034Identifier(bundleIdentifier); commonSedArgs << "-e \"s,@BUNDLEIDENTIFIER@," << bundleIdentifier << ",g\" "; if (!isFramework) { -- cgit v1.2.3 From 1c8224511dee2794553da9dc8ed484d49dc78b45 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Fri, 5 Jan 2018 00:40:46 -0800 Subject: qmake: set COPY_PHASE_STRIP to NO in Xcode generator Since Xcode 6.3, this must be set to NO because stripping on copy is no longer fully supported due to the potential of input binaries being code signed. In this case Xcode will simply ignore the strip step and issue a warning since stripping would invalidate the code signature. This change silences that annoying warning for release builds. Also, the setting assignment is moved from being hardcoded in the generator, to a QMAKE_MAC_XCODE_SETTINGS value. Change-Id: If25511edddc12b7b0407e2992d80884b7d6437dc Reviewed-by: Gabriel de Dietrich --- qmake/generators/mac/pbuilder_pbx.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'qmake') diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp index 0622ace71b..db7a1b2714 100644 --- a/qmake/generators/mac/pbuilder_pbx.cpp +++ b/qmake/generators/mac/pbuilder_pbx.cpp @@ -279,7 +279,6 @@ ProjectBuilderMakefileGenerator::writeSubDirs(QTextStream &t) QString configName = (as_release ? "Release" : "Debug"); QMap settings; - settings.insert("COPY_PHASE_STRIP", (as_release ? "YES" : "NO")); if(project->isActiveConfig("sdk") && !project->isEmpty("QMAKE_MAC_SDK")) settings.insert("SDKROOT", project->first("QMAKE_MAC_SDK").toQString()); { @@ -1493,7 +1492,6 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) settings.insert("PROVISIONING_PROFILE_SPECIFIER", project->first("QMAKE_PROVISIONING_PROFILE").toQString()); } - settings.insert("COPY_PHASE_STRIP", (as_release ? "YES" : "NO")); settings.insert("APPLICATION_EXTENSION_API_ONLY", project->isActiveConfig("app_extension_api_only") ? "YES" : "NO"); // required for tvOS (and watchos), optional on iOS (deployment target >= iOS 6.0) settings.insert("ENABLE_BITCODE", project->isActiveConfig("bitcode") ? "YES" : "NO"); -- cgit v1.2.3 From 0749ba2c5eacc4822cf9c7a31edf8d70c4ef6064 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Mon, 20 Nov 2017 23:49:34 -0800 Subject: Rewrite the Info.plist variable replacement handling This ensures that the same set of variables can be successfully replaced in both the Makefile and Xcode generators. It also switches the default templates to use the Xcode-style ${var} syntax instead of the @var@ syntax for better Info.plist compatibility across generators. Change-Id: Iff330bafd152773aafac9143c4a34e34f92f0ce6 Reviewed-by: Oswald Buddenhagen --- qmake/doc/src/qmake-manual.qdoc | 52 ++++++++++++++++++++++++++++++++++--- qmake/generators/unix/unixmake2.cpp | 48 ++++++++++++++++++++++++---------- 2 files changed, 84 insertions(+), 16 deletions(-) (limited to 'qmake') diff --git a/qmake/doc/src/qmake-manual.qdoc b/qmake/doc/src/qmake-manual.qdoc index a4e28b4d0c..58c51502b0 100644 --- a/qmake/doc/src/qmake-manual.qdoc +++ b/qmake/doc/src/qmake-manual.qdoc @@ -1821,9 +1821,55 @@ Specifies the name of the property list file, \c{.plist}, you would like to include in your \macos, iOS, tvOS, and watchOS application bundle. - In the \c{.plist} file, you can define some variables, e.g., @EXECUTABLE@, - which qmake will replace with the actual executable name. Other variables - include @ICON@, @TYPEINFO@, @LIBRARY@, and @SHORT_VERSION@. + In the \c{.plist} file, you can define some variables which + qmake will replace with the relevant values: + + \table + \header + \li Placeholder(s) + \li Effect + \row + \li \c ${PRODUCT_BUNDLE_IDENTIFIER}, \c @BUNDLEIDENTIFIER@ + \li Expands to the target bundle's bundle identifier string, + for example: \c{com.example.myapp}. Determined by concatenating the + values of QMAKE_TARGET_BUNDLE_PREFIX and QMAKE_BUNDLE, separated + by a full stop (\c{.}). + \row + \li \c ${EXECUTABLE_NAME}, \c @EXECUTABLE@, \c @LIBRARY@ + \li Equivalent to the value of QMAKE_APPLICATION_BUNDLE_NAME, + QMAKE_PLUGIN_BUNDLE_NAME, or QMAKE_FRAMEWORK_BUNDLE_NAME + (depending on the type of target being created), + or TARGET if none of the previous values are set. + \row + \li \c ${ASSETCATALOG_COMPILER_APPICON_NAME}, \c @ICON@ + \li Expands to the value of ICON. + \row + \li \c ${QMAKE_PKGINFO_TYPEINFO}, \c @TYPEINFO@ + \li Expands to the value of QMAKE_PKGINFO_TYPEINFO. + \row + \li \c ${QMAKE_FULL_VERSION}, \c @FULL_VERSION@ + \li Expands to the value of VERSION expressed with three version components. + \row + \li \c ${QMAKE_SHORT_VERSION}, \c @SHORT_VERSION@ + \li Expands to the value of VERSION expressed with two version components. + \row + \li \c ${MACOSX_DEPLOYMENT_TARGET} + \li Expands to the value of QMAKE_MACOSX_DEPLOYMENT_TARGET. + \row + \li \c ${IPHONEOS_DEPLOYMENT_TARGET} + \li Expands to the value of QMAKE_IPHONEOS_DEPLOYMENT_TARGET. + \row + \li \c ${TVOS_DEPLOYMENT_TARGET} + \li Expands to the value of QMAKE_TVOS_DEPLOYMENT_TARGET. + \row + \li \c ${WATCHOS_DEPLOYMENT_TARGET} + \li Expands to the value of QMAKE_WATCHOS_DEPLOYMENT_TARGET. + \endtable + + \note When using the Xcode generator, the above \c{${var}}-style + placeholders are replaced directly by the Xcode build system and are not + handled by qmake. The \c{@var@} style placeholders work only with the qmake + Makefile generators and not with the Xcode generator. If building for iOS, and the \c{.plist} file contains the key \c NSPhotoLibraryUsageDescription, qmake will include an additional plugin diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp index f7097e58dc..15ba4f0309 100644 --- a/qmake/generators/unix/unixmake2.cpp +++ b/qmake/generators/unix/unixmake2.cpp @@ -806,14 +806,23 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) t << mkdir_p_asstring(destdir) << "\n\t"; ProStringList commonSedArgs; if (!project->values("VERSION").isEmpty()) { - commonSedArgs << "-e \"s,@SHORT_VERSION@," << project->first("VER_MAJ") << "." - << project->first("VER_MIN") << ",g\" "; - commonSedArgs << "-e \"s,@FULL_VERSION@," << project->first("VER_MAJ") << "." - << project->first("VER_MIN") << "." - << project->first("VER_PAT") << ",g\" "; + const ProString shortVersion = + project->first("VER_MAJ") + "." + + project->first("VER_MIN"); + commonSedArgs << "-e \"s,@SHORT_VERSION@," << shortVersion << ",g\" "; + commonSedArgs << "-e \"s,\\$${QMAKE_SHORT_VERSION}," << shortVersion << ",g\" "; + const ProString fullVersion = + project->first("VER_MAJ") + "." + + project->first("VER_MIN") + "." + + project->first("VER_PAT"); + commonSedArgs << "-e \"s,@FULL_VERSION@," << fullVersion << ",g\" "; + commonSedArgs << "-e \"s,\\$${QMAKE_FULL_VERSION}," << fullVersion << ",g\" "; } - commonSedArgs << "-e \"s,@TYPEINFO@,"<< (project->isEmpty("QMAKE_PKGINFO_TYPEINFO") ? - QString::fromLatin1("????") : project->first("QMAKE_PKGINFO_TYPEINFO").left(4)) << ",g\" "; + const ProString typeInfo = project->isEmpty("QMAKE_PKGINFO_TYPEINFO") + ? QString::fromLatin1("????") + : project->first("QMAKE_PKGINFO_TYPEINFO").left(4); + commonSedArgs << "-e \"s,@TYPEINFO@," << typeInfo << ",g\" "; + commonSedArgs << "-e \"s,\\$${QMAKE_PKGINFO_TYPEINFO}," << typeInfo << ",g\" "; QString bundlePrefix = project->first("QMAKE_TARGET_BUNDLE_PREFIX").toQString(); if (bundlePrefix.isEmpty()) @@ -828,6 +837,16 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) // replace invalid bundle id characters bundleIdentifier.replace('_', '-'); commonSedArgs << "-e \"s,@BUNDLEIDENTIFIER@," << bundleIdentifier << ",g\" "; + commonSedArgs << "-e \"s,\\$${PRODUCT_BUNDLE_IDENTIFIER}," << bundleIdentifier << ",g\" "; + + commonSedArgs << "-e \"s,\\$${MACOSX_DEPLOYMENT_TARGET}," + << project->first("QMAKE_MACOSX_DEPLOYMENT_TARGET").toQString() << ",g\" "; + commonSedArgs << "-e \"s,\\$${IPHONEOS_DEPLOYMENT_TARGET}," + << project->first("QMAKE_IPHONEOS_DEPLOYMENT_TARGET").toQString() << ",g\" "; + commonSedArgs << "-e \"s,\\$${TVOS_DEPLOYMENT_TARGET}," + << project->first("QMAKE_TVOS_DEPLOYMENT_TARGET").toQString() << ",g\" "; + commonSedArgs << "-e \"s,\\$${WATCHOS_DEPLOYMENT_TARGET}," + << project->first("QMAKE_WATCHOS_DEPLOYMENT_TARGET").toQString() << ",g\" "; if (!isFramework) { ProString app_bundle_name = var("QMAKE_APPLICATION_BUNDLE_NAME"); @@ -843,11 +862,14 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) << "@sed "; for (const ProString &arg : qAsConst(commonSedArgs)) t << arg; - t << "-e \"s,@ICON@," << icon.section(Option::dir_sep, -1) << ",g\" " + const QString iconName = icon.section(Option::dir_sep, -1); + t << "-e \"s,@ICON@," << iconName << ",g\" " + << "-e \"s,\\$${ASSETCATALOG_COMPILER_APPICON_NAME}," << iconName << ",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\" " + << "-e \"s,\\$${EXECUTABLE_NAME}," << (app_bundle_name.isEmpty() ? app_bundle_name : plugin_bundle_name) << ",g\" " + << "-e \"s,@TYPEINFO@,"<< typeInfo << ",g\" " + << "-e \"s,\\$${QMAKE_PKGINFO_TYPEINFO},"<< typeInfo << ",g\" " << "" << info_plist << " >" << info_plist_out << endl; //copy the icon if (!project->isEmpty("ICON")) { @@ -873,9 +895,9 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) for (const ProString &arg : qAsConst(commonSedArgs)) t << arg; 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\" " + << "-e \"s,\\$${EXECUTABLE_NAME}," << lib_bundle_name << ",g\" " + << "-e \"s,@TYPEINFO@," << typeInfo << ",g\" " + << "-e \"s,\\$${QMAKE_PKGINFO_TYPEINFO}," << typeInfo << ",g\" " << "" << info_plist << " >" << info_plist_out << endl; } break; -- cgit v1.2.3 From af1a179cc8b599523ca858b1b9f55c93a734d047 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Tue, 2 Jan 2018 19:07:03 +0200 Subject: qmake: Introduce precompile_header_c for MSVC MSVC requires that the C PCH file is compiled (as an object) and linked if any C file is found, and the same for C++. Most qmake projects are C++. If a C++ project has a precompiled header, it is typically of C++ type, and cannot be compiled as C (for example, it contains or includes classes). Since there is no easy way to conditionally build the C PCH file only if C files are found in the project (as done for g++), we need a setting that is disabled by default. This amends 30331afda118. [ChangeLog][Tools][qmake] Introduced precompile_header_c CONFIG option for MSVC to enable precompiled header for C sources. Task-number: QTBUG-65103 Change-Id: Id9688a35ee7d9b5e4f5a846b81986cb674bc5f4e Reviewed-by: Oswald Buddenhagen --- qmake/doc/src/qmake-manual.qdoc | 7 +++++++ qmake/generators/win32/msvc_nmake.cpp | 29 +++++++++++++++++------------ qmake/generators/win32/msvc_nmake.h | 2 +- 3 files changed, 25 insertions(+), 13 deletions(-) (limited to 'qmake') diff --git a/qmake/doc/src/qmake-manual.qdoc b/qmake/doc/src/qmake-manual.qdoc index 58c51502b0..16b498d36e 100644 --- a/qmake/doc/src/qmake-manual.qdoc +++ b/qmake/doc/src/qmake-manual.qdoc @@ -939,6 +939,8 @@ order in which they are given. \row \li precompile_header \li Enables support for the use of \l{Using Precompiled Headers}{precompiled headers} in projects. + \row \li precompile_header_c (MSVC only) \li Enables support for the use of + \l{Using Precompiled Headers}{precompiled headers} for C files. \row \li warn_on \li The compiler should output as many warnings as possible. If \c warn_off is also specified, the last one takes effect. \row \li warn_off \li The compiler should output as few warnings as possible. @@ -4623,6 +4625,11 @@ \snippet code/doc_src_qmake-manual.pro 106 + To use the precompiled header also for C files on MSVC nmake target, add + \c precompile_header_c to the \l{CONFIG} variable. If the header is + used also for C++ and it contains C++ keywords/includes, enclose them + with \c{#ifdef __cplusplus}). + \section1 Notes on Possible Issues On some platforms, the file name suffix for precompiled header files is diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index b4c2579c5c..ccc2ea6d2b 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -51,7 +51,7 @@ static QString nmakePathList(const QStringList &list) .replace('#', QLatin1String("^#")).replace('$', QLatin1String("$$")); } -NmakeMakefileGenerator::NmakeMakefileGenerator() : Win32MakefileGenerator(), usePCH(false) +NmakeMakefileGenerator::NmakeMakefileGenerator() : usePCH(false), usePCHC(false) { } @@ -324,6 +324,8 @@ void NmakeMakefileGenerator::writeNmakeParts(QTextStream &t) << escapeDependencyPaths(findDependencies(precompH)).join(" \\\n\t\t") << "\n\t$(CXX) " + precompRule +" $(CXXFLAGS) $(INCPATH) -TP " << escapeFilePath(precompH) << endl << endl; + } + if (usePCHC) { QString precompRuleC = QString("-c -Yc -Fp%1 -Fo%2") .arg(escapeFilePath(precompPchC), escapeFilePath(precompObjC)); t << escapeDependencyPath(precompObjC) << ": " << escapeDependencyPath(precompH) << ' ' @@ -335,14 +337,14 @@ void NmakeMakefileGenerator::writeNmakeParts(QTextStream &t) QString NmakeMakefileGenerator::var(const ProKey &value) const { - if (usePCH) { + if (usePCH || usePCHC) { const bool isRunC = (value == "QMAKE_RUN_CC_IMP_BATCH" || value == "QMAKE_RUN_CC_IMP" || value == "QMAKE_RUN_CC"); - if (isRunC - || value == "QMAKE_RUN_CXX_IMP_BATCH" - || value == "QMAKE_RUN_CXX_IMP" - || value == "QMAKE_RUN_CXX") { + const bool isRunCpp = (value == "QMAKE_RUN_CXX_IMP_BATCH" + || value == "QMAKE_RUN_CXX_IMP" + || value == "QMAKE_RUN_CXX"); + if ((isRunCpp && usePCH) || (isRunC && usePCHC)) { QFileInfo precompHInfo(fileInfo(precompH)); QString precompH_f = escapeFilePath(precompHInfo.fileName()); QString precompRule = QString("-c -FI%1 -Yu%2 -Fp%3") @@ -410,21 +412,24 @@ void NmakeMakefileGenerator::init() // Setup PCH variables precompH = project->first("PRECOMPILED_HEADER").toQString(); usePCH = !precompH.isEmpty() && project->isActiveConfig("precompile_header"); + usePCHC = !precompH.isEmpty() && project->isActiveConfig("precompile_header_c"); if (usePCH) { // Created files precompObj = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch" + Option::obj_ext; precompPch = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch.pch"; - precompObjC = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch_c" + Option::obj_ext; - precompPchC = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch_c.pch"; // Add linking of precompObj (required for whole precompiled classes) - project->values("OBJECTS") += precompObj; - project->values("OBJECTS") += precompObjC; + project->values("OBJECTS") += precompObj; // Add pch file to cleanup - project->values("QMAKE_CLEAN") += precompPch; - project->values("QMAKE_CLEAN") += precompPchC; + project->values("QMAKE_CLEAN") += precompPch; // Return to variable pool project->values("PRECOMPILED_OBJECT") = ProStringList(precompObj); project->values("PRECOMPILED_PCH") = ProStringList(precompPch); + } + if (usePCHC) { + precompObjC = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch_c" + Option::obj_ext; + precompPchC = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch_c.pch"; + project->values("OBJECTS") += precompObjC; + project->values("QMAKE_CLEAN") += precompPchC; project->values("PRECOMPILED_OBJECT_C") = ProStringList(precompObjC); project->values("PRECOMPILED_PCH_C") = ProStringList(precompPchC); } diff --git a/qmake/generators/win32/msvc_nmake.h b/qmake/generators/win32/msvc_nmake.h index 4b0935bb66..67b609d0a6 100644 --- a/qmake/generators/win32/msvc_nmake.h +++ b/qmake/generators/win32/msvc_nmake.h @@ -53,7 +53,7 @@ protected: QString var(const ProKey &value) const; QString precompH, precompObj, precompPch; QString precompObjC, precompPchC; - bool usePCH; + bool usePCH, usePCHC; public: NmakeMakefileGenerator(); -- cgit v1.2.3