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
This commit is contained in:
@@ -154,47 +154,49 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert!
|
// Convert!
|
||||||
ok := true
|
files := flag.Args()
|
||||||
if *launcher != "" {
|
productConfigMap := buildProductConfigMap()
|
||||||
if len(flag.Args()) != 1 {
|
if *allInSource {
|
||||||
quit(fmt.Errorf("a launcher can be generated only for a single product"))
|
for _, path := range productConfigMap {
|
||||||
|
files = append(files, path)
|
||||||
}
|
}
|
||||||
product := flag.Args()[0]
|
}
|
||||||
productConfigMap := buildProductConfigMap()
|
for i, file := range files {
|
||||||
path, found := productConfigMap[product]
|
if _, err := os.Stat(file); os.IsNotExist(err) {
|
||||||
if !found {
|
temp, ok := productConfigMap[file]
|
||||||
quit(fmt.Errorf("cannot generate configuration launcher for %s, it is not a known product",
|
if ok {
|
||||||
product))
|
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(files) != 1 {
|
||||||
|
quit(fmt.Errorf("a launcher can be generated only for a single product"))
|
||||||
}
|
}
|
||||||
versionDefaults, err := generateVersionDefaults()
|
versionDefaults, err := generateVersionDefaults()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
quit(err)
|
quit(err)
|
||||||
}
|
}
|
||||||
ok = convertOne(path) && ok
|
|
||||||
versionDefaultsPath := outputFilePath(versionDefaultsMk)
|
versionDefaultsPath := outputFilePath(versionDefaultsMk)
|
||||||
err = writeGenerated(versionDefaultsPath, versionDefaults)
|
err = writeGenerated(versionDefaultsPath, versionDefaults)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "%s:%s", path, err)
|
fmt.Fprintf(os.Stderr, "%s:%s", files[0], err)
|
||||||
ok = false
|
ok = false
|
||||||
}
|
}
|
||||||
|
|
||||||
err = writeGenerated(*launcher, mk2rbc.Launcher(outputFilePath(path), versionDefaultsPath,
|
err = writeGenerated(*launcher, mk2rbc.Launcher(outputFilePath(files[0]), versionDefaultsPath,
|
||||||
mk2rbc.MakePath2ModuleName(path)))
|
mk2rbc.MakePath2ModuleName(files[0])))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "%s:%s", path, err)
|
fmt.Fprintf(os.Stderr, "%s:%s", files[0], err)
|
||||||
ok = false
|
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()
|
printStats()
|
||||||
|
Reference in New Issue
Block a user