diff --git a/BUILD.gn b/BUILD.gn index 4a2dbf182..954ac3a66 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -494,12 +494,16 @@ if (libyuv_include_tests) { } if (!build_with_chromium) { - # Write debug logs to gn_logs.txt. - # This is also required for Siso builds. - import("//build/gn_logs.gni") - lines = [ - "Generated during 'gn gen' by //BUILD.gn.", - "", - ] + build_gn_logs - write_file("$root_build_dir/gn_logs.txt", lines) + # GN evaluates each .gn file once per toolchain, so restricting to default + # toolchain will ensure write_file() is called only once. + if (current_toolchain == default_toolchain) { + # Write debug logs to gn_logs.txt. + # This is also required for Siso builds. + import("//build/gn_logs.gni") + lines = [ + "Generated during 'gn gen' by //BUILD.gn.", + "", + ] + build_gn_logs + write_file("$root_build_dir/gn_logs.txt", lines) + } }