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>
93 lines
3.3 KiB
CMake
93 lines
3.3 KiB
CMake
# Copyright (C) 2024 The Qt Company Ltd.
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
# This script writes its arguments to the file determined by OUT_FILE.
|
|
# Each argument appears on a separate line.
|
|
# This is used for writing the init-repository.opt file.
|
|
#
|
|
# This script takes the following arguments:
|
|
# IN_FILE: The input file. The whole command line as one string, or one argument per line.
|
|
# REDO_FILE: A file containing extra commands to be joined with IN_FILE.
|
|
# OUT_FILE: The output file. One argument per line.
|
|
# SKIP_ARGS: Number of arguments to skip from the front of the arguments list.
|
|
# IGNORE_ARGS: List of arguments to be ignored, i.e. that are not written.
|
|
#
|
|
# If the REDO_FILE is given, its parameters will be merged with IN_FILE parameters
|
|
# and be written into the OUT_FILE.
|
|
|
|
cmake_minimum_required(VERSION 3.16)
|
|
|
|
# Read arguments from IN_FILE and separate them.
|
|
file(READ "${IN_FILE}" raw_args)
|
|
# To catch cases where the path ends with an `\`, e.g., `-prefix "C:\Path\"`
|
|
string(REPLACE "\\\"" "\"" raw_args "${raw_args}")
|
|
string(REPLACE ";" "[[;]]" raw_args "${raw_args}")
|
|
|
|
separate_arguments(args NATIVE_COMMAND "${raw_args}")
|
|
|
|
string(REPLACE "\;" ";" args "${args}")
|
|
string(REPLACE "[[;]]" "\;" args "${args}")
|
|
|
|
if(DEFINED REDO_FILE)
|
|
file(READ "${REDO_FILE}" raw_redo_args)
|
|
separate_arguments(redo_args NATIVE_COMMAND "${raw_redo_args}")
|
|
|
|
if(args)
|
|
list(FIND args "--" args_ddash_loc)
|
|
list(FIND redo_args "--" redo_ddash_loc)
|
|
if("${redo_ddash_loc}" STREQUAL "-1")
|
|
if("${args_ddash_loc}" STREQUAL "-1")
|
|
list(LENGTH args args_ddash_loc)
|
|
endif()
|
|
# Avoid adding an empty line for an empty -redo
|
|
if(NOT "${redo_args}" STREQUAL "")
|
|
list(INSERT args ${args_ddash_loc} "${redo_args}")
|
|
endif()
|
|
else()
|
|
# Handling redo's configure options
|
|
list(SUBLIST redo_args 0 ${redo_ddash_loc} redo_config_args)
|
|
if(redo_config_args)
|
|
if("${args_ddash_loc}" STREQUAL "-1")
|
|
list(APPEND args "${redo_config_args}")
|
|
else()
|
|
list(INSERT args ${args_ddash_loc} "${redo_config_args}")
|
|
endif()
|
|
endif()
|
|
|
|
# Handling redo's CMake options
|
|
list(LENGTH redo_args redo_args_len)
|
|
math(EXPR redo_ddash_loc "${redo_ddash_loc} + 1")
|
|
# Catch an unlikely case of -redo being called with an empty --, ie., `-redo --`
|
|
if(NOT ${redo_ddash_loc} STREQUAL ${redo_args_len})
|
|
list(SUBLIST redo_args ${redo_ddash_loc} -1 redo_cmake_args)
|
|
endif()
|
|
|
|
if(DEFINED redo_cmake_args)
|
|
if("${args_ddash_loc}" STREQUAL "-1")
|
|
list(APPEND args "--")
|
|
endif()
|
|
list(APPEND args "${redo_cmake_args}")
|
|
endif()
|
|
endif()
|
|
else()
|
|
list(APPEND args "${redo_args}")
|
|
endif()
|
|
endif()
|
|
|
|
# Skip arguments if requested
|
|
if(DEFINED SKIP_ARGS)
|
|
foreach(i RANGE 1 ${SKIP_ARGS})
|
|
list(POP_FRONT args)
|
|
endforeach()
|
|
endif()
|
|
|
|
# Write config.opt
|
|
set(content "")
|
|
foreach(arg IN LISTS args)
|
|
if(NOT arg IN_LIST IGNORE_ARGS)
|
|
string(APPEND content "${arg}\n")
|
|
endif()
|
|
endforeach()
|
|
|
|
file(WRITE "${OUT_FILE}" "${content}")
|