summaryrefslogtreecommitdiff
path: root/android/defs.go
diff options
context:
space:
mode:
author Cole Faust <colefaust@google.com> 2022-12-16 10:56:24 -0800
committer Cole Faust <colefaust@google.com> 2023-01-03 14:42:23 -0800
commita7347491489a8e6b039cf9d74efe407064c8db8f (patch)
treea2a557bfe86c5196ddbf45176691b2d8b46b0b5b /android/defs.go
parent2266e02a3a643b138feb6f1ff94d88ec46dfda6d (diff)
Use WriteFileRule instead of custom echo commands
These instances could use WriteFileRule instead of making their own shell code to write a file. Test: Presubmits Change-Id: I9c809b2164a68b4ce1c22fbbd0d7497240110b39
Diffstat (limited to 'android/defs.go')
-rw-r--r--android/defs.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/android/defs.go b/android/defs.go
index 9ae360e36..6e5bb053f 100644
--- a/android/defs.go
+++ b/android/defs.go
@@ -174,10 +174,15 @@ func buildWriteFileRule(ctx BuilderContext, outputFile WritablePath, content str
// WriteFileRule creates a ninja rule to write contents to a file. The contents will be escaped
// so that the file contains exactly the contents passed to the function, plus a trailing newline.
func WriteFileRule(ctx BuilderContext, outputFile WritablePath, content string) {
+ WriteFileRuleVerbatim(ctx, outputFile, content+"\n")
+}
+
+// WriteFileRuleVerbatim creates a ninja rule to write contents to a file. The contents will be
+// escaped so that the file contains exactly the contents passed to the function.
+func WriteFileRuleVerbatim(ctx BuilderContext, outputFile WritablePath, content string) {
// This is MAX_ARG_STRLEN subtracted with some safety to account for shell escapes
const SHARD_SIZE = 131072 - 10000
- content += "\n"
if len(content) > SHARD_SIZE {
var chunks WritablePaths
for i, c := range ShardString(content, SHARD_SIZE) {