From f30dfc1e68ca48c332ca11e6c6c2d4d167fb978e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 21 Nov 2018 14:47:38 +0100 Subject: Build scripts: Implement --quiet Add a _verbose setting to the utils module and set it depending on option --quiet. Depending on this, suppress the messages about copying files, shortening the build log by over 1000 lines. Change-Id: I3f9abce3b145d43c4fe615f624ca4e2769a269f8 Reviewed-by: Alexandru Croitor --- build_scripts/main.py | 14 +++++++++----- build_scripts/options.py | 1 + build_scripts/utils.py | 33 ++++++++++++++++++++++----------- 3 files changed, 32 insertions(+), 16 deletions(-) (limited to 'build_scripts') diff --git a/build_scripts/main.py b/build_scripts/main.py index fdc5f4a08..b57e4978b 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 +from .utils import memoize, get_python_dict, set_quiet from .options import * setup_script_dir = os.getcwd() @@ -911,8 +911,11 @@ class PysideBuild(_build): module_src_dir = os.path.join(self.sources_dir, extension) # Build module - cmake_cmd = [ - OPTION_CMAKE, + cmake_cmd = [OPTION_CMAKE] + if OPTION_QUIET: + set_quiet(True) + cmake_cmd.append('--quiet') + cmake_cmd += [ "-G", self.make_generator, "-DBUILD_TESTS={}".format(self.build_tests), "-DQt5Help_DIR={}".format(self.qtinfo.docs_dir), @@ -1308,8 +1311,9 @@ class PysideBuild(_build): if not os.path.exists(srcpath): continue rpath_cmd(srcpath) - print("Patched rpath to '$ORIGIN/' (Linux) or " - "updated rpath (OS/X) in {}.".format(srcpath)) + if not OPTION_QUIET: + print("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 2d47bcca5..3a5caf392 100644 --- a/build_scripts/options.py +++ b/build_scripts/options.py @@ -171,6 +171,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_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/utils.py b/build_scripts/utils.py index 5c5f4927d..66c844d10 100644 --- a/build_scripts/utils.py +++ b/build_scripts/utils.py @@ -58,11 +58,16 @@ 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: @@ -254,7 +259,8 @@ def copyfile(src, dst, force=True, vars=None, force_copy_symlink=False, return if not os.path.islink(src) or force_copy_symlink: - log.info("Copying file {} to {}.".format(src, dst)) + if _verbose: + log.info("Copying file {} to {}.".format(src, dst)) shutil.copy2(src, dst) if make_writable_by_owner: make_file_writable_by_owner(dst) @@ -270,8 +276,9 @@ 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) - log.info("Symlinking {} -> {} in {}.".format(link_name, - link_target, target_dir)) + if _verbose: + 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, @@ -291,7 +298,8 @@ def makefile(dst, content=None, vars=None): content = content.format(**vars) dst = dst.format(**vars) - log.info("Making file {}.".format(dst)) + if _verbose: + log.info("Making file {}.".format(dst)) dstdir = os.path.dirname(dst) if not os.path.exists(dstdir): @@ -322,8 +330,9 @@ def copydir(src, dst, filter=None, ignore=None, force=True, recursive=True, "filter={}. ignore={}.".format(src, dst, filter, ignore)) return [] - log.info("Copying tree {} to {}. filter={}. ignore={}.".format(src, dst, - filter, ignore)) + if _verbose: + log.info("Copying tree {} to {}. filter={}. ignore={}.".format(src, + dst, filter, ignore)) names = os.listdir(src) @@ -405,9 +414,10 @@ def run_process(args, initial_env=None, redirect_stderr_to_stdout=True): Prints both stdout and stderr to the console. No output is captured. """ - 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 _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])) ) if initial_env is None: @@ -493,8 +503,9 @@ 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): - log.info('Regenerating {} from {}'.format(dstname, - os.path.basename(srcname))) + if _verbose: + log.info('Regenerating {} from {}'.format(dstname, + os.path.basename(srcname))) run_process([pyside_rcc_path, pyside_rcc_options, srcname, '-o', dstname]) -- cgit v1.2.3