Commit Graph

66 Commits

Author SHA1 Message Date
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
22dc78f417 CMake: pro2cmake.py: Fix handling of TEMPLATE=subdir .pro-files
Change-Id: I52f575df199c4d9b38123ab5d838f2e85344835d
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
2019-02-27 16:03:07 +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
Albert Astals Cid
e03596c2a7 pro2cmake: account for child .pro files having includes
Change-Id: Ic2213578c9bd27787ae9788acbe4455252a1158c
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-02-27 15:04:48 +00:00
Albert Astals Cid
dc0870db74 pro2cmake: Target dependencies can be on -private libs
so use map_qt_library instead of map_qt_base_library

Change-Id: I4dd0097fff3ffd9ec4aad36d11d79ea23a08cb90
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-02-18 08:05:49 +00:00
Tobias Hunger
3726b58d3b CMake: pro2cmake.py: Simplify condition generation
There is no need to try and avoid extra () and NOTs: Those will be
removed by sympy later anyway.

Change-Id: I39d3e4d1d829579e532bfbbf6c69e0f1e06e9a22
Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
2019-02-11 17:16:20 +00:00
Tobias Hunger
93564b3f8b CMake: pro2cmake.py: Treat ANDROID_EMBEDDED as ANDROID
Treat ANDROID_EMBEDDED as ANDROID when simplifying conditions.

Change-Id: I2cf0ea1e1a3e882e3a7b7276867dcee452866ade
Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
2019-02-11 17:16:08 +00:00
Tobias Hunger
fb33efd274 CMake: pro2cmake.py: Do not go into infinite loop
Do not go into an infinite loop when replacing a variable with itself.

Change-Id: I2765b1c0c567753f26ca75e0533c1d193362b456
Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
2019-02-11 17:15:58 +00:00
Tobias Hunger
b388bc7e77 CMake: pro2cmake.py: Handle equals(foo, bar) in conditions
This adds an overly simplistic mapping -- just like it does for the
rest of the qmake test functions.

Change-Id: I0c9e3b70c1c3d0c68a245706a141aa7b7cb4d8bf
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
2019-02-11 10:46:29 +00:00
Tobias Hunger
35a30c7ebb CMake: pro2cmake.py: Expand qmake values in file names, etc.
Expand qmake values when dealing with source file names, include
directories and more. This handles cases where variables are used
to refer to sources (e.g. $$VERSIONTAGGING_SOURCES in corelib) as
well as things like $$QT_SOURCE_TREE and friends.

Note that $$PWD and $$OUT_PWD are still need hand-holding since they
refer to the scopes directory relative to the top level directory --
which pro2cmake.py does not know.

Change-Id: I011ef55416ff820053d5f844b3008836849f5075
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-02-11 09:39:36 +00:00
Tobias Hunger
199cce0c20 CMake: pro2cmake.py: Better mapping of complex conditions
.pro-files support things like contains(Foo, bar), etc.

Map that in such a way that only one identifier will be visible to
CMake to unconfuse the logic handling on that side. These conditions
will need manual fixup later!

Change-Id: Id4946e694a9adccf9f54bcce26a6c227cd921007
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-02-11 09:38:33 +00:00
Tobias Hunger
d796410045 CMake: pro2cmake.py: Remove some dead code
Change-Id: I8e3e7e4c4ef9747e0749734bdf875baccc4646bd
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
2019-02-11 09:37:46 +00:00
Tobias Hunger
6104643db0 CMake: pro2cmake.py: Remove leading ./ in paths
Remove leading './' from paths before writing them into CMakeLists.txt.

Change-Id: I5680a3470cf491a8805b559197f94f8e6a6ce9b7
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-02-11 09:36:00 +00:00
Tobias Hunger
64e3c8bb19 CMake: pro2cmake: Fix handling of chained scopes with else branches
Fix handling of things like:

foo:bar:buz: {
    do something
} else: wat {
    do something else
}

The else relates to foo AND bar AND buz, not just to buz in this case.

Change-Id: I40d1fa295b4d6dd95ae5e1ce2d58372edc807b86
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-02-11 09:35:29 +00:00
Tobias Hunger
73f5036be5 CMake: Map dlopen feature to 'ON'
Map the dlopen feature to 'ON'. The effect is that cmake will figure
out whether or not linking to 'dl' is necessary or not.

The user-visible feature is 'library' anyway: That enables dynamic
library loading -- and will link in 'dl' as needed.

Change-Id: I0d68275a7234efba7f926150f120bb37b4a1163f
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-02-11 09:35:07 +00:00
Tobias Hunger
e616976fdf CMake: pro2cmake.py: Small fix to type markup
Change-Id: I2f7dc94f379d51c3816649849aa7365b17334ab5
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-01-31 15:24:09 +00:00
Tobias Hunger
6dd989fe61 CMake: pro2cmake.py: Add scope debugging support
Dump scope trees for all scopes that contain a variable
'PRO2CMAKE_SCOPE_DEBUG' (set to any value).

Change-Id: If17bb1697a32ccaa427a858c2330ab2b019d0fa8
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-01-31 15:23:59 +00:00
Tobias Hunger
cfbb110abe CMake: pro2cmake.py: Assign a unique id to each scope
This makes scopes much simpler to destinguish from each other.

Change-Id: I1af42f181b5899aba749bcf9267a345385149f90
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-01-31 15:23:22 +00:00
Tobias Hunger
0efd241d20 CMake: pro2cmake.py: report total condition when dumping a scope
Show the total_condition (if set) when dumping a scope.

Change-Id: I9dfe98c2251f1d28881771042f17d723cedc8907
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-01-31 15:23:09 +00:00
Tobias Hunger
ca4edbec66 CMake: pro2cmake.py: Add a way to debug merges of scopes
Generate debug output whenever a qmake scope with a variable
'PRO2CMAKE_MERGE_DEBUG' is involved in a scope merge.

Change-Id: I0ad94b881db9930de689c199adbac084efe6c03b
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-01-31 15:22:59 +00:00
Tobias Hunger
210762ae46 CMake: pro2cmake.py: Pass QMAKE_MOC_OPTIONS on to CMake
Change-Id: I39c1b0aedbffaa29a34253e0c1c4bb4a4dddbe98
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
2019-01-31 10:02:40 +00:00
Tobias Hunger
4d4bf61f9f CMake: pro2cmake.py: Convert more settings from .pro-file to CMake
Convert QMAKE_USE, QMAKE_CXX_FLAGS and QMAKE_LFLAGS into CMake.

Change-Id: I53a5b91664b6ab71892d4381c00f8d744d7d7abd
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
2019-01-31 10:02:24 +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
328de7aab9 CMake: pro2cmake: default QT_FEATURE_system_* to "ON"
Qt 6 will use external libraries for everything, so
default all QT_FEATURE_system_foo to "ON".

Change-Id: I884a4293c64487271be08de5fab82e6858d0a2ed
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-01-31 08:48:55 +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
0c43850687 CMake: pro2cmake.py: Better printing of scopes
Change-Id: Ibeb77a23c90d3a47c78d17c4683e4af3c64449fc
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-01-29 09:29:46 +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
aee1d1e96b CMake: pro2cmake.py: Work on mapping of conditions to cmake
Make sure complex things in qmake (e.g. function calls, etc.) are
mapped better to cmake. When there is no way to properly map the
qmake construct, then make sure to map everything into one
identifier.

This is to keep the structure of the condition simple.

Change-Id: I6d88e0cb85fce1041bbfdc96604dab7bd4e65856
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-01-29 09:01:26 +00:00
Tobias Hunger
404d0b5975 CMake: pro2cmake.py: Resolve file names for RESOURCES
Change-Id: I821cdc88c7f45260997e118ab2abfd7ba6526b75
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-01-29 09:01:16 +00:00
Tobias Hunger
0a9e5e139a CMake: pro2cmake.py: Fix handling of complex else branches
Return the current scope's condition, not the total condition from
recursive_evaluate_scope. That is the part the "else" referrs to.

The parent_condition stays identical for all branches, so that should
not get negated.

Change-Id: I0da91483d4d748d01a29ac16890d709d8d659843
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-01-29 09:01:07 +00:00
Tobias Hunger
0e2762651c CMake: pro2cmake.py: merge extend_targets with identical conditions
This should somewhat simplify the generated CMakeLists.txt files,
especially in complex cases like corelib or network.

Change-Id: I208c8f99a64cbb6c97d51dd3ae428bb234982202
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-01-29 09:00:56 +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
Tobias Hunger
0690c145db CMake: pro2cmake.py: Better output in debug dumps
Report more error conditions in debug dump and make the output
easier to read in the non-error case by wrapping all strings in
"".

Change-Id: I3c99deda3dfa27dcc0c9ce2800bfb891747e6934
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-01-23 15:41:44 +00:00
Tobias Hunger
2f50466995 CMake: pro2cmake.py: Give up on faithful representation of -=, +=, *= and =
Having a good representation is nice, but unfortunately very hard: pro2cmake.py
sees just a small part of the entire qmake build system at a time, so the information
it has is incomplete to start with. It is not worthwhile to pass the supposedly full
information around -- which will then need to get de-duplicated again -- considering
that the information is not complete in the first place.

So go back to the simplistic approach we used earsier. That is good enough and does not
suffer from the problem of having multi-part arguments getting messed up when the
scopes get de-duplicated.

Change-Id: I553329650d6b8046f7ad8b1282e3d0c961293a28
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-01-23 15:41:34 +00:00
Tobias Hunger
024edf4bfd CMake: pro2cmake.py: Report keys that were not converted in each scope
This makes it easier to see what is still missing.

Change-Id: I186abd609f20be680ac0943ac89068f764142a79
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-01-23 15:41:24 +00:00
Tobias Hunger
6ad9352544 CMake: pro2cmake.py: Do not print trailing / in directory names
Change-Id: I3da83b8908791e033cf33221631d2fe988f83957
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-01-23 15:41:13 +00:00
Tobias Hunger
29ff5f77ee CMake: pro2cmake.py: Do not double-report include files
Do not add scopes that are going to get merged into their parent scope
as a child of the parent scope. This leads to the information of the
child scope being duplicated.

Change-Id: If4d6a83b9c9eac477959e7774e9cf65fd4df98e6
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-01-23 12:06:22 +00:00
Tobias Hunger
cc593426eb CMake: pro2cmake.py: Better indentation in debug dump
Indent the individual parts of a scope relative to the scope itself.
This makes things a bit more readable.

Change-Id: Iffbffd69bc960118f9657a1b7fb488da3c7b48dd
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-01-23 12:02:35 +00:00
Tobias Hunger
6e9a2dd3c6 CMake: pro2cmake.py: Visit scopes depth-first for include resolution
This avoids some includes being done several times: We used to generate
scopes for the include files, add them to our current scope and then
traverse the children of the current scope.

Switch the order to avoid traversing the newly added scopes twice.

Change-Id: Icb9c53c9f54772d3305e0fb121824c23d5469e09
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-01-23 11:53:01 +00:00
Tobias Hunger
3f3517923e CMake: pro2cmake.py: Ignore 3rdparty code that gets included
Ignore include files that go into 3rdparty code. Qt 6 should work
with external libraries, so there is no need to drag in 3rdparty
include directories, etc.

Change-Id: I990f3a8a4983e1458843b4122420b9daec763ccb
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-01-23 11:52:44 +00:00
Tobias Hunger
23e3aaf2cd CMake: pro2cmake.py: Nicer printing of conditions
Do not needlessly add () and NOT all over the conditions.

Change-Id: If907357306eb3f8ab5b2878bcad5902171a90476
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-01-23 11:52:25 +00:00
Tobias Hunger
e5bee37762 CMake: pro2cmake.py: Improve debugging dump
Make the output of the project structure debug dump more readable.

Change-Id: Ib80b41f7fdb8e14ff878284c46f3760d84f4f004
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-01-18 08:52:58 +00:00