2 Commits

Author SHA1 Message Date
Alexandru Croitor
ff25d705a3 init-repository: Normalize git urls with more than one '../' segment
The qttools qlitehtml submodule url was recently updated to use a
relative url like '../../playground/qlitehtml.git' instead of an
absolute path to code.qt.io repo.
Same for the nested litehtml submodule.

This broke initialization of the qttools repository, because the
init-repository script only normalized one '../' segment in the
submodule url, instead of all of them, which ended up trying to clone
a non-existent git://code.qt.io/qt/../playground/qlitehtml.git repo.

Apply the url normalization in all the code paths where there might
still be '../' segments in the url.

Pick-to: 6.8 6.9
Change-Id: Iaa8e58104c92858318ad66aefa5a38d63ad7a155
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-12-11 07:09:53 +01:00
Alexandru Croitor
29019c9cae CMake: Rewrite init-repository using CMake and .sh / .bat scripts
init-repository is now implemented using CMake + .sh / .bat scripts.

The intent behind the change is not to require Perl to checkout and
build Qt, because it can be troublesome to acquire on Windows and it
can also lead to issues during builds due to CMake picking up a Perl
distribution-shipped compiler.

All previous options were ported over like
- module-subset
- alternates
- etc.

A few new options were added:
- --resolve-deps / --no-resolve-deps
- --optional-deps / --no-optional-deps
- --verbose
and some other internal ones for testing reasons.

The new script does automatic resolving of dependencies
based on the depends / recommends keys in .gitmodules unless
--no-resolve-deps is passed.
So if you configure with --module-subset=qtsvg, the script will also
initialize qtbase.
If --no-optional-deps is passed, only required dependencies ('depends'
ky) will be included and optional dependencies ('recommends' key) will
be excluded.

The new script now has a new default behavior when calling
init-repository a second time with --force, without specifying a
--module-subset option. Instead of initializing all submodules, it
will just update the existing / previously initialized submodules.

It also understands a new module-subset keyword "existing", which
expands to the previously initialized submodules, so someone can
initialize an additional submodule by calling
 init-repository -f --module-subset=existing,qtsvg

Implementation notes:

The overall code flow is init-repository -> cmake/QtIRScript.cmake
-> qt_ir_run_main_script -> qt_ir_run_after_args_parsed ->
qt_ir_handle_init_submodules (recursive) -> qt_ir_clone_one_submodule
with some bells and whistles on the side.

The command line parsing is an adapted copy of the functions
in qtbase/cmake/QtProcessConfigureArgs.cmake. We can't use those exact
functions because qtbase is not available when init-repository is
initially called, and force cloning qtbase was deemed undesirable.

We also have a new mechanism to detect whether init-repository was
previously called. The perl script used the existence of the qtbase
submodule as the check. In the cmake script, we instead set a custom
marker into the local repo config file.

Otherwise the code logic should be a faithful reimplementation of
init-repository.pl aside from some small things like logging and
progress reporting.

The pre-existing git cloning logic in QtTopLevelHelpers was not used
because it would not be compatible with the alternates option and I
didn't want to accidentally break the pre-existing code. Plus
init-repository is a bit opinionated about how it clones and checks
out repos.
The dependency collection and sorting logic uses the pre-existing code
though.

See follow up commit about implicitly calling init-repository when
qt5/configure is called and the repo was not initialized before.

[ChangeLog][General] init-repository was rewritten using CMake. Perl
is no longer required to initialize the qt5.git super repo.

Task-number: QTBUG-120030
Task-number: QTBUG-122622
Change-Id: Ibc38ab79d3fdedd62111ebbec496eabd64c20d2b
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2024-02-28 06:23:36 +01:00