Merge "Prevent unspecified values in soong_config_string_variable"
diff --git a/Android.bp b/Android.bp
index 7c50047..380a388 100644
--- a/Android.bp
+++ b/Android.bp
@@ -50,6 +50,7 @@
name: "device_kernel_headers",
vendor: true,
recovery_available: true,
+ min_sdk_version: "apex_inherit",
}
cc_genrule {
diff --git a/android/api_levels.go b/android/api_levels.go
index de56625..27a3b7f 100644
--- a/android/api_levels.go
+++ b/android/api_levels.go
@@ -18,6 +18,8 @@
"encoding/json"
"fmt"
"strconv"
+
+ "android/soong/starlark_fmt"
)
func init() {
@@ -380,3 +382,21 @@
apiLevelsJson := GetApiLevelsJson(ctx)
createApiLevelsJson(ctx, apiLevelsJson, apiLevelsMap)
}
+
+func printApiLevelsStarlarkDict(config Config) string {
+ apiLevelsMap := GetApiLevelsMap(config)
+ valDict := make(map[string]string, len(apiLevelsMap))
+ for k, v := range apiLevelsMap {
+ valDict[k] = strconv.Itoa(v)
+ }
+ return starlark_fmt.PrintDict(valDict, 0)
+}
+
+func StarlarkApiLevelConfigs(config Config) string {
+ return fmt.Sprintf(`# GENERATED FOR BAZEL FROM SOONG. DO NOT EDIT.
+_api_levels = %s
+
+api_levels = _api_levels
+`, printApiLevelsStarlarkDict(config),
+ )
+}
\ No newline at end of file
diff --git a/android/bazel.go b/android/bazel.go
index 97226c6..7e2727c 100644
--- a/android/bazel.go
+++ b/android/bazel.go
@@ -300,7 +300,7 @@
"external/bouncycastle": Bp2BuildDefaultTrue,
"external/brotli": Bp2BuildDefaultTrue,
"external/conscrypt": Bp2BuildDefaultTrue,
- "external/e2fsprogs/lib": Bp2BuildDefaultTrueRecursively,
+ "external/e2fsprogs": Bp2BuildDefaultTrueRecursively,
"external/error_prone": Bp2BuildDefaultTrueRecursively,
"external/fmtlib": Bp2BuildDefaultTrueRecursively,
"external/google-benchmark": Bp2BuildDefaultTrueRecursively,
@@ -393,7 +393,7 @@
// A module can either be in this list or its directory allowlisted entirely
// in bp2buildDefaultConfig, but not both at the same time.
bp2buildModuleAlwaysConvertList = []string{
- "junit-params-assertj-core",
+ "prebuilt_junit-params-assertj-core",
//external/avb
"avbtool",
@@ -419,6 +419,10 @@
"fec",
}
+ // Per-module-type allowlist to always opt modules in of both bp2build and mixed builds
+ // when they have the same type as one listed.
+ bp2buildModuleTypeAlwaysConvertList = []string{}
+
// Per-module denylist to always opt modules out of both bp2build and mixed builds.
bp2buildModuleDoNotConvertList = []string{
"libnativehelper_compat_libc", // Broken compile: implicit declaration of function 'strerror_r' is invalid in C99
@@ -612,10 +616,11 @@
}
// Used for quicker lookups
- bp2buildModuleDoNotConvert = map[string]bool{}
- bp2buildModuleAlwaysConvert = map[string]bool{}
- bp2buildCcLibraryStaticOnly = map[string]bool{}
- mixedBuildsDisabled = map[string]bool{}
+ bp2buildModuleDoNotConvert = map[string]bool{}
+ bp2buildModuleAlwaysConvert = map[string]bool{}
+ bp2buildModuleTypeAlwaysConvert = map[string]bool{}
+ bp2buildCcLibraryStaticOnly = map[string]bool{}
+ mixedBuildsDisabled = map[string]bool{}
)
func init() {
@@ -623,6 +628,10 @@
bp2buildModuleAlwaysConvert[moduleName] = true
}
+ for _, moduleType := range bp2buildModuleTypeAlwaysConvertList {
+ bp2buildModuleTypeAlwaysConvert[moduleType] = true
+ }
+
for _, moduleName := range bp2buildModuleDoNotConvertList {
bp2buildModuleDoNotConvert[moduleName] = true
}
@@ -698,11 +707,17 @@
}
func (b *BazelModuleBase) shouldConvertWithBp2build(ctx BazelConversionContext, module blueprint.Module) bool {
- moduleNameNoPrefix := RemoveOptionalPrebuiltPrefix(module.Name())
- alwaysConvert := bp2buildModuleAlwaysConvert[moduleNameNoPrefix]
+ moduleName := module.Name()
+ moduleNameAllowed := bp2buildModuleAlwaysConvert[moduleName]
+ moduleTypeAllowed := bp2buildModuleTypeAlwaysConvert[ctx.OtherModuleType(module)]
+ allowlistConvert := moduleNameAllowed || moduleTypeAllowed
+ if moduleNameAllowed && moduleTypeAllowed {
+ ctx.(BaseModuleContext).ModuleErrorf("A module cannot be in bp2buildModuleAlwaysConvert and also be" +
+ " in bp2buildModuleTypeAlwaysConvert")
+ }
- if bp2buildModuleDoNotConvert[moduleNameNoPrefix] {
- if alwaysConvert {
+ if bp2buildModuleDoNotConvert[moduleName] {
+ if moduleNameAllowed {
ctx.(BaseModuleContext).ModuleErrorf("a module cannot be in bp2buildModuleDoNotConvert" +
" and also be in bp2buildModuleAlwaysConvert")
}
@@ -713,19 +728,23 @@
return false
}
+ propValue := b.bazelProperties.Bazel_module.Bp2build_available
packagePath := ctx.OtherModuleDir(module)
- if alwaysConvert && ShouldKeepExistingBuildFileForDir(packagePath) {
- ctx.(BaseModuleContext).ModuleErrorf("A module cannot be in a directory listed in bp2buildKeepExistingBuildFile"+
- " and also be in bp2buildModuleAlwaysConvert. Directory: '%s'", packagePath)
-
+ // Modules in unit tests which are enabled in the allowlist by type or name
+ // trigger this conditional because unit tests run under the "." package path
+ isTestModule := packagePath == "." && proptools.BoolDefault(propValue, false)
+ if allowlistConvert && !isTestModule && ShouldKeepExistingBuildFileForDir(packagePath) {
+ if moduleNameAllowed {
+ ctx.(BaseModuleContext).ModuleErrorf("A module cannot be in a directory listed in bp2buildKeepExistingBuildFile"+
+ " and also be in bp2buildModuleAlwaysConvert. Directory: '%s'", packagePath)
+ }
return false
}
config := ctx.Config().bp2buildPackageConfig
// This is a tristate value: true, false, or unset.
- propValue := b.bazelProperties.Bazel_module.Bp2build_available
if bp2buildDefaultTrueRecursively(packagePath, config) {
- if alwaysConvert {
+ if moduleNameAllowed {
ctx.(BaseModuleContext).ModuleErrorf("A module cannot be in a directory marked Bp2BuildDefaultTrue"+
" or Bp2BuildDefaultTrueRecursively and also be in bp2buildModuleAlwaysConvert. Directory: '%s'",
packagePath)
@@ -736,7 +755,7 @@
}
// Allow modules to explicitly opt-in.
- return proptools.BoolDefault(propValue, alwaysConvert)
+ return proptools.BoolDefault(propValue, allowlistConvert)
}
// bp2buildDefaultTrueRecursively checks that the package contains a prefix from the
diff --git a/android/bazel_handler.go b/android/bazel_handler.go
index 3d6babc..d851a98 100644
--- a/android/bazel_handler.go
+++ b/android/bazel_handler.go
@@ -50,8 +50,8 @@
// Portion of cquery map key to describe target configuration.
type configKey struct {
- archType ArchType
- osType OsType
+ arch string
+ osType OsType
}
// Map key to describe bazel cquery requests.
@@ -862,7 +862,7 @@
}
func getConfigString(key cqueryKey) string {
- arch := key.configKey.archType.Name
+ arch := key.configKey.arch
if len(arch) == 0 || arch == "common" {
// Use host platform, which is currently hardcoded to be x86_64.
arch = "x86_64"
@@ -876,5 +876,9 @@
}
func GetConfigKey(ctx ModuleContext) configKey {
- return configKey{archType: ctx.Arch().ArchType, osType: ctx.Os()}
+ return configKey{
+ // use string because Arch is not a valid key in go
+ arch: ctx.Arch().String(),
+ osType: ctx.Os(),
+ }
}
diff --git a/android/bazel_handler_test.go b/android/bazel_handler_test.go
index ad5b63b..e5cff90 100644
--- a/android/bazel_handler_test.go
+++ b/android/bazel_handler_test.go
@@ -9,9 +9,9 @@
func TestRequestResultsAfterInvokeBazel(t *testing.T) {
label := "//foo:bar"
- cfg := configKey{Arm64, Android}
+ cfg := configKey{"arm64_armv8-a", Android}
bazelContext, _ := testBazelContext(t, map[bazelCommand]string{
- bazelCommand{command: "cquery", expression: "deps(@soong_injection//mixed_builds:buildroot, 2)"}: `//foo:bar|arm64|android>>out/foo/bar.txt`,
+ bazelCommand{command: "cquery", expression: "deps(@soong_injection//mixed_builds:buildroot, 2)"}: `//foo:bar|arm64_armv8-a|android>>out/foo/bar.txt`,
})
g, ok := bazelContext.GetOutputFiles(label, cfg)
if ok {
diff --git a/android/filegroup.go b/android/filegroup.go
index d2ff97d..50356d1 100644
--- a/android/filegroup.go
+++ b/android/filegroup.go
@@ -119,12 +119,12 @@
return
}
- archVariant := ctx.Arch().ArchType
+ archVariant := ctx.Arch().String()
osVariant := ctx.Os()
if len(fg.Srcs()) == 1 && fg.Srcs()[0].Base() == fg.Name() {
// This will be a regular file target, not filegroup, in Bazel.
// See FilegroupBp2Build for more information.
- archVariant = Common
+ archVariant = Common.String()
osVariant = CommonOS
}
diff --git a/android/module.go b/android/module.go
index 03d3f80..43509c0 100644
--- a/android/module.go
+++ b/android/module.go
@@ -456,6 +456,10 @@
// GetMissingDependencies returns the list of dependencies that were passed to AddDependencies or related methods,
// but do not exist.
GetMissingDependencies() []string
+
+ // LicenseMetadataFile returns the path where the license metadata for this module will be
+ // generated.
+ LicenseMetadataFile() Path
}
type Module interface {
@@ -3279,6 +3283,10 @@
return m.bp
}
+func (m *moduleContext) LicenseMetadataFile() Path {
+ return m.module.base().licenseMetadataFile
+}
+
// SrcIsModule decodes module references in the format ":unqualified-name" or "//namespace:name"
// into the module name, or empty string if the input was not a module reference.
func SrcIsModule(s string) (module string) {
diff --git a/androidmk/parser/parser.go b/androidmk/parser/parser.go
index d24efc1..fb6be38 100644
--- a/androidmk/parser/parser.go
+++ b/androidmk/parser/parser.go
@@ -222,7 +222,7 @@
if d == "ifdef" || d == "ifndef" || d == "ifeq" || d == "ifneq" {
d = "el" + d
p.ignoreSpaces()
- expression = p.parseExpression()
+ expression = p.parseExpression('#')
expression.TrimRightSpaces()
} else {
p.errorf("expected ifdef/ifndef/ifeq/ifneq, found %s", d)
@@ -232,7 +232,7 @@
expression, endPos = p.parseDefine()
default:
p.ignoreSpaces()
- expression = p.parseExpression()
+ expression = p.parseExpression('#')
}
p.nodes = append(p.nodes, &Directive{
@@ -338,9 +338,6 @@
value.appendString(`\` + string(p.tok))
}
p.accept(p.tok)
- case '#':
- p.parseComment()
- break loop
case '$':
var variable Variable
variable = p.parseVariable()
@@ -522,7 +519,7 @@
// non-whitespace character after the = until the end of the logical line,
// which may included escaped newlines
p.accept('=')
- value := p.parseExpression()
+ value := p.parseExpression('#')
value.TrimLeftSpaces()
if ident.EndsWith('+') && t == "=" {
ident.TrimRightOne()
diff --git a/androidmk/parser/parser_test.go b/androidmk/parser/parser_test.go
index f562c29..9efebf8 100644
--- a/androidmk/parser/parser_test.go
+++ b/androidmk/parser/parser_test.go
@@ -34,6 +34,56 @@
},
},
},
+ {
+ name: "Simple warning",
+ in: `$(warning A warning)`,
+ out: []Node{
+ &Variable{
+ Name: SimpleMakeString("warning A warning", NoPos),
+ },
+ },
+ },
+ {
+ name: "Warning with #",
+ in: `$(warning # A warning)`,
+ out: []Node{
+ &Variable{
+ Name: SimpleMakeString("warning # A warning", NoPos),
+ },
+ },
+ },
+ {
+ name: "Findstring with #",
+ in: `$(findstring x,x a #)`,
+ out: []Node{
+ &Variable{
+ Name: SimpleMakeString("findstring x,x a #", NoPos),
+ },
+ },
+ },
+ {
+ name: "If statement",
+ in: `ifeq (a,b) # comment
+endif`,
+ out: []Node{
+ &Directive{
+ NamePos: NoPos,
+ Name: "ifeq",
+ Args: SimpleMakeString("(a,b) ", NoPos),
+ EndPos: NoPos,
+ },
+ &Comment{
+ CommentPos: NoPos,
+ Comment: " comment",
+ },
+ &Directive{
+ NamePos: NoPos,
+ Name: "endif",
+ Args: SimpleMakeString("", NoPos),
+ EndPos: NoPos,
+ },
+ },
+ },
}
func TestParse(t *testing.T) {
diff --git a/bp2build/cc_binary_conversion_test.go b/bp2build/cc_binary_conversion_test.go
index 8d94079..17337f0 100644
--- a/bp2build/cc_binary_conversion_test.go
+++ b/bp2build/cc_binary_conversion_test.go
@@ -15,12 +15,13 @@
package bp2build
import (
- "android/soong/android"
- "android/soong/cc"
- "android/soong/genrule"
"fmt"
"strings"
"testing"
+
+ "android/soong/android"
+ "android/soong/cc"
+ "android/soong/genrule"
)
const (
@@ -127,6 +128,8 @@
keep_symbols_list: ["symbol"],
none: true,
},
+ sdk_version: "current",
+ min_sdk_version: "29",
}
`,
targets: []testBazelTarget{
@@ -150,6 +153,8 @@
"keep_symbols_list": ["symbol"],
"none": True,
}`,
+ "sdk_version": `"current"`,
+ "min_sdk_version": `"29"`,
},
},
},
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 8fde655..d84e156 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -115,6 +115,8 @@
},
},
include_build_directory: false,
+ sdk_version: "current",
+ min_sdk_version: "29",
}
`,
expectedBazelTargets: makeCcLibraryTargets("foo-lib", attrNameToString{
@@ -140,6 +142,8 @@
"//build/bazel/platforms/os:linux_bionic": ["bionic.cpp"],
"//conditions:default": [],
})`,
+ "sdk_version": `"current"`,
+ "min_sdk_version": `"29"`,
}),
})
}
diff --git a/bp2build/cc_library_headers_conversion_test.go b/bp2build/cc_library_headers_conversion_test.go
index e4cfa35..e5bb120 100644
--- a/bp2build/cc_library_headers_conversion_test.go
+++ b/bp2build/cc_library_headers_conversion_test.go
@@ -112,6 +112,8 @@
export_include_dirs: ["arch_x86_64_exported_include_dir"],
},
},
+ sdk_version: "current",
+ min_sdk_version: "29",
// TODO: Also support export_header_lib_headers
}`,
@@ -130,6 +132,8 @@
":lib-1",
":lib-2",
]`,
+ "sdk_version": `"current"`,
+ "min_sdk_version": `"29"`,
}),
},
})
diff --git a/bp2build/cc_library_shared_conversion_test.go b/bp2build/cc_library_shared_conversion_test.go
index 78192fe..22c9dfe 100644
--- a/bp2build/cc_library_shared_conversion_test.go
+++ b/bp2build/cc_library_shared_conversion_test.go
@@ -136,6 +136,8 @@
"header_lib_1",
"header_lib_2"
],
+ sdk_version: "current",
+ min_sdk_version: "29",
// TODO: Also support export_header_lib_headers
}`,
@@ -174,6 +176,8 @@
":whole_static_lib_1",
":whole_static_lib_2",
]`,
+ "sdk_version": `"current"`,
+ "min_sdk_version": `"29"`,
}),
},
})
diff --git a/bp2build/cc_library_static_conversion_test.go b/bp2build/cc_library_static_conversion_test.go
index 205bf4d..be10e86 100644
--- a/bp2build/cc_library_static_conversion_test.go
+++ b/bp2build/cc_library_static_conversion_test.go
@@ -166,6 +166,8 @@
"header_lib_1",
"header_lib_2"
],
+ sdk_version: "current",
+ min_sdk_version: "29",
// TODO: Also support export_header_lib_headers
}`,
@@ -202,6 +204,8 @@
":whole_static_lib_1",
":whole_static_lib_2",
]`,
+ "sdk_version": `"current"`,
+ "min_sdk_version": `"29"`,
}),
},
})
diff --git a/bp2build/cc_object_conversion_test.go b/bp2build/cc_object_conversion_test.go
index 0a6c317..ea58086 100644
--- a/bp2build/cc_object_conversion_test.go
+++ b/bp2build/cc_object_conversion_test.go
@@ -55,6 +55,8 @@
"a/b/*.c"
],
exclude_srcs: ["a/b/exclude.c"],
+ sdk_version: "current",
+ min_sdk_version: "29",
}
`,
expectedBazelTargets: []string{
@@ -71,6 +73,8 @@
]`,
"srcs": `["a/b/c.c"]`,
"system_dynamic_deps": `[]`,
+ "sdk_version": `"current"`,
+ "min_sdk_version": `"29"`,
}),
},
})
diff --git a/bp2build/conversion.go b/bp2build/conversion.go
index 3ab846b..91e614d 100644
--- a/bp2build/conversion.go
+++ b/bp2build/conversion.go
@@ -36,6 +36,7 @@
}
files = append(files, newFile("api_levels", GeneratedBuildFileName, `exports_files(["api_levels.json"])`))
files = append(files, newFile("api_levels", "api_levels.json", string(apiLevelsContent)))
+ files = append(files, newFile("api_levels", "api_levels.bzl", android.StarlarkApiLevelConfigs(cfg)))
return files
}
diff --git a/bp2build/conversion_test.go b/bp2build/conversion_test.go
index c94a923..d65ece8 100644
--- a/bp2build/conversion_test.go
+++ b/bp2build/conversion_test.go
@@ -114,6 +114,10 @@
dir: "api_levels",
basename: "api_levels.json",
},
+ {
+ dir: "api_levels",
+ basename: "api_levels.bzl",
+ },
}
if len(files) != len(expectedFilePaths) {
diff --git a/cc/binary.go b/cc/binary.go
index 9262f21..89e7262 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -630,6 +630,8 @@
},
Features: baseAttrs.features,
+
+ sdkAttributes: bp2BuildParseSdkAttributes(m),
}
ctx.CreateBazelTargetModule(bazel.BazelTargetModuleProperties{
@@ -673,4 +675,6 @@
Strip stripAttributes
Features bazel.StringListAttribute
+
+ sdkAttributes
}
diff --git a/cc/bp2build.go b/cc/bp2build.go
index 379d6f2..93d11c7 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -52,6 +52,8 @@
System_dynamic_deps bazel.LabelListAttribute
Enabled bazel.BoolAttribute
+
+ sdkAttributes
}
// groupSrcsByExtension partitions `srcs` into groups based on file extension.
@@ -539,6 +541,18 @@
}
}
+func bp2BuildParseSdkAttributes(module *Module) sdkAttributes {
+ return sdkAttributes {
+ Sdk_version: module.Properties.Sdk_version,
+ Min_sdk_version: module.Properties.Min_sdk_version,
+ }
+}
+
+type sdkAttributes struct {
+ Sdk_version *string
+ Min_sdk_version *string
+}
+
// Convenience struct to hold all attributes parsed from linker properties.
type linkerAttributes struct {
deps bazel.LabelListAttribute
diff --git a/cc/library.go b/cc/library.go
index 5fa3471..035a90e 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -316,6 +316,7 @@
Implementation_whole_archive_deps: linkerAttrs.implementationWholeArchiveDeps,
Whole_archive_deps: *linkerAttrs.wholeArchiveDeps.Clone().Append(staticAttrs.Whole_archive_deps),
System_dynamic_deps: *linkerAttrs.systemDynamicDeps.Clone().Append(staticAttrs.System_dynamic_deps),
+ sdkAttributes: bp2BuildParseSdkAttributes(m),
}
sharedCommonAttrs := staticOrSharedAttributes{
@@ -331,6 +332,7 @@
Implementation_dynamic_deps: *linkerAttrs.implementationDynamicDeps.Clone().Append(sharedAttrs.Implementation_dynamic_deps),
Whole_archive_deps: *linkerAttrs.wholeArchiveDeps.Clone().Append(sharedAttrs.Whole_archive_deps),
System_dynamic_deps: *linkerAttrs.systemDynamicDeps.Clone().Append(sharedAttrs.System_dynamic_deps),
+ sdkAttributes: bp2BuildParseSdkAttributes(m),
}
staticTargetAttrs := &bazelCcLibraryStaticAttributes{
@@ -2481,6 +2483,7 @@
Whole_archive_deps: linkerAttrs.wholeArchiveDeps,
Implementation_whole_archive_deps: linkerAttrs.implementationWholeArchiveDeps,
System_dynamic_deps: linkerAttrs.systemDynamicDeps,
+ sdkAttributes: bp2BuildParseSdkAttributes(module),
}
var attrs interface{}
diff --git a/cc/library_headers.go b/cc/library_headers.go
index 5d38fba..41ebcc7 100644
--- a/cc/library_headers.go
+++ b/cc/library_headers.go
@@ -117,6 +117,7 @@
Deps bazel.LabelListAttribute
Implementation_deps bazel.LabelListAttribute
System_dynamic_deps bazel.LabelListAttribute
+ sdkAttributes
}
func libraryHeadersBp2Build(ctx android.TopDownMutatorContext, module *Module) {
@@ -132,6 +133,7 @@
Deps: linkerAttrs.deps,
System_dynamic_deps: linkerAttrs.systemDynamicDeps,
Hdrs: baseAttributes.hdrs,
+ sdkAttributes: bp2BuildParseSdkAttributes(module),
}
props := bazel.BazelTargetModuleProperties{
diff --git a/cc/object.go b/cc/object.go
index fdd0b11..bd5bd45 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -133,6 +133,7 @@
Absolute_includes bazel.StringListAttribute
Stl *string
Linker_script bazel.LabelAttribute
+ sdkAttributes
}
// objectBp2Build is the bp2build converter from cc_object modules to the
@@ -191,6 +192,7 @@
Absolute_includes: compilerAttrs.absoluteIncludes,
Stl: compilerAttrs.stl,
Linker_script: linkerScript,
+ sdkAttributes: bp2BuildParseSdkAttributes(m),
}
props := bazel.BazelTargetModuleProperties{
diff --git a/cmd/soong_ui/main.go b/cmd/soong_ui/main.go
index a0cfbea..a03a86a 100644
--- a/cmd/soong_ui/main.go
+++ b/cmd/soong_ui/main.go
@@ -221,7 +221,6 @@
}
defer build.UploadMetrics(buildCtx, config, c.simpleOutput, buildStarted, files...)
defer met.Dump(soongMetricsFile)
- defer build.DumpRBEMetrics(buildCtx, config, rbeMetricsFile)
}
// Read the time at the starting point.
diff --git a/java/Android.bp b/java/Android.bp
index c062941..4bcae4f 100644
--- a/java/Android.bp
+++ b/java/Android.bp
@@ -81,6 +81,7 @@
"app_test.go",
"bootclasspath_fragment_test.go",
"device_host_converter_test.go",
+ "dex_test.go",
"dexpreopt_test.go",
"dexpreopt_bootjars_test.go",
"droiddoc_test.go",
diff --git a/java/base.go b/java/base.go
index 9978a66..2f425cd 100644
--- a/java/base.go
+++ b/java/base.go
@@ -872,6 +872,7 @@
// classpath
flags.bootClasspath = append(flags.bootClasspath, deps.bootClasspath...)
flags.classpath = append(flags.classpath, deps.classpath...)
+ flags.dexClasspath = append(flags.dexClasspath, deps.dexClasspath...)
flags.java9Classpath = append(flags.java9Classpath, deps.java9Classpath...)
flags.processorPath = append(flags.processorPath, deps.processorPath...)
flags.errorProneProcessorPath = append(flags.errorProneProcessorPath, deps.errorProneProcessorPath...)
@@ -1090,6 +1091,8 @@
flags.classpath = append(flags.classpath, deps.kotlinStdlib...)
flags.classpath = append(flags.classpath, deps.kotlinAnnotations...)
+ flags.dexClasspath = append(flags.dexClasspath, deps.kotlinAnnotations...)
+
flags.kotlincClasspath = append(flags.kotlincClasspath, flags.bootClasspath...)
flags.kotlincClasspath = append(flags.kotlincClasspath, flags.classpath...)
@@ -1118,6 +1121,8 @@
// Jar kotlin classes into the final jar after javac
if BoolDefault(j.properties.Static_kotlin_stdlib, true) {
kotlinJars = append(kotlinJars, deps.kotlinStdlib...)
+ } else {
+ flags.dexClasspath = append(flags.dexClasspath, deps.kotlinStdlib...)
}
}
@@ -1842,6 +1847,7 @@
} else if sdkDep.useFiles {
// sdkDep.jar is actually equivalent to turbine header.jar.
deps.classpath = append(deps.classpath, sdkDep.jars...)
+ deps.dexClasspath = append(deps.dexClasspath, sdkDep.jars...)
deps.aidlPreprocess = sdkDep.aidl
} else {
deps.aidlPreprocess = sdkDep.aidl
@@ -1866,7 +1872,9 @@
if dep, ok := module.(SdkLibraryDependency); ok {
switch tag {
case libTag:
- deps.classpath = append(deps.classpath, dep.SdkHeaderJars(ctx, j.SdkVersion(ctx))...)
+ depHeaderJars := dep.SdkHeaderJars(ctx, j.SdkVersion(ctx))
+ deps.classpath = append(deps.classpath, depHeaderJars...)
+ deps.dexClasspath = append(deps.dexClasspath, depHeaderJars...)
case staticLibTag:
ctx.ModuleErrorf("dependency on java_sdk_library %q can only be in libs", otherName)
}
@@ -1885,6 +1893,7 @@
deps.bootClasspath = append(deps.bootClasspath, dep.HeaderJars...)
case libTag, instrumentationForTag:
deps.classpath = append(deps.classpath, dep.HeaderJars...)
+ deps.dexClasspath = append(deps.dexClasspath, dep.HeaderJars...)
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs...)
addPlugins(&deps, dep.ExportedPlugins, dep.ExportedPluginClasses...)
deps.disableTurbine = deps.disableTurbine || dep.ExportedPluginDisableTurbine
@@ -1952,6 +1961,7 @@
case libTag:
checkProducesJars(ctx, dep)
deps.classpath = append(deps.classpath, dep.Srcs()...)
+ deps.dexClasspath = append(deps.classpath, dep.Srcs()...)
case staticLibTag:
checkProducesJars(ctx, dep)
deps.classpath = append(deps.classpath, dep.Srcs()...)
diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go
index eddcb61..c3a5d5f 100644
--- a/java/bootclasspath_fragment.go
+++ b/java/bootclasspath_fragment.go
@@ -140,7 +140,7 @@
BootclasspathFragmentsDepsProperties
}
-type SourceOnlyBootclasspathProperties struct {
+type HiddenApiPackageProperties struct {
Hidden_api struct {
// Contains prefixes of a package hierarchy that is provided solely by this
// bootclasspath_fragment.
@@ -149,6 +149,14 @@
// hidden API flags. See split_packages property for more details.
Package_prefixes []string
+ // A list of individual packages that are provided solely by this
+ // bootclasspath_fragment but which cannot be listed in package_prefixes
+ // because there are sub-packages which are provided by other modules.
+ //
+ // This should only be used for legacy packages. New packages should be
+ // covered by a package prefix.
+ Single_packages []string
+
// The list of split packages provided by this bootclasspath_fragment.
//
// A split package is one that contains classes which are provided by multiple
@@ -208,6 +216,11 @@
}
}
+type SourceOnlyBootclasspathProperties struct {
+ HiddenApiPackageProperties
+ Coverage HiddenApiPackageProperties
+}
+
type BootclasspathFragmentModule struct {
android.ModuleBase
android.ApexModuleBase
@@ -271,6 +284,12 @@
ctx.PropertyErrorf("coverage", "error trying to append coverage specific properties: %s", err)
return
}
+
+ err = proptools.AppendProperties(&m.sourceOnlyProperties.HiddenApiPackageProperties, &m.sourceOnlyProperties.Coverage, nil)
+ if err != nil {
+ ctx.PropertyErrorf("coverage", "error trying to append hidden api coverage specific properties: %s", err)
+ return
+ }
}
// Initialize the contents property from the image_name.
@@ -731,7 +750,8 @@
// TODO(b/192868581): Remove once the source and prebuilts provide a signature patterns file of
// their own.
if output.SignaturePatternsPath == nil {
- output.SignaturePatternsPath = buildRuleSignaturePatternsFile(ctx, output.AllFlagsPath, []string{"*"}, nil)
+ output.SignaturePatternsPath = buildRuleSignaturePatternsFile(
+ ctx, output.AllFlagsPath, []string{"*"}, nil, nil)
}
// Initialize a HiddenAPIInfo structure.
@@ -806,11 +826,13 @@
// signature patterns.
splitPackages := b.sourceOnlyProperties.Hidden_api.Split_packages
packagePrefixes := b.sourceOnlyProperties.Hidden_api.Package_prefixes
- if splitPackages != nil || packagePrefixes != nil {
+ singlePackages := b.sourceOnlyProperties.Hidden_api.Single_packages
+ if splitPackages != nil || packagePrefixes != nil || singlePackages != nil {
if splitPackages == nil {
splitPackages = []string{"*"}
}
- output.SignaturePatternsPath = buildRuleSignaturePatternsFile(ctx, output.AllFlagsPath, splitPackages, packagePrefixes)
+ output.SignaturePatternsPath = buildRuleSignaturePatternsFile(
+ ctx, output.AllFlagsPath, splitPackages, packagePrefixes, singlePackages)
}
return output
diff --git a/java/builder.go b/java/builder.go
index e64a61f..c48e3fa 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -247,16 +247,33 @@
}
type javaBuilderFlags struct {
- javacFlags string
- bootClasspath classpath
- classpath classpath
+ javacFlags string
+
+ // bootClasspath is the list of jars that form the boot classpath (generally the java.* and
+ // android.* classes) for tools that still use it. javac targeting 1.9 or higher uses
+ // systemModules and java9Classpath instead.
+ bootClasspath classpath
+
+ // classpath is the list of jars that form the classpath for javac and kotlinc rules. It
+ // contains header jars for all static and non-static dependencies.
+ classpath classpath
+
+ // dexClasspath is the list of jars that form the classpath for d8 and r8 rules. It contains
+ // header jars for all non-static dependencies. Static dependencies have already been
+ // combined into the program jar.
+ dexClasspath classpath
+
+ // java9Classpath is the list of jars that will be added to the classpath when targeting
+ // 1.9 or higher. It generally contains the android.* classes, while the java.* classes
+ // are provided by systemModules.
java9Classpath classpath
- processorPath classpath
- processors []string
- systemModules *systemModules
- aidlFlags string
- aidlDeps android.Paths
- javaVersion javaVersion
+
+ processorPath classpath
+ processors []string
+ systemModules *systemModules
+ aidlFlags string
+ aidlDeps android.Paths
+ javaVersion javaVersion
errorProneExtraJavacFlags string
errorProneProcessorPath classpath
diff --git a/java/config/kotlin.go b/java/config/kotlin.go
index 6cb61f3..a83f87f 100644
--- a/java/config/kotlin.go
+++ b/java/config/kotlin.go
@@ -47,4 +47,9 @@
pctx.StaticVariable("KotlincSuppressJDK9Warnings", strings.Join([]string{
"-J--add-opens=java.base/java.util=ALL-UNNAMED", // https://youtrack.jetbrains.com/issue/KT-43704
}, " "))
+
+ pctx.StaticVariable("KotlincGlobalFlags", strings.Join([]string{
+ // b/222162908: prevent kotlinc from reading /tmp/build.txt
+ "-Didea.plugins.compatible.build=999.SNAPSHOT",
+ }, " "))
}
diff --git a/java/dex.go b/java/dex.go
index 474694a..84665e7 100644
--- a/java/dex.go
+++ b/java/dex.go
@@ -132,12 +132,15 @@
`--no-data-resources ` +
`-printmapping ${outDict} ` +
`-printusage ${outUsage} ` +
+ `--deps-file ${out}.d ` +
`$r8Flags && ` +
`touch "${outDict}" "${outUsage}" && ` +
`${config.SoongZipCmd} -o ${outUsageZip} -C ${outUsageDir} -f ${outUsage} && ` +
`rm -rf ${outUsageDir} && ` +
`$zipTemplate${config.SoongZipCmd} $zipFlags -o $outDir/classes.dex.jar -C $outDir -f "$outDir/classes*.dex" && ` +
`${config.MergeZipsCmd} -D -stripFile "**/*.class" $mergeZipsFlags $out $outDir/classes.dex.jar $in`,
+ Depfile: "${out}.d",
+ Deps: blueprint.DepsGCC,
CommandDeps: []string{
"${config.R8Cmd}",
"${config.Zip2ZipCmd}",
@@ -205,10 +208,10 @@
func d8Flags(flags javaBuilderFlags) (d8Flags []string, d8Deps android.Paths) {
d8Flags = append(d8Flags, flags.bootClasspath.FormRepeatedClassPath("--lib ")...)
- d8Flags = append(d8Flags, flags.classpath.FormRepeatedClassPath("--lib ")...)
+ d8Flags = append(d8Flags, flags.dexClasspath.FormRepeatedClassPath("--lib ")...)
d8Deps = append(d8Deps, flags.bootClasspath...)
- d8Deps = append(d8Deps, flags.classpath...)
+ d8Deps = append(d8Deps, flags.dexClasspath...)
return d8Flags, d8Deps
}
@@ -231,11 +234,11 @@
r8Flags = append(r8Flags, proguardRaiseDeps.FormJavaClassPath("-libraryjars"))
r8Flags = append(r8Flags, flags.bootClasspath.FormJavaClassPath("-libraryjars"))
- r8Flags = append(r8Flags, flags.classpath.FormJavaClassPath("-libraryjars"))
+ r8Flags = append(r8Flags, flags.dexClasspath.FormJavaClassPath("-libraryjars"))
r8Deps = append(r8Deps, proguardRaiseDeps...)
r8Deps = append(r8Deps, flags.bootClasspath...)
- r8Deps = append(r8Deps, flags.classpath...)
+ r8Deps = append(r8Deps, flags.dexClasspath...)
flagFiles := android.Paths{
android.PathForSource(ctx, "build/make/core/proguard.flags"),
diff --git a/java/dex_test.go b/java/dex_test.go
new file mode 100644
index 0000000..fbdccb6
--- /dev/null
+++ b/java/dex_test.go
@@ -0,0 +1,103 @@
+// Copyright 2022 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package java
+
+import (
+ "testing"
+
+ "android/soong/android"
+)
+
+func TestR8(t *testing.T) {
+ result := PrepareForTestWithJavaDefaultModulesWithoutFakeDex2oatd.RunTestWithBp(t, `
+ android_app {
+ name: "app",
+ srcs: ["foo.java"],
+ libs: ["lib"],
+ static_libs: ["static_lib"],
+ platform_apis: true,
+ }
+
+ java_library {
+ name: "lib",
+ srcs: ["foo.java"],
+ }
+
+ java_library {
+ name: "static_lib",
+ srcs: ["foo.java"],
+ }
+ `)
+
+ app := result.ModuleForTests("app", "android_common")
+ lib := result.ModuleForTests("lib", "android_common")
+ staticLib := result.ModuleForTests("static_lib", "android_common")
+
+ appJavac := app.Rule("javac")
+ appR8 := app.Rule("r8")
+ libHeader := lib.Output("turbine-combined/lib.jar").Output
+ staticLibHeader := staticLib.Output("turbine-combined/static_lib.jar").Output
+
+ android.AssertStringDoesContain(t, "expected lib header jar in app javac classpath",
+ appJavac.Args["classpath"], libHeader.String())
+ android.AssertStringDoesContain(t, "expected static_lib header jar in app javac classpath",
+ appJavac.Args["classpath"], staticLibHeader.String())
+
+ android.AssertStringDoesContain(t, "expected lib header jar in app r8 classpath",
+ appR8.Args["r8Flags"], libHeader.String())
+ android.AssertStringDoesNotContain(t, "expected no static_lib header jar in app javac classpath",
+ appR8.Args["r8Flags"], staticLibHeader.String())
+}
+
+func TestD8(t *testing.T) {
+ result := PrepareForTestWithJavaDefaultModulesWithoutFakeDex2oatd.RunTestWithBp(t, `
+ java_library {
+ name: "foo",
+ srcs: ["foo.java"],
+ libs: ["lib"],
+ static_libs: ["static_lib"],
+ installable: true,
+ }
+
+ java_library {
+ name: "lib",
+ srcs: ["foo.java"],
+ }
+
+ java_library {
+ name: "static_lib",
+ srcs: ["foo.java"],
+ }
+ `)
+
+ foo := result.ModuleForTests("foo", "android_common")
+ lib := result.ModuleForTests("lib", "android_common")
+ staticLib := result.ModuleForTests("static_lib", "android_common")
+
+ fooJavac := foo.Rule("javac")
+ fooD8 := foo.Rule("d8")
+ libHeader := lib.Output("turbine-combined/lib.jar").Output
+ staticLibHeader := staticLib.Output("turbine-combined/static_lib.jar").Output
+
+ android.AssertStringDoesContain(t, "expected lib header jar in foo javac classpath",
+ fooJavac.Args["classpath"], libHeader.String())
+ android.AssertStringDoesContain(t, "expected static_lib header jar in foo javac classpath",
+ fooJavac.Args["classpath"], staticLibHeader.String())
+
+ android.AssertStringDoesContain(t, "expected lib header jar in foo d8 classpath",
+ fooD8.Args["d8Flags"], libHeader.String())
+ android.AssertStringDoesNotContain(t, "expected no static_lib header jar in foo javac classpath",
+ fooD8.Args["d8Flags"], staticLibHeader.String())
+}
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index cad9c33..3d91aec 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -276,11 +276,17 @@
// Rules which should be used in make to install the outputs.
profileInstalls android.RuleBuilderInstalls
+ // Path to the license metadata file for the module that built the profile.
+ profileLicenseMetadataFile android.OptionalPath
+
// Path to the image profile file on host (or empty, if profile is not generated).
profilePathOnHost android.Path
// Target-dependent fields.
variants []*bootImageVariant
+
+ // Path of the preloaded classes file.
+ preloadedClassesFile string
}
// Target-dependent description of a boot image.
@@ -320,6 +326,9 @@
// Rules which should be used in make to install the outputs on device.
deviceInstalls android.RuleBuilderInstalls
+
+ // Path to the license metadata file for the module that built the image.
+ licenseMetadataFile android.OptionalPath
}
// Get target-specific boot image variant for the given boot image config and target.
@@ -680,6 +689,13 @@
cmd.FlagWithArg("--base=", ctx.Config().LibartImgDeviceBaseAddress())
}
+ // We always expect a preloaded classes file to be available. However, if we cannot find it, it's
+ // OK to not pass the flag to dex2oat.
+ preloadedClassesPath := android.ExistentPathForSource(ctx, image.preloadedClassesFile)
+ if preloadedClassesPath.Valid() {
+ cmd.FlagWithInput("--preloaded-classes=", preloadedClassesPath.Path())
+ }
+
cmd.
FlagForEachInput("--dex-file=", image.dexPaths.Paths()).
FlagForEachArg("--dex-location=", image.dexLocations).
@@ -759,6 +775,7 @@
image.vdexInstalls = vdexInstalls
image.unstrippedInstalls = unstrippedInstalls
image.deviceInstalls = deviceInstalls
+ image.licenseMetadataFile = android.OptionalPathForPath(ctx.LicenseMetadataFile())
}
const failureMessage = `ERROR: Dex2oat failed to compile a boot image.
@@ -807,6 +824,7 @@
if image == defaultBootImageConfig(ctx) {
rule.Install(profile, "/system/etc/boot-image.prof")
image.profileInstalls = append(image.profileInstalls, rule.Installs()...)
+ image.profileLicenseMetadataFile = android.OptionalPathForPath(ctx.LicenseMetadataFile())
}
rule.Build("bootJarsProfile", "profile boot jars")
@@ -844,6 +862,7 @@
rule.Install(profile, "/system/etc/boot-image.bprof")
rule.Build("bootFrameworkProfile", "profile boot framework jars")
image.profileInstalls = append(image.profileInstalls, rule.Installs()...)
+ image.profileLicenseMetadataFile = android.OptionalPathForPath(ctx.LicenseMetadataFile())
return profile
}
@@ -909,6 +928,9 @@
image := d.defaultBootImage
if image != nil {
ctx.Strict("DEXPREOPT_IMAGE_PROFILE_BUILT_INSTALLED", image.profileInstalls.String())
+ if image.profileLicenseMetadataFile.Valid() {
+ ctx.Strict("DEXPREOPT_IMAGE_PROFILE_LICENSE_METADATA", image.profileLicenseMetadataFile.String())
+ }
global := dexpreopt.GetGlobalConfig(ctx)
dexPaths, dexLocations := bcpForDexpreopt(ctx, global.PreoptWithUpdatableBcp)
@@ -934,6 +956,9 @@
ctx.Strict("DEXPREOPT_IMAGE_DEPS_"+sfx, strings.Join(variant.imagesDeps.Strings(), " "))
ctx.Strict("DEXPREOPT_IMAGE_BUILT_INSTALLED_"+sfx, variant.installs.String())
ctx.Strict("DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_"+sfx, variant.unstrippedInstalls.String())
+ if variant.licenseMetadataFile.Valid() {
+ ctx.Strict("DEXPREOPT_IMAGE_LICENSE_METADATA_"+sfx, variant.licenseMetadataFile.String())
+ }
}
imageLocationsOnHost, imageLocationsOnDevice := current.getAnyAndroidVariant().imageLocations()
ctx.Strict("DEXPREOPT_IMAGE_LOCATIONS_ON_HOST"+current.name, strings.Join(imageLocationsOnHost, ":"))
diff --git a/java/dexpreopt_config.go b/java/dexpreopt_config.go
index 21e1d12..4d0bd09 100644
--- a/java/dexpreopt_config.go
+++ b/java/dexpreopt_config.go
@@ -62,18 +62,20 @@
installDirOnDevice: "system/framework",
profileInstallPathInApex: "etc/boot-image.prof",
modules: artModules,
+ preloadedClassesFile: "art/build/boot/preloaded-classes",
}
// Framework config for the boot image extension.
// It includes framework libraries and depends on the ART config.
frameworkSubdir := "system/framework"
frameworkCfg := bootImageConfig{
- extends: &artCfg,
- name: frameworkBootImageName,
- stem: "boot",
- installDirOnHost: frameworkSubdir,
- installDirOnDevice: frameworkSubdir,
- modules: frameworkModules,
+ extends: &artCfg,
+ name: frameworkBootImageName,
+ stem: "boot",
+ installDirOnHost: frameworkSubdir,
+ installDirOnDevice: frameworkSubdir,
+ modules: frameworkModules,
+ preloadedClassesFile: "frameworks/base/config/preloaded-classes",
}
return map[string]*bootImageConfig{
diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go
index 0cc960d..95ded34 100644
--- a/java/hiddenapi_modular.go
+++ b/java/hiddenapi_modular.go
@@ -943,7 +943,9 @@
// buildRuleSignaturePatternsFile creates a rule to generate a file containing the set of signature
// patterns that will select a subset of the monolithic flags.
-func buildRuleSignaturePatternsFile(ctx android.ModuleContext, flagsPath android.Path, splitPackages []string, packagePrefixes []string) android.Path {
+func buildRuleSignaturePatternsFile(
+ ctx android.ModuleContext, flagsPath android.Path,
+ splitPackages []string, packagePrefixes []string, singlePackages []string) android.Path {
patternsFile := android.PathForModuleOut(ctx, "modular-hiddenapi", "signature-patterns.csv")
// Create a rule to validate the output from the following rule.
rule := android.NewRuleBuilder(pctx, ctx)
@@ -959,6 +961,7 @@
FlagWithInput("--flags ", flagsPath).
FlagForEachArg("--split-package ", quotedSplitPackages).
FlagForEachArg("--package-prefix ", packagePrefixes).
+ FlagForEachArg("--single-package ", singlePackages).
FlagWithOutput("--output ", patternsFile)
rule.Build("hiddenAPISignaturePatterns", "hidden API signature patterns")
diff --git a/java/java.go b/java/java.go
index 895ce7a..ddef34d 100644
--- a/java/java.go
+++ b/java/java.go
@@ -421,9 +421,25 @@
}
type deps struct {
- classpath classpath
- java9Classpath classpath
- bootClasspath classpath
+ // bootClasspath is the list of jars that form the boot classpath (generally the java.* and
+ // android.* classes) for tools that still use it. javac targeting 1.9 or higher uses
+ // systemModules and java9Classpath instead.
+ bootClasspath classpath
+
+ // classpath is the list of jars that form the classpath for javac and kotlinc rules. It
+ // contains header jars for all static and non-static dependencies.
+ classpath classpath
+
+ // dexClasspath is the list of jars that form the classpath for d8 and r8 rules. It contains
+ // header jars for all non-static dependencies. Static dependencies have already been
+ // combined into the program jar.
+ dexClasspath classpath
+
+ // java9Classpath is the list of jars that will be added to the classpath when targeting
+ // 1.9 or higher. It generally contains the android.* classes, while the java.* classes
+ // are provided by systemModules.
+ java9Classpath classpath
+
processorPath classpath
errorProneProcessorPath classpath
processorClasses []string
@@ -1458,7 +1474,10 @@
if ctx.OtherModuleHasProvider(module, JavaInfoProvider) {
dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
switch tag {
- case libTag, staticLibTag:
+ case libTag:
+ flags.classpath = append(flags.classpath, dep.HeaderJars...)
+ flags.dexClasspath = append(flags.dexClasspath, dep.HeaderJars...)
+ case staticLibTag:
flags.classpath = append(flags.classpath, dep.HeaderJars...)
case bootClasspathTag:
flags.bootClasspath = append(flags.bootClasspath, dep.HeaderJars...)
diff --git a/java/kotlin.go b/java/kotlin.go
index e4f1bc1..3e5cec0 100644
--- a/java/kotlin.go
+++ b/java/kotlin.go
@@ -34,7 +34,8 @@
`${config.GenKotlinBuildFileCmd} --classpath "$classpath" --name "$name"` +
` --out_dir "$classesDir" --srcs "$out.rsp" --srcs "$srcJarDir/list"` +
` $commonSrcFilesArg --out "$kotlinBuildFile" && ` +
- `${config.KotlincCmd} ${config.KotlincSuppressJDK9Warnings} ${config.JavacHeapFlags} ` +
+ `${config.KotlincCmd} ${config.KotlincGlobalFlags} ` +
+ `${config.KotlincSuppressJDK9Warnings} ${config.JavacHeapFlags} ` +
`$kotlincFlags -jvm-target $kotlinJvmTarget -Xbuild-file=$kotlinBuildFile ` +
`-kotlin-home $emptyDir && ` +
`${config.SoongZipCmd} -jar -o $out -C $classesDir -D $classesDir && ` +
@@ -125,7 +126,8 @@
`${config.GenKotlinBuildFileCmd} --classpath "$classpath" --name "$name"` +
` --srcs "$out.rsp" --srcs "$srcJarDir/list"` +
` $commonSrcFilesArg --out "$kotlinBuildFile" && ` +
- `${config.KotlincCmd} ${config.KaptSuppressJDK9Warnings} ${config.KotlincSuppressJDK9Warnings} ` +
+ `${config.KotlincCmd} ${config.KotlincGlobalFlags} ` +
+ `${config.KaptSuppressJDK9Warnings} ${config.KotlincSuppressJDK9Warnings} ` +
`${config.JavacHeapFlags} $kotlincFlags -Xplugin=${config.KotlinKaptJar} ` +
`-P plugin:org.jetbrains.kotlin.kapt3:sources=$kaptDir/sources ` +
`-P plugin:org.jetbrains.kotlin.kapt3:classes=$kaptDir/classes ` +
diff --git a/mk2rbc/mk2rbc.go b/mk2rbc/mk2rbc.go
index 35d7d4d..c881751 100644
--- a/mk2rbc/mk2rbc.go
+++ b/mk2rbc/mk2rbc.go
@@ -566,6 +566,12 @@
}
}
+ if asgn.lhs.valueType() == starlarkTypeString &&
+ asgn.value.typ() != starlarkTypeUnknown &&
+ asgn.value.typ() != starlarkTypeString {
+ asgn.value = &toStringExpr{expr: asgn.value}
+ }
+
asgn.previous = ctx.lastAssignment(lhs)
ctx.setLastAssignment(lhs, asgn)
switch a.Type {
@@ -1370,7 +1376,7 @@
if !args.Empty() {
return ctx.newBadExpr(node, "my-dir function cannot have any arguments passed to it.")
}
- return &variableRefExpr{ctx.addVariable("LOCAL_PATH"), true}
+ return &stringLiteralExpr{literal: filepath.Dir(ctx.script.mkFile)}
}
type isProductInListCallParser struct{}
diff --git a/mk2rbc/mk2rbc_test.go b/mk2rbc/mk2rbc_test.go
index 4084660..31739fa 100644
--- a/mk2rbc/mk2rbc_test.go
+++ b/mk2rbc/mk2rbc_test.go
@@ -254,6 +254,8 @@
in: `
$(warning this is the warning)
$(warning)
+$(warning # this warning starts with a pound)
+$(warning this warning has a # in the middle)
$(info this is the info)
$(error this is the error)
PRODUCT_NAME:=$(shell echo *)
@@ -264,6 +266,8 @@
cfg = rblf.cfg(handle)
rblf.mkwarning("product.mk", "this is the warning")
rblf.mkwarning("product.mk", "")
+ rblf.mkwarning("product.mk", "# this warning starts with a pound")
+ rblf.mkwarning("product.mk", "this warning has a # in the middle")
rblf.mkinfo("product.mk", "this is the info")
rblf.mkerror("product.mk", "this is the error")
cfg["PRODUCT_NAME"] = rblf.shell("echo *")
@@ -1265,7 +1269,7 @@
TEST_VAR_LIST += bar
TEST_VAR_2 := $(if $(TEST_VAR),bar)
TEST_VAR_3 := $(if $(TEST_VAR),bar,baz)
-TEST_VAR_3 := $(if $(TEST_VAR),$(TEST_VAR_LIST))
+TEST_VAR_4 := $(if $(TEST_VAR),$(TEST_VAR_LIST))
`,
expected: `load("//build/make/core:product_config.rbc", "rblf")
@@ -1276,7 +1280,7 @@
g["TEST_VAR_LIST"] += ["bar"]
g["TEST_VAR_2"] = ("bar" if g["TEST_VAR"] else "")
g["TEST_VAR_3"] = ("bar" if g["TEST_VAR"] else "baz")
- g["TEST_VAR_3"] = (g["TEST_VAR_LIST"] if g["TEST_VAR"] else [])
+ g["TEST_VAR_4"] = (g["TEST_VAR_LIST"] if g["TEST_VAR"] else [])
`,
},
{
@@ -1419,6 +1423,7 @@
# Duplicated variable
#RBC# type_hint list MY_VAR_2
#RBC# type_hint list my-local-var-with-dashes
+#RBC# type_hint string MY_STRING_VAR
MY_VAR := foo
MY_VAR_UNHINTED := foo
@@ -1431,6 +1436,8 @@
MY_VAR_4 := foo
my-local-var-with-dashes := foo
+
+MY_STRING_VAR := $(wildcard foo/bar.mk)
`,
expected: `# Test type hints
# Unsupported type
@@ -1448,9 +1455,23 @@
# Vars set after other statements still get the hint
g["MY_VAR_2"] = ["foo"]
# You can't specify a type hint after the first statement
- rblf.mk2rbc_error("product.mk:19", "type_hint annotations must come before the first Makefile statement")
+ rblf.mk2rbc_error("product.mk:20", "type_hint annotations must come before the first Makefile statement")
g["MY_VAR_4"] = "foo"
_my_local_var_with_dashes = ["foo"]
+ g["MY_STRING_VAR"] = " ".join(rblf.expand_wildcard("foo/bar.mk"))
+`,
+ },
+ {
+ desc: "Set LOCAL_PATH to my-dir",
+ mkname: "product.mk",
+ in: `
+LOCAL_PATH := $(call my-dir)
+`,
+ expected: `load("//build/make/core:product_config.rbc", "rblf")
+
+def init(g, handle):
+ cfg = rblf.cfg(handle)
+
`,
},
}
diff --git a/mk2rbc/variable.go b/mk2rbc/variable.go
index 506266a..be1b174 100644
--- a/mk2rbc/variable.go
+++ b/mk2rbc/variable.go
@@ -319,15 +319,13 @@
v = &localVariable{baseVariable{nam: name, typ: hintType}}
} else {
vt := hintType
- if strings.HasPrefix(name, "LOCAL_") && vt == starlarkTypeUnknown {
- // Heuristics: local variables that contribute to corresponding config variables
- if cfgVarName, found := localProductConfigVariables[name]; found {
- vi, found2 := KnownVariables[cfgVarName]
- if !found2 {
- panic(fmt.Errorf("unknown config variable %s for %s", cfgVarName, name))
- }
- vt = vi.valueType
+ // Heuristics: local variables that contribute to corresponding config variables
+ if cfgVarName, found := localProductConfigVariables[name]; found && vt == starlarkTypeUnknown {
+ vi, found2 := KnownVariables[cfgVarName]
+ if !found2 {
+ panic(fmt.Errorf("unknown config variable %s for %s", cfgVarName, name))
}
+ vt = vi.valueType
}
if strings.HasSuffix(name, "_LIST") && vt == starlarkTypeUnknown {
// Heuristics: Variables with "_LIST" suffix are lists
diff --git a/scripts/hiddenapi/signature_patterns.py b/scripts/hiddenapi/signature_patterns.py
index e75ee95..5a82be7 100755
--- a/scripts/hiddenapi/signature_patterns.py
+++ b/scripts/hiddenapi/signature_patterns.py
@@ -25,92 +25,138 @@
import sys
-def dict_reader(csvfile):
+def dict_reader(csv_file):
return csv.DictReader(
- csvfile, delimiter=',', quotechar='|', fieldnames=['signature'])
+ csv_file, delimiter=',', quotechar='|', fieldnames=['signature'])
-def dotPackageToSlashPackage(pkg):
+def dot_package_to_slash_package(pkg):
return pkg.replace('.', '/')
-def slashPackageToDotPackage(pkg):
+def dot_packages_to_slash_packages(pkgs):
+ return [dot_package_to_slash_package(p) for p in pkgs]
+
+
+def slash_package_to_dot_package(pkg):
return pkg.replace('/', '.')
-def isSplitPackage(splitPackages, pkg):
- return splitPackages and (pkg in splitPackages or '*' in splitPackages)
+def slash_packages_to_dot_packages(pkgs):
+ return [slash_package_to_dot_package(p) for p in pkgs]
-def matchedByPackagePrefixPattern(packagePrefixes, prefix):
- for packagePrefix in packagePrefixes:
+def is_split_package(split_packages, pkg):
+ return split_packages and (pkg in split_packages or '*' in split_packages)
+
+
+def matched_by_package_prefix_pattern(package_prefixes, prefix):
+ for packagePrefix in package_prefixes:
if prefix == packagePrefix:
return packagePrefix
- elif prefix.startswith(packagePrefix) and prefix[len(
- packagePrefix)] == '/':
+ if (prefix.startswith(packagePrefix) and
+ prefix[len(packagePrefix)] == '/'):
return packagePrefix
return False
-def validate_package_prefixes(splitPackages, packagePrefixes):
+def validate_package_is_not_matched_by_package_prefix(package_type, pkg,
+ package_prefixes):
+ package_prefix = matched_by_package_prefix_pattern(package_prefixes, pkg)
+ if package_prefix:
+ # A package prefix matches the package.
+ package_for_output = slash_package_to_dot_package(pkg)
+ package_prefix_for_output = slash_package_to_dot_package(package_prefix)
+ return [
+ f'{package_type} {package_for_output} is matched by '
+ f'package prefix {package_prefix_for_output}'
+ ]
+ return []
+
+
+def validate_package_prefixes(split_packages, single_packages,
+ package_prefixes):
# If there are no package prefixes then there is no possible conflict
# between them and the split packages.
- if len(packagePrefixes) == 0:
- return
+ if len(package_prefixes) == 0:
+ return []
# Check to make sure that the split packages and package prefixes do not
# overlap.
errors = []
- for splitPackage in splitPackages:
- if splitPackage == '*':
+ for split_package in split_packages:
+ if split_package == '*':
# A package prefix matches a split package.
- packagePrefixesForOutput = ', '.join(
- map(slashPackageToDotPackage, packagePrefixes))
+ package_prefixes_for_output = ', '.join(
+ slash_packages_to_dot_packages(package_prefixes))
errors.append(
- 'split package "*" conflicts with all package prefixes %s\n'
- ' add split_packages:[] to fix' % packagePrefixesForOutput)
+ "split package '*' conflicts with all package prefixes "
+ f'{package_prefixes_for_output}\n'
+ ' add split_packages:[] to fix')
else:
- packagePrefix = matchedByPackagePrefixPattern(
- packagePrefixes, splitPackage)
- if packagePrefix:
- # A package prefix matches a split package.
- splitPackageForOutput = slashPackageToDotPackage(splitPackage)
- packagePrefixForOutput = slashPackageToDotPackage(packagePrefix)
- errors.append(
- 'split package %s is matched by package prefix %s' %
- (splitPackageForOutput, packagePrefixForOutput))
+ errs = validate_package_is_not_matched_by_package_prefix(
+ 'split package', split_package, package_prefixes)
+ errors.extend(errs)
+
+ # Check to make sure that the single packages and package prefixes do not
+ # overlap.
+ for single_package in single_packages:
+ errs = validate_package_is_not_matched_by_package_prefix(
+ 'single package', single_package, package_prefixes)
+ errors.extend(errs)
return errors
-def validate_split_packages(splitPackages):
+def validate_split_packages(split_packages):
errors = []
- if '*' in splitPackages and len(splitPackages) > 1:
+ if '*' in split_packages and len(split_packages) > 1:
errors.append('split packages are invalid as they contain both the'
' wildcard (*) and specific packages, use the wildcard or'
' specific packages, not a mixture')
return errors
-def produce_patterns_from_file(file, splitPackages=None, packagePrefixes=None):
- with open(file, 'r') as f:
- return produce_patterns_from_stream(f, splitPackages, packagePrefixes)
+def validate_single_packages(split_packages, single_packages):
+ overlaps = []
+ for single_package in single_packages:
+ if single_package in split_packages:
+ overlaps.append(single_package)
+ if overlaps:
+ indented = ''.join([f'\n {o}' for o in overlaps])
+ return [
+ f'single_packages and split_packages overlap, please ensure the '
+ f'following packages are only present in one:{indented}'
+ ]
+ return []
+
+
+def produce_patterns_from_file(file,
+ split_packages=None,
+ single_packages=None,
+ package_prefixes=None):
+ with open(file, 'r', encoding='utf8') as f:
+ return produce_patterns_from_stream(f, split_packages, single_packages,
+ package_prefixes)
def produce_patterns_from_stream(stream,
- splitPackages=None,
- packagePrefixes=None):
- splitPackages = set(splitPackages or [])
- packagePrefixes = list(packagePrefixes or [])
+ split_packages=None,
+ single_packages=None,
+ package_prefixes=None):
+ split_packages = set(split_packages or [])
+ single_packages = set(single_packages or [])
+ package_prefixes = list(package_prefixes or [])
# Read in all the signatures into a list and remove any unnecessary class
# and member names.
patterns = set()
+ unmatched_packages = set()
for row in dict_reader(stream):
signature = row['signature']
text = signature.removeprefix('L')
# Remove the class specific member signature
pieces = text.split(';->')
- qualifiedClassName = pieces[0]
- pieces = qualifiedClassName.rsplit('/', maxsplit=1)
+ qualified_class_name = pieces[0]
+ pieces = qualified_class_name.rsplit('/', maxsplit=1)
pkg = pieces[0]
# If the package is split across multiple modules then it cannot be used
# to select the subset of the monolithic flags that this module
@@ -121,27 +167,54 @@
# If the package is not split then every class in the package must be
# provided by this module so there is no need to list the classes
# explicitly so just use the package name instead.
- if isSplitPackage(splitPackages, pkg):
+ if is_split_package(split_packages, pkg):
# Remove inner class names.
- pieces = qualifiedClassName.split('$', maxsplit=1)
+ pieces = qualified_class_name.split('$', maxsplit=1)
pattern = pieces[0]
- else:
+ patterns.add(pattern)
+ elif pkg in single_packages:
# Add a * to ensure that the pattern matches the classes in that
# package.
pattern = pkg + '/*'
- patterns.add(pattern)
+ patterns.add(pattern)
+ else:
+ unmatched_packages.add(pkg)
+
+ # Remove any unmatched packages that would be matched by a package prefix
+ # pattern.
+ unmatched_packages = [
+ p for p in unmatched_packages
+ if not matched_by_package_prefix_pattern(package_prefixes, p)
+ ]
+ errors = []
+ if unmatched_packages:
+ unmatched_packages.sort()
+ indented = ''.join([
+ f'\n {slash_package_to_dot_package(p)}'
+ for p in unmatched_packages
+ ])
+ errors.append('The following packages were unexpected, please add them '
+ 'to one of the hidden_api properties, split_packages, '
+ f'single_packages or package_prefixes:{indented}')
# Remove any patterns that would be matched by a package prefix pattern.
- patterns = list(
- filter(lambda p: not matchedByPackagePrefixPattern(packagePrefixes, p),
- patterns))
+ patterns = [
+ p for p in patterns
+ if not matched_by_package_prefix_pattern(package_prefixes, p)
+ ]
# Add the package prefix patterns to the list. Add a ** to ensure that each
# package prefix pattern will match the classes in that package and all
# sub-packages.
- patterns = patterns + list(map(lambda x: x + '/**', packagePrefixes))
+ patterns = patterns + [f'{p}/**' for p in package_prefixes]
# Sort the patterns.
patterns.sort()
- return patterns
+ return patterns, errors
+
+
+def print_and_exit(errors):
+ for error in errors:
+ print(error)
+ sys.exit(1)
def main(args):
@@ -155,35 +228,50 @@
args_parser.add_argument(
'--split-package',
action='append',
- help='A package that is split across multiple bootclasspath_fragment modules'
- )
+ help='A package that is split across multiple bootclasspath_fragment '
+ 'modules')
args_parser.add_argument(
'--package-prefix',
action='append',
help='A package prefix unique to this set of flags')
+ args_parser.add_argument(
+ '--single-package',
+ action='append',
+ help='A single package unique to this set of flags')
args_parser.add_argument('--output', help='Generated signature prefixes')
args = args_parser.parse_args(args)
- splitPackages = set(map(dotPackageToSlashPackage, args.split_package or []))
- errors = validate_split_packages(splitPackages)
+ split_packages = set(
+ dot_packages_to_slash_packages(args.split_package or []))
+ errors = validate_split_packages(split_packages)
+ if errors:
+ print_and_exit(errors)
- packagePrefixes = list(
- map(dotPackageToSlashPackage, args.package_prefix or []))
+ single_packages = list(
+ dot_packages_to_slash_packages(args.single_package or []))
- if not errors:
- errors = validate_package_prefixes(splitPackages, packagePrefixes)
+ errors = validate_single_packages(split_packages, single_packages)
+ if errors:
+ print_and_exit(errors)
+
+ package_prefixes = dot_packages_to_slash_packages(args.package_prefix or [])
+
+ errors = validate_package_prefixes(split_packages, single_packages,
+ package_prefixes)
+ if errors:
+ print_and_exit(errors)
+
+ patterns = []
+ # Read in all the patterns into a list.
+ patterns, errors = produce_patterns_from_file(args.flags, split_packages,
+ single_packages,
+ package_prefixes)
if errors:
- for error in errors:
- print(error)
- sys.exit(1)
-
- # Read in all the patterns into a list.
- patterns = produce_patterns_from_file(args.flags, splitPackages,
- packagePrefixes)
+ print_and_exit(errors)
# Write out all the patterns.
- with open(args.output, 'w') as outputFile:
+ with open(args.output, 'w', encoding='utf8') as outputFile:
for pattern in patterns:
outputFile.write(pattern)
outputFile.write('\n')
diff --git a/scripts/hiddenapi/signature_patterns_test.py b/scripts/hiddenapi/signature_patterns_test.py
index b59dfd7..90b3d0b 100755
--- a/scripts/hiddenapi/signature_patterns_test.py
+++ b/scripts/hiddenapi/signature_patterns_test.py
@@ -17,37 +17,52 @@
import io
import unittest
-from signature_patterns import * #pylint: disable=unused-wildcard-import,wildcard-import
+import signature_patterns
class TestGeneratedPatterns(unittest.TestCase):
- csvFlags = """
+ csv_flags = """
Ljava/lang/ProcessBuilder$Redirect$1;-><init>()V,blocked
Ljava/lang/Character$UnicodeScript;->of(I)Ljava/lang/Character$UnicodeScript;,public-api
Ljava/lang/Object;->hashCode()I,public-api,system-api,test-api
Ljava/lang/Object;->toString()Ljava/lang/String;,blocked
"""
- def produce_patterns_from_string(self,
- csv,
- splitPackages=None,
- packagePrefixes=None):
- with io.StringIO(csv) as f:
- return produce_patterns_from_stream(f, splitPackages,
- packagePrefixes)
+ @staticmethod
+ def produce_patterns_from_string(csv_text,
+ split_packages=None,
+ single_packages=None,
+ package_prefixes=None):
+ with io.StringIO(csv_text) as f:
+ return signature_patterns.produce_patterns_from_stream(
+ f, split_packages, single_packages, package_prefixes)
+
+ def test_generate_unmatched(self):
+ _, errors = self.produce_patterns_from_string(
+ TestGeneratedPatterns.csv_flags)
+ self.assertEqual([
+ 'The following packages were unexpected, please add them to one of '
+ 'the hidden_api properties, split_packages, single_packages or '
+ 'package_prefixes:\n'
+ ' java.lang'
+ ], errors)
def test_generate_default(self):
- patterns = self.produce_patterns_from_string(
- TestGeneratedPatterns.csvFlags)
+ patterns, errors = self.produce_patterns_from_string(
+ TestGeneratedPatterns.csv_flags, single_packages=['java/lang'])
+ self.assertEqual([], errors)
+
expected = [
'java/lang/*',
]
self.assertEqual(expected, patterns)
def test_generate_split_package(self):
- patterns = self.produce_patterns_from_string(
- TestGeneratedPatterns.csvFlags, splitPackages={'java/lang'})
+ patterns, errors = self.produce_patterns_from_string(
+ TestGeneratedPatterns.csv_flags, split_packages={'java/lang'})
+ self.assertEqual([], errors)
+
expected = [
'java/lang/Character',
'java/lang/Object',
@@ -56,8 +71,10 @@
self.assertEqual(expected, patterns)
def test_generate_split_package_wildcard(self):
- patterns = self.produce_patterns_from_string(
- TestGeneratedPatterns.csvFlags, splitPackages={'*'})
+ patterns, errors = self.produce_patterns_from_string(
+ TestGeneratedPatterns.csv_flags, split_packages={'*'})
+ self.assertEqual([], errors)
+
expected = [
'java/lang/Character',
'java/lang/Object',
@@ -66,23 +83,27 @@
self.assertEqual(expected, patterns)
def test_generate_package_prefix(self):
- patterns = self.produce_patterns_from_string(
- TestGeneratedPatterns.csvFlags, packagePrefixes={'java/lang'})
+ patterns, errors = self.produce_patterns_from_string(
+ TestGeneratedPatterns.csv_flags, package_prefixes={'java/lang'})
+ self.assertEqual([], errors)
+
expected = [
'java/lang/**',
]
self.assertEqual(expected, patterns)
def test_generate_package_prefix_top_package(self):
- patterns = self.produce_patterns_from_string(
- TestGeneratedPatterns.csvFlags, packagePrefixes={'java'})
+ patterns, errors = self.produce_patterns_from_string(
+ TestGeneratedPatterns.csv_flags, package_prefixes={'java'})
+ self.assertEqual([], errors)
+
expected = [
'java/**',
]
self.assertEqual(expected, patterns)
def test_split_package_wildcard_conflicts_with_other_split_packages(self):
- errors = validate_split_packages({'*', 'java'})
+ errors = signature_patterns.validate_split_packages({'*', 'java'})
expected = [
'split packages are invalid as they contain both the wildcard (*)'
' and specific packages, use the wildcard or specific packages,'
@@ -91,21 +112,39 @@
self.assertEqual(expected, errors)
def test_split_package_wildcard_conflicts_with_package_prefixes(self):
- errors = validate_package_prefixes({'*'}, packagePrefixes={'java'})
+ errors = signature_patterns.validate_package_prefixes(
+ {'*'}, [], package_prefixes={'java'})
expected = [
- 'split package "*" conflicts with all package prefixes java\n'
+ "split package '*' conflicts with all package prefixes java\n"
' add split_packages:[] to fix',
]
self.assertEqual(expected, errors)
- def test_split_package_conflict(self):
- errors = validate_package_prefixes({'java/split'},
- packagePrefixes={'java'})
+ def test_split_package_conflicts_with_package_prefixes(self):
+ errors = signature_patterns.validate_package_prefixes(
+ {'java/split'}, [], package_prefixes={'java'})
expected = [
'split package java.split is matched by package prefix java',
]
self.assertEqual(expected, errors)
+ def test_single_package_conflicts_with_package_prefixes(self):
+ errors = signature_patterns.validate_package_prefixes(
+ {}, ['java/single'], package_prefixes={'java'})
+ expected = [
+ 'single package java.single is matched by package prefix java',
+ ]
+ self.assertEqual(expected, errors)
+
+ def test_single_package_conflicts_with_split_packages(self):
+ errors = signature_patterns.validate_single_packages({'java/pkg'},
+ ['java/pkg'])
+ expected = [
+ 'single_packages and split_packages overlap, please ensure the '
+ 'following packages are only present in one:\n java/pkg'
+ ]
+ self.assertEqual(expected, errors)
+
if __name__ == '__main__':
unittest.main(verbosity=2)
diff --git a/tests/lib.sh b/tests/lib.sh
index e6074f8..55f9ab4 100644
--- a/tests/lib.sh
+++ b/tests/lib.sh
@@ -86,6 +86,7 @@
symlink_directory prebuilts/go
symlink_directory prebuilts/build-tools
+ symlink_directory prebuilts/clang/host
symlink_directory external/go-cmp
symlink_directory external/golang-protobuf
diff --git a/ui/build/build.go b/ui/build/build.go
index 2e44aaa..d261f89 100644
--- a/ui/build/build.go
+++ b/ui/build/build.go
@@ -264,6 +264,7 @@
if config.StartRBE() {
startRBE(ctx, config)
+ defer DumpRBEMetrics(ctx, config, filepath.Join(config.LogsDir(), "rbe_metrics.pb"))
}
if what&RunProductConfig != 0 {
diff --git a/ui/build/config.go b/ui/build/config.go
index 01fe8fa..dd5bd0c 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -187,7 +187,7 @@
}
if err := fetchEnvConfig(ctx, config, bc); err != nil {
- fmt.Fprintf(os.Stderr, "Failed to fetch config file: %v", err)
+ fmt.Fprintf(os.Stderr, "Failed to fetch config file: %v\n", err)
}
configDirs := []string{
@@ -1191,7 +1191,12 @@
}
func (c *configImpl) rbeAuth() (string, string) {
- credFlags := []string{"use_application_default_credentials", "use_gce_credentials", "credential_file"}
+ credFlags := []string{
+ "use_application_default_credentials",
+ "use_gce_credentials",
+ "credential_file",
+ "use_google_prod_creds",
+ }
for _, cf := range credFlags {
for _, f := range []string{"RBE_" + cf, "FLAG_" + cf} {
if v, ok := c.environ.Get(f); ok {