Commit Graph

2113 Commits

Author SHA1 Message Date
Friedemann Kleint
64dc6fe87d Add some exclusions for CMake Unity (Jumbo) builds
Add exclusions for issues that are likely not fixable
(3rd party code, X11 define clashes, etc) in 3rd party,
tools and plugins.

Pick-to: 6.5
Task-number: QTBUG-109394
Done-with: Amir Masoud Abdol <amir.abdol@qt.io>
Change-Id: I698c004201a76a48389271c130e44fba20f5adf7
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-02-16 16:03:06 +01:00
Joerg Bornemann
98a3634299 Make qmake and qtpaths report Qt version baked into the binaries
QMake and qtpaths used qVersion() to report Qt's version number. This is
problematic if those tools are run in an environment where a different
Qt version is loaded (e.g. by setting LD_LIBRARY_PATH).

This reverts commit a783c3d574, which
changed the use of the QT_VERSION define to a qVersion() call in qmake.
Additionally, we use QT_VERSION in qtpaths too for consistency.

Pick-to: 6.5
Change-Id: I6c8a1aa6ee6169becd7c685a98ce23c22c3864c7
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-01-18 13:21:05 +01:00
Alexey Edelev
0e3ef41112 Set GenerateDebugInformation to true in vcproj if at least /DEBUG is set
If the command line option contains /DEBUG without the following
argument, GenerateDebugInformation remained 'false' because the
DebugInfoOption contained the initial value.

Set GenerateDebugInformation to 'true' if the /DEBUG option is found and
reset to 'false' only if option is set to 'none'.

Amends commit 6a6b27940d.

Pick-to: 6.2 6.4 6.5 5.15
Fixes: QTBUG-110068
Change-Id: I792d7335d8b9536d4beed54cabfd70dcf54f09ac
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2023-01-13 14:29:37 +01:00
Alexandru Croitor
5fe52a0420 qmake: Document that QMAKE_PRE_LINK does not work with Xcode
When generating an Xcode project using qmake that's targeting the new
Xcode build system, QMAKE_PRE_LINK does not work properly.
It generates rules that conflict with the default linker rules.
This is a limitation of the new Xcode build system which does not have
any known workaround.

Document the limitation.

Pick-to: 5.15 6.2 6.4 6.5
Fixes: QTBUG-99601
Change-Id: Ie4e6bcb0603ced85f786e9f7f407172e84a00d83
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-12-15 20:23:28 +01:00
Marc Mutz
885aba7ffd Use qtversion.h instead of qlibraryinfo.h
... where 50b05e3e2a originally added
them.

While qtversion.h is included in qglobal.h, using qtversion.h directly
is a tiny step towards removing qglobal.h includes from our code-base,
so don't let this opportunity go to waste.

Change-Id: I28eaca1f4e250fc9e12e2ce6a6f94670a1d08dbe
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-12-09 07:21:22 +01:00
Yuhang Zhao
bd7fa4a537 Windows: centralize how we handle error messages
Currently QtBase contains multiple implementation of how to get the Win32
and COM error messages, and they are almost exactly the same, what's worse,
Qt already has a private QSystemError class to do such things, so we are
re-inventing the wheel in many places. This patch removes all other custom
error message implementations besides the QSystemError one. And since there
are a lot of places need the COM error message, move the implementation to
QSystemError so that it can handle both Win32 error and COM error.

Since I'm touching these lines anyway, break them into short lines if they
are above the length limit.

Change-Id: I1067c874011800303f0f114b5cb8830ac6810fc0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-11-16 19:44:43 +08:00
Marc Mutz
1c6bf3e09e Port from container::count() and length() to size() - V5
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to
handle typedefs and accesses through pointers, too:

    const std::string o = "object";

    auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); };

    auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) {
        auto exprOfDeclaredType = [&](auto decl) {
            return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o);
        };
        return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))));
    };

    auto renameMethod = [&] (ArrayRef<StringRef> classes,
                            StringRef from, StringRef to) {
        return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)),
                            callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))),
                        changeTo(cat(access(o, cat(to)), "()")),
                        cat("use '", to, "' instead of '", from, "'"));
    };

    renameMethod(<classes>, "count", "size");
    renameMethod(<classes>, "length", "size");

except that the on() matcher has been replaced by one that doesn't
ignoreParens().

a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'.

Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache,
to avoid porting calls that explicitly test count().

Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-11-03 14:59:24 +01:00
Maximilian Blochberger
bbad6440ae Ensure proper format of Info.plist
The Information Property List (Info.plist) is a property list that
contains information about macOS and iOS application and framework
bundles. There are multiple supported formats, those property lists can
be stored in, most notably XML and binary.

Problem
If the Info.plist file is edited with an external editor, such as Xcode,
it is possible that it is stored in binary format. A Makefile generated
by the qmake tool contains a call to sed, which works on text but not
binary files. Consequently, this call would fail.

Solution
Since Mac OS X 10.2, the plutil tool is available. It can be used to
convert the property lists into a specific format. The plutil tool is
now used to convert the plist to XML, so that the sed invocation
succeeds.

[ChangeLog][qmake] Fixed handling binary Info.plist files in generated
Makefiles by always converting them to XML before substituting
placeholders.

Fixes: QTBUG-45357
Change-Id: I066039301c391a5034710458500a096f09e5ca24
Pick-to: 6.2 6.4
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-10-19 12:06:09 +02:00
Marc Mutz
aa37e67ef7 Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.

Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace, with manual
unstaging of the actual definition and documentation in dist/,
src/corelib/doc/ and src/corelib/global/.

Task-number: QTBUG-99313
Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-10-11 23:17:18 +02:00
Marc Mutz
df9d882d41 Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator:

  auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)
  makeRule(cxxMemberCallExpr(on(QtContainerClass),
                             callee(cxxMethodDecl(hasAnyName({"count", "length"),
                                                  parameterCountIs(0))))),
           changeTo(cat(access(o, cat("size"), "()"))),
           cat("use 'size()' instead of 'count()/length()'"))

a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'.

<classes> are:

    // sequential:
    "QByteArray",
    "QList",
    "QQueue",
    "QStack",
    "QString",
    "QVarLengthArray",
    "QVector",
    // associative:
    "QHash",
    "QMultiHash",
    "QMap",
    "QMultiMap",
    "QSet",
    // Qt has no QMultiSet

Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-10-04 07:40:08 +02:00
Alexey Edelev
b89d63515b Replace the syncqt.pl script with syncqt tool
syncqt.pl adds an extra dependency on perl when building Qt. Modern C++
provides the convenient cross-platform way to access a filesystem and
to use regular expressions, so we may replace the perl script with C++
application. The syncqt executable is built at configure time and
installed as QtCore tool. It's running at configure time to deliver the
required header files for IDE to build a consistent code model and at
the build time to keep tracking changes in header files and generate
the missing aliases without reconfiguring. 'syncqt' only parses header
files from a CMake build tree, so the resulting Qt installation only
contains interfacing headers that belong to the platform that Qt is
built for. 'sync.profile' files are not used as the 'source of truth'
for sync qt procedure anymore, all the necessary information is taken
from either CMake files at configure time or from the module header
files while parsing them.

syncqt.pl is still in place since it's required as fallback solution
for a smooth transition to the new syncqt implementation for all qt
repositories.

This patchset only enables the C++ based syncqt for 'qtbase'
repository.

From the performance perspective C++ version works faster then perl
script, also the configure time is reduced significally on subsequent
reconfigurations - up x2 times faster when re-configuring repository,
but it also takes time to compile the tool itself the first time.
Numbers for qtbase:
           syncqt.pl  syncqt.cpp
 initial:  0m16,035s  0m20,413s
 reconfig: 0m6,819s   0m3,725s

The syncing procedure can be run separately for each module using
<ModuleName>_sync_headers targets. The 'sync_headers' target can be
used to sync all the modules at once.

Task-number: QTBUG-87480
Task-number: QTBUG-103196
Change-Id: I8c938bcaf88a8713b39bbfd66d9e7ef12b2c3523
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-27 13:12:11 +02:00
Sona Kurazyan
50b05e3e2a Move qVersion() from qglobal.h to qlibraryinfo.h
Since qVersion() might be called also from C code, disable the parts of
qlibraryinfo.h that are relevant only for C++ code if __cplusplus is not
defined.

[ChangeLog][Potentially Source-Incompatible Changes] qVersion() is
moved from qglobal.h to qlibraryinfo.h, '#include <QtCore/QLibraryInfo>'
needs to be added where it's used.

Task-number: QTBUG-99313
Change-Id: I3363ef3fa4073114e5151cb3a2a1e8282ad42a4d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-09-01 13:26:30 +02:00
Ivan Solovev
35a50491e7 QtBase tools: port away from deprecated qSetGlobalQHashSeed(0)
Use QHashSeed::setDeterministicGlobalSeed() instead

Task-number: QTBUG-105102
Change-Id: Ib7d4b6e7bca89870913a140d68bbdd6018e8f8ed
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2022-08-30 22:46:34 +02:00
Lucie Gérard
32df595275 Change the license of all CMakeLists.txt and *.cmake files to BSD
Task-number: QTBUG-105718
Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-23 23:58:42 +02:00
Ivan Solovev
3226c82740 Rename QT_DISABLE_DEPRECATED_BEFORE -> QT_DISABLE_DEPRECATED_UP_TO
The new name describes the behavior in a better way.

[ChangeLog][Build System] The QT_DISABLE_DEPRECATED_BEFORE macro is
renamed to QT_DISABLE_DEPRECATED_UP_TO. The old name is deprecated, but
is still recognized if it is defined during configuration and the new
name is not defined.

Task-number: QTBUG-104944
Change-Id: Ifc34323e0bbd9e3dc2f86c3e80d4d0940ebccbb8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-08-19 23:52:05 +02:00
Lucie Gérard
fb1b20eab3 Add license headers to cmake files
CMakeLists.txt and .cmake files of significant size
(more than 2 lines according to our check in tst_license.pl)
now have the copyright and license header.

Existing copyright statements remain intact

Task-number: QTBUG-88621
Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-03 17:14:55 +02:00
Joerg Bornemann
c155734bfc Doc: Clarify qmake's c++latest CONFIG value
Fixes: QTBUG-104631
Change-Id: I1d2b7de0f76de9c6ba4b7e47de7e777fedc7bd30
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-06-29 18:32:05 +02:00
Andreas Eliasson
e8a782fb2c Doc: Document QML_IMPORTS_PATH and QMLPATHS
Fixes: QTBUG-101615
Pick-to: 6.4 6.3 6.2 5.15
Change-Id: I0c83f36db4e4731095610683c4a722438f9b804e
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2022-06-27 12:02:47 +00:00
Joerg Bornemann
073214fdf9 qmake/msbuild: Turn off "use full paths in diagnostics" by default
The default setting for "Full Path of Source Code File in Diagnostics"
changed with VS 2017: it's now turned on by default.  It can also be
enabled with the compiler flag /FC, but there is no flag for turning it
off.

Users might want to disable /FC to obtain reproducable binaries.

Change qmake's default from "use Visual Studio's default" to "off" for
this feature.  Users can enable it manually by putting the following
into their project files:

    QMAKE_CXXFLAGS += /FC

CMake faced the same problem.  See CMake upstream issue #18261 for
comparison.

Pick-to: 5.15 6.2 6.3 6.4
Task-number: QTBUG-104450
Change-Id: Ibe636a0ac5d18aefb44f2b7179b59fcec2ad8353
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-06-22 16:05:07 +02:00
Joerg Bornemann
6a6b27940d qmake/msbuild: Support all /DEBUG:xxx linker options
/DEBUG:OFF now turns debug info generation off.
/DEBUG:FULL maps to DebugFull.
Unknown /DEBUG:xxx options are added to AdditionalOptions.

Pick-to: 5.15 6.2 6.3 6.4
Task-number: QTBUG-104450
Change-Id: Ibd072145e51551b29370e809b880c0d7f1a00c03
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-06-22 16:05:07 +02:00
Joerg Bornemann
566ede6ee1 qmake/msbuild: Support all /LTCG:xxx options
/LTCG:OFF now turns off LTCG.
/LTCG:INCREMENTAL maps to UseFastLinkTimeCodeGeneration.
Unknown /LTCG:xxx values are passed to AdditionalOptions.

Pick-to: 5.15 6.2 6.3 6.4
Task-number: QTBUG-104450
Change-Id: If85942dbeec204dc2571a861a43201cb3d5993ae
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-06-22 16:05:07 +02:00
Edward Welbourne
cfcbf38f76 Teach qmake about digit-grouping apostrophes in numeric literals
It was previously understanding them as character literal delimiters,
with unfortunate consequences if a numeric literal contained an odd
number of them. Recognize that an apostrophe with a digit on each side
of it isn't the opening quote of a character literal (unless the digit
before it is preceded by a u). Extend the findMocs test to trigger the
bug, prior to the fix; verified it passes with the fix.

Fixes: QTBUG-98845
Change-Id: I5db3ac59aaeade7c2d6c1fb680ba97261ec0e8a9
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-06-17 00:05:53 +02:00
Alexandru Croitor
94207621ee qmake: Document Xcode behavior when bundling translation files
Xcode's legacy and new build system modes have different behavior
in how they bundle resource paths that start with lang_code.lproj.

Document how to bundle translation files for both legacy
and new build systems.

Pick-to: 5.15 6.2 6.3 6.4
Fixes: QTBUG-98417
Change-Id: I857ec76577f8244a751d4bf38fbe305fef614734
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-06-14 15:45:06 +02:00
Lucie Gérard
05fc3aef53 Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
Files that have to be modified by hand are modified.
License files are organized under LICENSES directory.

Task-number: QTBUG-67283
Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-16 16:37:38 +02:00
Kai Köhne
01b50bfcda qdoc: Remove dependencies to non-existing help modules
Pick-to: 6.2 6.3
Change-Id: I953b714db27dc8bd9ecc1f65bbfd3e02d6068785
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2022-05-10 11:51:11 +02:00
Joerg Bornemann
fc16855eaa Fix qmake/qtpaths -query for static relocatable builds
The install prefix was determined incorrectly for static relocatable
builds.  The reason was that for those builds, QLibraryInfo::path()
returns the application directory, which is <prefix>/bin for qmake and
qtpaths.

Fix this by removing the bin directory part from the installation prefix
that QLibraryInfo returns if qmake/qtpaths are used.

Fixes: QTBUG-102877
Change-Id: I2e9ff96ded0ee2a7802b265741a3cfbe2bf0a4ba
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-05-09 08:32:04 +02:00
Alexandru Croitor
a783c3d574 qmake: Use qVersion for version reporting instead of QT_VERSION_STR
Apart from being consistent with qtpaths (which uses qVersion()),
this also ensures that Qt Creator loads correct debug helpers for types
like QString when debugging qmake.

As a drive by, remove all QT_VERSION_MAJOR, QT_VERSION_MINOR,
QT_VERSION_PATCH defines which are not used anywhere.

Change-Id: Ibc8f2a6af833e1ec6e6cd6e1937ac3c1ab328555
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-06 12:51:12 +02:00
Sona Kurazyan
908e85cc85 Replace uses of _qs with _s in sources and examples
Task-number: QTBUG-101408
Change-Id: I48360ba3b23965cd3d90ac243c100a0656a4cde8
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-04-19 19:12:20 +02:00
Tor Arne Vestbø
e6c80fc011 Remove unused parameter in NmakeMakefileGenerator::suppressBuiltinRules()
Change-Id: I05100656d89ca464c9ef57a442dac7f75da235aa
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-04-05 11:06:23 +02:00
Orgad Shaneh
48ef124047 qmake: Suppress built-in suffixes for make
They cause make to run much slower, and qmake writes everything
explicitly, so they're not really needed.

Change-Id: Ia47674eec8309e120c8264b7b6687677a520d5b9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-03-31 17:02:01 +03:00
Marc Mutz
32692667a6 Apply Q_CONSTINIT across the codebase
Still not complete. Just grepping for static and thread_local.

Task-number: QTBUG-100486
Change-Id: I90ca14e8db3a95590ecde5f89924cf6fcc9755a3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-29 06:18:49 +01:00
Fabian Kosmale
468e9c13a9 Misc: Do not depend on transitive includes
As a drive-by, remove superfluous includes from qnetworkmanagerservice.h
and obey the coding conventions for includes in a few more places.

Change-Id: I65b68c0cef7598d06a125e97637040392d4be9ff
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-17 17:14:37 +01:00
Sona Kurazyan
6585963583 Deprecate {QString, QByteArray}::count()
And remove their uses.

[ChangeLog][QtCore][Deprecation Notice] Deprecated QString::count()
and QByteArray::count() that take no parameters, to avoid confusion
with the algorithm overloads of the same name. They can be replaced
by size() or length() methods.

Change-Id: I6541e3235ab58cf750d89568d66d3b1d9bbd4a04
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-12 01:05:45 +01:00
Joerg Bornemann
1d3b190425 qmake: Fix overlong command lines for static Qt builds on Windows
Linker response files for the MinGW and Unix makefile generators are
controlled by the variable QMAKE_LINK_OBJECT_MAX.  This variable holds a
number.  If the number of object files passed to the linker exceeds this
number, a linker response file containing object file paths is created.

This heuristic is extremely imprecise.  It doesn't take into account the
length of object file names nor the length of $$OBJECTS_DIR.

Also, when using a static Qt, a big part of the linker command line are
libraries.  A relatively small example can fail to link with "The
command line is too long" on Windows, even with the object files being
in a response file.

The MinGW makefile generator already reads the variable
QMAKE_RESPONSEFILE_THRESHOLD for compiler response files.  Re-use this
variable for the linker response file of the Unix and MinGW makefile
generators.

If QMAKE_RESPONSEFILE_THRESHOLD is set, use it to determine whether to
create a response file.  QMAKE_LINK_OBJECT_MAX is then ignored.  The
response file contains objects and libraries.

If QMAKE_RESPONSEFILE_THRESHOLD is not set, use QMAKE_LINK_OBJECT_MAX to
determine whether to create a response file.  The response file contains
only object files.

QMAKE_LINK_OBJECT_SCRIPT is used in both cases to specify a common base
name of all linker response files.

Pick-to: 6.2 6.3
Task-number: QTBUG-100559
Change-Id: I3c78354fa5ebb1a86438ec804679e0ee776c3f49
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-02-21 12:37:19 +01:00
Thiago Macieira
8058127a9d QLibraryInfo: remove load-time variable
Since this is only used by qtpaths and qmake, let's not make every
application pay the price of dynamically initializing a QString whenever
QtCore is loaded (which 100% of Qt applications do). Instead,
initializing a null pointer costs zero and is one third the size of
QString. Even the assignment in qmake and qtpaths is faster this way.

Pick-to: 6.3
Change-Id: I6fcda969a9e9427198bffffd16ce8d1eb8dc19da
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-05 11:57:34 -08:00
Joerg Bornemann
9b2bf17f3e qmake: Print proper error if no .pro file could be detected
When passing a directory to qmake, it tries to detect a .pro file in
that directory.  Whenever the detection failed, qmake printed an error
message like "Access is denied." or "file to open is a directory".

Now, qmake prints an actually helpful error message:

    ***Cannot detect .pro file in directory '../foo'.

    QMake expects the file '../foo/foo.pro' or exactly one .pro file in
    the given directory.

Fixes: QTBUG-34673
Change-Id: I3d21ead247734172eee4eb68d3f9782d3ddaea52
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2022-02-02 19:36:42 +01:00
Joerg Bornemann
747bca3d67 qmake: Scan source files with QFile
The C API we've used so far underlies stronger restrictions regarding
path length than QFile.  Since qmake is not bootstrapped anymore, we can
use QFile.

Task-number: QTBUG-99791
Change-Id: Ic7765b0c09a8aa07c208c1b1d02efe0c54bb44f2
Reviewed-by: Dominik Holland <dominik.holland@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-02-02 18:43:40 +01:00
Marc Mutz
be0dc7fbb8 QMake: replace a Q_ASSERT() with a Q_UNREACHABLE()
In release mode, the Q_ASSERT() is a no-op, and Clang rightfully
pointed out that, in that case, the bool ok variable will be used
uninitialized.

Fix by using Q_UNREACHABLE(), which has an effect in both debug and
release builds.

Pick-to: 6.3 6.2 5.15
Change-Id: I33480aabe1c5233d1caddf9404f475ca9fcb8eaf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-25 03:48:46 +01:00
Joerg Bornemann
9d15854138 Fix wrong QT_HOST_* values when qt.conf is present
When a qt.conf was present, QT_HOST_* variables got a wrong default
value.  For example, QT_HOST_BINS would end with /bin/bin.

We must not provide the defaults via QSettings::value(_, defaultValue).
The assignment of the default value is done in
QMakeLibraryInfo::rawLocation() separately after retrieving the value.

This amends commit 04ec14105e.

Pick-to: 6.3
Fixes: QTBUG-99656
Change-Id: I43431664e93ab40417a5432b03e7eb38ae21bad8
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-01-12 18:28:24 +01:00
Joerg Bornemann
41f211d25f qmake: Print error and exit if a response file cannot be created
This is always an error, and we should not silently return an empty
string and pretend that everything is in order.

Drive-by change: Add a comment stating what createResponseFile()
returns.

Pick-to: 6.3
Change-Id: I4ee940cfac826c7ae5d15e977b692f1368ab29ea
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-01-08 18:08:12 +01:00
Joerg Bornemann
7246058dfd qmake/MinGW: Fix linking target name with whitespace
When having a TARGET value that contains whitespace, linking would fail
with MinGW.  This was, because the function createResponseFile stitched
together a file name like this:
    objectScript."Target Name".Release

The inner double quotes make the file name invalid.

Fix this by retrieving QMAKE_ORIG_TARGET with the var() method instead
of fileVar().  The latter quotes the return value if it contains
spaces.

Pick-to: 5.15 6.2 6.3
Fixes: QTBUG-99522
Change-Id: Ieb7dcf3fbbd8a75de5a9b9a6beadb2170dddf35d
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-01-08 18:08:09 +01:00
Joerg Bornemann
4545d7d6a6 Doc: Mention how to interrupt/continue qmake loops
Fixes: QTBUG-99559
Pick-to: 6.3
Change-Id: Ib88bc0f93d7c0d6b9bf9a342410395f5a79675e5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-01-08 18:08:08 +01:00
Joerg Bornemann
64cac8b7be qmake/Xcode: Mark "Qt Preprocess" build phase as always out of date
This build phase executes the qt_preprocess.mak makefile from Xcode
and should be triggered whenever any input of any rule in this makefile
is out of date.  It was not triggered when a file that's referenced in
a .qrc file was changed.

The Xcode project lacks those files as rule input, but the makefile
itself has its inputs correctly set up, and can be triggered always.

Pick-to: 6.2 5.15
Fixes: QTBUG-94995
Change-Id: Ida1349039bd6f23a300a610ecbde96f7cd35edb6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-12-09 17:28:35 +01:00
Kai Köhne
69c38b4fd0 Fix size_t / int conversion warnings in qmake
Fixes

  qtbase\qmake\generators\makefiledeps.cpp(985): warning C4267: '+=': conversion from 'size_t' to 'int', possible loss of data
  qtbase\qmake\generators\makefiledeps.cpp(986): warning C4267: '+=': conversion from 'size_t' to 'int', possible loss of data

Pick-to: 6.2
Change-Id: I7c6b4f36dc383db420c10d674666d58dbf29d2dd
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-12-02 15:16:49 +01:00
Marc Mutz
a0f9aef11b Long live Q_GADGET_EXPORT!
Like Q_NAMESPACE_EXPORT for Q_NAMESPACE, this variant of Q_GADGET
allows passing an export macro. This is useful to avoid exporting the
whole class just to get the staticMetaObject hidden therein exported.

Before anyone asks: No, we don't need Q_OBJECT_EXPORT, because QObject
subclasses, being polymorphic, always need to have a class-level
export macro (to export their vtable), but while that technique also
works for value classes (the Q_GADGET audience), it is not desirable
for them, because it makes inline functions exported in Windows debug
builds, which is not what we want, because it needlessly restricts
what you can to with the inline functions (e.g. remove).

[ChangeLog][QtCore] Added the Q_GADGET_EXPORT macro, which is like
Q_GADGET, but allows passing an export macro (like Q_NAMESPACE_EXPORT
for Q_NAMESPACE).

Fixes: QTBUG-55458
Change-Id: I546297de1e8aa45d83381991bcd3fbca61e1eef0
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-27 01:25:10 +01:00
Marc Mutz
f8ab1f0576 qmake: use even fewer magic numbers
De-unroll the loop over the "interesting" keyword ignore comments by
using the existing array of their names. Replace magic numbers by
strlen() calls. Use local starts_with() instead of strncmp() when
comparing with fixed-size constant string literals, to avoid repeating
the fixed string's lengths for the third argument of strncmp().

Task-number: QTBUG-55458
Change-Id: If458aced382948fb719d984702857fb2171c87ee
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-11-26 18:28:50 +01:00
Marc Mutz
5750a9728e qmake: don't use magic numbers
Use a local enum to enumerate the different "interesting" keywords.

Task-number: QTBUG-55458
Change-Id: I30a6336072d3184b720d8c016f199572dba87a81
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-11-24 10:47:10 +01:00
Yuhang Zhao
e01c25e859 QtBase: replace windows.h with qt_windows.h
We have some special handling in qt_windows.h,
use it instead of the original windows.h

Change-Id: I12fa45b09d3f2aad355573dce45861d7d28e1d77
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-23 12:53:46 +08:00
Joerg Bornemann
610123b1c8 Move the 'qmake' feature to src/tools/configure.cmake
This allows us to present 'qmake' in the tool-related section of the
configure summary.

Change-Id: I897dec23cb0608706ec01d9b91283dbce92b293f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-19 20:44:51 +01:00
Joerg Bornemann
04ec14105e Change qt.conf key Qml2Imports to QmlImports
[ChangeLog][qt.conf] The key Paths/Qml2Imports has been renamed to
Paths/QmlImports. For backwards-compatibility, Paths/Qml2Imports is
still accepted and acts as default value for when Paths/QmlImports is
not present.

Fixes: QTBUG-98335
Change-Id: If7ffedd281eb8a87e8ab1a2b69a823e615c33541
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-11-19 16:44:32 +01:00