Fix the issue "\n" didn't get interpreted properly.

Added params to WriteFile rule that allow users to turn on the
specific 'echo' options, such as "enable the interpretation of backslash
escapes".

Bug: b/38261000
Test: tested with real data files.
Change-Id: I5145056b5c2522a3a72b9436055ec95d2fbd94c0
This commit is contained in:
Nan Zhang 2017-05-12 14:02:13 -07:00
parent 6df46f5d93
commit 270051119a
2 changed files with 5 additions and 2 deletions

View File

@ -80,9 +80,12 @@ var (
Description: "concatenate licenses $out", Description: "concatenate licenses $out",
}) })
// ubuntu 14.04 offcially use dash for /bin/sh, and its builtin echo command
// doesn't support -e option. Therefore we force to use /bin/bash when writing out
// content to file.
WriteFile = pctx.AndroidStaticRule("WriteFile", WriteFile = pctx.AndroidStaticRule("WriteFile",
blueprint.RuleParams{ blueprint.RuleParams{
Command: "echo '$content' > $out", Command: "/bin/bash -c 'echo -e $$0 > $out' '$content'",
Description: "writing file $out", Description: "writing file $out",
}, },
"content") "content")

View File

@ -82,7 +82,7 @@ func registerBuildActionForModuleFileList(ctx android.ModuleContext,
Output: fileList, Output: fileList,
Implicits: files, Implicits: files,
Args: map[string]string{ Args: map[string]string{
"content": strings.Join(content, "\n"), "content": strings.Join(content, `\n`),
}, },
}) })