pro2cmake: Clean up debug messages

Don't needlessly show a bunch of special case debug messages
unless debugging is enabled.
There used to be a barrage of scary message when using
run_pro2cmake.

Change-Id: I49ab3522e11844a99653034b5f15a634a368d227
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexandru Croitor 2019-11-11 18:47:28 +01:00
parent 2199a50a2a
commit 37ab7eae9d
2 changed files with 25 additions and 18 deletions

View File

@ -3383,8 +3383,9 @@ def cmakeify_scope(
cm_fh.write(buffer_value)
def generate_new_cmakelists(scope: Scope, *, is_example: bool = False) -> None:
print("Generating CMakeLists.gen.txt")
def generate_new_cmakelists(scope: Scope, *, is_example: bool = False, debug: bool = False) -> None:
if debug:
print("Generating CMakeLists.gen.txt")
with open(scope.generated_cmake_lists_path, "w") as cm_fh:
assert scope.file
cm_fh.write(f"# Generated from {os.path.basename(scope.file)}.\n\n")
@ -3415,8 +3416,11 @@ def do_include(scope: Scope, *, debug: bool = False) -> None:
scope.merge(include_scope)
def copy_generated_file_to_final_location(scope: Scope, keep_temporary_files=False) -> None:
print(f"Copying {scope.generated_cmake_lists_path} to {scope.original_cmake_lists_path}")
def copy_generated_file_to_final_location(
scope: Scope, keep_temporary_files=False, debug: bool = False
) -> None:
if debug:
print(f"Copying {scope.generated_cmake_lists_path} to {scope.original_cmake_lists_path}")
copyfile(scope.generated_cmake_lists_path, scope.original_cmake_lists_path)
if not keep_temporary_files:
os.remove(scope.generated_cmake_lists_path)
@ -3526,7 +3530,7 @@ def main() -> None:
file_scope.dump()
print("\n#### End of full .pro/.pri file structure.\n")
generate_new_cmakelists(file_scope, is_example=args.is_example)
generate_new_cmakelists(file_scope, is_example=args.is_example, debug=args.debug)
copy_generated_file = True
if not args.skip_special_case_preservation:

View File

@ -161,13 +161,14 @@ def run_process_quiet(args_string: str, debug=False) -> bool:
# git merge with conflicts returns with exit code 1, but that's not
# an error for us.
if "git merge" not in args_string:
print(
dedent(
f"""\
Error while running: "{args_string}"
{e.stdout}"""
if debug:
print(
dedent(
f"""\
Error while running: "{args_string}"
{e.stdout}"""
)
)
)
return False
return True
@ -333,9 +334,11 @@ class SpecialCaseHandler(object):
time.sleep(0.1)
if failed_once and not success:
print("Retrying git add, the index.lock was probably acquired.")
if self.debug:
print("Retrying git add, the index.lock was probably acquired.")
if failed_once and success:
print("git add succeeded.")
if self.debug:
print("git add succeeded.")
elif failed_once and not success:
print(f"git add failed. Make sure to git add {self.prev_file_path} yourself.")
@ -375,11 +378,11 @@ class SpecialCaseHandler(object):
copyfile_log(self.post_merge_file_path, self.generated_file_path)
if not self.keep_temporary_files:
os.remove(self.post_merge_file_path)
print(
"Special case reapplication using git is complete. "
"Make sure to fix remaining conflict markers."
)
if self.debug:
print(
"Special case reapplication using git is complete. "
"Make sure to fix remaining conflict markers."
)
except Exception as e:
print(f"Error occurred while trying to reapply special case modifications: {e}")