diff --git a/BUILD.gn b/BUILD.gn index f7ca30dd95c7057c9617115d11bdf43442660e61..b12fd17005b6399eb1cad8a1362bf555fad74e1a 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -201,6 +201,7 @@ declare_args() { # 5. Build again with v8_builtins_profiling_log_file set to the file created # in step 3 or 4. v8_builtins_profiling_log_file = "default" + pgo_exists_flag = false # Enables various testing features. v8_enable_test_features = "" @@ -402,6 +403,13 @@ declare_args() { } # Derived defaults. +pgo_exists_flag = exec_script("tools/builtins-pgo/check_pgo.py", ["--pgo_path", "profiles/ohos.profile"], "value") +if (pgo_exists_flag) { + v8_builtins_profiling_log_file = "tools/builtins-pgo/profiles/ohos.profile" +} else { + v8_builtins_profiling_log_file = "default" +} +print(v8_builtins_profiling_log_file) if (cppgc_enable_verify_heap == "") { cppgc_enable_verify_heap = v8_enable_debugging_features || dcheck_always_on } diff --git a/tools/builtins-pgo/check_pgo.py b/tools/builtins-pgo/check_pgo.py new file mode 100644 index 0000000000000000000000000000000000000000..d8757d954e1ba59dcdd127f5c806cb6c8611df4c --- /dev/null +++ b/tools/builtins-pgo/check_pgo.py @@ -0,0 +1,20 @@ +import argparse +import os + +def check_pgo_exists(path): + return os.path.exists(path) + +def main(): + parser = argparse.ArgumentParser(description="Check if pgo profile exists") + parser.add_argument('--pgo_path', type=str, required=True, help='pgo path') + args = parser.parse_args() + path = args.pgo_path + abs_path = os.path.join(os.path.dirname(__file__), path) + return check_pgo_exists(abs_path) + +if __name__ == '__main__': + value = main() + if value: + print("true") + else: + print("false") \ No newline at end of file