summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2018-11-28 17:05:08 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2018-12-07 12:41:43 +0000
commit9fa13b2c5f43d6fbaeb4360ac54391a91b3e9e54 (patch)
tree61887ff3f838bf890bbd6d95302e862d829da9a0
parent4d82ee992992251bcadf0097a4df60fe7c3b7ef8 (diff)
Make quiet builds really quiet
The change does a couple of things: - Sets the distutils / setuptools --verbose option to 0 - Sets the distutils / setuptools --quiet option to 1 - The options above end up calling distutils.log.set_verbosity(0) - Passes the QUIET_BUILD cmake option from setup.py to every CMake invocation, when --quiet is passed to setup.py - Sets the CMAKE_INSTALL_MESSAGE variable to silence messages regarding installation of files - Sets the CMAKE_RULE_MESSAGES variable to disable progress report in makefiles when building each source file - Overrides the CMake message function, not to display STATUS / info / untyped messages (still displays warnings and errors) - Changes the build / install elapsed time messages to always be printed even in quiet mode - Reverts the previously introduced set_quiet function in utils, because log.set_verbosity() now takes care of silencing those messages As a result, there's a lot less clutter when doing a quiet build. Warnings, errors and shiboken output is still displayed. Change-Id: Ie05c593ce7dc0aa04554c2d2859ce655233ddb9f Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--build_scripts/config.py8
-rw-r--r--build_scripts/main.py23
-rw-r--r--build_scripts/options.py13
-rw-r--r--build_scripts/setup_runner.py4
-rw-r--r--build_scripts/utils.py33
-rw-r--r--sources/pyside2/CMakeLists.txt52
-rw-r--r--sources/shiboken2/CMakeLists.txt19
7 files changed, 101 insertions, 51 deletions
diff --git a/build_scripts/config.py b/build_scripts/config.py
index 78d7d404..f47230a6 100644
--- a/build_scripts/config.py
+++ b/build_scripts/config.py
@@ -99,7 +99,8 @@ class Config(object):
def init_config(self, build_type=None, internal_build_type=None,
cmd_class_dict=None, package_version=None,
- ext_modules=None, setup_script_dir=None):
+ ext_modules=None, setup_script_dir=None,
+ quiet=False):
"""
Sets up the global singleton config which is used in many parts
of the setup process.
@@ -135,6 +136,11 @@ class Config(object):
setup_kwargs['cmdclass'] = cmd_class_dict
setup_kwargs['version'] = package_version
+ if quiet:
+ # Tells distutils / setuptools to be quiet, and only print warnings or errors.
+ # Makes way less noise in the terminal when building.
+ setup_kwargs['verbose'] = 0
+
# Setting these two keys is still a bit of a discussion point.
# In general not setting them will allow using "build" and
# "bdist_wheel" just fine. What they do, is they specify to the
diff --git a/build_scripts/main.py b/build_scripts/main.py
index 0fec51a6..cdc6dce7 100644
--- a/build_scripts/main.py
+++ b/build_scripts/main.py
@@ -43,7 +43,7 @@ from distutils.version import LooseVersion
import os
import time
from .config import config
-from .utils import memoize, get_python_dict, set_quiet
+from .utils import memoize, get_python_dict
from .options import *
setup_script_dir = os.getcwd()
@@ -304,7 +304,7 @@ def prepare_build():
for n in ["build"]:
d = os.path.join(setup_script_dir, n)
if os.path.isdir(d):
- print("Removing {}".format(d))
+ log.info("Removing {}".format(d))
try:
rmtree(d)
except Exception as e:
@@ -346,7 +346,7 @@ class PysideInstall(_install):
def run(self):
_install.run(self)
- log.info('*** Install completed ({}s)'.format(elapsed()))
+ print('*** Install completed ({}s)'.format(elapsed()))
class PysideDevelop(_develop):
@@ -727,7 +727,7 @@ class PysideBuild(_build):
_build.run(self)
else:
log.info("Skipped preparing and building packages.")
- log.info('*** Build completed ({}s)'.format(elapsed()))
+ print('*** Build completed ({}s)'.format(elapsed()))
def log_pre_build_info(self):
if config.is_internal_shiboken_generator_build_and_part_of_top_level_all():
@@ -915,8 +915,14 @@ class PysideBuild(_build):
# Build module
cmake_cmd = [OPTION_CMAKE]
if OPTION_QUIET:
- set_quiet(True)
- cmake_cmd.append('--quiet')
+ # Pass a special custom option, to allow printing a lot less information when doing
+ # a quiet build.
+ cmake_cmd.append('-DQUIET_BUILD=1')
+ if self.make_generator == "Unix Makefiles":
+ # Hide progress messages for each built source file.
+ # Doesn't seem to work if set within the cmake files themselves.
+ cmake_cmd.append('-DCMAKE_RULE_MESSAGES=0')
+
cmake_cmd += [
"-G", self.make_generator,
"-DBUILD_TESTS={}".format(self.build_tests),
@@ -1315,9 +1321,8 @@ class PysideBuild(_build):
if not os.path.exists(srcpath):
continue
rpath_cmd(srcpath)
- if not OPTION_QUIET:
- print("Patched rpath to '$ORIGIN/' (Linux) or "
- "updated rpath (OS/X) in {}.".format(srcpath))
+ log.info("Patched rpath to '$ORIGIN/' (Linux) or "
+ "updated rpath (OS/X) in {}.".format(srcpath))
cmd_class_dict = {
diff --git a/build_scripts/options.py b/build_scripts/options.py
index 3a5caf39..64464993 100644
--- a/build_scripts/options.py
+++ b/build_scripts/options.py
@@ -59,12 +59,15 @@ class Options(object):
# Dictionary containing values of all the possible options.
self.dict = {}
- def has_option(self, name):
+ def has_option(self, name, remove=True):
""" Returns True if argument '--name' was passed on the command
line. """
option = '--' + name
count = sys.argv.count(option)
- for i in range(count):
+ remove_count = count
+ if not remove and count > 0:
+ remove_count -= 1
+ for i in range(remove_count):
sys.argv.remove(option)
if count > 1:
_warn_multiple_option(option)
@@ -120,8 +123,8 @@ class Options(object):
options = Options()
-def has_option(name):
- return options.has_option(name)
+def has_option(*args, **kwargs):
+ return options.has_option(*args, **kwargs)
def option_value(*args,**kwargs):
@@ -171,7 +174,7 @@ OPTION_MODULE_SUBSET = option_value("module-subset")
OPTION_RPATH_VALUES = option_value("rpath")
OPTION_QT_CONF_PREFIX = option_value("qt-conf-prefix")
OPTION_QT_SRC = option_value("qt-src-dir")
-OPTION_QUIET = has_option('quiet')
+OPTION_QUIET = has_option('quiet', remove=False)
OPTION_VERBOSE_BUILD = has_option("verbose-build")
OPTION_SANITIZE_ADDRESS = has_option("sanitize-address")
OPTION_SNAPSHOT_BUILD = has_option("snapshot-build")
diff --git a/build_scripts/setup_runner.py b/build_scripts/setup_runner.py
index 709b4b25..8efb2883 100644
--- a/build_scripts/setup_runner.py
+++ b/build_scripts/setup_runner.py
@@ -43,6 +43,7 @@ from build_scripts.config import config
from build_scripts.main import get_package_version, get_setuptools_extension_modules
from build_scripts.main import cmd_class_dict
from build_scripts.options import OPTION_BUILD_TYPE, OPTION_INTERNAL_BUILD_TYPE
+from build_scripts.options import OPTION_QUIET
from build_scripts.utils import run_process
from setuptools import setup
@@ -105,7 +106,8 @@ class SetupRunner(object):
cmd_class_dict=cmd_class_dict,
package_version=get_package_version(),
ext_modules=get_setuptools_extension_modules(),
- setup_script_dir=self.setup_script_dir)
+ setup_script_dir=self.setup_script_dir,
+ quiet=OPTION_QUIET)
# This is an internal invocation of setup.py, so start actual
# build.
diff --git a/build_scripts/utils.py b/build_scripts/utils.py
index 66c844d1..924b698d 100644
--- a/build_scripts/utils.py
+++ b/build_scripts/utils.py
@@ -58,16 +58,11 @@ import distutils.log as log
from distutils.errors import DistutilsOptionError
from distutils.errors import DistutilsSetupError
-_verbose = True
-
try:
WindowsError
except NameError:
WindowsError = None
-def set_quiet(quiet):
- global _verbose
- _verbose = not quiet
def filter_match(name, patterns):
for pattern in patterns:
@@ -259,8 +254,7 @@ def copyfile(src, dst, force=True, vars=None, force_copy_symlink=False,
return
if not os.path.islink(src) or force_copy_symlink:
- if _verbose:
- log.info("Copying file {} to {}.".format(src, dst))
+ log.info("Copying file {} to {}.".format(src, dst))
shutil.copy2(src, dst)
if make_writable_by_owner:
make_file_writable_by_owner(dst)
@@ -276,9 +270,8 @@ def copyfile(src, dst, force=True, vars=None, force_copy_symlink=False,
os.chdir(target_dir)
if os.path.exists(link_name):
os.remove(link_name)
- if _verbose:
- log.info("Symlinking {} -> {} in {}.".format(link_name,
- link_target, target_dir))
+ log.info("Symlinking {} -> {} in {}.".format(link_name,
+ link_target, target_dir))
os.symlink(link_target, link_name)
except OSError:
log.error("{} -> {}: Error creating symlink".format(link_name,
@@ -298,8 +291,7 @@ def makefile(dst, content=None, vars=None):
content = content.format(**vars)
dst = dst.format(**vars)
- if _verbose:
- log.info("Making file {}.".format(dst))
+ log.info("Making file {}.".format(dst))
dstdir = os.path.dirname(dst)
if not os.path.exists(dstdir):
@@ -330,9 +322,8 @@ def copydir(src, dst, filter=None, ignore=None, force=True, recursive=True,
"filter={}. ignore={}.".format(src, dst, filter, ignore))
return []
- if _verbose:
- log.info("Copying tree {} to {}. filter={}. ignore={}.".format(src,
- dst, filter, ignore))
+ log.info("Copying tree {} to {}. filter={}. ignore={}.".format(src,
+ dst, filter, ignore))
names = os.listdir(src)
@@ -414,10 +405,9 @@ def run_process(args, initial_env=None, redirect_stderr_to_stdout=True):
Prints both stdout and stderr to the console.
No output is captured.
"""
- if _verbose:
- log.info("Running process in directory {0}: command {1}".format(
- os.getcwd(),
- " ".join([(" " in x and '"{0}"'.format(x) or x) for x in args]))
+ log.info("Running process in directory {0}: command {1}".format(
+ os.getcwd(),
+ " ".join([(" " in x and '"{0}"'.format(x) or x) for x in args]))
)
if initial_env is None:
@@ -503,9 +493,8 @@ def regenerate_qt_resources(src, pyside_rcc_path, pyside_rcc_options):
srcname_split = srcname.rsplit('.qrc', 1)
dstname = '_rc.py'.join(srcname_split)
if os.path.exists(dstname):
- if _verbose:
- log.info('Regenerating {} from {}'.format(dstname,
- os.path.basename(srcname)))
+ log.info('Regenerating {} from {}'.format(dstname,
+ os.path.basename(srcname)))
run_process([pyside_rcc_path,
pyside_rcc_options,
srcname, '-o', dstname])
diff --git a/sources/pyside2/CMakeLists.txt b/sources/pyside2/CMakeLists.txt
index 25598bb5..1d563fb4 100644
--- a/sources/pyside2/CMakeLists.txt
+++ b/sources/pyside2/CMakeLists.txt
@@ -15,6 +15,25 @@ include(helpers)
option(USE_PYTHON_VERSION "Use specific python version to build pyside2." "")
+# Don't display "up-to-date / install" messages when installing, to reduce visual clutter.
+if (QUIET_BUILD)
+ set(CMAKE_INSTALL_MESSAGE NEVER)
+endif()
+
+# Override message not to display info messages when doing a quiet build.
+if (QUIET_BUILD)
+ function(message)
+ list(GET ARGV 0 MessageType)
+ if (MessageType STREQUAL FATAL_ERROR OR
+ MessageType STREQUAL SEND_ERROR OR
+ MessageType STREQUAL WARNING OR
+ MessageType STREQUAL AUTHOR_WARNING)
+ list(REMOVE_AT ARGV 0)
+ _message(${MessageType} "${ARGV}")
+ endif()
+ endfunction()
+endif()
+
if (USE_PYTHON_VERSION)
find_package(PythonInterp ${USE_PYTHON_VERSION} REQUIRED)
find_package(PythonLibs ${USE_PYTHON_VERSION} REQUIRED)
@@ -252,7 +271,26 @@ include(PySideModules)
macro(COLLECT_MODULE_IF_FOUND shortname)
set(name "Qt5${shortname}")
- find_package(${name})
+
+ # Determine essential/optional/missing
+ set(module_state "missing")
+ list(FIND ALL_ESSENTIAL_MODULES "${shortname}" essentialIndex)
+ if(${essentialIndex} EQUAL -1)
+ list(FIND ALL_OPTIONAL_MODULES "${shortname}" optionalIndex)
+ if(NOT ${optionalIndex} EQUAL -1)
+ set(module_state "optional")
+ endif()
+ else()
+ set(module_state "essential")
+ endif()
+
+ # Silence warnings when optional packages are not found when doing a quiet build.
+ set(quiet_argument "")
+ if (QUIET_BUILD AND "${module_state}" STREQUAL "optional")
+ set(quiet_argument "QUIET")
+ endif()
+
+ find_package(${name} ${quiet_argument})
# If package is found, _name_found will be equal to 1
set(_name_found "${name}_FOUND")
# _name_dir will keep the path to the directory where the CMake rules were found
@@ -276,18 +314,6 @@ macro(COLLECT_MODULE_IF_FOUND shortname)
get_filename_component(_module_dir "${${_name_dir}}" ABSOLUTE)
string(FIND "${_module_dir}" "${_core_abs_dir}" found_basepath)
- # Determine essential/optional/missing
- set(module_state "missing")
- list(FIND ALL_ESSENTIAL_MODULES "${shortname}" essentialIndex)
- if(${essentialIndex} EQUAL -1)
- list(FIND ALL_OPTIONAL_MODULES "${shortname}" optionalIndex)
- if(NOT ${optionalIndex} EQUAL -1)
- set(module_state "optional")
- endif()
- else()
- set(module_state "essential")
- endif()
-
# If the module was found, and also the module path is the same as the
# Qt5Core base path, we will generate the list with the modules to be installed
set(looked_in_message ". Looked in: ${${_name_dir}}")
diff --git a/sources/shiboken2/CMakeLists.txt b/sources/shiboken2/CMakeLists.txt
index 12a9b877..619c0f08 100644
--- a/sources/shiboken2/CMakeLists.txt
+++ b/sources/shiboken2/CMakeLists.txt
@@ -16,6 +16,25 @@ add_definitions(${Qt5Core_DEFINITIONS})
option(BUILD_TESTS "Build tests." TRUE)
option(USE_PYTHON_VERSION "Use specific python version to build shiboken2." "")
+# Don't display "up-to-date / install" messages when installing, to reduce visual clutter.
+if (QUIET_BUILD)
+ set(CMAKE_INSTALL_MESSAGE NEVER)
+endif()
+
+# Override message not to display info messages when doing a quiet build.
+if (QUIET_BUILD)
+ function(message)
+ list(GET ARGV 0 MessageType)
+ if (MessageType STREQUAL FATAL_ERROR OR
+ MessageType STREQUAL SEND_ERROR OR
+ MessageType STREQUAL WARNING OR
+ MessageType STREQUAL AUTHOR_WARNING)
+ list(REMOVE_AT ARGV 0)
+ _message(${MessageType} "${ARGV}")
+ endif()
+ endfunction()
+endif()
+
if (USE_PYTHON_VERSION)
find_package(PythonInterp ${USE_PYTHON_VERSION} REQUIRED)
find_package(PythonLibs ${USE_PYTHON_VERSION} REQUIRED)