Commit Graph

40 Commits

Author SHA1 Message Date
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
Joerg Bornemann
928828b549 pro2cmake: Handle QT_(MAJOR_|MINOR_|PATCH_)VERSION conditions
Task-number: QTBUG-98852
Change-Id: I4c86fff7bbcc6c42cd04094f2409c3d04779597c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-08 03:45:30 +01:00
Joerg Bornemann
3954b7385e pro2cmake: Generate find_package call for Qt5/Qt6 for examples
This makes the QT_VERSION_(MAJOR|MINOR|PATH) variables available.

Task-number: QTBUG-98852
Change-Id: I7e40f2a7ac09975ce21e45cda384af928e1fa629
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-08 03:45:30 +01:00
Joerg Bornemann
eab2a57b37 pro2cmake: Handle optional Qt modules
...and write a separate find_package(Qt6 OPTIONAL_COMPONENTS Foo Bar)
call for those.

Task-number: QTBUG-96799
Change-Id: I3386487774c386edde6767dca92ce433bfed906e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-08 03:45:30 +01:00
Joerg Bornemann
50f3b1c519 pro2cmake: Add a blackbox test for converting from qmake to CMake
If you can set the environment variable DEBUG_PRO2CMAKE_TEST_CONVERSION
to 1, the output of pro2cmake is written to the temp directory.  This
helps analysing test failures.

Change-Id: Ida42c5b76a67172d00ce0d2488adc7fb376c6b11
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-08 03:45:30 +01:00
Alexandru Croitor
2389aaf8c7 pro2cmake: Handle qmake condition operator precedence
Unfortunately qmake does not have operator precedence in conditions,
and each sub-expression is simply evaluated left to right.

So c1|c2:c3 is evaluated as (c1|c2):c3 and not c1|(c2:c3). To handle
that in pro2cmake, wrap each condition sub-expression in parentheses.

It's ugly, but there doesn't seem to be another way of handling it,
because SymPy uses Python operator precedence for condition operators,
and it's not possible to change the precendece.

Fixes: QTBUG-78929
Change-Id: I6ab767c4243e3f2d0fea1c36cd004409faba3a53
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-28 15:41:11 +01:00
Joerg Bornemann
6708fad936 pro2cmake: Fix test_realworld_comment_scope
Change the expected value from None to [], because that's the value of
the if branch.  It has been like that since v6.0.0 at least.

Change-Id: Iefdb22a772fc5540ad5a38566be5a7f529e00cb1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-28 15:40:43 +01:00
Joerg Bornemann
e33c88a36d pro2cmake: Fix test_scope_handling.py
When the android-embedded scope was removed in
7a4b586f4b, the conditions in
test_scope_handling.py were adjusted following the laws of logic.
However, the scope handling code does not follow the same laws.

Effectively revert the part of said commit in test_scope_handling.py but
use "UNKNOWN_PLATFORM" instead of "ANDROID_EMBEDDED".

Change-Id: Ic090451e2a28b50f5be5668503e216cbe3871633
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-28 15:40:36 +01:00
Edward Welbourne
7a4b586f4b Remove conditioning on Android embedded
It is no longer handled separately from Android.
This effectively reverts commit 6d50f746fe

Change-Id: Ic2d75b8c5a09895810913311ab2fe3355d4d2983
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-09-17 17:30:14 +02:00
Tor Arne Vestbø
77885f8402 cmake: Remove APPLE prefix from platform names
None of the other platforms have it.

Change-Id: Ib448c2c03ba03f711b507ef391977c0e6aa7c192
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-16 17:57:56 +01:00
Tor Arne Vestbø
db745fdd2d cmake: Fix naming when referring to Apple macOS
Change-Id: Iafb5e448d0d65d42f788464fc600594a5666f9af
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-16 17:57:52 +01:00
Alexandru Croitor
a0967c2a4f pro2cmake: Handle operation evaluation order when including children
Instead of processing included_children operations either before or
after the parent scope, collect all operations within that scope and
its included children scopes, and order them based on line number
information.

This requires propagating line numbers for each operation as well as
line numbers for each include() statement, all the way from the
parser grammar to the operator evaluation routines.

This should improve operation handling for included_children
(via include()), but not for regular children (introduced by ifs or
elses), aka this doesn't solve the whole imperative vs declarative
dilemma.

Sample projects where the improvement should be seen:
tests/auto/gui/kernel/qguiapplication and
src/plugins/sqldrivers/sqlite.

This amends f745ef0f67

Change-Id: I40b8302ba6aa09b6b9986ea60eac87de8676b469
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-11-12 11:47:42 +00:00
Frederik Gladhorn
a5060e9f99 cmake scripts: move parser into separate file
The code is nicely separated between parsing and processing. Splitting
that into two files makes it easier to follow which function belongs to
which part.

Change-Id: I576b8613b0d05b2dae3f9c6fa65d9ed5b582a0f7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-10 13:35:43 +00:00
Frederik Gladhorn
2659d31d93 cmake scripts: fix test_scope_handling
The file parameter for a new Scope got renamed to qmake_file.

Change-Id: I6cb9d010892f3e3132fac09eead1dbf45d6ba86d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-10-10 13:12:38 +00:00
Alexandru Croitor
590213e531 Move sympy condition simplification code into separate file
Change-Id: I3f062bf939b452bb41b7a27508a83cbf93abff8c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-10-01 14:13:12 +00:00
Leander Beernaert
5d7bb2e4f0 Add support for converting qtTargetLibrary() value assignments
Add support to pro2cmake to handle variable assignments via functions,
e.g: TARGET = $$qtTargetLibrary($$TARGET). The evalulation of the
functions happens during parsing and is very rudementary in nature.

Currently it only covers the qtTargetLibrary(), required for certain
projects, and quote(), required for passing unit tests.

If we run into any unhanlded function an exception will be thrown.

This patch also changes the TARGET property on Scope to expand the
value.

Change-Id: I678b7058067348a3972944bdba110f556cf22447
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-08-08 13:03:28 +00:00
Leander Beernaert
341ccc3b59 Enable recursive expansion of simple qmake variables
Allow _expand_value to expand variables that may have more than
one level of expansion when the regular expression covers all
of the input. E.g.:

A = Foo
B = $$A/Bar
scope.expand('$$B')

While the original code was able to expand the string '$$B/source.cpp' to
'Foo/Bar/source.cpp', it could not expand the string '$$B' completely.
The latter would always return '$$A/Bar' instead of the expected 'Foo/Bar'
string.

A test case has been added which coveres the above example.

Change-Id: Ie3b5739c24ecbeb67d408dd204b0f54bab1d0f3f
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-18 07:26:01 +00:00
Alexandru Croitor
4e907f1f62 Fix comment fixup in pro2cmake
Comments should be removed before line continuations, otherwise
the semantics of an assignment change.
Found this during reconversion of qtimageformats.

Adjust test to specifically test for all the expected values.

Amends 76f5b784ce.

Change-Id: Iaa46bbc9cbd7b2390fe9b5f0078ac33d225a9258
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-06-06 08:38:08 +00:00
Alexandru Croitor
bfed22e3b7 Remove all line continuations when processing qmake syntax
We constantly had to adjust the qmake grammar to handle line
continuations (\\\n) in weird places. Instead of doing that,
just do a preprocess step to remove all the LCs like we do with
comments, and simplify the grammar not to take into account the
LCs.

From some manual testing it doesn't look like we get any regressions.

Change-Id: I2017d59396004cf67b6cb54977583db65c65e7d3
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-05-23 14:19:22 +00:00
Alexandru Croitor
6dfeb81bcb Improve qmake syntax parser in pro2cmake.py
Some qtdeclarative pro files caused exceptions when trying to parse
them using the script. This included the following:
- handling conditions divided by newlines and backslashes
- handling conditions that have no scope

The parser has been fixed to deal with those cases and relevant
tests were added.

After the change, all qtdeclarative project files are parseable by
the script.

Change-Id: Ib9736423f7fb3bcc1944b26cfb3114306b4db9a7
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-05-23 14:17:46 +00:00
Alexandru Croitor
76f5b784ce Fix the fix to correctly handle comments in multi-line assignments
The previous fix where the Grammar comment style was changed to
remove the newlines was incorrect, because if you have

 foo=1#comment
 bar=2

after the Grammar comment ignoring, it would transform into

 foo=1bar=2

which will clearly fail to parse, so the new line has to stay.

But we would still have the following case which would fail:
 foo=a \
 # comment
 b

Apparently qmake things that's the equivalent of
foo=a b

but the grammar parses it as
 foo=a \
 \n (newline)
 b

Thus the parsing fails because there's a newline and then some
weird 'b' token which the grammar does not expect.

The best fix I found is to preprocess the source, to remove
completely commented out lines.

So:
 foo=a \
 # comment
 b

gets transformed into

 foo=a \
 b

Change-Id: I2487a0dbf94a6ad4d917d0a0ce05247341e9b7da
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-05-20 13:18:11 +00:00
Alexandru Croitor
e0a6e9f3aa Fix parsing qmake assignments that have comments in between
For some reason the python comment regex that we used does not ignore
the line break at the end of a comment line.

This caused issues when parsing multi line assignments with comments
in between.

Use our own regex for comments to circumvent the issue. It was found
while trying to port the qtimageformats repo.

Added a pytest as well.

Change-Id: Ie4bbdac2d1e1c133bc787a995224d0bbd8238204
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-05-17 13:31:03 +00:00
Tobias Hunger
14bf7e952e CMake: Fix test_scope_handling
Adapt to updated APIs in pro2cmake.py

Change-Id: I39898b675e27d6295ef6cfa049c82b245d71188a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-17 13:26:29 +00:00
Tobias Hunger
5fe8a38af3 CMake: Fix test_operations
Fix test_operations and do some small mypy cleanups along the way

Change-Id: I6586b5d3491e5dcf44252c098516f0922fa60420
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-05-17 13:26:26 +00:00
Jędrzej Nowacki
89f34ee42a Fix turned logic in RemoveOperation
It is regression caused by a0a94576fa
("Fix RemoveOperation").

Add unit test for all operation types to make sure this code actually
works:-)

Change-Id: I97c94cb3411f05de89422e3fa2222f2217a09e49
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-03-28 06:30:32 +00:00
Tobias Hunger
83354655b2 CMake: pro2cmake.py: Simplify code and add test for line continuation
Simplify code a bit and add a test for line continuation fixup.

Change-Id: If865bc94d7d419c65d3280b5f9613ebc0d3db74a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-02-28 08:08:41 +00:00
Tobias Hunger
f2e968b245 CMake: pro2cmake.py: Handle for loops without block
Handle for loops with a single line of instructions and add a test
for that.

Change-Id: I041ae30f64abcbd3db7df29933647f047b92ede3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-02-28 08:08:30 +00:00
Tobias Hunger
33fe56c630 CMake: pro2cmake.py: Make \$\$QT_FOO work in assignments
This broke somewhere along the way. Add a test for this.

Change-Id: I106ddff6eb86a51ef132285d1bc623f3b5cf71fb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-02-28 08:08:17 +00:00
Tobias Hunger
754ba28799 CMake: pro2cmake.py: Fix parsing of Line continuation before end of file
... and add a test case for this.

Change-Id: If20d737b54ecb3f9e128e59070b238c840acad6c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-02-28 08:08:08 +00:00
Tobias Hunger
8512f5179d CMake: pro2cmake.py: Fix parsing of for loops
Ignore for loops in the pro2cmake.py parser and add a unit test for that.

Change-Id: I2a0c075c45cf56f4f24ada2d53e8e8e94ce19f26
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-02-28 08:08:00 +00:00
Tobias Hunger
eb832cb00a CMake: pro2cmake.py: Handle complex conditions
Change-Id: Ifb047e5736f1831ddbd65b210e760c2729378334
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-02-28 08:06:49 +00:00
Tobias Hunger
951e297362 CMake: pro2cmake.py: Warn and fix broken line continuation
Warn on broken line continuation in .pro-files, but fix up the issue
and proceed.

Change-Id: Ibe68011b312bcea25620ce790a0b44b2983fbd88
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-02-28 08:06:41 +00:00
Tobias Hunger
c971d2d359 CMake: pro2cmake.py: Handle values with () in assignments
Change-Id: I0f59c7fa57cd6c64b151f439d4eea4ae56dca288
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
2019-02-27 16:03:20 +00:00
Tobias Hunger
8c04d6c967 CMake: pro2cmake.py: Improve condition simplification code
Improve the code that simplifies conditions to take "OS families"
into account. E.g. if a system must be ANDROID, then it is redundant
to express that it is NOT APPLE_OSX.

Change-Id: Ib7e62726c309bf84b9e5e0d6a6e3465511db0ead
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
2019-02-27 16:02:58 +00:00
Tobias Hunger
35f23a3dad CMake: pro2cmake.py: Better parsing of scopes with else
Parse conditions more exactly as before, enabling proper handling
of else scopes.

Change-Id: Icb5dcc73010be4833b2d1cbc1396191992df1ee4
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
2019-02-27 16:02:45 +00:00
Tobias Hunger
194022d3a6 CMake: pro2cmake.py: Use properties
Make use of @property to make code a bit nicer.

Change-Id: Iff0bfed57874cf13b7e5f85acde2660a397933d7
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-01-31 08:49:14 +00:00
Tobias Hunger
9cee04ac94 CMake: pro2cmake.py: Merge more scopes
* Remove scopes with condition 'OFF'
* Merge scopes with identical conditions

This e.g. merges children with a condition that simplifies to
'ON' with their parent scope.

Change-Id: Ieb3d60e1234f189ac45869853555ca8c0cfb5c76
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-01-31 08:48:32 +00:00
Tobias Hunger
4a2562e5db CMake: pro2cmake.py: Simplify conditions
Use pysym to simplify conditions in extend_target.

Do some manual changes to the condition based on domain knowledge.

Change-Id: I7fbb9ebc93b620a483c6a3a796d84c9bc0e36ef7
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-01-29 09:29:38 +00:00
Tobias Hunger
1c1bb53c55 CMake: pro2cmake.py: Fix pyls warnings
Fix pyls warnings in pro2cmake.py as well as its tests.

Change-Id: Ib8ee1daa9b97735d13c0fde43616daa46de9e171
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-01-29 09:00:45 +00:00
Simon Hausmann
e9c45bbddd Begin port of qtbase to CMake
Done-by: Alexandru Croitor <alexandru.croitor@qt.io>
Done-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Done-by: Kevin Funk <kevin.funk@kdab.com>
Done-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
Done-by: Simon Hausmann <simon.hausmann@qt.io>
Done-by: Tobias Hunger <tobias.hunger@qt.io>
Done-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Done-by: Volker Krause <volker.krause@kdab.com>
Change-Id: Ida4f8bd190f9a4849a1af7b5b7981337a5df5310
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
2018-11-01 11:48:46 +00:00