diff options
-rwxr-xr-x | scripts/incremental_build/incremental_build.py | 8 | ||||
-rwxr-xr-x | scripts/incremental_build/perf_metrics.py | 5 |
2 files changed, 8 insertions, 5 deletions
diff --git a/scripts/incremental_build/incremental_build.py b/scripts/incremental_build/incremental_build.py index 7a83318b..ba5f978d 100755 --- a/scripts/incremental_build/incremental_build.py +++ b/scripts/incremental_build/incremental_build.py @@ -93,6 +93,8 @@ def _build(user_input: ui.UserInput, logfile: Path) -> (int, dict[str, any]): ninja_log_file = util.get_out_dir().joinpath('.ninja_log') def get_action_count() -> int: + if not ninja_log_file.exists(): + return 0 with open(ninja_log_file, 'r') as ninja_log: # subtracting 1 to account for "# ninja log v5" in the first line return sum(1 for _ in ninja_log) - 1 @@ -109,11 +111,9 @@ def _build(user_input: ui.UserInput, logfile: Path) -> (int, dict[str, any]): stdout=f, stderr=f) with open(logfile, mode='w') as f: - if ninja_log_file.exists(): + action_count_before = get_action_count() + if action_count_before > 0: recompact_ninja_log() - action_count_before = get_action_count() - else: - action_count_before = 0 f.write(f'Command: {cmd}\n') f.write(f'Environment Variables:\n{textwrap.indent(env_str, " ")}\n\n\n') f.flush() diff --git a/scripts/incremental_build/perf_metrics.py b/scripts/incremental_build/perf_metrics.py index 90000259..0ee4b253 100755 --- a/scripts/incremental_build/perf_metrics.py +++ b/scripts/incremental_build/perf_metrics.py @@ -206,7 +206,10 @@ def _get_column_headers(rows: list[Row], allow_cycles: bool) -> list[str]: def get_build_info_and_perf(d: Path) -> dict[str, any]: perf = read_pbs(d) - with open(d.joinpath(util.BUILD_INFO_JSON), 'r') as f: + build_info_json = d.joinpath(util.BUILD_INFO_JSON) + if not build_info_json.exists(): + return perf + with open(build_info_json, 'r') as f: build_info = json.load(f) return build_info | perf |