[llvm] [gn] make write_file.py replace literal \n with newlines (PR #231034)
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 11 14:14:51 PDT 2026
https://github.com/nico created https://github.com/llvm/llvm-project/pull/231034
Like write_cmake_config.py. This makes it possible to write multi-line
generated headers from an action(), which is needed for the next commit.
As demo, update the only current existing caller to write a
trailing newline. This matches the CMake build.
>From f091cd95f6fecaa79895b49a923828b7793d46a9 Mon Sep 17 00:00:00 2001
From: Nico Weber <thakis at chromium.org>
Date: Sun, 11 Oct 2026 17:07:53 -0400
Subject: [PATCH] [gn] make write_file.py replace literal \n with newlines
Like write_cmake_config.py. This makes it possible to write multi-line
generated headers from an action(), which is needed for the next commit.
As demo, update the only current existing caller to write a
trailing newline. This matches the CMake build.
---
llvm/utils/gn/build/write_file.py | 4 ++--
llvm/utils/gn/secondary/lldb/test/BUILD.gn | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/utils/gn/build/write_file.py b/llvm/utils/gn/build/write_file.py
index 112164f208e54..ba938187bd669 100755
--- a/llvm/utils/gn/build/write_file.py
+++ b/llvm/utils/gn/build/write_file.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
-"""Write content into file."""
+"""Write content into file. Literal '\\n' in content is replaced with a newline."""
import argparse
import sys
@@ -14,7 +14,7 @@ def main():
args = parser.parse_args()
with open(args.filepath, "w") as f:
- f.write(args.content)
+ f.write(args.content.replace("\\n", "\n"))
if __name__ == "__main__":
diff --git a/llvm/utils/gn/secondary/lldb/test/BUILD.gn b/llvm/utils/gn/secondary/lldb/test/BUILD.gn
index 4afbb577bac6e..a7e63ef1a17bc 100644
--- a/llvm/utils/gn/secondary/lldb/test/BUILD.gn
+++ b/llvm/utils/gn/secondary/lldb/test/BUILD.gn
@@ -204,7 +204,7 @@ action("lit-lldb-init-quiet") {
outputs = [ "$root_out_dir/obj/lldb/test/Shell/lit-lldb-init-quiet" ]
args = [
rebase_path(outputs[0], root_build_dir),
- "command source -C --silent-run true lit-lldb-init",
+ "command source -C --silent-run true lit-lldb-init\n",
]
}
More information about the llvm-commits
mailing list