From b86630b4b0c2fc76c49baed205b3bbfc0fa612cb Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 7 Oct 2019 15:28:05 +0200 Subject: [PATCH] pro2cmake: Allow disabling condition cache New option --skip-condition-cache allows forcing recomputation of condition simplification. Useful when debugging certain condition mappings. Change-Id: I68a85c2e4085ad7a3043d7334db71a334a6469e9 Reviewed-by: Simon Hausmann --- util/cmake/condition_simplifier_cache.py | 9 ++++++++- util/cmake/pro2cmake.py | 12 +++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/util/cmake/condition_simplifier_cache.py b/util/cmake/condition_simplifier_cache.py index b405ef23f84..d1efff1d87c 100644 --- a/util/cmake/condition_simplifier_cache.py +++ b/util/cmake/condition_simplifier_cache.py @@ -37,6 +37,13 @@ import time from typing import Callable +condition_simplifier_cache_enabled = True + + +def set_condition_simplified_cache_enabled(value: bool): + global condition_simplifier_cache_enabled + condition_simplifier_cache_enabled = value + def get_current_file_path() -> str: try: @@ -106,7 +113,7 @@ def simplify_condition_memoize(f: Callable[[str], str]): atexit.register(update_cache_file) def helper(condition: str) -> str: - if condition not in cache_file_content["cache"]["conditions"]: + if condition not in cache_file_content["cache"]["conditions"] or not condition_simplifier_cache_enabled: cache_file_content["cache"]["conditions"][condition] = f(condition) return cache_file_content["cache"]["conditions"][condition] diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index 7698876553e..042d8022f19 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -40,6 +40,7 @@ import glob import collections from condition_simplifier import simplify_condition +from condition_simplifier_cache import set_condition_simplified_cache_enabled try: collectionsAbc = collections.abc @@ -155,6 +156,14 @@ def _parse_commandline(): help="Don't automatically remove CMakeLists.gen.txt and other " "intermediate files.", ) + parser.add_argument( + "-e", + "--skip-condition-cache", + dest="skip_condition_cache", + action="store_true", + help="Don't use condition simplifier cache (conversion speed may decrease).", + ) + parser.add_argument( "files", metavar="<.pro/.pri file>", @@ -162,7 +171,6 @@ def _parse_commandline(): nargs="+", help="The .pro/.pri file to process", ) - return parser.parse_args() @@ -3460,6 +3468,8 @@ def main() -> None: args = _parse_commandline() debug_parsing = args.debug_parser or args.debug + if args.skip_condition_cache: + set_condition_simplified_cache_enabled(False) backup_current_dir = os.getcwd()