Load a list of plugins from vendor/google_clockwork

Some wear partners have vendor/google_clockwork but not vendor/google.

Bug: 290816499
Test: Presubmits
Change-Id: Id45f68bf6f734acc1ee6abbfd2314d9ff6be75fb
This commit is contained in:
Cole Faust 2023-10-20 11:51:33 -07:00
parent 052f882a04
commit 97e19031c2

View file

@ -16,8 +16,6 @@ package android
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"strings"
@ -72,30 +70,33 @@ var allowedPluginsByName = map[string]bool{
"xsdc-soong-rules": true,
}
const (
internalPluginsPath = "vendor/google/build/soong/internal_plugins.json"
)
var internalPluginsPaths = []string{
"vendor/google/build/soong/internal_plugins.json",
"vendor/google_clockwork/build/internal_plugins.json",
}
type pluginProvider interface {
IsPluginFor(string) bool
}
func maybeAddInternalPluginsToAllowlist(ctx SingletonContext) {
for _, internalPluginsPath := range internalPluginsPaths {
if path := ExistentPathForSource(ctx, internalPluginsPath); path.Valid() {
ctx.AddNinjaFileDeps(path.String())
absPath := absolutePath(path.String())
var moreAllowed map[string]bool
data, err := ioutil.ReadFile(absPath)
data, err := os.ReadFile(absPath)
if err != nil {
ctx.Errorf("Failed to open internal plugins path %q %q", internalPluginsPath, err)
}
if err := json.Unmarshal(data, &moreAllowed); err != nil {
fmt.Fprintf(os.Stderr, "Internal plugins file %q did not parse correctly: %q", data, err)
ctx.Errorf("Internal plugins file %q did not parse correctly: %q", data, err)
}
for k, v := range moreAllowed {
allowedPluginsByName[k] = v
}
}
}
}
func (p *pluginSingleton) GenerateBuildActions(ctx SingletonContext) {