diff options
author | Alan Viverette <alanv@google.com> | 2022-08-11 10:59:12 -0400 |
---|---|---|
committer | Alan Viverette <alanv@google.com> | 2022-12-16 20:29:27 +0000 |
commit | c8e4a79ecacd11384b1e65a58fa95f99e87f5c76 (patch) | |
tree | 7fba3dcf23757d46f7e7688c5ba578c94a1ee9e7 | |
parent | 962bc244de4fea186f052ee74effe1eeee9b9b7a (diff) | |
download | soong-c8e4a79ecacd11384b1e65a58fa95f99e87f5c76.tar.gz |
Add support for prepending text from a file
Bug: b/241826272
Bug: b/258279262
Test: ./update_prebuilts.py -x <bid>
Change-Id: I47146fc8a4f9120891ee28d15b006448d66aaff7
(cherry picked from commit a1fb0d98dad224e82ad2377ed8b9705259022e98)
-rw-r--r-- | cmd/pom2bp/pom2bp.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/cmd/pom2bp/pom2bp.go b/cmd/pom2bp/pom2bp.go index e0638b8ed..0e8ad05a9 100644 --- a/cmd/pom2bp/pom2bp.go +++ b/cmd/pom2bp/pom2bp.go @@ -828,6 +828,7 @@ Usage: %s [--rewrite <regex>=<replace>] [--exclude <module>] [--extra-static-lib var regen string var pom2build bool + var prepend string flag.Var(&excludes, "exclude", "Exclude module") flag.Var(&extraStaticLibs, "extra-static-libs", "Extra static dependencies needed when depending on a module") @@ -844,6 +845,7 @@ Usage: %s [--rewrite <regex>=<replace>] [--exclude <module>] [--extra-static-lib flag.BoolVar(&jetifier, "jetifier", false, "Sets jetifier: true on all modules") flag.StringVar(®en, "regen", "", "Rewrite specified file") flag.BoolVar(&pom2build, "pom2build", false, "If true, will generate a Bazel BUILD file *instead* of a .bp file") + flag.StringVar(&prepend, "prepend", "", "Path to a file containing text to insert at the beginning of the generated build file") flag.Parse() if regen != "" { @@ -975,6 +977,15 @@ Usage: %s [--rewrite <regex>=<replace>] [--exclude <module>] [--extra-static-lib fmt.Fprintln(buf, commentString, "pom2bp", strings.Join(proptools.ShellEscapeList(os.Args[1:]), " ")) } + if prepend != "" { + contents, err := ioutil.ReadFile(prepend) + if err != nil { + fmt.Fprintln(os.Stderr, "Error reading", prepend, err) + os.Exit(1) + } + fmt.Fprintln(buf, string(contents)) + } + depsTemplate := bpDepsTemplate template := bpTemplate if pom2build { |