build: Generate gn_logs.txt under build directory for Siso build support
This is necessary to propagate GN variables to Siso.
Bug: 393606976
Change-Id: Iea39d4ca4e55faa8bbaf6a9f4f4c13e57c6a1b4f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/224314
Auto-Submit: Junji Watanabe <jwata@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index 7d680b7..197d981 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -113,3 +113,17 @@
testonly = true
deps = [ ":all" ]
}
+
+# 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) {
+ import("//build/gn_logs.gni")
+
+ # Write debug logs to gn_logs.txt.
+ _lines = [
+ "Generated during 'gn gen' by //BUILD.gn.",
+ "",
+ ] + build_gn_logs
+
+ write_file("$root_build_dir/gn_logs.txt", _lines)
+}