diff options
| author | 2021-09-30 16:11:16 -0700 | |
|---|---|---|
| committer | 2021-10-04 18:09:48 +0000 | |
| commit | 07ea503ab395d8f781c46d924e1e185d76e6abfd (patch) | |
| tree | 391958708700bbb69ca3907a31c78f63f4e0dc9a | |
| parent | 6a779a4b5026e4b693c0ca336eb09420c76262c8 (diff) | |
Make mk2rbc accept either a makefile or product
The current behavior of mk2rbc is that it can accept either
a makefile to convert, or if it's also generating a launcher,
it must accept a product name instead of a makefile.
For board configuration, we need to convert a specific makefile,
but we also want to generate a launcher. Change mk2rbc so that
its non-flag arguments can be either makefiles or product names.
Bug: 201700692
Test: ./build/bazel/ci/rbc_product_config.sh aosp_arm64-userdebug
with board config changes patched in
Change-Id: I521e31fe0bdc608b8f26c9aa803ca690dd1c538e
| -rw-r--r-- | mk2rbc/cmd/mk2rbc.go | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/mk2rbc/cmd/mk2rbc.go b/mk2rbc/cmd/mk2rbc.go index 7b5f298e2..9d0f0c1b0 100644 --- a/mk2rbc/cmd/mk2rbc.go +++ b/mk2rbc/cmd/mk2rbc.go @@ -154,47 +154,49 @@ func main() { } // Convert! + files := flag.Args() + productConfigMap := buildProductConfigMap() + if *allInSource { + for _, path := range productConfigMap { + files = append(files, path) + } + } + for i, file := range files { + if _, err := os.Stat(file); os.IsNotExist(err) { + temp, ok := productConfigMap[file] + if ok { + files[i] = temp + } else { + quit(fmt.Errorf("%s is neither a product makefile nor a product name", file)) + } + } + } ok := true + for _, mkFile := range files { + ok = convertOne(mkFile) && ok + } + if *launcher != "" { - if len(flag.Args()) != 1 { + if len(files) != 1 { quit(fmt.Errorf("a launcher can be generated only for a single product")) } - product := flag.Args()[0] - productConfigMap := buildProductConfigMap() - path, found := productConfigMap[product] - if !found { - quit(fmt.Errorf("cannot generate configuration launcher for %s, it is not a known product", - product)) - } versionDefaults, err := generateVersionDefaults() if err != nil { quit(err) } - ok = convertOne(path) && ok versionDefaultsPath := outputFilePath(versionDefaultsMk) err = writeGenerated(versionDefaultsPath, versionDefaults) if err != nil { - fmt.Fprintf(os.Stderr, "%s:%s", path, err) + fmt.Fprintf(os.Stderr, "%s:%s", files[0], err) ok = false } - err = writeGenerated(*launcher, mk2rbc.Launcher(outputFilePath(path), versionDefaultsPath, - mk2rbc.MakePath2ModuleName(path))) + err = writeGenerated(*launcher, mk2rbc.Launcher(outputFilePath(files[0]), versionDefaultsPath, + mk2rbc.MakePath2ModuleName(files[0]))) if err != nil { - fmt.Fprintf(os.Stderr, "%s:%s", path, err) + fmt.Fprintf(os.Stderr, "%s:%s", files[0], err) ok = false } - } else { - files := flag.Args() - if *allInSource { - productConfigMap := buildProductConfigMap() - for _, path := range productConfigMap { - files = append(files, path) - } - } - for _, mkFile := range files { - ok = convertOne(mkFile) && ok - } } printStats() |