aboutsummaryrefslogtreecommitdiffstats
path: root/build_scripts/options.py
diff options
context:
space:
mode:
Diffstat (limited to 'build_scripts/options.py')
-rw-r--r--build_scripts/options.py119
1 files changed, 74 insertions, 45 deletions
diff --git a/build_scripts/options.py b/build_scripts/options.py
index fdca440a5..806d4a8a3 100644
--- a/build_scripts/options.py
+++ b/build_scripts/options.py
@@ -1,13 +1,7 @@
# Copyright (C) 2018 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-try:
- from setuptools import Command
-except ModuleNotFoundError:
- # This is motivated by our CI using an old version of setuptools
- # so then the coin_build_instructions.py script is executed, and
- # import from this file, it was failing.
- from distutils.cmd import Command # TODO: remove
+from setuptools import Command
import sys
import logging
@@ -24,12 +18,13 @@ _AVAILABLE_MKSPECS = ["ninja", "msvc", "mingw"] if sys.platform == "win32" else
ADDITIONAL_OPTIONS = """
Additional options:
--limited-api Use Limited API [yes/no]
- ---macos-use-libc++ Use libc++ on macOS
+ --macos-use-libc++ Use libc++ on macOS
--snapshot-build Snapshot build
--package-timestamp Package Timestamp
--cmake-toolchain-file Path to CMake toolchain to enable cross-compiling
--shiboken-host-path Path to host shiboken package when cross-compiling
--qt-host-path Path to host Qt installation when cross-compiling
+ --disable-pyi Disable .pyi file generation
"""
@@ -76,6 +71,7 @@ class Options(object):
:return: Either the option value or None.
"""
+
option = f"--{name}"
short_option = f"-{short_option_name}" if short_option_name else None
single_option_prefix = f"{option}="
@@ -125,6 +121,30 @@ def _jobs_option_value():
return ''
+def find_qtpaths():
+ # for these command --qtpaths should not be required
+ no_qtpaths_commands = ["--help", "--help-commands", "--qt-target-path", "build_base_docs"]
+
+ for no_qtpaths_command in no_qtpaths_commands:
+ if any(no_qtpaths_command in argument for argument in sys.argv):
+ return None
+
+ qtpaths = option_value("qtpaths")
+ if qtpaths:
+ return qtpaths
+
+ # if qtpaths is not given as cli option, try to find it in PATH
+ qtpaths = which("qtpaths6")
+ if qtpaths:
+ return str(qtpaths.resolve())
+
+ qtpaths = which("qtpaths")
+ if qtpaths:
+ return str(qtpaths.resolve())
+
+ return qtpaths
+
+
# Declare options which need to be known when instantiating the setuptools
# commands or even earlier during SetupRunner.run().
OPTION = {
@@ -140,16 +160,21 @@ OPTION = {
"VERBOSE_BUILD": has_option('verbose-build'),
"SNAPSHOT_BUILD": has_option("snapshot-build"),
"LIMITED_API": option_value("limited-api"),
+ "DISABLE_PYI": has_option("disable-pyi"),
"PACKAGE_TIMESTAMP": option_value("package-timestamp"),
- # This is used automatically by distutils.command.install object, to
+ # This is used automatically by setuptools.command.install object, to
# specify the final installation location.
"FINAL_INSTALL_PREFIX": option_value("prefix", remove=False),
"CMAKE_TOOLCHAIN_FILE": option_value("cmake-toolchain-file"),
"SHIBOKEN_HOST_PATH": option_value("shiboken-host-path"),
"SHIBOKEN_HOST_PATH_QUERY_FILE": option_value("internal-shiboken-host-path-query-file"),
- "QT_HOST_PATH": option_value("qt-host-path")
+ "QT_HOST_PATH": option_value("qt-host-path"),
# This is used to identify the template for doc builds
+ "QTPATHS": find_qtpaths()
+ # This is an optional command line option. If --qtpaths is not provided via command-line,
+ # then qtpaths is checked inside PATH variable
}
+
_deprecated_option_jobs = option_value('jobs')
if _deprecated_option_jobs:
_warn_deprecated_option('jobs', 'parallel')
@@ -171,7 +196,6 @@ class CommandMixin(object):
('ignore-git', None, 'Do update subrepositories'),
('skip-docs', None, 'Skip documentation build (deprecated)'),
('build-docs', None, 'Build the API documentation'),
- ('no-examples', None, 'Do not build examples'),
('no-jom', None, 'Do not use jom (MSVC)'),
('build-tests', None, 'Build tests'),
('use-xvfb', None, 'Use Xvfb for testing'),
@@ -220,7 +244,8 @@ class CommandMixin(object):
# We redeclare plat-name as an option so it's recognized by the
# install command and doesn't throw an error.
('plat-name=', None, 'The platform name for which we are cross-compiling'),
- ('unity', None, 'Use CMake UNITY_BUILD_MODE'),
+ ('unity', None, 'Use CMake UNITY_BUILD_MODE (obsolete)'),
+ ('no-unity', None, 'Disable CMake UNITY_BUILD_MODE'),
('unity-build-batch-size=', None, 'Value of CMAKE_UNITY_BUILD_BATCH_SIZE')
]
@@ -234,7 +259,6 @@ class CommandMixin(object):
self.ignore_git = False
self.skip_docs = False
self.build_docs = False
- self.no_examples = False
self.no_jom = False
self.build_tests = False
self.use_xvfb = False
@@ -282,6 +306,7 @@ class CommandMixin(object):
self.internal_cmake_install_dir_query_file_path = None
self._per_command_mixin_options_finalized = False
self.unity = False
+ self.no_unity = False
self.unity_build_batch_size = "16"
# When initializing a command other than the main one (so the
@@ -303,6 +328,9 @@ class CommandMixin(object):
if key not in current_command_opts and key in mixin_options_set:
current_command_opts[key] = value
+ # qtpaths is already known before running SetupRunner
+ self.qtpaths = OPTION["QTPATHS"]
+
@staticmethod
@memoize
def get_mixin_options_set():
@@ -343,11 +371,12 @@ class CommandMixin(object):
OPTION['NO_STRIP'] = self.no_strip
OPTION['ONLYPACKAGE'] = self.only_package
OPTION['STANDALONE'] = self.standalone
- OPTION['IGNOREGIT'] = self.ignore_git
+ if self.ignore_git:
+ _warn_deprecated_option('ignore_git')
OPTION['SKIP_DOCS'] = self.skip_docs
OPTION['BUILD_DOCS'] = self.build_docs
- OPTION['NOEXAMPLES'] = self.no_examples
OPTION['BUILDTESTS'] = self.build_tests
+
OPTION['NO_JOM'] = self.no_jom
OPTION['XVFB'] = self.use_xvfb
OPTION['REUSE_BUILD'] = self.reuse_build
@@ -366,8 +395,8 @@ class CommandMixin(object):
# By default they are False, so we check if they changed with xor
if bool(OPTION["QUIET"]) != bool(OPTION["VERBOSE_BUILD"]):
- log.warn("Using --quiet and --verbose-build is deprecated. "
- "Please use --log-level=quiet or --log-level=verbose instead.")
+ log.warning("Using --quiet and --verbose-build is deprecated. "
+ "Please use --log-level=quiet or --log-level=verbose instead.")
# We assign a string value instead of the enum
# because is what we get from the command line.
# Later we assign the enum
@@ -394,13 +423,16 @@ class CommandMixin(object):
OPTION['SANITIZE_ADDRESS'] = self.sanitize_address
OPTION['SHORTER_PATHS'] = self.shorter_paths
OPTION['DOC_BUILD_ONLINE'] = self.doc_build_online
- OPTION['UNITY'] = self.unity
+ if self.unity:
+ log.warning("Using --unity no longer has any effect, "
+ "Unity build mode is now the default.")
+ OPTION['UNITY'] = not self.no_unity
OPTION['UNITY_BUILD_BATCH_SIZE'] = self.unity_build_batch_size
qtpaths_abs_path = None
- if self.qtpaths:
- qtpaths_abs_path = self.qtpaths.resolve()
- OPTION['QTPATHS'] = qtpaths_abs_path
+ if self.qtpaths and Path(self.qtpaths).exists():
+ qtpaths_abs_path = Path(self.qtpaths).resolve()
+
# FIXME PYSIDE7: Remove qmake handling
# make qtinfo.py independent of relative paths.
qmake_abs_path = None
@@ -418,8 +450,8 @@ class CommandMixin(object):
# qtpaths is available. This happens when building the host
# tools in the overall cross-building process.
use_cmake = False
- if (using_cmake_toolchain_file or
- (not self.qmake and not self.qtpaths and self.qt_target_path)):
+ if (using_cmake_toolchain_file or (not self.qmake
+ and not self.qtpaths and self.qt_target_path)):
use_cmake = True
QtInfo().setup(qtpaths_abs_path, self.cmake, qmake_abs_path,
@@ -428,18 +460,19 @@ class CommandMixin(object):
qt_target_path=qt_target_path,
cmake_toolchain_file=cmake_toolchain_file)
- try:
- QtInfo().prefix_dir
- except Exception as e:
- if not self.qt_target_path:
- log.error(
- "\nCould not find Qt. You can pass the --qt-target-path=<qt-dir> option as a "
- "hint where to find Qt. Error was:\n\n\n")
- else:
- log.error(
- f"\nCould not find Qt via provided option --qt-target-path={qt_target_path} "
- "Error was:\n\n\n")
- raise e
+ if 'build_base_docs' not in sys.argv:
+ try:
+ QtInfo().prefix_dir
+ except Exception as e:
+ if not self.qt_target_path:
+ log.error(
+ "\nCould not find Qt. You can pass the --qt-target-path=<qt-dir> option "
+ "as a hint where to find Qt. Error was:\n\n\n")
+ else:
+ log.error(
+ f"\nCould not find Qt via provided option --qt-target-path={qt_target_path}"
+ "Error was:\n\n\n")
+ raise e
OPTION['CMAKE'] = self.cmake.resolve()
OPTION['OPENSSL'] = self.openssl
@@ -481,16 +514,14 @@ class CommandMixin(object):
if not self._extra_checks():
sys.exit(-1)
+ OPTION['PLAT_NAME'] = self.plat_name
+
def _extra_checks(self):
if self.is_cross_compile and not self.plat_name:
log.error("No value provided to --plat-name while cross-compiling.")
return False
return True
- def _find_qtpaths_in_path(self):
- if not self.qtpaths:
- self.qtpaths = Path(which("qtpaths6"))
-
def _determine_defaults_and_check(self):
if not self.cmake:
self.cmake = Path(which("cmake"))
@@ -517,17 +548,15 @@ class CommandMixin(object):
# We also don't do auto-searching if qt-target-path is passed
# explicitly. This is to help with the building of host tools
# while cross-compiling.
- if not self.is_cross_compile and not self.qt_target_path:
+ # Skip this process for the 'build_base_docs' command
+ if (not self.is_cross_compile
+ and not self.qt_target_path
+ and 'build_base_docs' not in sys.argv):
# Enforce usage of qmake in QtInfo if it was given explicitly.
if self.qmake:
self.has_qmake_option = True
_warn_deprecated_option('qmake', 'qtpaths')
- # If no option was given explicitly, prefer to find qtpaths
- # in PATH.
- if not self.qmake and not self.qtpaths:
- self._find_qtpaths_in_path()
-
# If no tool was specified and qtpaths was not found in PATH,
# ask to provide a path to qtpaths.
if not self.qtpaths and not self.qmake and not self.qt_target_path: