Merge "transitive Java deps for r8"
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index 87554a2..0c1be6e 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -669,6 +669,13 @@
// kotlin srcs in java libs
"CtsPkgInstallerConstants",
"kotlinx_atomicfu",
+
+ // kotlin srcs in java binary
+ "AnalyzerKt",
+ "trebuchet-core",
+
+ // kotlin srcs in android_library
+ "renderscript_toolkit",
}
Bp2buildModuleTypeAlwaysConvertList = []string{
@@ -1318,8 +1325,6 @@
"libc_musl_sysroot",
}
- Bp2buildCcLibraryStaticOnlyList = []string{}
-
MixedBuildsDisabledList = []string{
"libruy_static", "libtflite_kernel_utils", // TODO(b/237315968); Depend on prebuilt stl, not from source
@@ -1379,5 +1384,9 @@
StagingMixedBuildsEnabledList = []string{
"com.android.adbd",
"adbd_test",
+ "adb_crypto_test",
+ "adb_pairing_auth_test",
+ "adb_pairing_connection_test",
+ "adb_tls_connection_test",
}
)
diff --git a/android/bazel.go b/android/bazel.go
index 3731dfe..10e9251 100644
--- a/android/bazel.go
+++ b/android/bazel.go
@@ -66,8 +66,8 @@
//
// This is a bool pointer to support tristates: true, false, not set.
//
- // To opt-in a module, set bazel_module: { bp2build_available: true }
- // To opt-out a module, set bazel_module: { bp2build_available: false }
+ // To opt in a module, set bazel_module: { bp2build_available: true }
+ // To opt out a module, set bazel_module: { bp2build_available: false }
// To defer the default setting for the directory, do not set the value.
Bp2build_available *bool
@@ -126,7 +126,7 @@
// one with the single member called Soong_config_variables, which itself is
// a struct containing fields for each supported feature in that namespace.
//
- // The reason for using an slice of interface{} is to support defaults
+ // The reason for using a slice of interface{} is to support defaults
// propagation of the struct pointers.
namespacedVariableProps() namespacedVariableProperties
setNamespacedVariableProps(props namespacedVariableProperties)
@@ -237,16 +237,6 @@
// Per-module denylist to always opt modules out of bp2build conversion.
moduleDoNotConvert map[string]bool
-
- // Per-module denylist of cc_library modules to only generate the static
- // variant if their shared variant isn't ready or buildable by Bazel.
- ccLibraryStaticOnly map[string]bool
-}
-
-// GenerateCcLibraryStaticOnly returns whether a cc_library module should only
-// generate a static version of itself based on the current global configuration.
-func (a Bp2BuildConversionAllowlist) GenerateCcLibraryStaticOnly(moduleName string) bool {
- return a.ccLibraryStaticOnly[moduleName]
}
// NewBp2BuildAllowlist creates a new, empty Bp2BuildConversionAllowlist
@@ -258,7 +248,6 @@
map[string]bool{},
map[string]bool{},
map[string]bool{},
- map[string]bool{},
}
}
@@ -322,18 +311,6 @@
return a
}
-// SetCcLibraryStaticOnlyList copies the entries from ccLibraryStaticOnly into the allowlist
-func (a Bp2BuildConversionAllowlist) SetCcLibraryStaticOnlyList(ccLibraryStaticOnly []string) Bp2BuildConversionAllowlist {
- if a.ccLibraryStaticOnly == nil {
- a.ccLibraryStaticOnly = map[string]bool{}
- }
- for _, m := range ccLibraryStaticOnly {
- a.ccLibraryStaticOnly[m] = true
- }
-
- return a
-}
-
// ShouldKeepExistingBuildFileForDir returns whether an existing BUILD file should be
// added to the build symlink forest based on the current global configuration.
func (a Bp2BuildConversionAllowlist) ShouldKeepExistingBuildFileForDir(dir string) bool {
@@ -365,8 +342,7 @@
SetKeepExistingBuildFile(allowlists.Bp2buildKeepExistingBuildFile).
SetModuleAlwaysConvertList(allowlists.Bp2buildModuleAlwaysConvertList).
SetModuleTypeAlwaysConvertList(allowlists.Bp2buildModuleTypeAlwaysConvertList).
- SetModuleDoNotConvertList(allowlists.Bp2buildModuleDoNotConvertList).
- SetCcLibraryStaticOnlyList(allowlists.Bp2buildCcLibraryStaticOnlyList)
+ SetModuleDoNotConvertList(allowlists.Bp2buildModuleDoNotConvertList)
}).(Bp2BuildConversionAllowlist)
}
@@ -375,30 +351,16 @@
// method will also log whether this module is mixed build enabled for
// metrics reporting.
func MixedBuildsEnabled(ctx BaseModuleContext) bool {
- mixedBuildEnabled := mixedBuildPossible(ctx)
+ module := ctx.Module()
+ mixedBuildEnabled := ctx.Config().IsMixedBuildsEnabled() &&
+ ctx.Os() != Windows && // Windows toolchains are not currently supported.
+ module.Enabled() &&
+ convertedToBazel(ctx, module) &&
+ ctx.Config().BazelContext.IsModuleNameAllowed(module.Name())
ctx.Config().LogMixedBuild(ctx, mixedBuildEnabled)
return mixedBuildEnabled
}
-// mixedBuildPossible returns true if a module is ready to be replaced by a
-// converted or handcrafted Bazel target.
-func mixedBuildPossible(ctx BaseModuleContext) bool {
- if !ctx.Config().IsMixedBuildsEnabled() {
- return false
- }
- if ctx.Os() == Windows {
- // Windows toolchains are not currently supported.
- return false
- }
- if !ctx.Module().Enabled() {
- return false
- }
- if !convertedToBazel(ctx, ctx.Module()) {
- return false
- }
- return ctx.Config().BazelContext.BazelAllowlisted(ctx.Module().Name())
-}
-
// ConvertedToBazel returns whether this module has been converted (with bp2build or manually) to Bazel.
func convertedToBazel(ctx BazelConversionContext, module blueprint.Module) bool {
b, ok := module.(Bazelable)
diff --git a/android/bazel_handler.go b/android/bazel_handler.go
index 40cc6a2..8d45041 100644
--- a/android/bazel_handler.go
+++ b/android/bazel_handler.go
@@ -152,7 +152,7 @@
// Note that this only implies "bazel mixed build" allowlisting. The caller
// should independently verify the module is eligible for Bazel handling
// (for example, that it is MixedBuildBuildable).
- BazelAllowlisted(moduleName string) bool
+ IsModuleNameAllowed(moduleName string) bool
// Returns the bazel output base (the root directory for all bazel intermediate outputs).
OutputBase() string
@@ -181,7 +181,7 @@
// A context object which tracks queued requests that need to be made to Bazel,
// and their results after the requests have been made.
-type bazelContext struct {
+type mixedBuildBazelContext struct {
bazelRunner
paths *bazelPaths
requests map[cqueryKey]bool // cquery requests that have not yet been issued to Bazel
@@ -210,7 +210,7 @@
targetBuildVariant string
}
-var _ BazelContext = &bazelContext{}
+var _ BazelContext = &mixedBuildBazelContext{}
// A bazel context to use when Bazel is disabled.
type noopBazelContext struct{}
@@ -261,7 +261,7 @@
panic("unimplemented")
}
-func (m MockBazelContext) BazelAllowlisted(_ string) bool {
+func (m MockBazelContext) IsModuleNameAllowed(_ string) bool {
return true
}
@@ -277,14 +277,14 @@
var _ BazelContext = MockBazelContext{}
-func (bazelCtx *bazelContext) QueueBazelRequest(label string, requestType cqueryRequest, cfgKey configKey) {
+func (bazelCtx *mixedBuildBazelContext) QueueBazelRequest(label string, requestType cqueryRequest, cfgKey configKey) {
key := makeCqueryKey(label, requestType, cfgKey)
bazelCtx.requestMutex.Lock()
defer bazelCtx.requestMutex.Unlock()
bazelCtx.requests[key] = true
}
-func (bazelCtx *bazelContext) GetOutputFiles(label string, cfgKey configKey) ([]string, error) {
+func (bazelCtx *mixedBuildBazelContext) GetOutputFiles(label string, cfgKey configKey) ([]string, error) {
key := makeCqueryKey(label, cquery.GetOutputFiles, cfgKey)
if rawString, ok := bazelCtx.results[key]; ok {
bazelOutput := strings.TrimSpace(rawString)
@@ -294,7 +294,7 @@
return nil, fmt.Errorf("no bazel response found for %v", key)
}
-func (bazelCtx *bazelContext) GetCcInfo(label string, cfgKey configKey) (cquery.CcInfo, error) {
+func (bazelCtx *mixedBuildBazelContext) GetCcInfo(label string, cfgKey configKey) (cquery.CcInfo, error) {
key := makeCqueryKey(label, cquery.GetCcInfo, cfgKey)
if rawString, ok := bazelCtx.results[key]; ok {
bazelOutput := strings.TrimSpace(rawString)
@@ -303,7 +303,7 @@
return cquery.CcInfo{}, fmt.Errorf("no bazel response found for %v", key)
}
-func (bazelCtx *bazelContext) GetPythonBinary(label string, cfgKey configKey) (string, error) {
+func (bazelCtx *mixedBuildBazelContext) GetPythonBinary(label string, cfgKey configKey) (string, error) {
key := makeCqueryKey(label, cquery.GetPythonBinary, cfgKey)
if rawString, ok := bazelCtx.results[key]; ok {
bazelOutput := strings.TrimSpace(rawString)
@@ -312,7 +312,7 @@
return "", fmt.Errorf("no bazel response found for %v", key)
}
-func (bazelCtx *bazelContext) GetApexInfo(label string, cfgKey configKey) (cquery.ApexInfo, error) {
+func (bazelCtx *mixedBuildBazelContext) GetApexInfo(label string, cfgKey configKey) (cquery.ApexInfo, error) {
key := makeCqueryKey(label, cquery.GetApexInfo, cfgKey)
if rawString, ok := bazelCtx.results[key]; ok {
return cquery.GetApexInfo.ParseResult(strings.TrimSpace(rawString))
@@ -320,7 +320,7 @@
return cquery.ApexInfo{}, fmt.Errorf("no bazel response found for %v", key)
}
-func (bazelCtx *bazelContext) GetCcUnstrippedInfo(label string, cfgKey configKey) (cquery.CcUnstrippedInfo, error) {
+func (bazelCtx *mixedBuildBazelContext) GetCcUnstrippedInfo(label string, cfgKey configKey) (cquery.CcUnstrippedInfo, error) {
key := makeCqueryKey(label, cquery.GetCcUnstrippedInfo, cfgKey)
if rawString, ok := bazelCtx.results[key]; ok {
return cquery.GetCcUnstrippedInfo.ParseResult(strings.TrimSpace(rawString))
@@ -361,7 +361,7 @@
return ""
}
-func (n noopBazelContext) BazelAllowlisted(_ string) bool {
+func (n noopBazelContext) IsModuleNameAllowed(_ string) bool {
return false
}
@@ -396,12 +396,6 @@
enabledModules[enabledAdHocModule] = true
}
case BazelDevMode:
- // Don't use partially-converted cc_library targets in mixed builds,
- // since mixed builds would generally rely on both static and shared
- // variants of a cc_library.
- for staticOnlyModule := range GetBp2BuildAllowList().ccLibraryStaticOnly {
- disabledModules[staticOnlyModule] = true
- }
addToStringSet(disabledModules, allowlists.MixedBuildsDisabledList)
default:
panic("Expected BazelProdMode, BazelStagingMode, or BazelDevMode")
@@ -475,7 +469,7 @@
targetProduct = c.DeviceProduct()
}
- return &bazelContext{
+ return &mixedBuildBazelContext{
bazelRunner: &builtinBazelRunner{},
paths: &paths,
requests: make(map[cqueryKey]bool),
@@ -491,7 +485,7 @@
return p.metricsDir
}
-func (context *bazelContext) BazelAllowlisted(moduleName string) bool {
+func (context *mixedBuildBazelContext) IsModuleNameAllowed(moduleName string) bool {
if context.bazelDisabledModules[moduleName] {
return false
}
@@ -618,7 +612,7 @@
}
-func (context *bazelContext) mainBzlFileContents() []byte {
+func (context *mixedBuildBazelContext) mainBzlFileContents() []byte {
// TODO(cparsons): Define configuration transitions programmatically based
// on available archs.
contents := `
@@ -687,7 +681,7 @@
return []byte(productReplacer.Replace(contents))
}
-func (context *bazelContext) mainBuildFileContents() []byte {
+func (context *mixedBuildBazelContext) mainBuildFileContents() []byte {
// TODO(cparsons): Map label to attribute programmatically; don't use hard-coded
// architecture mapping.
formatString := `
@@ -751,10 +745,10 @@
// Returns the file contents of the buildroot.cquery file that should be used for the cquery
// expression in order to obtain information about buildroot and its dependencies.
-// The contents of this file depend on the bazelContext's requests; requests are enumerated
+// The contents of this file depend on the mixedBuildBazelContext's requests; requests are enumerated
// and grouped by their request type. The data retrieved for each label depends on its
// request type.
-func (context *bazelContext) cqueryStarlarkFileContents() []byte {
+func (context *mixedBuildBazelContext) cqueryStarlarkFileContents() []byte {
requestTypeToCqueryIdEntries := map[cqueryRequest][]string{}
for val := range context.requests {
cqueryId := getCqueryId(val)
@@ -912,7 +906,7 @@
// Issues commands to Bazel to receive results for all cquery requests
// queued in the BazelContext.
-func (context *bazelContext) InvokeBazel(config Config, ctx *Context) error {
+func (context *mixedBuildBazelContext) InvokeBazel(config Config, ctx *Context) error {
if ctx != nil {
ctx.EventHandler.Begin("bazel")
defer ctx.EventHandler.End("bazel")
@@ -939,7 +933,7 @@
return nil
}
-func (context *bazelContext) runCquery(ctx *Context) error {
+func (context *mixedBuildBazelContext) runCquery(ctx *Context) error {
if ctx != nil {
ctx.EventHandler.Begin("cquery")
defer ctx.EventHandler.End("cquery")
@@ -994,7 +988,7 @@
return nil
}
-func (context *bazelContext) runAquery(config Config, ctx *Context) error {
+func (context *mixedBuildBazelContext) runAquery(config Config, ctx *Context) error {
if ctx != nil {
ctx.EventHandler.Begin("aquery")
defer ctx.EventHandler.End("aquery")
@@ -1032,7 +1026,7 @@
return err
}
-func (context *bazelContext) generateBazelSymlinks(ctx *Context) error {
+func (context *mixedBuildBazelContext) generateBazelSymlinks(ctx *Context) error {
if ctx != nil {
ctx.EventHandler.Begin("symlinks")
defer ctx.EventHandler.End("symlinks")
@@ -1044,15 +1038,15 @@
return err
}
-func (context *bazelContext) BuildStatementsToRegister() []bazel.BuildStatement {
+func (context *mixedBuildBazelContext) BuildStatementsToRegister() []bazel.BuildStatement {
return context.buildStatements
}
-func (context *bazelContext) AqueryDepsets() []bazel.AqueryDepset {
+func (context *mixedBuildBazelContext) AqueryDepsets() []bazel.AqueryDepset {
return context.depsets
}
-func (context *bazelContext) OutputBase() string {
+func (context *mixedBuildBazelContext) OutputBase() string {
return context.paths.outputBase
}
diff --git a/android/bazel_handler_test.go b/android/bazel_handler_test.go
index 10bbf31..013e19c 100644
--- a/android/bazel_handler_test.go
+++ b/android/bazel_handler_test.go
@@ -189,7 +189,7 @@
return actual
}
-func testBazelContext(t *testing.T, bazelCommandResults map[bazelCommand]string) (*bazelContext, string) {
+func testBazelContext(t *testing.T, bazelCommandResults map[bazelCommand]string) (*mixedBuildBazelContext, string) {
t.Helper()
p := bazelPaths{
soongOutDir: t.TempDir(),
@@ -201,7 +201,7 @@
bazelCommandResults[aqueryCommand] = ""
}
runner := &mockBazelRunner{bazelCommandResults: bazelCommandResults}
- return &bazelContext{
+ return &mixedBuildBazelContext{
bazelRunner: runner,
paths: &p,
requests: map[cqueryKey]bool{},
diff --git a/android/bazel_paths.go b/android/bazel_paths.go
index 1ecb0af..e151521 100644
--- a/android/bazel_paths.go
+++ b/android/bazel_paths.go
@@ -496,13 +496,15 @@
if err != nil {
reportPathError(ctx, err)
}
- relativeRootPath := filepath.Join("execroot", "__main__", relativeRoot)
- if pathComponents := strings.Split(path, "/"); len(pathComponents) >= 3 &&
+ var relativeRootPath string
+ if pathComponents := strings.SplitN(path, "/", 4); len(pathComponents) >= 3 &&
pathComponents[0] == "bazel-out" && pathComponents[2] == "bin" {
// If the path starts with something like: bazel-out/linux_x86_64-fastbuild-ST-b4ef1c4402f9/bin/
// make it relative to that folder. bazel-out/volatile-status.txt is an example
// of something that starts with bazel-out but is not relative to the bin folder
relativeRootPath = filepath.Join("execroot", "__main__", pathComponents[0], pathComponents[1], pathComponents[2], relativeRoot)
+ } else {
+ relativeRootPath = filepath.Join("execroot", "__main__", relativeRoot)
}
var relPath string
diff --git a/android/bazel_test.go b/android/bazel_test.go
index 7b38b6a..87b2c8f 100644
--- a/android/bazel_test.go
+++ b/android/bazel_test.go
@@ -417,11 +417,6 @@
t.Errorf("bp2build module do not convert of %s: expected: true, got: %v", k, allowlist.moduleDoNotConvert[k])
}
}
- for _, k := range allowlists.Bp2buildCcLibraryStaticOnlyList {
- if !allowlist.ccLibraryStaticOnly[k] {
- t.Errorf("bp2build cc library static only of %s: expected: true, got: %v", k, allowlist.ccLibraryStaticOnly[k])
- }
- }
}
func TestShouldKeepExistingBuildFileForDir(t *testing.T) {
diff --git a/android/config.go b/android/config.go
index d5ed883..a8b0a40 100644
--- a/android/config.go
+++ b/android/config.go
@@ -583,32 +583,28 @@
c.mockBpList = blueprint.MockModuleListFile
}
+// TODO(b/265062549): Add a field to our collected (and uploaded) metrics which
+// describes a reason that we fell back to non-mixed builds.
// Returns true if "Bazel builds" is enabled. In this mode, part of build
// analysis is handled by Bazel.
func (c *config) IsMixedBuildsEnabled() bool {
globalMixedBuildsSupport := c.Once(OnceKey{"globalMixedBuildsSupport"}, func() interface{} {
if c.productVariables.DeviceArch != nil && *c.productVariables.DeviceArch == "riscv64" {
- fmt.Fprintln(os.Stderr, "unsupported device arch 'riscv64' for Bazel: falling back to non-mixed build")
return false
}
if c.IsEnvTrue("GLOBAL_THINLTO") {
- fmt.Fprintln(os.Stderr, "unsupported env var GLOBAL_THINLTO for Bazel: falling back to non-mixed build")
return false
}
if len(c.productVariables.SanitizeHost) > 0 {
- fmt.Fprintln(os.Stderr, "unsupported product var SanitizeHost for Bazel: falling back to non-mixed build")
return false
}
if len(c.productVariables.SanitizeDevice) > 0 {
- fmt.Fprintln(os.Stderr, "unsupported product var SanitizeDevice for Bazel: falling back to non-mixed build")
return false
}
if len(c.productVariables.SanitizeDeviceDiag) > 0 {
- fmt.Fprintln(os.Stderr, "unsupported product var SanitizeDeviceDiag for Bazel: falling back to non-mixed build")
return false
}
if len(c.productVariables.SanitizeDeviceArch) > 0 {
- fmt.Fprintln(os.Stderr, "unsupported product var SanitizeDeviceArch for Bazel: falling back to non-mixed build")
return false
}
return true
diff --git a/android/mutator.go b/android/mutator.go
index d92b87c..4e55609 100644
--- a/android/mutator.go
+++ b/android/mutator.go
@@ -409,7 +409,7 @@
return &bottomUpMutatorContext{
bp: ctx,
- baseModuleContext: a.base().baseModuleContextFactory(ctx),
+ baseModuleContext: moduleContext,
finalPhase: finalPhase,
}
}
diff --git a/android/sdk_version.go b/android/sdk_version.go
index d73c912..8953eae 100644
--- a/android/sdk_version.go
+++ b/android/sdk_version.go
@@ -51,6 +51,7 @@
SdkModule
SdkSystemServer
SdkPrivate
+ SdkToolchain // API surface provided by ART to compile other API domains
)
// String returns the string representation of this SdkKind
@@ -76,6 +77,8 @@
return "module-lib"
case SdkSystemServer:
return "system-server"
+ case SdkToolchain:
+ return "toolchain"
default:
return "invalid"
}
diff --git a/android/variable.go b/android/variable.go
index 9725895..e838b7c 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -702,124 +702,9 @@
}
}
- productConfigProperties.zeroValuesForNamespacedVariables()
-
return productConfigProperties
}
-// zeroValuesForNamespacedVariables ensures that selects that contain __only__
-// conditions default values have zero values set for the other non-default
-// values for that select statement.
-//
-// If the ProductConfigProperties map contains these items, as parsed from the .bp file:
-//
-// library_linking_strategy: {
-// prefer_static: {
-// static_libs: [
-// "lib_a",
-// "lib_b",
-// ],
-// },
-// conditions_default: {
-// shared_libs: [
-// "lib_a",
-// "lib_b",
-// ],
-// },
-// },
-//
-// Static_libs {Library_linking_strategy ANDROID prefer_static} [lib_a lib_b]
-// Shared_libs {Library_linking_strategy ANDROID conditions_default} [lib_a lib_b]
-//
-// We need to add this:
-//
-// Shared_libs {Library_linking_strategy ANDROID prefer_static} []
-//
-// so that the following gets generated for the "dynamic_deps" attribute,
-// instead of putting lib_a and lib_b directly into dynamic_deps without a
-// select:
-//
-// dynamic_deps = select({
-// "//build/bazel/product_variables:android__library_linking_strategy__prefer_static": [],
-// "//conditions:default": [
-// "//foo/bar:lib_a",
-// "//foo/bar:lib_b",
-// ],
-// }),
-func (props *ProductConfigProperties) zeroValuesForNamespacedVariables() {
- // A map of product config properties to the zero values of their respective
- // property value.
- zeroValues := make(map[ProductConfigProperty]interface{})
-
- // A map of prop names (e.g. cflags) to product config properties where the
- // (prop name, ProductConfigProperty) tuple contains a non-conditions_default key.
- //
- // e.g.
- //
- // prefer_static: {
- // static_libs: [
- // "lib_a",
- // "lib_b",
- // ],
- // },
- // conditions_default: {
- // shared_libs: [
- // "lib_a",
- // "lib_b",
- // ],
- // },
- //
- // The tuple of ("static_libs", prefer_static) would be in this map.
- hasNonDefaultValue := make(map[string]map[ProductConfigProperty]bool)
-
- // Iterate over all added soong config variables.
- for propName, v := range *props {
- for p, intf := range v {
- if p.Namespace == "" {
- // If there's no namespace, this isn't a soong config variable,
- // i.e. this is a product variable. product variables have no
- // conditions_defaults, so skip them.
- continue
- }
- if p.FullConfig == bazel.ConditionsDefaultConfigKey {
- // Skip conditions_defaults.
- continue
- }
- if hasNonDefaultValue[propName] == nil {
- hasNonDefaultValue[propName] = make(map[ProductConfigProperty]bool)
- hasNonDefaultValue[propName][p] = false
- }
- // Create the zero value of the variable.
- if _, exists := zeroValues[p]; !exists {
- zeroValue := reflect.Zero(reflect.ValueOf(intf).Type()).Interface()
- if zeroValue == nil {
- panic(fmt.Errorf("Expected non-nil zero value for product/config variable %+v\n", intf))
- }
- zeroValues[p] = zeroValue
- }
- hasNonDefaultValue[propName][p] = true
- }
- }
-
- for propName := range *props {
- for p, zeroValue := range zeroValues {
- // Ignore variables that already have a non-default value for that axis
- if exists, _ := hasNonDefaultValue[propName][p]; !exists {
- // fmt.Println(propName, p.Namespace, p.Name, p.FullConfig, zeroValue)
- // Insert the zero value for this propname + product config value.
- props.AddProductConfigProperty(
- propName,
- p.Namespace,
- p.Name,
- p.FullConfig,
- zeroValue,
- bazel.NoConfigAxis,
- )
- }
- }
- }
-}
-
func (p *ProductConfigProperties) AddProductConfigProperty(
propertyName, namespace, productVariableName, config string, property interface{}, outerAxis bazel.ConfigurationAxis) {
if (*p)[propertyName] == nil {
@@ -945,14 +830,16 @@
for j := 0; j < variableValue.NumField(); j++ {
property := variableValue.Field(j)
+ // e.g. Asflags, Cflags, Enabled, etc.
+ propertyName := variableValue.Type().Field(j).Name
+ // config can also be "conditions_default".
+ config := proptools.PropertyNameForField(propertyName)
+
// If the property wasn't set, no need to pass it along
if property.IsZero() {
continue
}
- // e.g. Asflags, Cflags, Enabled, etc.
- propertyName := variableValue.Type().Field(j).Name
-
if v, ok := maybeExtractConfigVarProp(property); ok {
// The field is a struct, which is used by:
// 1) soong_config_string_variables
@@ -972,13 +859,14 @@
// static_libs: ...
// }
field := v
+ // Iterate over fields of this struct prop.
for k := 0; k < field.NumField(); k++ {
- // Iterate over fields of this struct prop.
- if field.Field(k).IsZero() {
+ // For product variables, zero values are irrelevant; however, for soong config variables,
+ // empty values are relevant because there can also be a conditions default which is not
+ // applied for empty variables.
+ if field.Field(k).IsZero() && namespace == "" {
continue
}
- // config can also be "conditions_default".
- config := proptools.PropertyNameForField(propertyName)
actualPropertyName := field.Type().Field(k).Name
productConfigProperties.AddProductConfigProperty(
diff --git a/android/visibility.go b/android/visibility.go
index b209599..5955133 100644
--- a/android/visibility.go
+++ b/android/visibility.go
@@ -155,7 +155,11 @@
}
func isAncestor(p1 string, p2 string) bool {
- return strings.HasPrefix(p2+"/", p1+"/")
+ // Equivalent to strings.HasPrefix(p2+"/", p1+"/"), but without the string copies
+ // The check for a trailing slash is so that we don't consider sibling
+ // directories with common prefixes to be ancestors, e.g. "fooo/bar" should not be
+ // a descendant of "foo".
+ return strings.HasPrefix(p2, p1) && (len(p2) == len(p1) || p2[len(p1)] == '/')
}
func (r subpackagesRule) String() string {
diff --git a/apex/androidmk.go b/apex/androidmk.go
index b76f6bd..aadccb7 100644
--- a/apex/androidmk.go
+++ b/apex/androidmk.go
@@ -317,14 +317,14 @@
func (a *apexBundle) androidMkForType() android.AndroidMkData {
return android.AndroidMkData{
Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
- moduleNames := []string{}
apexType := a.properties.ApexType
- if a.installable() {
- apexName := proptools.StringDefault(a.properties.Apex_name, name)
- moduleNames = a.androidMkForFiles(w, name, apexName, moduleDir, data)
- }
if apexType == flattenedApex {
+ var moduleNames []string = nil
+ if a.installable() {
+ apexName := proptools.StringDefault(a.properties.Apex_name, name)
+ moduleNames = a.androidMkForFiles(w, name, apexName, moduleDir, data)
+ }
// Only image APEXes can be flattened.
fmt.Fprintln(w, "\ninclude $(CLEAR_VARS) # apex.apexBundle.flat")
fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
@@ -366,7 +366,7 @@
}
android.AndroidMkEmitAssignList(w, "LOCAL_OVERRIDES_MODULES", a.overridableProperties.Overrides)
- a.writeRequiredModules(w, moduleNames)
+ a.writeRequiredModules(w, nil)
fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
diff --git a/apex/apex.go b/apex/apex.go
index b9a3c8f..9485a4b 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1905,9 +1905,15 @@
return
}
a.installDir = android.PathForModuleInstall(ctx, "apex")
- a.outputApexFile = android.PathForBazelOut(ctx, outputs.SignedOutput)
- a.outputFile = a.outputApexFile
+
+ // Set the output file to .apex or .capex depending on the compression configuration.
a.setCompression(ctx)
+ if a.isCompressed {
+ a.outputApexFile = android.PathForBazelOut(ctx, outputs.SignedCompressedOutput)
+ } else {
+ a.outputApexFile = android.PathForBazelOut(ctx, outputs.SignedOutput)
+ }
+ a.outputFile = a.outputApexFile
// TODO(b/257829940): These are used by the apex_keys_text singleton; would probably be a clearer
// interface if these were set in a provider rather than the module itself
@@ -3420,7 +3426,7 @@
Key bazel.LabelAttribute
Certificate bazel.LabelAttribute // used when the certificate prop is a module
Certificate_name bazel.StringAttribute // used when the certificate prop is a string
- Min_sdk_version *string
+ Min_sdk_version bazel.StringAttribute
Updatable bazel.BoolAttribute
Installable bazel.BoolAttribute
Binaries bazel.LabelListAttribute
@@ -3439,6 +3445,10 @@
Native_shared_libs_64 bazel.LabelListAttribute
}
+const (
+ minSdkVersionPropName = "Min_sdk_version"
+)
+
// ConvertWithBp2build performs bp2build conversion of an apex
func (a *apexBundle) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
// We only convert apex and apex_test modules at this time
@@ -3477,11 +3487,19 @@
fileContextsLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, *a.properties.File_contexts))
}
+ productVariableProps := android.ProductVariableProperties(ctx)
// TODO(b/219503907) this would need to be set to a.MinSdkVersionValue(ctx) but
// given it's coming via config, we probably don't want to put it in here.
- var minSdkVersion *string
+ var minSdkVersion bazel.StringAttribute
if a.properties.Min_sdk_version != nil {
- minSdkVersion = a.properties.Min_sdk_version
+ minSdkVersion.SetValue(*a.properties.Min_sdk_version)
+ }
+ if props, ok := productVariableProps[minSdkVersionPropName]; ok {
+ for c, p := range props {
+ if val, ok := p.(*string); ok {
+ minSdkVersion.SetSelectValue(c.ConfigurationAxis(), c.SelectKey(), val)
+ }
+ }
}
var keyLabelAttribute bazel.LabelAttribute
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 33fce7c..28097aa 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -526,7 +526,6 @@
data.Custom(&builder, ab.BaseModuleName(), "TARGET_", "", data)
androidMk := builder.String()
- ensureContains(t, androidMk, "LOCAL_MODULE := mylib.myapex\n")
ensureNotContains(t, androidMk, "LOCAL_MODULE := mylib.com.android.myapex\n")
optFlags := apexRule.Args["opt_flags"]
@@ -2996,7 +2995,7 @@
var builder strings.Builder
data.Custom(&builder, name, prefix, "", data)
androidMk := builder.String()
- ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES := libc++.vendor.myapex:64 mylib.vendor.myapex:64 apex_manifest.pb.myapex apex_pubkey.myapex libc.vendor libm.vendor libdl.vendor\n")
+ ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES := libc.vendor libm.vendor libdl.vendor\n")
}
func TestAndroidMkWritesCommonProperties(t *testing.T) {
@@ -4153,7 +4152,6 @@
var builder strings.Builder
data.Custom(&builder, name, prefix, "", data)
androidMk := builder.String()
- ensureContains(t, androidMk, "LOCAL_MODULE := mylib.myapex\n")
ensureNotContains(t, androidMk, "LOCAL_MODULE := mylib.com.android.myapex\n")
}
@@ -5687,12 +5685,6 @@
var builder strings.Builder
data.Custom(&builder, name, prefix, "", data)
androidMk := builder.String()
- ensureContains(t, androidMk, "LOCAL_MODULE := mytest.myapex\n")
- ensureContains(t, androidMk, "LOCAL_MODULE := mytest1.myapex\n")
- ensureContains(t, androidMk, "LOCAL_MODULE := mytest2.myapex\n")
- ensureContains(t, androidMk, "LOCAL_MODULE := mytest3.myapex\n")
- ensureContains(t, androidMk, "LOCAL_MODULE := apex_manifest.pb.myapex\n")
- ensureContains(t, androidMk, "LOCAL_MODULE := apex_pubkey.myapex\n")
ensureContains(t, androidMk, "LOCAL_MODULE := myapex\n")
flatBundle := ctx.ModuleForTests("myapex", "android_common_myapex_flattened").Module().(*apexBundle)
@@ -5726,7 +5718,7 @@
var builder strings.Builder
mk.Custom(&builder, ab.Name(), "TARGET_", "", mk)
androidMk := builder.String()
- ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES := apex_manifest.pb.myapex apex_pubkey.myapex myapex.flattened\n")
+ ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES := myapex.flattened\n")
}
func TestErrorsIfDepsAreNotEnabled(t *testing.T) {
@@ -6519,12 +6511,6 @@
var builder strings.Builder
data.Custom(&builder, name, "TARGET_", "", data)
androidMk := builder.String()
- ensureContains(t, androidMk, "LOCAL_MODULE := override_app.override_myapex")
- ensureContains(t, androidMk, "LOCAL_MODULE := overrideBpf.o.override_myapex")
- ensureContains(t, androidMk, "LOCAL_MODULE := apex_manifest.pb.override_myapex")
- ensureContains(t, androidMk, "LOCAL_MODULE := override_bcplib.override_myapex")
- ensureContains(t, androidMk, "LOCAL_MODULE := override_systemserverlib.override_myapex")
- ensureContains(t, androidMk, "LOCAL_MODULE := override_java_library.override_myapex")
ensureContains(t, androidMk, "LOCAL_MODULE_STEM := override_myapex.apex")
ensureContains(t, androidMk, "LOCAL_OVERRIDES_MODULES := unknownapex myapex")
ensureNotContains(t, androidMk, "LOCAL_MODULE := app.myapex")
@@ -7116,7 +7102,7 @@
var builder strings.Builder
data.Custom(&builder, name, prefix, "", data)
androidMk := builder.String()
- ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES := mylib.myapex:64 apex_manifest.pb.myapex apex_pubkey.myapex a b\n")
+ ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES := a b\n")
ensureContains(t, androidMk, "LOCAL_HOST_REQUIRED_MODULES := c d\n")
ensureContains(t, androidMk, "LOCAL_TARGET_REQUIRED_MODULES := e f\n")
}
@@ -7287,6 +7273,9 @@
"myapex",
"//apex_available:platform",
],
+ stubs: {
+ versions: ["current"],
+ },
}
`)
@@ -7296,11 +7285,10 @@
data.Custom(&builder, apexBundle.BaseModuleName(), "TARGET_", "", data)
androidMk := builder.String()
// `myotherlib` is added to `myapex` as symlink
- ensureContains(t, androidMk, "LOCAL_MODULE := mylib.myapex\n")
ensureNotContains(t, androidMk, "LOCAL_MODULE := prebuilt_myotherlib.myapex\n")
ensureNotContains(t, androidMk, "LOCAL_MODULE := myotherlib.myapex\n")
// `myapex` should have `myotherlib` in its required line, not `prebuilt_myotherlib`
- ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES := mylib.myapex:64 myotherlib:64 apex_manifest.pb.myapex apex_pubkey.myapex\n")
+ ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES := myotherlib\n")
}
func TestApexWithJniLibs(t *testing.T) {
@@ -8813,7 +8801,7 @@
// The make level dependency needs to be on otherlib - prebuilt_otherlib isn't
// a thing there.
- ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES := libc++:64 mylib.myapex:64 apex_manifest.pb.myapex apex_pubkey.myapex otherlib\n")
+ ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES := otherlib\n")
}
func TestExcludeDependency(t *testing.T) {
@@ -9207,7 +9195,7 @@
var builder strings.Builder
data.Custom(&builder, apexBundle.BaseModuleName(), "TARGET_", "", data)
androidMk := builder.String()
- ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES := foo.myapex apex_manifest.pb.myapex apex_pubkey.myapex foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.odex foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.vdex\n")
+ ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES := foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.odex foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.vdex\n")
}
func TestAndroidMk_DexpreoptBuiltInstalledForApex_Prebuilt(t *testing.T) {
@@ -9283,7 +9271,7 @@
var builder strings.Builder
data.Custom(&builder, apexBundle.BaseModuleName(), "TARGET_", "", data)
androidMk := builder.String()
- ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES := foo.myapex apex_manifest.pb.myapex apex_pubkey.myapex otherapex")
+ ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES := otherapex")
}
func TestAndroidMk_RequiredDeps(t *testing.T) {
@@ -9307,7 +9295,7 @@
var builder strings.Builder
data.Custom(&builder, bundle.BaseModuleName(), "TARGET_", "", data)
androidMk := builder.String()
- ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES := apex_manifest.pb.myapex apex_pubkey.myapex foo\n")
+ ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES := foo\n")
flattenedBundle := ctx.ModuleForTests("myapex", "android_common_myapex_flattened").Module().(*apexBundle)
flattenedBundle.requiredDeps = append(flattenedBundle.requiredDeps, "foo")
diff --git a/apex/bp2build_test.go b/apex/bp2build_test.go
index 58f30bd..01afa52 100644
--- a/apex/bp2build_test.go
+++ b/apex/bp2build_test.go
@@ -42,15 +42,16 @@
OutputBaseDir: outputBaseDir,
LabelToApexInfo: map[string]cquery.ApexInfo{
"//:foo": cquery.ApexInfo{
- SignedOutput: "signed_out.apex",
- UnsignedOutput: "unsigned_out.apex",
- BundleKeyInfo: []string{"public_key", "private_key"},
- ContainerKeyInfo: []string{"container_cert", "container_private"},
- SymbolsUsedByApex: "foo_using.txt",
- JavaSymbolsUsedByApex: "foo_using.xml",
- BundleFile: "apex_bundle.zip",
- InstalledFiles: "installed-files.txt",
- RequiresLibs: []string{"//path/c:c", "//path/d:d"},
+ SignedOutput: "signed_out.apex",
+ SignedCompressedOutput: "signed_out.capex",
+ UnsignedOutput: "unsigned_out.apex",
+ BundleKeyInfo: []string{"public_key", "private_key"},
+ ContainerKeyInfo: []string{"container_cert", "container_private"},
+ SymbolsUsedByApex: "foo_using.txt",
+ JavaSymbolsUsedByApex: "foo_using.xml",
+ BundleFile: "apex_bundle.zip",
+ InstalledFiles: "installed-files.txt",
+ RequiresLibs: []string{"//path/c:c", "//path/d:d"},
// unused
PackageName: "pkg_name",
@@ -115,6 +116,68 @@
}
}
+func TestCompressedApexImageInMixedBuilds(t *testing.T) {
+ bp := `
+apex_key{
+ name: "foo_key",
+}
+apex {
+ name: "foo",
+ key: "foo_key",
+ updatable: true,
+ min_sdk_version: "31",
+ file_contexts: ":myapex-file_contexts",
+ bazel_module: { label: "//:foo" },
+ test_only_force_compression: true, // force compression
+}`
+
+ outputBaseDir := "out/bazel"
+ result := android.GroupFixturePreparers(
+ prepareForApexTest,
+ android.FixtureModifyConfig(func(config android.Config) {
+ config.BazelContext = android.MockBazelContext{
+ OutputBaseDir: outputBaseDir,
+ LabelToApexInfo: map[string]cquery.ApexInfo{
+ "//:foo": cquery.ApexInfo{
+ SignedOutput: "signed_out.apex",
+ SignedCompressedOutput: "signed_out.capex",
+ BundleKeyInfo: []string{"public_key", "private_key"},
+ ContainerKeyInfo: []string{"container_cert", "container_private"},
+ },
+ },
+ }
+ }),
+ ).RunTestWithBp(t, bp)
+
+ m := result.ModuleForTests("foo", "android_common_foo_image").Module()
+ ab, ok := m.(*apexBundle)
+ if !ok {
+ t.Fatalf("Expected module to be an apexBundle, was not")
+ }
+
+ if w, g := "out/bazel/execroot/__main__/signed_out.capex", ab.outputFile.String(); w != g {
+ t.Errorf("Expected output file to be compressed apex %q, got %q", w, g)
+ }
+
+ mkData := android.AndroidMkDataForTest(t, result.TestContext, m)
+ var builder strings.Builder
+ mkData.Custom(&builder, "foo", "BAZEL_TARGET_", "", mkData)
+
+ data := builder.String()
+
+ expectedAndroidMk := []string{
+ "LOCAL_PREBUILT_MODULE_FILE := out/bazel/execroot/__main__/signed_out.capex",
+
+ // Check that the source install file is the capex. The dest is not important.
+ "LOCAL_SOONG_INSTALL_PAIRS := out/bazel/execroot/__main__/signed_out.capex:",
+ }
+ for _, androidMk := range expectedAndroidMk {
+ if !strings.Contains(data, androidMk) {
+ t.Errorf("Expected %q in androidmk data, but did not find %q", androidMk, data)
+ }
+ }
+}
+
func TestOverrideApexImageInMixedBuilds(t *testing.T) {
bp := `
apex_key{
diff --git a/apex/builder.go b/apex/builder.go
index 3b9cac0..18d0836 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -1133,7 +1133,7 @@
if a.properties.Canned_fs_config != nil {
cmd.Text("cat").Input(android.PathForModuleSrc(ctx, *a.properties.Canned_fs_config))
}
- cmd.Text(")").FlagWithOutput("> ", cannedFsConfig)
+ cmd.Text(") | LC_ALL=C sort ").FlagWithOutput("> ", cannedFsConfig)
builder.Build("generateFsConfig", fmt.Sprintf("Generating canned fs config for %s", a.BaseModuleName()))
return cannedFsConfig.OutputPath
diff --git a/bazel/cquery/request_type.go b/bazel/cquery/request_type.go
index 7c9ae3b..81c60d9 100644
--- a/bazel/cquery/request_type.go
+++ b/bazel/cquery/request_type.go
@@ -232,8 +232,14 @@
fail("%s did not provide ApexInfo" % id_string)
bundle_key_info = info.bundle_key_info
container_key_info = info.container_key_info
+
+signed_compressed_output = "" # no .capex if the apex is not compressible, cannot be None as it needs to be json encoded.
+if info.signed_compressed_output:
+ signed_compressed_output = info.signed_compressed_output.path
+
return json_encode({
"signed_output": info.signed_output.path,
+ "signed_compressed_output": signed_compressed_output,
"unsigned_output": info.unsigned_output.path,
"provides_native_libs": [str(lib) for lib in info.provides_native_libs],
"requires_native_libs": [str(lib) for lib in info.requires_native_libs],
@@ -249,18 +255,19 @@
}
type ApexInfo struct {
- SignedOutput string `json:"signed_output"`
- UnsignedOutput string `json:"unsigned_output"`
- ProvidesLibs []string `json:"provides_native_libs"`
- RequiresLibs []string `json:"requires_native_libs"`
- BundleKeyInfo []string `json:"bundle_key_info"`
- ContainerKeyInfo []string `json:"container_key_info"`
- PackageName string `json:"package_name"`
- SymbolsUsedByApex string `json:"symbols_used_by_apex"`
- JavaSymbolsUsedByApex string `json:"java_symbols_used_by_apex"`
- BackingLibs string `json:"backing_libs"`
- BundleFile string `json:"bundle_file"`
- InstalledFiles string `json:"installed_files"`
+ SignedOutput string `json:"signed_output"`
+ SignedCompressedOutput string `json:"signed_compressed_output"`
+ UnsignedOutput string `json:"unsigned_output"`
+ ProvidesLibs []string `json:"provides_native_libs"`
+ RequiresLibs []string `json:"requires_native_libs"`
+ BundleKeyInfo []string `json:"bundle_key_info"`
+ ContainerKeyInfo []string `json:"container_key_info"`
+ PackageName string `json:"package_name"`
+ SymbolsUsedByApex string `json:"symbols_used_by_apex"`
+ JavaSymbolsUsedByApex string `json:"java_symbols_used_by_apex"`
+ BackingLibs string `json:"backing_libs"`
+ BundleFile string `json:"bundle_file"`
+ InstalledFiles string `json:"installed_files"`
}
// ParseResult returns a value obtained by parsing the result of the request's Starlark function.
diff --git a/bazel/properties.go b/bazel/properties.go
index 76450dc..0fca60b 100644
--- a/bazel/properties.go
+++ b/bazel/properties.go
@@ -814,6 +814,16 @@
return false
}
+// HasAxisSpecificValues returns true if the attribute contains axis specific label list values from a given axis
+func (lla LabelListAttribute) HasAxisSpecificValues(axis ConfigurationAxis) bool {
+ for _, values := range lla.ConfigurableValues[axis] {
+ if !values.IsNil() {
+ return true
+ }
+ }
+ return false
+}
+
// IsEmpty returns true if the attribute has no values under any configuration.
func (lla LabelListAttribute) IsEmpty() bool {
if len(lla.Value.Includes) > 0 {
@@ -1080,14 +1090,10 @@
if cs[axis] == nil {
cs[axis] = make(stringSelectValues)
}
- var v = ""
- if str != nil {
- v = *str
- }
- cs[axis][config] = v
+ cs[axis][config] = str
}
-type stringSelectValues map[string]string
+type stringSelectValues map[string]*string
// HasConfigurableValues returns true if the attribute contains axis-specific string values.
func (sa StringAttribute) HasConfigurableValues() bool {
@@ -1099,6 +1105,11 @@
return false
}
+// SetValue sets the base, non-configured value for the Label
+func (sa *StringAttribute) SetValue(value string) {
+ sa.SetSelectValue(NoConfigAxis, "", &value)
+}
+
// SetSelectValue set a value for a bazel select for the given axis, config and value.
func (sa *StringAttribute) SetSelectValue(axis ConfigurationAxis, config string, str *string) {
axis.validateConfig(config)
@@ -1123,7 +1134,7 @@
return sa.Value
case arch, os, osArch, productVariables:
if v, ok := sa.ConfigurableValues[axis][config]; ok {
- return &v
+ return v
} else {
return nil
}
@@ -1154,7 +1165,7 @@
_, containsProductVariables := axisTypes[productVariables]
if containsProductVariables {
if containsOs || containsArch || containsOsArch {
- return fmt.Errorf("boolean attribute could not be collapsed as it has two or more unrelated axes")
+ return fmt.Errorf("string attribute could not be collapsed as it has two or more unrelated axes")
}
}
if (containsOs && containsArch) || (containsOsArch && (containsOs || containsArch)) {
@@ -1181,7 +1192,7 @@
}
}
}
- // All os_arch values are now set. Clear os and arch axes.
+ /// All os_arch values are now set. Clear os and arch axes.
delete(sa.ConfigurableValues, ArchConfigurationAxis)
delete(sa.ConfigurableValues, OsConfigurationAxis)
// Verify post-condition; this should never fail, provided no additional
@@ -1189,6 +1200,21 @@
if len(sa.ConfigurableValues) > 1 {
panic(fmt.Errorf("error in collapsing attribute: %#v", sa))
}
+ } else if containsProductVariables {
+ usedBaseValue := false
+ for a, configToProp := range sa.ConfigurableValues {
+ if a.configurationType == productVariables {
+ for c, p := range configToProp {
+ if p == nil {
+ sa.SetSelectValue(a, c, sa.Value)
+ usedBaseValue = true
+ }
+ }
+ }
+ }
+ if usedBaseValue {
+ sa.Value = nil
+ }
}
return nil
}
@@ -1367,6 +1393,9 @@
// TryVariableSubstitution, replace string substitution formatting within each string in slice with
// Starlark string.format compatible tag for productVariable.
func TryVariableSubstitutions(slice []string, productVariable string) ([]string, bool) {
+ if len(slice) == 0 {
+ return slice, false
+ }
ret := make([]string, 0, len(slice))
changesMade := false
for _, s := range slice {
diff --git a/bp2build/aar_conversion_test.go b/bp2build/aar_conversion_test.go
index df7cced..0cda5dd 100644
--- a/bp2build/aar_conversion_test.go
+++ b/bp2build/aar_conversion_test.go
@@ -133,7 +133,41 @@
"exports": `[":static_import_dep"]`,
},
),
+ MakeNeverlinkDuplicateTarget("android_library", "TestImport"),
},
},
)
}
+
+func TestConvertAndroidLibraryKotlin(t *testing.T) {
+ t.Helper()
+ RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, Bp2buildTestCase{
+ Description: "Android Library with .kt srcs and common_srcs attribute",
+ ModuleTypeUnderTest: "android_library",
+ ModuleTypeUnderTestFactory: java.AndroidLibraryFactory,
+ Filesystem: map[string]string{
+ "AndroidManifest.xml": "",
+ },
+ Blueprint: `
+android_library {
+ name: "TestLib",
+ srcs: ["a.java", "b.kt"],
+ common_srcs: ["c.kt"],
+}
+`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget(
+ "android_library",
+ "TestLib",
+ AttrNameToString{
+ "srcs": `[
+ "a.java",
+ "b.kt",
+ ]`,
+ "common_srcs": `["c.kt"]`,
+ "manifest": `"AndroidManifest.xml"`,
+ "resource_files": `[]`,
+ }),
+ MakeNeverlinkDuplicateTarget("android_library", "TestLib"),
+ }})
+}
diff --git a/bp2build/android_app_conversion_test.go b/bp2build/android_app_conversion_test.go
index 2b35521..067e34f 100644
--- a/bp2build/android_app_conversion_test.go
+++ b/bp2build/android_app_conversion_test.go
@@ -28,6 +28,7 @@
func registerAndroidAppModuleTypes(ctx android.RegistrationContext) {
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
+ ctx.RegisterModuleType("java_library", java.LibraryFactory)
}
func TestMinimalAndroidApp(t *testing.T) {
@@ -200,3 +201,29 @@
}),
}})
}
+
+func TestAndroidAppLibs(t *testing.T) {
+ runAndroidAppTestCase(t, Bp2buildTestCase{
+ Description: "Android app with libs",
+ ModuleTypeUnderTest: "android_app",
+ ModuleTypeUnderTestFactory: java.AndroidAppFactory,
+ Filesystem: map[string]string{},
+ Blueprint: simpleModuleDoNotConvertBp2build("filegroup", "foocert") + `
+android_app {
+ name: "foo",
+ libs: ["barLib"]
+}
+java_library{
+ name: "barLib",
+}
+`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("java_library", "barLib", AttrNameToString{}),
+ MakeNeverlinkDuplicateTarget("java_library", "barLib"),
+ MakeBazelTarget("android_binary", "foo", AttrNameToString{
+ "manifest": `"AndroidManifest.xml"`,
+ "resource_files": `[]`,
+ "deps": `[":barLib-neverlink"]`,
+ }),
+ }})
+}
diff --git a/bp2build/bp2build.go b/bp2build/bp2build.go
index 5dc9612..86b9b27 100644
--- a/bp2build/bp2build.go
+++ b/bp2build/bp2build.go
@@ -45,17 +45,27 @@
bp2buildFiles := CreateBazelFiles(ctx.Config(), nil, res.buildFileToTargets, ctx.mode)
writeFiles(ctx, bp2buildDir, bp2buildFiles)
+ soongInjectionDir := android.PathForOutput(ctx, bazel.SoongInjectionDirName)
+ writeFiles(ctx, soongInjectionDir, CreateSoongInjectionDirFiles(ctx, res.metrics))
+
+ return &res.metrics
+}
+
+// Wrapper function that will be responsible for all files in soong_injection directory
+// This includes
+// 1. config value(s) that are hardcoded in Soong
+// 2. product_config variables
+func CreateSoongInjectionDirFiles(ctx *CodegenContext, metrics CodegenMetrics) []BazelFile {
+ var ret []BazelFile
+
productConfigFiles, err := CreateProductConfigFiles(ctx)
if err != nil {
fmt.Printf("ERROR: %s", err.Error())
os.Exit(1)
}
-
- soongInjectionDir := android.PathForOutput(ctx, bazel.SoongInjectionDirName)
- writeFiles(ctx, soongInjectionDir, productConfigFiles)
- writeFiles(ctx, soongInjectionDir, CreateSoongInjectionFiles(ctx.Config(), res.metrics))
-
- return &res.metrics
+ ret = append(ret, productConfigFiles...)
+ ret = append(ret, soongInjectionFiles(ctx.Config(), metrics)...)
+ return ret
}
// Get the output directory and create it if it doesn't exist.
diff --git a/bp2build/bp2build_product_config.go b/bp2build/bp2build_product_config.go
index e343a05..3eec439 100644
--- a/bp2build/bp2build_product_config.go
+++ b/bp2build/bp2build_product_config.go
@@ -97,6 +97,8 @@
build:android --platforms=@soong_injection//{PRODUCT_FOLDER}:{PRODUCT}-{VARIANT}
build:linux_x86_64 --platforms=@soong_injection//{PRODUCT_FOLDER}:{PRODUCT}-{VARIANT}_linux_x86_64
build:linux_bionic_x86_64 --platforms=@soong_injection//{PRODUCT_FOLDER}:{PRODUCT}-{VARIANT}_linux_bionic_x86_64
+build:linux_musl_x86 --platforms=@soong_injection//{PRODUCT_FOLDER}:{PRODUCT}-{VARIANT}_linux_musl_x86
+build:linux_musl_x86_64 --platforms=@soong_injection//{PRODUCT_FOLDER}:{PRODUCT}-{VARIANT}_linux_musl_x86_64
`)),
newFile(
"product_config_platforms",
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index f924d00..052bc32 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -1806,6 +1806,11 @@
ModuleTypeUnderTestFactory: cc.LibraryFactory,
Blueprint: soongCcLibraryPreamble + `
cc_library {
+ name: "libc_musl",
+ bazel_module: { bp2build_available: false },
+}
+
+cc_library {
name: "target_linux_bionic_empty",
target: {
linux_bionic: {
@@ -1816,7 +1821,10 @@
}
`,
ExpectedBazelTargets: makeCcLibraryTargets("target_linux_bionic_empty", AttrNameToString{
- "system_dynamic_deps": `[]`,
+ "system_dynamic_deps": `select({
+ "//build/bazel/platforms/os:linux_musl": [":libc_musl"],
+ "//conditions:default": [],
+ })`,
}),
},
)
@@ -1829,6 +1837,11 @@
ModuleTypeUnderTestFactory: cc.LibraryFactory,
Blueprint: soongCcLibraryPreamble + `
cc_library {
+ name: "libc_musl",
+ bazel_module: { bp2build_available: false },
+}
+
+cc_library {
name: "target_bionic_empty",
target: {
bionic: {
@@ -1839,12 +1852,68 @@
}
`,
ExpectedBazelTargets: makeCcLibraryTargets("target_bionic_empty", AttrNameToString{
- "system_dynamic_deps": `[]`,
+ "system_dynamic_deps": `select({
+ "//build/bazel/platforms/os:linux_musl": [":libc_musl"],
+ "//conditions:default": [],
+ })`,
}),
},
)
}
+func TestCcLibrary_SystemSharedLibsMuslEmpty(t *testing.T) {
+ runCcLibraryTestCase(t, Bp2buildTestCase{
+ Description: "cc_library system_shared_lib empty for musl variant",
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Blueprint: soongCcLibraryPreamble + `
+cc_library {
+ name: "libc_musl",
+ bazel_module: { bp2build_available: false },
+}
+
+cc_library {
+ name: "target_musl_empty",
+ target: {
+ musl: {
+ system_shared_libs: [],
+ },
+ },
+ include_build_directory: false,
+}
+`,
+ ExpectedBazelTargets: makeCcLibraryTargets("target_musl_empty", AttrNameToString{
+ "system_dynamic_deps": `[]`,
+ }),
+ })
+}
+
+func TestCcLibrary_SystemSharedLibsLinuxMuslEmpty(t *testing.T) {
+ runCcLibraryTestCase(t, Bp2buildTestCase{
+ Description: "cc_library system_shared_lib empty for linux_musl variant",
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Blueprint: soongCcLibraryPreamble + `
+cc_library {
+ name: "libc_musl",
+ bazel_module: { bp2build_available: false },
+}
+
+cc_library {
+ name: "target_linux_musl_empty",
+ target: {
+ linux_musl: {
+ system_shared_libs: [],
+ },
+ },
+ include_build_directory: false,
+}
+`,
+ ExpectedBazelTargets: makeCcLibraryTargets("target_linux_musl_empty", AttrNameToString{
+ "system_dynamic_deps": `[]`,
+ }),
+ })
+}
func TestCcLibrary_SystemSharedLibsSharedAndRoot(t *testing.T) {
runCcLibraryTestCase(t, Bp2buildTestCase{
Description: "cc_library system_shared_libs set for shared and root",
diff --git a/bp2build/cc_library_static_conversion_test.go b/bp2build/cc_library_static_conversion_test.go
index 767f4ad..d5256f6 100644
--- a/bp2build/cc_library_static_conversion_test.go
+++ b/bp2build/cc_library_static_conversion_test.go
@@ -1310,6 +1310,11 @@
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
Description: "cc_library_static system_shared_lib empty for bionic variant",
Blueprint: soongCcLibraryStaticPreamble + `
+cc_library {
+ name: "libc_musl",
+ bazel_module: { bp2build_available: false },
+}
+
cc_library_static {
name: "target_bionic_empty",
target: {
@@ -1322,7 +1327,10 @@
`,
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_library_static", "target_bionic_empty", AttrNameToString{
- "system_dynamic_deps": `[]`,
+ "system_dynamic_deps": `select({
+ "//build/bazel/platforms/os:linux_musl": [":libc_musl"],
+ "//conditions:default": [],
+ })`,
}),
},
})
@@ -1336,6 +1344,11 @@
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
Description: "cc_library_static system_shared_lib empty for linux_bionic variant",
Blueprint: soongCcLibraryStaticPreamble + `
+cc_library {
+ name: "libc_musl",
+ bazel_module: { bp2build_available: false },
+}
+
cc_library_static {
name: "target_linux_bionic_empty",
target: {
@@ -1348,6 +1361,63 @@
`,
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_library_static", "target_linux_bionic_empty", AttrNameToString{
+ "system_dynamic_deps": `select({
+ "//build/bazel/platforms/os:linux_musl": [":libc_musl"],
+ "//conditions:default": [],
+ })`,
+ }),
+ },
+ })
+}
+
+func TestStaticLibrary_SystemSharedLibsMuslEmpty(t *testing.T) {
+ runCcLibraryStaticTestCase(t, Bp2buildTestCase{
+ Description: "cc_library_static system_shared_lib empty for musl variant",
+ Blueprint: soongCcLibraryStaticPreamble + `
+cc_library {
+ name: "libc_musl",
+ bazel_module: { bp2build_available: false },
+}
+
+cc_library_static {
+ name: "target_musl_empty",
+ target: {
+ musl: {
+ system_shared_libs: [],
+ },
+ },
+ include_build_directory: false,
+}
+`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_static", "target_musl_empty", AttrNameToString{
+ "system_dynamic_deps": `[]`,
+ }),
+ },
+ })
+}
+
+func TestStaticLibrary_SystemSharedLibsLinuxMuslEmpty(t *testing.T) {
+ runCcLibraryStaticTestCase(t, Bp2buildTestCase{
+ Description: "cc_library_static system_shared_lib empty for linux_musl variant",
+ Blueprint: soongCcLibraryStaticPreamble + `
+cc_library {
+ name: "libc_musl",
+ bazel_module: { bp2build_available: false },
+}
+
+cc_library_static {
+ name: "target_linux_musl_empty",
+ target: {
+ linux_musl: {
+ system_shared_libs: [],
+ },
+ },
+ include_build_directory: false,
+}
+`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_static", "target_linux_musl_empty", AttrNameToString{
"system_dynamic_deps": `[]`,
}),
},
@@ -1359,6 +1429,11 @@
Description: "cc_library_static system_shared_libs set for bionic variant",
Blueprint: soongCcLibraryStaticPreamble +
simpleModuleDoNotConvertBp2build("cc_library", "libc") + `
+cc_library {
+ name: "libc_musl",
+ bazel_module: { bp2build_available: false },
+}
+
cc_library_static {
name: "target_bionic",
target: {
@@ -1374,6 +1449,7 @@
"system_dynamic_deps": `select({
"//build/bazel/platforms/os:android": [":libc"],
"//build/bazel/platforms/os:linux_bionic": [":libc"],
+ "//build/bazel/platforms/os:linux_musl": [":libc_musl"],
"//conditions:default": [],
})`,
}),
@@ -1387,6 +1463,11 @@
Blueprint: soongCcLibraryStaticPreamble +
simpleModuleDoNotConvertBp2build("cc_library", "libc") +
simpleModuleDoNotConvertBp2build("cc_library", "libm") + `
+cc_library {
+ name: "libc_musl",
+ bazel_module: { bp2build_available: false },
+}
+
cc_library_static {
name: "target_linux_bionic",
system_shared_libs: ["libc"],
@@ -1402,6 +1483,7 @@
MakeBazelTarget("cc_library_static", "target_linux_bionic", AttrNameToString{
"system_dynamic_deps": `[":libc"] + select({
"//build/bazel/platforms/os:linux_bionic": [":libm"],
+ "//build/bazel/platforms/os:linux_musl": [":libc_musl"],
"//conditions:default": [],
})`,
}),
diff --git a/bp2build/configurability.go b/bp2build/configurability.go
index 987c903..4244956 100644
--- a/bp2build/configurability.go
+++ b/bp2build/configurability.go
@@ -28,10 +28,13 @@
ret[selectKey] = reflect.ValueOf(strs)
}
}
+
// if there is a select, use the base value as the conditions default value
if len(ret) > 0 {
- ret[bazel.ConditionsDefaultSelectKey] = value
- value = reflect.Zero(value.Type())
+ if _, ok := ret[bazel.ConditionsDefaultSelectKey]; !ok {
+ ret[bazel.ConditionsDefaultSelectKey] = value
+ value = reflect.Zero(value.Type())
+ }
}
return value, []selects{ret}
diff --git a/bp2build/conversion.go b/bp2build/conversion.go
index e15dd59..c43fbd8 100644
--- a/bp2build/conversion.go
+++ b/bp2build/conversion.go
@@ -6,6 +6,7 @@
"strings"
"android/soong/android"
+ "android/soong/cc"
cc_config "android/soong/cc/config"
java_config "android/soong/java/config"
@@ -20,14 +21,16 @@
Contents string
}
-func CreateSoongInjectionFiles(cfg android.Config, metrics CodegenMetrics) []BazelFile {
+// PRIVATE: Use CreateSoongInjectionDirFiles instead
+func soongInjectionFiles(cfg android.Config, metrics CodegenMetrics) []BazelFile {
var files []BazelFile
files = append(files, newFile("android", GeneratedBuildFileName, "")) // Creates a //cc_toolchain package.
files = append(files, newFile("android", "constants.bzl", android.BazelCcToolchainVars(cfg)))
files = append(files, newFile("cc_toolchain", GeneratedBuildFileName, "")) // Creates a //cc_toolchain package.
- files = append(files, newFile("cc_toolchain", "constants.bzl", cc_config.BazelCcToolchainVars(cfg)))
+ files = append(files, newFile("cc_toolchain", "config_constants.bzl", cc_config.BazelCcToolchainVars(cfg)))
+ files = append(files, newFile("cc_toolchain", "sanitizer_constants.bzl", cc.BazelCcSanitizerToolchainVars(cfg)))
files = append(files, newFile("java_toolchain", GeneratedBuildFileName, "")) // Creates a //java_toolchain package.
files = append(files, newFile("java_toolchain", "constants.bzl", java_config.BazelJavaToolchainVars(cfg)))
diff --git a/bp2build/conversion_test.go b/bp2build/conversion_test.go
index dfc7f0b..b9c06bc 100644
--- a/bp2build/conversion_test.go
+++ b/bp2build/conversion_test.go
@@ -84,7 +84,7 @@
func TestCreateBazelFiles_Bp2Build_CreatesDefaultFiles(t *testing.T) {
testConfig := android.TestConfig("", make(map[string]string), "", make(map[string][]byte))
- files := CreateSoongInjectionFiles(testConfig, CreateCodegenMetrics())
+ files := soongInjectionFiles(testConfig, CreateCodegenMetrics())
expectedFilePaths := []bazelFilepath{
{
@@ -101,7 +101,11 @@
},
{
dir: "cc_toolchain",
- basename: "constants.bzl",
+ basename: "config_constants.bzl",
+ },
+ {
+ dir: "cc_toolchain",
+ basename: "sanitizer_constants.bzl",
},
{
dir: "java_toolchain",
diff --git a/bp2build/java_binary_host_conversion_test.go b/bp2build/java_binary_host_conversion_test.go
index e8551e5..46105c7 100644
--- a/bp2build/java_binary_host_conversion_test.go
+++ b/bp2build/java_binary_host_conversion_test.go
@@ -134,3 +134,153 @@
},
})
}
+
+func TestJavaBinaryHostKotlinSrcs(t *testing.T) {
+ runJavaBinaryHostTestCase(t, Bp2buildTestCase{
+ Description: "java_binary_host with srcs, libs.",
+ Filesystem: testFs,
+ Blueprint: `java_binary_host {
+ name: "java-binary-host",
+ manifest: "test.mf",
+ srcs: ["a.java", "b.kt"],
+}
+`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("kt_jvm_library", "java-binary-host_kt", AttrNameToString{
+ "srcs": `[
+ "a.java",
+ "b.kt",
+ ]`,
+ "target_compatible_with": `select({
+ "//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ })`,
+ }),
+ MakeBazelTarget("java_binary", "java-binary-host", AttrNameToString{
+ "main_class": `"com.android.test.MainClass"`,
+ "runtime_deps": `[":java-binary-host_kt"]`,
+ "target_compatible_with": `select({
+ "//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ })`,
+ }),
+ },
+ })
+}
+
+func TestJavaBinaryHostKotlinCommonSrcs(t *testing.T) {
+ runJavaBinaryHostTestCase(t, Bp2buildTestCase{
+ Description: "java_binary_host with common_srcs",
+ Filesystem: testFs,
+ Blueprint: `java_binary_host {
+ name: "java-binary-host",
+ manifest: "test.mf",
+ srcs: ["a.java"],
+ common_srcs: ["b.kt"],
+}
+`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("kt_jvm_library", "java-binary-host_kt", AttrNameToString{
+ "srcs": `["a.java"]`,
+ "common_srcs": `["b.kt"]`,
+ "target_compatible_with": `select({
+ "//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ })`,
+ }),
+ MakeBazelTarget("java_binary", "java-binary-host", AttrNameToString{
+ "main_class": `"com.android.test.MainClass"`,
+ "runtime_deps": `[":java-binary-host_kt"]`,
+ "target_compatible_with": `select({
+ "//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ })`,
+ }),
+ },
+ })
+}
+
+func TestJavaBinaryHostKotlinWithResourceDir(t *testing.T) {
+ runJavaBinaryHostTestCase(t, Bp2buildTestCase{
+ Description: "java_binary_host with srcs, libs, resource dir .",
+ Filesystem: map[string]string{
+ "test.mf": "Main-Class: com.android.test.MainClass",
+ "res/a.res": "",
+ "res/dir1/b.res": "",
+ },
+ Blueprint: `java_binary_host {
+ name: "java-binary-host",
+ manifest: "test.mf",
+ srcs: ["a.java", "b.kt"],
+ java_resource_dirs: ["res"],
+}
+`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("kt_jvm_library", "java-binary-host_kt", AttrNameToString{
+ "srcs": `[
+ "a.java",
+ "b.kt",
+ ]`,
+ "target_compatible_with": `select({
+ "//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ })`,
+ }),
+ MakeBazelTarget("java_binary", "java-binary-host", AttrNameToString{
+ "main_class": `"com.android.test.MainClass"`,
+ "runtime_deps": `[":java-binary-host_kt"]`,
+ "resources": `[
+ "res/a.res",
+ "res/dir1/b.res",
+ ]`,
+ "resource_strip_prefix": `"res"`,
+ "target_compatible_with": `select({
+ "//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ })`,
+ }),
+ },
+ })
+}
+
+func TestJavaBinaryHostKotlinWithResources(t *testing.T) {
+ runJavaBinaryHostTestCase(t, Bp2buildTestCase{
+ Description: "java_binary_host with srcs, libs, resources.",
+ Filesystem: map[string]string{
+ "test.mf": "Main-Class: com.android.test.MainClass",
+ "res/a.res": "",
+ "res/b.res": "",
+ },
+ Blueprint: `java_binary_host {
+ name: "java-binary-host",
+ manifest: "test.mf",
+ srcs: ["a.java", "b.kt"],
+ java_resources: ["res/a.res", "res/b.res"],
+}
+`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("kt_jvm_library", "java-binary-host_kt", AttrNameToString{
+ "srcs": `[
+ "a.java",
+ "b.kt",
+ ]`,
+ "resources": `[
+ "res/a.res",
+ "res/b.res",
+ ]`,
+ "target_compatible_with": `select({
+ "//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ })`,
+ }),
+ MakeBazelTarget("java_binary", "java-binary-host", AttrNameToString{
+ "main_class": `"com.android.test.MainClass"`,
+ "runtime_deps": `[":java-binary-host_kt"]`,
+ "target_compatible_with": `select({
+ "//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ })`,
+ }),
+ },
+ })
+}
diff --git a/bp2build/java_plugin_conversion_test.go b/bp2build/java_plugin_conversion_test.go
index d9049d4..8c6337b 100644
--- a/bp2build/java_plugin_conversion_test.go
+++ b/bp2build/java_plugin_conversion_test.go
@@ -60,7 +60,7 @@
"//conditions:default": [],
})`,
"deps": `[
- ":java-lib-1",
+ ":java-lib-1-neverlink",
":java-lib-2",
]`,
"srcs": `[
@@ -101,7 +101,7 @@
"//conditions:default": [],
})`,
"deps": `[
- ":java-lib-1",
+ ":java-lib-1-neverlink",
":java-lib-2",
]`,
}),
diff --git a/bp2build/metrics.go b/bp2build/metrics.go
index bd21629..d6e5cf3 100644
--- a/bp2build/metrics.go
+++ b/bp2build/metrics.go
@@ -148,11 +148,26 @@
func (metrics *CodegenMetrics) AddEvent(event *bp2build_metrics_proto.Event) {
metrics.serialized.Events = append(metrics.serialized.Events, event)
}
+
func (metrics *CodegenMetrics) AddUnconvertedModule(moduleType string) {
metrics.serialized.UnconvertedModuleCount += 1
metrics.serialized.TotalModuleTypeCount[moduleType] += 1
}
+func (metrics *CodegenMetrics) SetSymlinkCount(n uint64) {
+ if m := metrics.serialized.WorkspaceSymlinkCount; m != 0 {
+ fmt.Fprintf(os.Stderr, "unexpected non-zero workspaceSymlinkCount of %d", m)
+ }
+ metrics.serialized.WorkspaceSymlinkCount = n
+}
+
+func (metrics *CodegenMetrics) SetMkDirCount(n uint64) {
+ if m := metrics.serialized.WorkspaceMkDirCount; m != 0 {
+ fmt.Fprintf(os.Stderr, "unexpected non-zero workspaceDirCount of %d", m)
+ }
+ metrics.serialized.WorkspaceMkDirCount = n
+}
+
func (metrics *CodegenMetrics) TotalModuleCount() uint64 {
return metrics.serialized.HandCraftedModuleCount +
metrics.serialized.GeneratedModuleCount +
diff --git a/bp2build/soong_config_module_type_conversion_test.go b/bp2build/soong_config_module_type_conversion_test.go
index dcd1f85..89be767 100644
--- a/bp2build/soong_config_module_type_conversion_test.go
+++ b/bp2build/soong_config_module_type_conversion_test.go
@@ -32,6 +32,7 @@
android.RegisterSoongConfigModuleBuildComponents(ctx)
ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
+ ctx.RegisterModuleType("custom", customModuleFactoryHostAndDevice)
}
func TestErrorInBpFileDoesNotPanic(t *testing.T) {
@@ -192,6 +193,7 @@
copts = select({
"//build/bazel/product_variables:acme__board__soc_a": ["-DSOC_A"],
"//build/bazel/product_variables:acme__board__soc_b": ["-DSOC_B"],
+ "//build/bazel/product_variables:acme__board__soc_c": [],
"//conditions:default": ["-DSOC_DEFAULT"],
}),
local_includes = ["."],
@@ -210,7 +212,7 @@
soong_config_string_variable {
name: "board",
- values: ["soc_a", "soc_b", "soc_c"],
+ values: ["soc_a", "soc_b", "soc_c", "soc_d"],
}
soong_config_module_type {
@@ -263,6 +265,7 @@
copts = select({
"//build/bazel/product_variables:acme__board__soc_a": ["-DSOC_A"],
"//build/bazel/product_variables:acme__board__soc_b": ["-DSOC_B"],
+ "//build/bazel/product_variables:acme__board__soc_c": [],
"//conditions:default": ["-DSOC_DEFAULT"],
}) + select({
"//build/bazel/product_variables:acme__feature1": ["-DFEATURE1"],
@@ -279,7 +282,7 @@
bp := `
soong_config_string_variable {
name: "board",
- values: ["soc_a", "soc_b", "soc_c"],
+ values: ["soc_a", "soc_b", "soc_c", "soc_d"],
}
soong_config_module_type {
@@ -332,11 +335,13 @@
copts = select({
"//build/bazel/product_variables:acme__board__soc_a": ["-DSOC_A"],
"//build/bazel/product_variables:acme__board__soc_b": ["-DSOC_B"],
+ "//build/bazel/product_variables:acme__board__soc_c": [],
"//conditions:default": ["-DSOC_DEFAULT"],
}),
implementation_deps = select({
"//build/bazel/product_variables:acme__board__soc_a": ["//foo/bar:soc_a_dep"],
"//build/bazel/product_variables:acme__board__soc_b": ["//foo/bar:soc_b_dep"],
+ "//build/bazel/product_variables:acme__board__soc_c": [],
"//conditions:default": ["//foo/bar:soc_default_static_dep"],
}),
local_includes = ["."],
@@ -604,6 +609,139 @@
)`}})
}
+func TestSoongConfigModuleType_Defaults_UseBaselineValueForStringProp(t *testing.T) {
+ bp := `
+soong_config_string_variable {
+ name: "library_linking_strategy",
+ values: [
+ "prefer_static",
+ ],
+}
+
+soong_config_module_type {
+ name: "library_linking_strategy_custom",
+ module_type: "custom",
+ config_namespace: "ANDROID",
+ variables: ["library_linking_strategy"],
+ properties: [
+ "string_literal_prop",
+ ],
+}
+
+library_linking_strategy_custom {
+ name: "foo",
+ string_literal_prop: "29",
+ soong_config_variables: {
+ library_linking_strategy: {
+ prefer_static: {},
+ conditions_default: {
+ string_literal_prop: "30",
+ },
+ },
+ },
+}`
+
+ runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
+ Description: "soong config variables - generates selects for library_linking_strategy",
+ ModuleTypeUnderTest: "cc_binary",
+ ModuleTypeUnderTestFactory: cc.BinaryFactory,
+ Blueprint: bp,
+ Filesystem: map[string]string{},
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("custom", "foo", AttrNameToString{
+ "string_literal_prop": `select({
+ "//build/bazel/product_variables:android__library_linking_strategy__prefer_static": "29",
+ "//conditions:default": "30",
+ })`,
+ }),
+ },
+ })
+}
+
+func TestSoongConfigModuleType_UnsetConditions(t *testing.T) {
+ bp := `
+soong_config_string_variable {
+ name: "library_linking_strategy",
+ values: [
+ "prefer_static",
+ ],
+}
+
+soong_config_module_type {
+ name: "library_linking_strategy_cc_defaults",
+ module_type: "cc_defaults",
+ config_namespace: "ANDROID",
+ variables: ["library_linking_strategy"],
+ properties: [
+ "shared_libs",
+ "static_libs",
+ ],
+}
+
+library_linking_strategy_cc_defaults {
+ name: "library_linking_strategy_lib_a_defaults",
+ soong_config_variables: {
+ library_linking_strategy: {
+ prefer_static: {},
+ conditions_default: {
+ shared_libs: [
+ "lib_a",
+ ],
+ },
+ },
+ },
+}
+
+library_linking_strategy_cc_defaults {
+ name: "library_linking_strategy_merged_defaults",
+ defaults: ["library_linking_strategy_lib_a_defaults"],
+ host_supported: true,
+ soong_config_variables: {
+ library_linking_strategy: {
+ prefer_static: {},
+ conditions_default: {
+ shared_libs: [
+ "lib_b",
+ ],
+ },
+ },
+ },
+}
+
+cc_binary {
+ name: "library_linking_strategy_sample_binary",
+ srcs: ["library_linking_strategy.cc"],
+ defaults: ["library_linking_strategy_merged_defaults"],
+ include_build_directory: false,
+}`
+
+ otherDeps := `
+cc_library { name: "lib_a", bazel_module: { bp2build_available: false } }
+cc_library { name: "lib_b", bazel_module: { bp2build_available: false } }
+cc_library { name: "lib_default", bazel_module: { bp2build_available: false } }
+`
+
+ runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
+ Description: "soong config variables - generates selects for library_linking_strategy",
+ ModuleTypeUnderTest: "cc_binary",
+ ModuleTypeUnderTestFactory: cc.BinaryFactory,
+ Blueprint: bp,
+ Filesystem: map[string]string{
+ "foo/bar/Android.bp": otherDeps,
+ },
+ ExpectedBazelTargets: []string{`cc_binary(
+ name = "library_linking_strategy_sample_binary",
+ dynamic_deps = select({
+ "//build/bazel/product_variables:android__library_linking_strategy__prefer_static": [],
+ "//conditions:default": [
+ "//foo/bar:lib_b",
+ "//foo/bar:lib_a",
+ ],
+ }),
+ srcs = ["library_linking_strategy.cc"],
+)`}})
+}
+
func TestSoongConfigModuleType_Defaults(t *testing.T) {
bp := `
soong_config_string_variable {
diff --git a/bp2build/symlink_forest.go b/bp2build/symlink_forest.go
index 81ec7ee..37188f1 100644
--- a/bp2build/symlink_forest.go
+++ b/bp2build/symlink_forest.go
@@ -22,6 +22,7 @@
"os"
"path/filepath"
"regexp"
+ "sort"
"sync"
"sync/atomic"
@@ -46,9 +47,10 @@
topdir string // $TOPDIR
// State
- wg sync.WaitGroup
- depCh chan string
- okay atomic.Bool // Whether the forest was successfully constructed
+ wg sync.WaitGroup
+ depCh chan string
+ mkdirCount atomic.Uint64
+ symlinkCount atomic.Uint64
}
// A simple thread pool to limit concurrency on system calls.
@@ -274,22 +276,26 @@
}
}
- allEntries := make(map[string]struct{})
+ allEntries := make([]string, 0, len(srcDirMap)+len(buildFilesMap))
for n := range srcDirMap {
- allEntries[n] = struct{}{}
+ allEntries = append(allEntries, n)
}
-
for n := range buildFilesMap {
- allEntries[n] = struct{}{}
+ if _, ok := srcDirMap[n]; !ok {
+ allEntries = append(allEntries, n)
+ }
}
+ // Tests read the error messages generated, so ensure their order is deterministic
+ sort.Strings(allEntries)
err := os.MkdirAll(shared.JoinPath(context.topdir, forestDir), 0777)
if err != nil {
fmt.Fprintf(os.Stderr, "Cannot mkdir '%s': %s\n", forestDir, err)
os.Exit(1)
}
+ context.mkdirCount.Add(1)
- for f := range allEntries {
+ for _, f := range allEntries {
if f[0] == '.' {
continue // Ignore dotfiles
}
@@ -318,6 +324,7 @@
if instructionsChild != nil && instructionsChild.excluded {
if bExists {
symlinkIntoForest(context.topdir, forestChild, buildFilesChild)
+ context.symlinkCount.Add(1)
}
continue
}
@@ -334,6 +341,7 @@
} else {
// Not in the source tree, symlink BUILD file
symlinkIntoForest(context.topdir, forestChild, buildFilesChild)
+ context.symlinkCount.Add(1)
}
} else if !bExists {
if sDir && instructionsChild != nil {
@@ -344,6 +352,7 @@
} else {
// Not in the build file tree, symlink source tree, carry on
symlinkIntoForest(context.topdir, forestChild, srcChild)
+ context.symlinkCount.Add(1)
}
} else if sDir && bDir {
// Both are directories. Descend.
@@ -360,14 +369,14 @@
if err != nil {
fmt.Fprintf(os.Stderr, "Error merging %s and %s: %s",
srcBuildFile, generatedBuildFile, err)
- context.okay.Store(false)
+ os.Exit(1)
}
} else {
// Both exist and one is a file. This is an error.
fmt.Fprintf(os.Stderr,
"Conflict in workspace symlink tree creation: both '%s' and '%s' exist and exactly one is a directory\n",
srcChild, buildFilesChild)
- context.okay.Store(false)
+ os.Exit(1)
}
}
}
@@ -417,19 +426,19 @@
wg.Wait()
}
-// Creates a symlink forest by merging the directory tree at "buildFiles" and
+// PlantSymlinkForest Creates a symlink forest by merging the directory tree at "buildFiles" and
// "srcDir" while excluding paths listed in "exclude". Returns the set of paths
// under srcDir on which readdir() had to be called to produce the symlink
// forest.
-func PlantSymlinkForest(verbose bool, topdir string, forest string, buildFiles string, exclude []string) []string {
+func PlantSymlinkForest(verbose bool, topdir string, forest string, buildFiles string, exclude []string) (deps []string, mkdirCount, symlinkCount uint64) {
context := &symlinkForestContext{
- verbose: verbose,
- topdir: topdir,
- depCh: make(chan string),
+ verbose: verbose,
+ topdir: topdir,
+ depCh: make(chan string),
+ mkdirCount: atomic.Uint64{},
+ symlinkCount: atomic.Uint64{},
}
- context.okay.Store(true)
-
removeParallel(shared.JoinPath(topdir, forest))
instructions := instructionsFromExcludePathList(exclude)
@@ -440,14 +449,9 @@
close(context.depCh)
}()
- deps := make([]string, 0)
for dep := range context.depCh {
deps = append(deps, dep)
}
- if !context.okay.Load() {
- os.Exit(1)
- }
-
- return deps
+ return deps, context.mkdirCount.Load(), context.symlinkCount.Load()
}
diff --git a/bp2build/testing.go b/bp2build/testing.go
index 1f9874c..c340a8f 100644
--- a/bp2build/testing.go
+++ b/bp2build/testing.go
@@ -453,6 +453,14 @@
}
}
}
+ productVariableProps := android.ProductVariableProperties(ctx)
+ if props, ok := productVariableProps["String_literal_prop"]; ok {
+ for c, p := range props {
+ if val, ok := p.(*string); ok {
+ strAttr.SetSelectValue(c.ConfigurationAxis(), c.SelectKey(), val)
+ }
+ }
+ }
paths.ResolveExcludes()
diff --git a/cc/Android.bp b/cc/Android.bp
index 8860f78..5fd9afe 100644
--- a/cc/Android.bp
+++ b/cc/Android.bp
@@ -52,7 +52,6 @@
"vndk.go",
"vndk_prebuilt.go",
- "cflag_artifacts.go",
"cmakelists.go",
"compdb.go",
"compiler.go",
diff --git a/cc/bp2build.go b/cc/bp2build.go
index d331d89..aea1fa1 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -91,12 +91,12 @@
}
archVariantProps := m.GetArchVariantProperties(ctx, &BaseCompilerProperties{})
for axis, configToProps := range archVariantProps {
- for config, _props := range configToProps {
+ for cfg, _props := range configToProps {
if archProps, ok := _props.(*BaseCompilerProperties); ok {
archDisabledSrcs := android.BazelLabelForModuleSrc(ctx, archProps.Tidy_disabled_srcs)
- moduleAttrs.Tidy_disabled_srcs.SetSelectValue(axis, config, archDisabledSrcs)
+ moduleAttrs.Tidy_disabled_srcs.SetSelectValue(axis, cfg, archDisabledSrcs)
archTimeoutSrcs := android.BazelLabelForModuleSrc(ctx, archProps.Tidy_timeout_srcs)
- moduleAttrs.Tidy_timeout_srcs.SetSelectValue(axis, config, archTimeoutSrcs)
+ moduleAttrs.Tidy_timeout_srcs.SetSelectValue(axis, cfg, archTimeoutSrcs)
}
}
}
@@ -205,14 +205,14 @@
func bp2BuildPropParseHelper(ctx android.ArchVariantContext, module *Module, propsType interface{}, parseFunc func(axis bazel.ConfigurationAxis, config string, props interface{})) {
for axis, configToProps := range module.GetArchVariantProperties(ctx, propsType) {
- for config, props := range configToProps {
- parseFunc(axis, config, props)
+ for cfg, props := range configToProps {
+ parseFunc(axis, cfg, props)
}
}
}
// Parses properties common to static and shared libraries. Also used for prebuilt libraries.
-func bp2buildParseStaticOrSharedProps(ctx android.BazelConversionPathContext, module *Module, lib *libraryDecorator, isStatic bool) staticOrSharedAttributes {
+func bp2buildParseStaticOrSharedProps(ctx android.BazelConversionPathContext, module *Module, _ *libraryDecorator, isStatic bool) staticOrSharedAttributes {
attrs := staticOrSharedAttributes{}
setAttrs := func(axis bazel.ConfigurationAxis, config string, props StaticOrSharedProperties) {
@@ -669,8 +669,8 @@
ret := &bazel.LabelAttribute{}
for _, axis := range ca.asmSrcs.SortedConfigurationAxes() {
- for config := range ca.asmSrcs.ConfigurableValues[axis] {
- ret.SetSelectValue(axis, config, bazel.Label{Label: ":" + m.Name() + "_yasm"})
+ for cfg := range ca.asmSrcs.ConfigurableValues[axis] {
+ ret.SetSelectValue(axis, cfg, bazel.Label{Label: ":" + m.Name() + "_yasm"})
}
}
return ret
@@ -690,8 +690,8 @@
if _, ok := axisToConfigs[axis]; !ok {
axisToConfigs[axis] = map[string]bool{}
}
- for config, _ := range configMap {
- axisToConfigs[axis][config] = true
+ for cfg := range configMap {
+ axisToConfigs[axis][cfg] = true
}
}
}
@@ -703,49 +703,49 @@
linkerAttrs := linkerAttributes{}
for axis, configs := range axisToConfigs {
- for config, _ := range configs {
+ for cfg := range configs {
var allHdrs []string
- if baseCompilerProps, ok := archVariantCompilerProps[axis][config].(*BaseCompilerProperties); ok {
+ if baseCompilerProps, ok := archVariantCompilerProps[axis][cfg].(*BaseCompilerProperties); ok {
allHdrs = baseCompilerProps.Generated_headers
if baseCompilerProps.Lex != nil {
- compilerAttrs.lexopts.SetSelectValue(axis, config, baseCompilerProps.Lex.Flags)
+ compilerAttrs.lexopts.SetSelectValue(axis, cfg, baseCompilerProps.Lex.Flags)
}
- (&compilerAttrs).bp2buildForAxisAndConfig(ctx, axis, config, baseCompilerProps)
+ (&compilerAttrs).bp2buildForAxisAndConfig(ctx, axis, cfg, baseCompilerProps)
}
var exportHdrs []string
- if baseLinkerProps, ok := archVariantLinkerProps[axis][config].(*BaseLinkerProperties); ok {
+ if baseLinkerProps, ok := archVariantLinkerProps[axis][cfg].(*BaseLinkerProperties); ok {
exportHdrs = baseLinkerProps.Export_generated_headers
- (&linkerAttrs).bp2buildForAxisAndConfig(ctx, module.Binary(), axis, config, baseLinkerProps)
+ (&linkerAttrs).bp2buildForAxisAndConfig(ctx, module.Binary(), axis, cfg, baseLinkerProps)
}
headers := maybePartitionExportedAndImplementationsDeps(ctx, !module.Binary(), allHdrs, exportHdrs, android.BazelLabelForModuleDeps)
- implementationHdrs.SetSelectValue(axis, config, headers.implementation)
- compilerAttrs.hdrs.SetSelectValue(axis, config, headers.export)
+ implementationHdrs.SetSelectValue(axis, cfg, headers.implementation)
+ compilerAttrs.hdrs.SetSelectValue(axis, cfg, headers.export)
exportIncludes, exportAbsoluteIncludes := includesFromLabelList(headers.export)
- compilerAttrs.includes.Includes.SetSelectValue(axis, config, exportIncludes)
- compilerAttrs.includes.AbsoluteIncludes.SetSelectValue(axis, config, exportAbsoluteIncludes)
+ compilerAttrs.includes.Includes.SetSelectValue(axis, cfg, exportIncludes)
+ compilerAttrs.includes.AbsoluteIncludes.SetSelectValue(axis, cfg, exportAbsoluteIncludes)
includes, absoluteIncludes := includesFromLabelList(headers.implementation)
- currAbsoluteIncludes := compilerAttrs.absoluteIncludes.SelectValue(axis, config)
+ currAbsoluteIncludes := compilerAttrs.absoluteIncludes.SelectValue(axis, cfg)
currAbsoluteIncludes = android.FirstUniqueStrings(append(currAbsoluteIncludes, absoluteIncludes...))
- compilerAttrs.absoluteIncludes.SetSelectValue(axis, config, currAbsoluteIncludes)
+ compilerAttrs.absoluteIncludes.SetSelectValue(axis, cfg, currAbsoluteIncludes)
- currIncludes := compilerAttrs.localIncludes.SelectValue(axis, config)
+ currIncludes := compilerAttrs.localIncludes.SelectValue(axis, cfg)
currIncludes = android.FirstUniqueStrings(append(currIncludes, includes...))
- compilerAttrs.localIncludes.SetSelectValue(axis, config, currIncludes)
+ compilerAttrs.localIncludes.SetSelectValue(axis, cfg, currIncludes)
- if libraryProps, ok := archVariantLibraryProperties[axis][config].(*LibraryProperties); ok {
+ if libraryProps, ok := archVariantLibraryProperties[axis][cfg].(*LibraryProperties); ok {
if axis == bazel.NoConfigAxis {
compilerAttrs.stubsSymbolFile = libraryProps.Stubs.Symbol_file
- compilerAttrs.stubsVersions.SetSelectValue(axis, config, libraryProps.Stubs.Versions)
+ compilerAttrs.stubsVersions.SetSelectValue(axis, cfg, libraryProps.Stubs.Versions)
}
if suffix := libraryProps.Suffix; suffix != nil {
- compilerAttrs.suffix.SetSelectValue(axis, config, suffix)
+ compilerAttrs.suffix.SetSelectValue(axis, cfg, suffix)
}
}
}
@@ -813,6 +813,8 @@
features := compilerAttrs.features.Clone().Append(linkerAttrs.features).Append(bp2buildSanitizerFeatures(ctx, module))
features.DeduplicateAxesFromBase()
+ addMuslSystemDynamicDeps(ctx, linkerAttrs)
+
return baseAttributes{
compilerAttrs,
linkerAttrs,
@@ -823,6 +825,16 @@
}
}
+// As a workaround for b/261657184, we are manually adding the default value
+// of system_dynamic_deps for the linux_musl os.
+// TODO: Solve this properly
+func addMuslSystemDynamicDeps(ctx android.Bp2buildMutatorContext, attrs linkerAttributes) {
+ systemDynamicDeps := attrs.systemDynamicDeps.SelectValue(bazel.OsConfigurationAxis, "linux_musl")
+ if attrs.systemDynamicDeps.HasAxisSpecificValues(bazel.OsConfigurationAxis) && systemDynamicDeps.IsNil() {
+ attrs.systemDynamicDeps.SetSelectValue(bazel.OsConfigurationAxis, "linux_musl", android.BazelLabelForModuleDeps(ctx, config.MuslDefaultSharedLibraries))
+ }
+}
+
type fdoProfileAttributes struct {
Absolute_path_profile string
}
@@ -1213,7 +1225,7 @@
for name, dep := range productVarToDepFields {
props, exists := productVariableProps[name]
excludeProps, excludesExists := productVariableProps[dep.excludesField]
- // if neither an include or excludes property exists, then skip it
+ // if neither an include nor excludes property exists, then skip it
if !exists && !excludesExists {
continue
}
@@ -1352,7 +1364,7 @@
func bazelLabelForStaticModule(ctx android.BazelConversionPathContext, m blueprint.Module) string {
label := android.BazelModuleLabel(ctx, m)
- if ccModule, ok := m.(*Module); ok && ccModule.typ() == fullLibrary && !android.GetBp2BuildAllowList().GenerateCcLibraryStaticOnly(m.Name()) {
+ if ccModule, ok := m.(*Module); ok && ccModule.typ() == fullLibrary {
return BazelLabelNameForStaticModule(label)
}
return label
diff --git a/cc/cc.go b/cc/cc.go
index cb425c3..b194360 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -1859,6 +1859,10 @@
var (
mixedBuildSupportedCcTest = []string{
"adbd_test",
+ "adb_crypto_test",
+ "adb_pairing_auth_test",
+ "adb_pairing_connection_test",
+ "adb_tls_connection_test",
}
)
diff --git a/cc/cflag_artifacts.go b/cc/cflag_artifacts.go
deleted file mode 100644
index be46fc0..0000000
--- a/cc/cflag_artifacts.go
+++ /dev/null
@@ -1,183 +0,0 @@
-package cc
-
-import (
- "fmt"
- "sort"
- "strings"
-
- "github.com/google/blueprint/proptools"
-
- "android/soong/android"
-)
-
-func init() {
- android.RegisterSingletonType("cflag_artifacts_text", cflagArtifactsTextFactory)
-}
-
-var (
- TrackedCFlags = []string{
- "-Wall",
- "-Werror",
- "-Wextra",
- "-Wthread-safety",
- "-O3",
- }
-
- TrackedCFlagsDir = []string{
- "device/google/",
- "vendor/google/",
- }
-)
-
-const FileBP = 50
-
-// Stores output files.
-type cflagArtifactsText struct {
- interOutputs map[string]android.WritablePaths
- outputs android.WritablePaths
-}
-
-// allowedDir verifies if the directory/project is part of the TrackedCFlagsDir
-// filter.
-func allowedDir(subdir string) bool {
- subdir += "/"
- return android.HasAnyPrefix(subdir, TrackedCFlagsDir)
-}
-
-func (s *cflagArtifactsText) genFlagFilename(flag string) string {
- return fmt.Sprintf("module_cflags%s.txt", flag)
-}
-
-// incrementFile is used to generate an output path object with the passed in flag
-// and part number.
-// e.g. FLAG + part # -> out/soong/cflags/module_cflags-FLAG.txt.0
-func (s *cflagArtifactsText) incrementFile(ctx android.SingletonContext,
- flag string, part int) (string, android.OutputPath) {
-
- filename := fmt.Sprintf("%s.%d", s.genFlagFilename(flag), part)
- filepath := android.PathForOutput(ctx, "cflags", filename)
- s.interOutputs[flag] = append(s.interOutputs[flag], filepath)
- return filename, filepath
-}
-
-// GenCFlagArtifactParts is used to generate the build rules which produce the
-// intermediary files for each desired C Flag artifact
-// e.g. module_cflags-FLAG.txt.0, module_cflags-FLAG.txt.1, ...
-func (s *cflagArtifactsText) GenCFlagArtifactParts(ctx android.SingletonContext,
- flag string, using bool, modules []string, part int) int {
-
- cleanedName := strings.Replace(flag, "=", "_", -1)
- filename, filepath := s.incrementFile(ctx, cleanedName, part)
- rule := android.NewRuleBuilder(pctx, ctx)
- rule.Command().Textf("rm -f %s", filepath.String())
-
- if using {
- rule.Command().
- Textf("echo '# Modules using %s'", flag).
- FlagWithOutput(">> ", filepath)
- } else {
- rule.Command().
- Textf("echo '# Modules not using %s'", flag).
- FlagWithOutput(">> ", filepath)
- }
-
- length := len(modules)
-
- if length == 0 {
- rule.Build(filename, "gen "+filename)
- part++
- }
-
- // Following loop splits the module list for each tracked C Flag into
- // chunks of length FileBP (file breakpoint) and generates a partial artifact
- // (intermediary file) build rule for each split.
- moduleShards := android.ShardStrings(modules, FileBP)
- for index, shard := range moduleShards {
- rule.Command().
- Textf("for m in %s; do echo $m",
- strings.Join(proptools.ShellEscapeList(shard), " ")).
- FlagWithOutput(">> ", filepath).
- Text("; done")
- rule.Build(filename, "gen "+filename)
-
- if index+1 != len(moduleShards) {
- filename, filepath = s.incrementFile(ctx, cleanedName, part+index+1)
- rule = android.NewRuleBuilder(pctx, ctx)
- rule.Command().Textf("rm -f %s", filepath.String())
- }
- }
-
- return part + len(moduleShards)
-}
-
-// GenCFlagArtifacts is used to generate build rules which combine the
-// intermediary files of a specific tracked flag into a single C Flag artifact
-// for each tracked flag.
-// e.g. module_cflags-FLAG.txt.0 + module_cflags-FLAG.txt.1 = module_cflags-FLAG.txt
-func (s *cflagArtifactsText) GenCFlagArtifacts(ctx android.SingletonContext) {
- // Scans through s.interOutputs and creates a build rule for each tracked C
- // Flag that concatenates the associated intermediary file into a single
- // artifact.
- for _, flag := range TrackedCFlags {
- // Generate build rule to combine related intermediary files into a
- // C Flag artifact
- rule := android.NewRuleBuilder(pctx, ctx)
- filename := s.genFlagFilename(flag)
- outputpath := android.PathForOutput(ctx, "cflags", filename)
- rule.Command().
- Text("cat").
- Inputs(s.interOutputs[flag].Paths()).
- FlagWithOutput("> ", outputpath)
- rule.Build(filename, "gen "+filename)
- s.outputs = append(s.outputs, outputpath)
- }
-}
-
-func (s *cflagArtifactsText) GenerateBuildActions(ctx android.SingletonContext) {
- modulesWithCFlag := make(map[string][]string)
-
- // Scan through all modules, selecting the ones that are part of the filter,
- // and then storing into a map which tracks whether or not tracked C flag is
- // used or not.
- ctx.VisitAllModules(func(module android.Module) {
- if ccModule, ok := module.(*Module); ok {
- if allowedDir(ctx.ModuleDir(ccModule)) {
- cflags := ccModule.flags.Local.CFlags
- cppflags := ccModule.flags.Local.CppFlags
- module := fmt.Sprintf("%s:%s (%s)",
- ctx.BlueprintFile(ccModule),
- ctx.ModuleName(ccModule),
- ctx.ModuleSubDir(ccModule))
- for _, flag := range TrackedCFlags {
- if inList(flag, cflags) || inList(flag, cppflags) {
- modulesWithCFlag[flag] = append(modulesWithCFlag[flag], module)
- } else {
- modulesWithCFlag["!"+flag] = append(modulesWithCFlag["!"+flag], module)
- }
- }
- }
- }
- })
-
- // Traversing map and setting up rules to produce intermediary files which
- // contain parts of each expected C Flag artifact.
- for _, flag := range TrackedCFlags {
- sort.Strings(modulesWithCFlag[flag])
- part := s.GenCFlagArtifactParts(ctx, flag, true, modulesWithCFlag[flag], 0)
- sort.Strings(modulesWithCFlag["!"+flag])
- s.GenCFlagArtifactParts(ctx, flag, false, modulesWithCFlag["!"+flag], part)
- }
-
- // Combine intermediary files into a single C Flag artifact.
- s.GenCFlagArtifacts(ctx)
-}
-
-func cflagArtifactsTextFactory() android.Singleton {
- return &cflagArtifactsText{
- interOutputs: make(map[string]android.WritablePaths),
- }
-}
-
-func (s *cflagArtifactsText) MakeVars(ctx android.MakeVarsContext) {
- ctx.Strict("SOONG_MODULES_CFLAG_ARTIFACTS", strings.Join(s.outputs.Strings(), " "))
-}
diff --git a/cc/config/global.go b/cc/config/global.go
index e78839b..811e86e 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -369,10 +369,6 @@
flags = append(flags, "-Wno-unused-command-line-argument")
}
- if ctx.Config().IsEnvTrue("LLVM_NEXT") {
- flags = append(flags, llvmNextExtraCommonGlobalCflags...)
- }
-
if ctx.Config().IsEnvTrue("ALLOW_UNKNOWN_WARNING_OPTION") {
flags = append(flags, "-Wno-error=unknown-warning-option")
}
@@ -388,8 +384,17 @@
return strings.Join(deviceGlobalCflags, " ")
})
+ // Export the static default NoOverrideGlobalCflags to Bazel.
+ exportedVars.ExportStringList("NoOverrideGlobalCflags", noOverrideGlobalCflags)
+ pctx.VariableFunc("NoOverrideGlobalCflags", func(ctx android.PackageVarContext) string {
+ flags := noOverrideGlobalCflags
+ if ctx.Config().IsEnvTrue("LLVM_NEXT") {
+ flags = append(noOverrideGlobalCflags, llvmNextExtraCommonGlobalCflags...)
+ }
+ return strings.Join(flags, " ")
+ })
+
exportedVars.ExportStringListStaticVariable("HostGlobalCflags", hostGlobalCflags)
- exportedVars.ExportStringListStaticVariable("NoOverrideGlobalCflags", noOverrideGlobalCflags)
exportedVars.ExportStringListStaticVariable("NoOverrideExternalGlobalCflags", noOverrideExternalGlobalCflags)
exportedVars.ExportStringListStaticVariable("CommonGlobalCppflags", commonGlobalCppflags)
exportedVars.ExportStringListStaticVariable("ExternalCflags", extraExternalCflags)
diff --git a/cc/config/tidy.go b/cc/config/tidy.go
index 1180da4..d55a13d 100644
--- a/cc/config/tidy.go
+++ b/cc/config/tidy.go
@@ -40,6 +40,8 @@
"-cert-err33-c",
// http://b/241125373
"-bugprone-unchecked-optional-access",
+ // http://b/265438407
+ "-misc-use-anonymous-namespace",
}
// Some clang-tidy checks are included in some tidy_checks_as_errors lists,
diff --git a/cc/config/x86_linux_host.go b/cc/config/x86_linux_host.go
index 740405e..93aa82e 100644
--- a/cc/config/x86_linux_host.go
+++ b/cc/config/x86_linux_host.go
@@ -112,7 +112,7 @@
muslCrtBeginSharedBinary, muslCrtEndSharedBinary = []string{"libc_musl_crtbegin_dynamic"}, []string{"libc_musl_crtend"}
muslCrtBeginSharedLibrary, muslCrtEndSharedLibrary = []string{"libc_musl_crtbegin_so"}, []string{"libc_musl_crtend_so"}
- muslDefaultSharedLibraries = []string{"libc_musl"}
+ MuslDefaultSharedLibraries = []string{"libc_musl"}
)
const (
@@ -331,7 +331,7 @@
func (toolchainMusl) CrtEndSharedBinary() []string { return muslCrtEndSharedBinary }
func (toolchainMusl) CrtEndSharedLibrary() []string { return muslCrtEndSharedLibrary }
-func (toolchainMusl) DefaultSharedLibraries() []string { return muslDefaultSharedLibraries }
+func (toolchainMusl) DefaultSharedLibraries() []string { return MuslDefaultSharedLibraries }
func (toolchainMusl) Cflags() string {
return "${config.LinuxMuslCflags}"
diff --git a/cc/library.go b/cc/library.go
index 787de44..1291f5c 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -292,14 +292,6 @@
}
func libraryBp2Build(ctx android.TopDownMutatorContext, m *Module) {
- // For some cc_library modules, their static variants are ready to be
- // converted, but not their shared variants. For these modules, delegate to
- // the cc_library_static bp2build converter temporarily instead.
- if android.GetBp2BuildAllowList().GenerateCcLibraryStaticOnly(ctx.Module().Name()) {
- sharedOrStaticLibraryBp2Build(ctx, m, true)
- return
- }
-
sharedAttrs := bp2BuildParseSharedProps(ctx, m)
staticAttrs := bp2BuildParseStaticProps(ctx, m)
baseAttributes := bp2BuildParseBaseProps(ctx, m)
@@ -413,12 +405,12 @@
sharedTargetAttrs.Suffix = compilerAttrs.suffix
for axis, configToProps := range m.GetArchVariantProperties(ctx, &LibraryProperties{}) {
- for config, props := range configToProps {
+ for cfg, props := range configToProps {
if props, ok := props.(*LibraryProperties); ok {
if props.Inject_bssl_hash != nil {
// This is an edge case applies only to libcrypto
if m.Name() == "libcrypto" || m.Name() == "libcrypto_for_testing" {
- sharedTargetAttrs.Inject_bssl_hash.SetSelectValue(axis, config, props.Inject_bssl_hash)
+ sharedTargetAttrs.Inject_bssl_hash.SetSelectValue(axis, cfg, props.Inject_bssl_hash)
} else {
ctx.PropertyErrorf("inject_bssl_hash", "only applies to libcrypto")
}
@@ -1034,7 +1026,7 @@
return ret
}
-func GlobGeneratedHeadersForSnapshot(ctx android.ModuleContext, paths android.Paths) android.Paths {
+func GlobGeneratedHeadersForSnapshot(_ android.ModuleContext, paths android.Paths) android.Paths {
ret := android.Paths{}
for _, header := range paths {
// TODO(b/148123511): remove exportedDeps after cleaning up genrule
@@ -1247,6 +1239,10 @@
// b/239274367 --apex and --systemapi filters symbols tagged with # apex and #
// systemapi, respectively. The former is for symbols defined in platform libraries
// and the latter is for symbols defined in APEXes.
+ // A single library can contain either # apex or # systemapi, but not both.
+ // The stub generator (ndkstubgen) is additive, so passing _both_ of these to it should be a no-op.
+ // However, having this distinction helps guard accidental
+ // promotion or demotion of API and also helps the API review process b/191371676
var flag string
if ctx.Module().(android.ApexModule).NotInPlatform() {
flag = "--apex"
@@ -1900,7 +1896,7 @@
errorMessage := "error: Please follow https://android.googlesource.com/platform/development/+/master/vndk/tools/header-checker/README.md#configure-cross_version-abi-check to resolve the ABI difference between your source code and version " + prevVersion + "."
library.sourceAbiDiff(ctx, referenceDump, baseName, prevVersion,
- isLlndkOrNdk, /* allowExtensions */ true, sourceVersion, errorMessage)
+ isLlndkOrNdk, true /* allowExtensions */, sourceVersion, errorMessage)
}
func (library *libraryDecorator) sameVersionAbiDiff(ctx android.ModuleContext, referenceDump android.Path,
@@ -1909,7 +1905,7 @@
libName := strings.TrimSuffix(baseName, filepath.Ext(baseName))
errorMessage := "error: Please update ABI references with: $$ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l " + libName
- library.sourceAbiDiff(ctx, referenceDump, baseName, /* nameExt */ "",
+ library.sourceAbiDiff(ctx, referenceDump, baseName, "",
isLlndkOrNdk, allowExtensions, "current", errorMessage)
}
@@ -1920,7 +1916,7 @@
errorMessage := "error: Please update ABI references with: $$ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py -l " + libName + " -ref-dump-dir $$ANDROID_BUILD_TOP/" + refDumpDir
library.sourceAbiDiff(ctx, referenceDump, baseName, nameExt,
- isLlndkOrNdk, /* allowExtensions */ false, "current", errorMessage)
+ isLlndkOrNdk, false /* allowExtensions */, "current", errorMessage)
}
func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objects, fileName string, soFile android.Path) {
diff --git a/cc/library_stub.go b/cc/library_stub.go
index d21df51..08a5eb6 100644
--- a/cc/library_stub.go
+++ b/cc/library_stub.go
@@ -205,6 +205,14 @@
d.libraryDecorator.flagExporter.Properties.Export_include_dirs = append(
d.libraryDecorator.flagExporter.Properties.Export_include_dirs,
variantMod.exportProperties.Export_include_dirs...)
+
+ // Export headers as system include dirs if specified. Mostly for libc
+ if Bool(variantMod.exportProperties.Export_headers_as_system) {
+ d.libraryDecorator.flagExporter.Properties.Export_system_include_dirs = append(
+ d.libraryDecorator.flagExporter.Properties.Export_system_include_dirs,
+ d.libraryDecorator.flagExporter.Properties.Export_include_dirs...)
+ d.libraryDecorator.flagExporter.Properties.Export_include_dirs = nil
+ }
}
}
}
diff --git a/cc/linker.go b/cc/linker.go
index 625d89c..371d78d 100644
--- a/cc/linker.go
+++ b/cc/linker.go
@@ -15,10 +15,10 @@
package cc
import (
- "fmt"
-
"android/soong/android"
"android/soong/cc/config"
+ "fmt"
+ "path/filepath"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -270,8 +270,7 @@
type baseLinker struct {
Properties BaseLinkerProperties
dynamicProperties struct {
- RunPaths []string `blueprint:"mutated"`
- BuildStubs bool `blueprint:"mutated"`
+ BuildStubs bool `blueprint:"mutated"`
}
sanitize *sanitize
@@ -281,13 +280,8 @@
linker.Properties.Ldflags = append(linker.Properties.Ldflags, flags...)
}
-// linkerInit initializes dynamic properties of the linker (such as runpath).
+// linkerInit initializes dynamic properties of the linker.
func (linker *baseLinker) linkerInit(ctx BaseModuleContext) {
- if ctx.toolchain().Is64Bit() {
- linker.dynamicProperties.RunPaths = append(linker.dynamicProperties.RunPaths, "../lib64", "lib64")
- } else {
- linker.dynamicProperties.RunPaths = append(linker.dynamicProperties.RunPaths, "../lib", "lib")
- }
}
func (linker *baseLinker) linkerProps() []interface{} {
@@ -529,17 +523,8 @@
flags.Local.LdFlags = append(flags.Local.LdFlags, proptools.NinjaAndShellEscapeList(linker.Properties.Ldflags)...)
- if ctx.Host() && !ctx.Windows() {
- rpathPrefix := `\$$ORIGIN/`
- if ctx.Darwin() {
- rpathPrefix = "@loader_path/"
- }
-
- if !ctx.static() {
- for _, rpath := range linker.dynamicProperties.RunPaths {
- flags.Global.LdFlags = append(flags.Global.LdFlags, "-Wl,-rpath,"+rpathPrefix+rpath)
- }
- }
+ if ctx.Host() && !ctx.Windows() && !ctx.static() {
+ flags.Global.LdFlags = append(flags.Global.LdFlags, RpathFlags(ctx)...)
}
if ctx.useSdk() {
@@ -610,6 +595,45 @@
return flags
}
+// RpathFlags returns the rpath linker flags for current target to search the following directories relative
+// to the binary:
+//
+// - "." to find libraries alongside tests
+// - "lib[64]" to find libraries in a subdirectory of the binaries' directory
+// - "../lib[64]" to find libraries when the binaries are in a bin directory
+// - "../../lib[64]" to find libraries in out/host/linux-x86/lib64 when the test or binary is in
+// out/host/linux-x86/nativetest/<test dir>/<test>
+// - "../../../lib[[64] to find libraries in out/host/linux-x86/lib64 when the test or binary is in
+// out/host/linux-x86/testcases/<test dir>/<CPU>/<test>
+func RpathFlags(ctx android.ModuleContext) []string {
+ key := struct {
+ os android.OsType
+ arch android.ArchType
+ }{ctx.Target().Os, ctx.Target().Arch.ArchType}
+
+ return ctx.Config().OnceStringSlice(android.NewCustomOnceKey(key), func() []string {
+ rpathPrefix := `\$$ORIGIN/`
+ if key.os == android.Darwin {
+ rpathPrefix = "@loader_path/"
+ }
+
+ var libDir string
+ if key.arch.Multilib == "lib64" {
+ libDir = "lib64"
+ } else {
+ libDir = "lib"
+ }
+
+ return []string{
+ "-Wl,-rpath," + rpathPrefix,
+ "-Wl,-rpath," + rpathPrefix + libDir,
+ "-Wl,-rpath," + rpathPrefix + filepath.Join("..", libDir),
+ "-Wl,-rpath," + rpathPrefix + filepath.Join("../..", libDir),
+ "-Wl,-rpath," + rpathPrefix + filepath.Join("../../..", libDir),
+ }
+ })
+}
+
func (linker *baseLinker) link(ctx ModuleContext,
flags Flags, deps PathDeps, objs Objects) android.Path {
panic(fmt.Errorf("baseLinker doesn't know how to link"))
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 8e2d161..c61e5e4 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -78,6 +78,9 @@
hwasanGlobalOptions = []string{"heap_history_size=1023", "stack_history_size=512",
"export_memory_stats=0", "max_malloc_fill_size=4096", "malloc_fill_byte=0"}
memtagStackCommonFlags = []string{"-march=armv8-a+memtag"}
+
+ hostOnlySanitizeFlags = []string{"-fno-sanitize-recover=all"}
+ deviceOnlySanitizeFlags = []string{"-fsanitize-trap=all", "-ftrap-function=abort"}
)
type SanitizerType int
@@ -379,7 +382,12 @@
var _ android.SkipApexAllowedDependenciesCheck = (*libraryDependencyTag)(nil)
+var exportedVars = android.NewExportedVariables(pctx)
+
func init() {
+ exportedVars.ExportStringListStaticVariable("HostOnlySanitizeFlags", hostOnlySanitizeFlags)
+ exportedVars.ExportStringList("DeviceOnlySanitizeFlags", deviceOnlySanitizeFlags)
+
android.RegisterMakeVarsProvider(pctx, cfiMakeVarsProvider)
android.RegisterMakeVarsProvider(pctx, hwasanMakeVarsProvider)
}
@@ -869,9 +877,9 @@
// When fuzzing, we wish to crash with diagnostics on any bug.
flags.Local.CFlags = append(flags.Local.CFlags, "-fno-sanitize-trap=all", "-fno-sanitize-recover=all")
} else if ctx.Host() {
- flags.Local.CFlags = append(flags.Local.CFlags, "-fno-sanitize-recover=all")
+ flags.Local.CFlags = append(flags.Local.CFlags, hostOnlySanitizeFlags...)
} else {
- flags.Local.CFlags = append(flags.Local.CFlags, "-fsanitize-trap=all", "-ftrap-function=abort")
+ flags.Local.CFlags = append(flags.Local.CFlags, deviceOnlySanitizeFlags...)
}
if enableMinimalRuntime(s) {
@@ -1787,3 +1795,7 @@
func hwasanMakeVarsProvider(ctx android.MakeVarsContext) {
hwasanStaticLibs(ctx.Config()).exportToMake(ctx)
}
+
+func BazelCcSanitizerToolchainVars(config android.Config) string {
+ return android.BazelToolchainVars(config, exportedVars)
+}
diff --git a/cc/test.go b/cc/test.go
index 16ef0ef..4b968dc 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -311,23 +311,6 @@
return deps
}
-func (test *testDecorator) linkerInit(ctx BaseModuleContext, linker *baseLinker) {
- // 1. Add ../../lib[64] to rpath so that out/host/linux-x86/nativetest/<test dir>/<test> can
- // find out/host/linux-x86/lib[64]/library.so
- // 2. Add ../../../lib[64] to rpath so that out/host/linux-x86/testcases/<test dir>/<CPU>/<test> can
- // also find out/host/linux-x86/lib[64]/library.so
- runpaths := []string{"../../lib", "../../../lib"}
- for _, runpath := range runpaths {
- if ctx.toolchain().Is64Bit() {
- runpath += "64"
- }
- linker.dynamicProperties.RunPaths = append(linker.dynamicProperties.RunPaths, runpath)
- }
-
- // add "" to rpath so that test binaries can find libraries in their own test directory
- linker.dynamicProperties.RunPaths = append(linker.dynamicProperties.RunPaths, "")
-}
-
func (test *testDecorator) linkerProps() []interface{} {
return []interface{}{&test.LinkerProperties}
}
@@ -356,11 +339,6 @@
return props
}
-func (test *testBinary) linkerInit(ctx BaseModuleContext) {
- test.testDecorator.linkerInit(ctx, test.binaryDecorator.baseLinker)
- test.binaryDecorator.linkerInit(ctx)
-}
-
func (test *testBinary) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps = test.testDecorator.linkerDeps(ctx, deps)
deps = test.binaryDecorator.linkerDeps(ctx, deps)
@@ -535,11 +513,6 @@
return append(props, test.libraryDecorator.linkerProps()...)
}
-func (test *testLibrary) linkerInit(ctx BaseModuleContext) {
- test.testDecorator.linkerInit(ctx, test.libraryDecorator.baseLinker)
- test.libraryDecorator.linkerInit(ctx)
-}
-
func (test *testLibrary) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps = test.testDecorator.linkerDeps(ctx, deps)
deps = test.libraryDecorator.linkerDeps(ctx, deps)
@@ -610,15 +583,6 @@
return true
}
-func (benchmark *benchmarkDecorator) linkerInit(ctx BaseModuleContext) {
- runpath := "../../lib"
- if ctx.toolchain().Is64Bit() {
- runpath += "64"
- }
- benchmark.baseLinker.dynamicProperties.RunPaths = append(benchmark.baseLinker.dynamicProperties.RunPaths, runpath)
- benchmark.binaryDecorator.linkerInit(ctx)
-}
-
func (benchmark *benchmarkDecorator) linkerProps() []interface{} {
props := benchmark.binaryDecorator.linkerProps()
props = append(props, &benchmark.Properties)
diff --git a/cmd/multiproduct_kati/main.go b/cmd/multiproduct_kati/main.go
index d8d5e5d..0115f4a 100644
--- a/cmd/multiproduct_kati/main.go
+++ b/cmd/multiproduct_kati/main.go
@@ -321,7 +321,7 @@
jobs = runtime.NumCPU() / 4
ramGb := int(detectTotalRAM() / (1024 * 1024 * 1024))
- if ramJobs := ramGb / 30; ramGb > 0 && jobs > ramJobs {
+ if ramJobs := ramGb / 40; ramGb > 0 && jobs > ramJobs {
jobs = ramJobs
}
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index baa7380..29a6f95 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -145,8 +145,10 @@
func runApiBp2build(ctx *android.Context, extraNinjaDeps []string) string {
ctx.EventHandler.Begin("api_bp2build")
defer ctx.EventHandler.End("api_bp2build")
- // Do not allow missing dependencies.
- ctx.SetAllowMissingDependencies(false)
+ // api_bp2build does not run the typical pipeline of soong mutators.
+ // Hoevever, it still runs the defaults mutator which can create dependencies.
+ // These dependencies might not always exist (e.g. in tests)
+ ctx.SetAllowMissingDependencies(ctx.Config().AllowMissingDependencies())
ctx.RegisterForApiBazelConversion()
// Register the Android.bp files in the tree
@@ -176,7 +178,7 @@
ninjaDeps = append(ninjaDeps, codegenContext.AdditionalNinjaDeps()...)
// Create soong_injection repository
- soongInjectionFiles := bp2build.CreateSoongInjectionFiles(ctx.Config(), bp2build.CreateCodegenMetrics())
+ soongInjectionFiles := bp2build.CreateSoongInjectionDirFiles(codegenContext, bp2build.CreateCodegenMetrics())
absoluteSoongInjectionDir := shared.JoinPath(topDir, ctx.Config().SoongOutDir(), bazel.SoongInjectionDirName)
for _, file := range soongInjectionFiles {
// The API targets in api_bp2build workspace do not have any dependency on api_bp2build.
@@ -189,7 +191,7 @@
workspace := shared.JoinPath(ctx.Config().SoongOutDir(), "api_bp2build")
// Create the symlink forest
- symlinkDeps := bp2build.PlantSymlinkForest(
+ symlinkDeps, _, _ := bp2build.PlantSymlinkForest(
ctx.Config().IsEnvTrue("BP2BUILD_VERBOSE"),
topDir,
workspace,
@@ -459,8 +461,10 @@
// symlink tree creation binary. Then the latter would not need to depend on
// the very heavy-weight machinery of soong_build .
func runSymlinkForestCreation(ctx *android.Context, extraNinjaDeps []string, metricsDir string) string {
+ var ninjaDeps []string
+ var mkdirCount, symlinkCount uint64
+
ctx.EventHandler.Do("symlink_forest", func() {
- var ninjaDeps []string
ninjaDeps = append(ninjaDeps, extraNinjaDeps...)
verbose := ctx.Config().IsEnvTrue("BP2BUILD_VERBOSE")
@@ -469,15 +473,16 @@
// or file created/deleted under it would trigger an update of the symlink forest.
generatedRoot := shared.JoinPath(ctx.Config().SoongOutDir(), "bp2build")
workspaceRoot := shared.JoinPath(ctx.Config().SoongOutDir(), "workspace")
+ var symlinkForestDeps []string
ctx.EventHandler.Do("plant", func() {
- symlinkForestDeps := bp2build.PlantSymlinkForest(
+ symlinkForestDeps, mkdirCount, symlinkCount = bp2build.PlantSymlinkForest(
verbose, topDir, workspaceRoot, generatedRoot, excludedFromSymlinkForest(ctx, verbose))
- ninjaDeps = append(ninjaDeps, symlinkForestDeps...)
})
-
- writeDepFile(cmdlineArgs.SymlinkForestMarker, ctx.EventHandler, ninjaDeps)
- touch(shared.JoinPath(topDir, cmdlineArgs.SymlinkForestMarker))
+ ninjaDeps = append(ninjaDeps, symlinkForestDeps...)
})
+
+ writeDepFile(cmdlineArgs.SymlinkForestMarker, ctx.EventHandler, ninjaDeps)
+ touch(shared.JoinPath(topDir, cmdlineArgs.SymlinkForestMarker))
codegenMetrics := bp2build.ReadCodegenMetrics(metricsDir)
if codegenMetrics == nil {
m := bp2build.CreateCodegenMetrics()
@@ -486,6 +491,8 @@
//TODO (usta) we cannot determine if we loaded a stale file, i.e. from an unrelated prior
//invocation of codegen. We should simply use a separate .pb file
}
+ codegenMetrics.SetSymlinkCount(symlinkCount)
+ codegenMetrics.SetMkDirCount(mkdirCount)
writeBp2BuildMetrics(codegenMetrics, ctx.EventHandler, metricsDir)
return cmdlineArgs.SymlinkForestMarker
}
diff --git a/filesystem/Android.bp b/filesystem/Android.bp
index dfcd405..07d57c9 100644
--- a/filesystem/Android.bp
+++ b/filesystem/Android.bp
@@ -13,6 +13,7 @@
],
srcs: [
"avb_add_hash_footer.go",
+ "avb_gen_vbmeta_image.go",
"bootimg.go",
"filesystem.go",
"logical_partition.go",
diff --git a/filesystem/avb_add_hash_footer.go b/filesystem/avb_add_hash_footer.go
index 2ee420c..f3fecd0 100644
--- a/filesystem/avb_add_hash_footer.go
+++ b/filesystem/avb_add_hash_footer.go
@@ -67,6 +67,9 @@
// List of properties to add to the footer
Props []avbProp
+
+ // Include descriptors from images
+ Include_descriptors_from_images []string `android:"path,arch_variant"`
}
// The AVB footer adds verification information to the image.
@@ -116,6 +119,11 @@
}
cmd.FlagWithArg("--salt ", proptools.String(a.properties.Salt))
+ imagePaths := android.PathsForModuleSrc(ctx, a.properties.Include_descriptors_from_images)
+ for _, imagePath := range imagePaths {
+ cmd.FlagWithInput("--include_descriptors_from_image ", imagePath)
+ }
+
for _, prop := range a.properties.Props {
addAvbProp(ctx, cmd, prop)
}
diff --git a/filesystem/avb_gen_vbmeta_image.go b/filesystem/avb_gen_vbmeta_image.go
new file mode 100644
index 0000000..0f331f9
--- /dev/null
+++ b/filesystem/avb_gen_vbmeta_image.go
@@ -0,0 +1,108 @@
+// Copyright (C) 2022 The Android Open Source Project
+//
+// 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 filesystem
+
+import (
+ "fmt"
+
+ "github.com/google/blueprint/proptools"
+
+ "android/soong/android"
+)
+
+type avbGenVbmetaImage struct {
+ android.ModuleBase
+
+ properties avbGenVbmetaImageProperties
+
+ output android.OutputPath
+ installDir android.InstallPath
+}
+
+type avbGenVbmetaImageProperties struct {
+ // Source file of this image. Can reference a genrule type module with the ":module" syntax.
+ Src *string `android:"path,arch_variant"`
+
+ // Name of the image partition. Defaults to the name of this module.
+ Partition_name *string
+
+ // The salt in hex. Required for reproducible builds.
+ Salt *string
+}
+
+// The avbGenVbmetaImage generates an unsigned VBMeta image output for the given image.
+func avbGenVbmetaImageFactory() android.Module {
+ module := &avbGenVbmetaImage{}
+ module.AddProperties(&module.properties)
+ android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
+ return module
+}
+
+func (a *avbGenVbmetaImage) installFileName() string {
+ return a.Name() + ".img"
+}
+
+func (a *avbGenVbmetaImage) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ builder := android.NewRuleBuilder(pctx, ctx)
+ cmd := builder.Command().BuiltTool("avbtool").Text("add_hash_footer")
+ cmd.Flag("--dynamic_partition_size")
+ cmd.Flag("--do_not_append_vbmeta_image")
+
+ partition_name := proptools.StringDefault(a.properties.Partition_name, a.Name())
+ cmd.FlagWithArg("--partition_name ", partition_name)
+
+ if a.properties.Src == nil {
+ ctx.PropertyErrorf("src", "missing source file")
+ return
+ }
+ input := android.PathForModuleSrc(ctx, proptools.String(a.properties.Src))
+ cmd.FlagWithInput("--image ", input)
+
+ if a.properties.Salt == nil {
+ ctx.PropertyErrorf("salt", "missing salt value")
+ return
+ }
+ cmd.FlagWithArg("--salt ", proptools.String(a.properties.Salt))
+
+ a.output = android.PathForModuleOut(ctx, a.installFileName()).OutputPath
+ cmd.FlagWithOutput("--output_vbmeta_image ", a.output)
+ builder.Build("avbGenVbmetaImage", fmt.Sprintf("avbGenVbmetaImage %s", ctx.ModuleName()))
+}
+
+var _ android.AndroidMkEntriesProvider = (*avbGenVbmetaImage)(nil)
+
+// Implements android.AndroidMkEntriesProvider
+func (a *avbGenVbmetaImage) AndroidMkEntries() []android.AndroidMkEntries {
+ return []android.AndroidMkEntries{android.AndroidMkEntries{
+ Class: "ETC",
+ OutputFile: android.OptionalPathForPath(a.output),
+ ExtraEntries: []android.AndroidMkExtraEntriesFunc{
+ func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
+ entries.SetString("LOCAL_MODULE_PATH", a.installDir.String())
+ entries.SetString("LOCAL_INSTALLED_MODULE_STEM", a.installFileName())
+ },
+ },
+ }}
+}
+
+var _ android.OutputFileProducer = (*avbGenVbmetaImage)(nil)
+
+// Implements android.OutputFileProducer
+func (a *avbGenVbmetaImage) OutputFiles(tag string) (android.Paths, error) {
+ if tag == "" {
+ return []android.Path{a.output}, nil
+ }
+ return nil, fmt.Errorf("unsupported module reference tag %q", tag)
+}
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index c73c4a4..25b8fe8 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -35,6 +35,7 @@
ctx.RegisterModuleType("android_filesystem", filesystemFactory)
ctx.RegisterModuleType("android_system_image", systemImageFactory)
ctx.RegisterModuleType("avb_add_hash_footer", avbAddHashFooterFactory)
+ ctx.RegisterModuleType("avb_gen_vbmeta_image", avbGenVbmetaImageFactory)
}
type filesystem struct {
diff --git a/filesystem/filesystem_test.go b/filesystem/filesystem_test.go
index 9bfcc3d..444ffd0 100644
--- a/filesystem/filesystem_test.go
+++ b/filesystem/filesystem_test.go
@@ -126,8 +126,34 @@
android.AssertDeepEquals(t, "entries should have foo only", []string{"components/foo"}, module.entries)
}
+func TestAvbGenVbmetaImage(t *testing.T) {
+ result := fixture.RunTestWithBp(t, `
+ avb_gen_vbmeta_image {
+ name: "input_hashdesc",
+ src: "input.img",
+ partition_name: "input_partition_name",
+ salt: "2222",
+ }`)
+ cmd := result.ModuleForTests("input_hashdesc", "android_arm64_armv8-a").Rule("avbGenVbmetaImage").RuleParams.Command
+ android.AssertStringDoesContain(t, "Can't find correct --partition_name argument",
+ cmd, "--partition_name input_partition_name")
+ android.AssertStringDoesContain(t, "Can't find --do_not_append_vbmeta_image",
+ cmd, "--do_not_append_vbmeta_image")
+ android.AssertStringDoesContain(t, "Can't find --output_vbmeta_image",
+ cmd, "--output_vbmeta_image ")
+ android.AssertStringDoesContain(t, "Can't find --salt argument",
+ cmd, "--salt 2222")
+}
+
func TestAvbAddHashFooter(t *testing.T) {
result := fixture.RunTestWithBp(t, `
+ avb_gen_vbmeta_image {
+ name: "input_hashdesc",
+ src: "input.img",
+ partition_name: "input",
+ salt: "2222",
+ }
+
avb_add_hash_footer {
name: "myfooter",
src: "input.img",
@@ -145,6 +171,7 @@
file: "value_file",
},
],
+ include_descriptors_from_images: ["input_hashdesc"],
}
`)
cmd := result.ModuleForTests("myfooter", "android_arm64_armv8-a").Rule("avbAddHashFooter").RuleParams.Command
@@ -158,4 +185,6 @@
cmd, "--prop 'prop1:value1'")
android.AssertStringDoesContain(t, "Can't find --prop_from_file argument",
cmd, "--prop_from_file 'prop2:value_file'")
+ android.AssertStringDoesContain(t, "Can't find --include_descriptors_from_image",
+ cmd, "--include_descriptors_from_image ")
}
diff --git a/go.mod b/go.mod
index 7239f6d..a5d9dd5 100644
--- a/go.mod
+++ b/go.mod
@@ -1,21 +1,9 @@
module android/soong
+go 1.19
+
require (
- google.golang.org/protobuf v0.0.0
- github.com/google/blueprint v0.0.0
- prebuilts/bazel/common/proto/analysis_v2 v0.0.0
- prebuilts/bazel/common/proto/build v0.0.0 // indirect
+ github.com/google/blueprint v0.0.0
+ google.golang.org/protobuf v0.0.0
+ prebuilts/bazel/common/proto/analysis_v2 v0.0.0
)
-
-replace (
- google.golang.org/protobuf v0.0.0 => ../../external/golang-protobuf
- github.com/google/blueprint v0.0.0 => ../blueprint
- github.com/google/go-cmp v0.5.5 => ../../external/go-cmp
- prebuilts/bazel/common/proto/analysis_v2 => ../../prebuilts/bazel/common/proto/analysis_v2
- prebuilts/bazel/common/proto/build => ../../prebuilts/bazel/common/proto/build
-)
-
-// Indirect deps from golang-protobuf
-exclude github.com/golang/protobuf v1.5.0
-
-go 2.0
diff --git a/go.work b/go.work
new file mode 100644
index 0000000..737a9df
--- /dev/null
+++ b/go.work
@@ -0,0 +1,19 @@
+go 1.19
+
+use (
+ .
+ ../../external/go-cmp
+ ../../external/golang-protobuf
+ ../../prebuilts/bazel/common/proto/analysis_v2
+ ../../prebuilts/bazel/common/proto/build
+ ../blueprint
+)
+
+replace (
+ github.com/golang/protobuf v0.0.0 => ../../external/golang-protobuf
+ github.com/google/blueprint v0.0.0 => ../blueprint
+ github.com/google/go-cmp v0.0.0 => ../../external/go-cmp
+ google.golang.org/protobuf v0.0.0 => ../../external/golang-protobuf
+ prebuilts/bazel/common/proto/analysis_v2 v0.0.0 => ../../prebuilts/bazel/common/proto/analysis_v2
+ prebuilts/bazel/common/proto/build v0.0.0 => ../../prebuilts/bazel/common/proto/build
+)
diff --git a/java/aar.go b/java/aar.go
index 0826693..a483e13 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -1036,7 +1036,7 @@
ctx.CreateBazelTargetModule(
bazel.BazelTargetModuleProperties{
Rule_class: "aar_import",
- Bzl_load_location: "@rules_android//rules:rules.bzl",
+ Bzl_load_location: "//build/bazel/rules/android:rules.bzl",
},
android.CommonAttributes{Name: name},
&bazelAndroidLibraryImport{
@@ -1046,6 +1046,21 @@
},
)
+ neverlink := true
+ ctx.CreateBazelTargetModule(
+ bazel.BazelTargetModuleProperties{
+ Rule_class: "android_library",
+ Bzl_load_location: "//build/bazel/rules/android:rules.bzl",
+ },
+ android.CommonAttributes{Name: name + "-neverlink"},
+ &bazelAndroidLibrary{
+ javaLibraryAttributes: &javaLibraryAttributes{
+ Neverlink: bazel.BoolAttribute{Value: &neverlink},
+ Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}),
+ },
+ },
+ )
+
}
func (a *AndroidLibrary) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
@@ -1059,10 +1074,14 @@
ctx.ModuleErrorf("Module has direct dependencies but no sources. Bazel will not allow this.")
}
+ if len(a.properties.Common_srcs) != 0 {
+ commonAttrs.Common_srcs = bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, a.properties.Common_srcs))
+ }
+
name := a.Name()
props := bazel.BazelTargetModuleProperties{
Rule_class: "android_library",
- Bzl_load_location: "@rules_android//rules:rules.bzl",
+ Bzl_load_location: "//build/bazel/rules/android:rules.bzl",
}
ctx.CreateBazelTargetModule(
diff --git a/java/app.go b/java/app.go
index 7eff4c3..4d9c407 100755
--- a/java/app.go
+++ b/java/app.go
@@ -801,6 +801,8 @@
unstrippedFile: dep.UnstrippedOutputFile(),
partition: dep.Partition(),
})
+ } else if ctx.Config().AllowMissingDependencies() {
+ ctx.AddMissingDependencies([]string{otherName})
} else {
ctx.ModuleErrorf("dependency %q missing output file", otherName)
}
@@ -1479,7 +1481,7 @@
props := bazel.BazelTargetModuleProperties{
Rule_class: "android_app_certificate",
- Bzl_load_location: "//build/bazel/rules/android:android_app_certificate.bzl",
+ Bzl_load_location: "//build/bazel/rules/android:rules.bzl",
}
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: module.Name()}, attrs)
@@ -1518,7 +1520,7 @@
props := bazel.BazelTargetModuleProperties{
Rule_class: "android_binary",
- Bzl_load_location: "//build/bazel/rules/android:android_binary.bzl",
+ Bzl_load_location: "//build/bazel/rules/android:rules.bzl",
}
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: a.Name()}, attrs)
diff --git a/java/app_import.go b/java/app_import.go
index 8c1e19c..e24e780 100644
--- a/java/app_import.go
+++ b/java/app_import.go
@@ -17,6 +17,7 @@
// This file contains the module implementations for android_app_import and android_test_import.
import (
+ "github.com/google/blueprint"
"reflect"
"github.com/google/blueprint/proptools"
@@ -31,6 +32,24 @@
initAndroidAppImportVariantGroupTypes()
}
+var (
+ uncompressEmbeddedJniLibsRule = pctx.AndroidStaticRule("uncompress-embedded-jni-libs", blueprint.RuleParams{
+ Command: `if (zipinfo $in 'lib/*.so' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then ` +
+ `${config.Zip2ZipCmd} -i $in -o $out -0 'lib/**/*.so'` +
+ `; else cp -f $in $out; fi`,
+ CommandDeps: []string{"${config.Zip2ZipCmd}"},
+ Description: "Uncompress embedded JNI libs",
+ })
+
+ uncompressDexRule = pctx.AndroidStaticRule("uncompress-dex", blueprint.RuleParams{
+ Command: `if (zipinfo $in '*.dex' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then ` +
+ `${config.Zip2ZipCmd} -i $in -o $out -0 'classes*.dex'` +
+ `; else cp -f $in $out; fi`,
+ CommandDeps: []string{"${config.Zip2ZipCmd}"},
+ Description: "Uncompress dex files",
+ })
+)
+
func RegisterAppImportBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("android_app_import", AndroidAppImportFactory)
ctx.RegisterModuleType("android_test_import", AndroidTestImportFactory)
@@ -193,15 +212,12 @@
})
return
}
- rule := android.NewRuleBuilder(pctx, ctx)
- rule.Command().
- Textf(`if (zipinfo %s 'lib/*.so' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then`, inputPath).
- BuiltTool("zip2zip").
- FlagWithInput("-i ", inputPath).
- FlagWithOutput("-o ", outputPath).
- FlagWithArg("-0 ", "'lib/**/*.so'").
- Textf(`; else cp -f %s %s; fi`, inputPath, outputPath)
- rule.Build("uncompress-embedded-jni-libs", "Uncompress embedded JIN libs")
+
+ ctx.Build(pctx, android.BuildParams{
+ Rule: uncompressEmbeddedJniLibsRule,
+ Input: inputPath,
+ Output: outputPath,
+ })
}
// Returns whether this module should have the dex file stored uncompressed in the APK.
@@ -218,19 +234,6 @@
return shouldUncompressDex(ctx, &a.dexpreopter)
}
-func (a *AndroidAppImport) uncompressDex(
- ctx android.ModuleContext, inputPath android.Path, outputPath android.OutputPath) {
- rule := android.NewRuleBuilder(pctx, ctx)
- rule.Command().
- Textf(`if (zipinfo %s '*.dex' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then`, inputPath).
- BuiltTool("zip2zip").
- FlagWithInput("-i ", inputPath).
- FlagWithOutput("-o ", outputPath).
- FlagWithArg("-0 ", "'classes*.dex'").
- Textf(`; else cp -f %s %s; fi`, inputPath, outputPath)
- rule.Build("uncompress-dex", "Uncompress dex files")
-}
-
func (a *AndroidAppImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.generateAndroidBuildActions(ctx)
}
@@ -306,7 +309,11 @@
a.dexpreopter.dexpreopt(ctx, jnisUncompressed)
if a.dexpreopter.uncompressedDex {
dexUncompressed := android.PathForModuleOut(ctx, "dex-uncompressed", ctx.ModuleName()+".apk")
- a.uncompressDex(ctx, jnisUncompressed, dexUncompressed.OutputPath)
+ ctx.Build(pctx, android.BuildParams{
+ Rule: uncompressDexRule,
+ Input: jnisUncompressed,
+ Output: dexUncompressed,
+ })
jnisUncompressed = dexUncompressed
}
diff --git a/java/app_import_test.go b/java/app_import_test.go
index ad27e3a..a29606f 100644
--- a/java/app_import_test.go
+++ b/java/app_import_test.go
@@ -17,7 +17,6 @@
import (
"fmt"
"reflect"
- "regexp"
"strings"
"testing"
@@ -294,7 +293,6 @@
},
}
- jniRuleRe := regexp.MustCompile("^if \\(zipinfo (\\S+)")
for _, test := range testCases {
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
@@ -305,13 +303,9 @@
).RunTestWithBp(t, bp)
variant := result.ModuleForTests("foo", "android_common")
- jniRuleCommand := variant.Output("jnis-uncompressed/foo.apk").RuleParams.Command
- matches := jniRuleRe.FindStringSubmatch(jniRuleCommand)
- if len(matches) != 2 {
- t.Errorf("failed to extract the src apk path from %q", jniRuleCommand)
- }
- if strings.HasSuffix(matches[1], test.expected) {
- t.Errorf("wrong src apk, expected: %q got: %q", test.expected, matches[1])
+ input := variant.Output("jnis-uncompressed/foo.apk").Input.String()
+ if strings.HasSuffix(input, test.expected) {
+ t.Errorf("wrong src apk, expected: %q got: %q", test.expected, input)
}
provenanceMetaDataRule := variant.Rule("genProvenanceMetaData")
@@ -456,7 +450,6 @@
},
}
- jniRuleRe := regexp.MustCompile("^if \\(zipinfo (\\S+)")
for _, test := range testCases {
ctx, _ := testJava(t, test.bp)
@@ -469,13 +462,9 @@
android.AssertDeepEquals(t, "Provenance metadata is not empty", android.TestingBuildParams{}, rule)
continue
}
- jniRuleCommand := variant.Output("jnis-uncompressed/foo.apk").RuleParams.Command
- matches := jniRuleRe.FindStringSubmatch(jniRuleCommand)
- if len(matches) != 2 {
- t.Errorf("failed to extract the src apk path from %q", jniRuleCommand)
- }
- if strings.HasSuffix(matches[1], test.expected) {
- t.Errorf("wrong src apk, expected: %q got: %q", test.expected, matches[1])
+ input := variant.Output("jnis-uncompressed/foo.apk").Input.String()
+ if strings.HasSuffix(input, test.expected) {
+ t.Errorf("wrong src apk, expected: %q got: %q", test.expected, input)
}
rule := variant.Rule("genProvenanceMetaData")
android.AssertStringEquals(t, "Invalid input", test.artifactPath, rule.Inputs[0].String())
@@ -686,8 +675,8 @@
`)
variant := ctx.ModuleForTests("foo", "android_common")
- jniRule := variant.Output("jnis-uncompressed/foo.apk").RuleParams.Command
- if !strings.HasPrefix(jniRule, "if (zipinfo") {
+ jniRule := variant.Output("jnis-uncompressed/foo.apk").BuildParams.Rule.String()
+ if jniRule == android.Cp.String() {
t.Errorf("Unexpected JNI uncompress rule command: " + jniRule)
}
diff --git a/java/app_test.go b/java/app_test.go
index cd88864..3fb67c1 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -3163,6 +3163,7 @@
variables.Platform_sdk_version = &platform_sdk_version
variables.Platform_sdk_codename = &platform_sdk_codename
variables.Platform_version_active_codenames = []string{platform_sdk_codename}
+ variables.Unbundled_build = proptools.BoolPtr(true)
variables.Unbundled_build_apps = []string{"sampleModule"}
}),
)
@@ -3241,6 +3242,7 @@
variables.Platform_sdk_final = &testCase.platform_sdk_final
variables.Platform_sdk_version = &platform_sdk_version
variables.Platform_sdk_codename = &platform_sdk_codename
+ variables.Unbundled_build = proptools.BoolPtr(true)
variables.Unbundled_build_apps = []string{"sampleModule"}
}),
)
@@ -3311,6 +3313,7 @@
variables.Platform_sdk_final = &testCase.platform_sdk_final
variables.Platform_sdk_version = &platform_sdk_version
variables.Platform_sdk_codename = &platform_sdk_codename
+ variables.Unbundled_build = proptools.BoolPtr(true)
variables.Unbundled_build_apps = []string{"sampleModule"}
}),
)
diff --git a/java/core-libraries/Android.bp b/java/core-libraries/Android.bp
index 4fb1d76..b9332dd 100644
--- a/java/core-libraries/Android.bp
+++ b/java/core-libraries/Android.bp
@@ -63,11 +63,6 @@
// This one is not on device but it's needed when javac compiles code
// containing lambdas.
"core-lambda-stubs-for-system-modules",
- // This one is not on device but it's needed when javac compiles code
- // containing @Generated annotations produced by some code generation
- // tools.
- // See http://b/123891440.
- "core-generated-annotation-stubs",
],
sdk_version: "none",
system_modules: "none",
@@ -148,11 +143,6 @@
// This one is not on device but it's needed when javac compiles code
// containing lambdas.
"core-lambda-stubs-for-system-modules",
- // This one is not on device but it's needed when javac compiles code
- // containing @Generated annotations produced by some code generation
- // tools.
- // See http://b/123891440.
- "core-generated-annotation-stubs",
],
sdk_version: "none",
system_modules: "none",
@@ -278,11 +268,6 @@
// This one is not on device but it's needed when javac compiles code
// containing lambdas.
"core-lambda-stubs-for-system-modules",
- // This one is not on device but it's needed when javac compiles code
- // containing @Generated annotations produced by some code generation
- // tools.
- // See http://b/123891440.
- "core-generated-annotation-stubs",
],
}
@@ -294,11 +279,6 @@
// This one is not on device but it's needed when javac compiles code
// containing lambdas.
"core-lambda-stubs-for-system-modules",
- // This one is not on device but it's needed when javac compiles code
- // containing @Generated annotations produced by some code generation
- // tools.
- // See http://b/123891440.
- "core-generated-annotation-stubs",
],
}
@@ -322,11 +302,6 @@
// This one is not on device but it's needed when javac compiles code
// containing lambdas.
"core-lambda-stubs-for-system-modules",
- // This one is not on device but it's needed when javac compiles code
- // containing @Generated annotations produced by some code generation
- // tools.
- // See http://b/123891440.
- "core-generated-annotation-stubs",
// Ensure that core libraries that depend on the public API can access
// the UnsupportedAppUsage, CorePlatformApi and IntraCoreApi
diff --git a/java/droidstubs.go b/java/droidstubs.go
index 066f0d6..4bbe70a 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -877,6 +877,7 @@
"module_lib": android.SdkModule,
"module-lib": android.SdkModule,
"test": android.SdkTest,
+ "toolchain": android.SdkToolchain,
}
)
diff --git a/java/java.go b/java/java.go
index 10d60f0..7078cc3 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1625,13 +1625,17 @@
// List of flags to be passed to the javac compiler to generate jar file
Javacflags []string
+
+ // List of shared java libs that this module has dependencies to and
+ // should be passed as classpath in javac invocation
+ Libs []string
}
func ApiLibraryFactory() android.Module {
module := &ApiLibrary{}
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
- android.InitDefaultableModule(module)
module.AddProperties(&module.properties)
+ android.InitDefaultableModule(module)
return module
}
@@ -1696,6 +1700,7 @@
for _, apiContributionName := range apiContributions {
ctx.AddDependency(ctx.Module(), javaApiContributionTag, apiContributionName)
}
+ ctx.AddVariationDependencies(nil, libTag, al.properties.Libs...)
}
func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
@@ -1713,10 +1718,18 @@
homeDir := android.PathForModuleOut(ctx, "metalava", "home")
- var srcFiles []android.Path
- ctx.VisitDirectDepsWithTag(javaApiContributionTag, func(dep android.Module) {
- provider := ctx.OtherModuleProvider(dep, JavaApiImportProvider).(JavaApiImportInfo)
- srcFiles = append(srcFiles, android.PathForSource(ctx, provider.ApiFile.String()))
+ var srcFiles android.Paths
+ var classPaths android.Paths
+ ctx.VisitDirectDeps(func(dep android.Module) {
+ tag := ctx.OtherModuleDependencyTag(dep)
+ switch tag {
+ case javaApiContributionTag:
+ provider := ctx.OtherModuleProvider(dep, JavaApiImportProvider).(JavaApiImportInfo)
+ srcFiles = append(srcFiles, android.PathForSource(ctx, provider.ApiFile.String()))
+ case libTag:
+ provider := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo)
+ classPaths = append(classPaths, provider.HeaderJars...)
+ }
})
// Add the api_files inputs
@@ -1746,11 +1759,16 @@
var flags javaBuilderFlags
flags.javaVersion = getStubsJavaVersion()
flags.javacFlags = strings.Join(al.properties.Javacflags, " ")
+ flags.classpath = classpath(classPaths)
TransformJavaToClasses(ctx, al.stubsJar, 0, android.Paths{},
android.Paths{al.stubsSrcJar}, flags, android.Paths{})
ctx.Phony(ctx.ModuleName(), al.stubsJar)
+
+ ctx.SetProvider(JavaInfoProvider, JavaInfo{
+ HeaderJars: android.PathsIfNonNil(al.stubsJar),
+ })
}
//
@@ -2411,6 +2429,7 @@
&RuntimeResourceOverlayProperties{},
&LintProperties{},
&appTestHelperAppProperties{},
+ &JavaApiLibraryProperties{},
)
android.InitDefaultsModule(module)
@@ -2535,9 +2554,10 @@
type javaCommonAttributes struct {
*javaResourcesAttributes
- Srcs bazel.LabelListAttribute
- Plugins bazel.LabelListAttribute
- Javacopts bazel.StringListAttribute
+ Srcs bazel.LabelListAttribute
+ Plugins bazel.LabelListAttribute
+ Javacopts bazel.StringListAttribute
+ Common_srcs bazel.LabelListAttribute
}
type javaDependencyLabels struct {
@@ -2682,17 +2702,10 @@
}
if m.properties.Libs != nil {
-
- // TODO 244210934 ALIX Check if this else statement breaks presubmits get rid of it if it doesn't
- if strings.HasPrefix(ctx.ModuleType(), "java_binary") || strings.HasPrefix(ctx.ModuleType(), "java_library") || ctx.ModuleType() == "android_library" {
- for _, d := range m.properties.Libs {
- neverlinkLabel := android.BazelLabelForModuleDepSingle(ctx, d)
- neverlinkLabel.Label = neverlinkLabel.Label + "-neverlink"
- deps.Add(&neverlinkLabel)
- }
-
- } else {
- deps.Append(android.BazelLabelForModuleDeps(ctx, android.LastUniqueStrings(android.CopyOf(m.properties.Libs))))
+ for _, d := range m.properties.Libs {
+ neverlinkLabel := android.BazelLabelForModuleDepSingle(ctx, d)
+ neverlinkLabel.Label = neverlinkLabel.Label + "-neverlink"
+ deps.Add(&neverlinkLabel)
}
}
@@ -2723,10 +2736,9 @@
type javaLibraryAttributes struct {
*javaCommonAttributes
- Deps bazel.LabelListAttribute
- Exports bazel.LabelListAttribute
- Neverlink bazel.BoolAttribute
- Common_srcs bazel.LabelListAttribute
+ Deps bazel.LabelListAttribute
+ Exports bazel.LabelListAttribute
+ Neverlink bazel.BoolAttribute
}
func javaLibraryBp2Build(ctx android.TopDownMutatorContext, m *Library) {
@@ -2760,7 +2772,7 @@
Bzl_load_location: "//build/bazel/rules/java:library.bzl",
}
} else {
- attrs.Common_srcs = bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, m.properties.Common_srcs))
+ attrs.javaCommonAttributes.Common_srcs = bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, m.properties.Common_srcs))
props = bazel.BazelTargetModuleProperties{
Rule_class: "kt_jvm_library",
@@ -2816,14 +2828,8 @@
mainClass = mainClassInManifest
}
- attrs := &javaBinaryHostAttributes{
- javaCommonAttributes: commonAttrs,
- Deps: deps,
- Runtime_deps: runtimeDeps,
- Main_class: mainClass,
- }
-
// Attribute jvm_flags
+ var jvmFlags bazel.StringListAttribute
if m.binaryProperties.Jni_libs != nil {
jniLibPackages := map[string]bool{}
for _, jniLibLabel := range android.BazelLabelForModuleDeps(ctx, m.binaryProperties.Jni_libs).Includes {
@@ -2846,12 +2852,56 @@
// See cs/f:.*/third_party/bazel/.*java_stub_template.txt for the use of RUNPATH
jniLibPaths = append(jniLibPaths, "$${RUNPATH}"+jniLibPackage)
}
- attrs.Jvm_flags = bazel.MakeStringListAttribute([]string{"-Djava.library.path=" + strings.Join(jniLibPaths, ":")})
+ jvmFlags = bazel.MakeStringListAttribute([]string{"-Djava.library.path=" + strings.Join(jniLibPaths, ":")})
}
props := bazel.BazelTargetModuleProperties{
Rule_class: "java_binary",
}
+ attrs := &javaBinaryHostAttributes{
+ Runtime_deps: runtimeDeps,
+ Main_class: mainClass,
+ Jvm_flags: jvmFlags,
+ }
+
+ if !bp2BuildInfo.hasKotlinSrcs && len(m.properties.Common_srcs) == 0 {
+ attrs.javaCommonAttributes = commonAttrs
+ attrs.Deps = deps
+ } else {
+ ktName := m.Name() + "_kt"
+ ktProps := bazel.BazelTargetModuleProperties{
+ Rule_class: "kt_jvm_library",
+ Bzl_load_location: "@rules_kotlin//kotlin:jvm_library.bzl",
+ }
+ ktAttrs := &javaLibraryAttributes{
+ Deps: deps,
+ javaCommonAttributes: &javaCommonAttributes{
+ Srcs: commonAttrs.Srcs,
+ Plugins: commonAttrs.Plugins,
+ Javacopts: commonAttrs.Javacopts,
+ },
+ }
+
+ if len(m.properties.Common_srcs) != 0 {
+ ktAttrs.javaCommonAttributes.Common_srcs = bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, m.properties.Common_srcs))
+ }
+
+ // kt_jvm_library does not support resource_strip_prefix, if this attribute
+ // is set, than javaResourcesAttributes needs to be set in the
+ // javaCommonAttributes of the java_binary target
+ if commonAttrs.javaResourcesAttributes != nil {
+ if commonAttrs.javaResourcesAttributes.Resource_strip_prefix != nil {
+ attrs.javaCommonAttributes = &javaCommonAttributes{
+ javaResourcesAttributes: commonAttrs.javaResourcesAttributes,
+ }
+ } else {
+ ktAttrs.javaCommonAttributes.javaResourcesAttributes = commonAttrs.javaResourcesAttributes
+ }
+ }
+
+ ctx.CreateBazelTargetModule(ktProps, android.CommonAttributes{Name: ktName}, ktAttrs)
+ attrs.Runtime_deps.Add(&bazel.LabelAttribute{Value: &bazel.Label{Label: ":" + ktName}})
+ }
// Create the BazelTargetModule.
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs)
diff --git a/java/java_test.go b/java/java_test.go
index 085f627..ae77842 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -1894,6 +1894,98 @@
}
}
+func TestJavaApiLibraryAndDefaultsLink(t *testing.T) {
+ provider_bp_a := `
+ java_api_contribution {
+ name: "foo1",
+ api_file: "foo1.txt",
+ }
+ `
+ provider_bp_b := `
+ java_api_contribution {
+ name: "foo2",
+ api_file: "foo2.txt",
+ }
+ `
+ provider_bp_c := `
+ java_api_contribution {
+ name: "foo3",
+ api_file: "foo3.txt",
+ }
+ `
+ provider_bp_d := `
+ java_api_contribution {
+ name: "foo4",
+ api_file: "foo4.txt",
+ }
+ `
+ ctx, _ := testJavaWithFS(t, `
+ java_defaults {
+ name: "baz1",
+ api_surface: "public",
+ api_contributions: ["foo1", "foo2"],
+ }
+
+ java_defaults {
+ name: "baz2",
+ api_surface: "system",
+ api_contributions: ["foo3"],
+ }
+
+ java_api_library {
+ name: "bar1",
+ api_surface: "public",
+ api_contributions: ["foo1"],
+ }
+
+ java_api_library {
+ name: "bar2",
+ api_surface: "public",
+ defaults:["baz1"],
+ }
+
+ java_api_library {
+ name: "bar3",
+ api_surface: "system",
+ defaults:["baz1", "baz2"],
+ api_contributions: ["foo4"],
+ api_files: ["api1/current.txt", "api2/current.txt"]
+ }
+ `,
+ map[string][]byte{
+ "a/Android.bp": []byte(provider_bp_a),
+ "b/Android.bp": []byte(provider_bp_b),
+ "c/Android.bp": []byte(provider_bp_c),
+ "d/Android.bp": []byte(provider_bp_d),
+ })
+
+ testcases := []struct {
+ moduleName string
+ sourceTextFileDirs []string
+ }{
+ {
+ moduleName: "bar1",
+ sourceTextFileDirs: []string{"a/foo1.txt"},
+ },
+ {
+ moduleName: "bar2",
+ sourceTextFileDirs: []string{"a/foo1.txt", "b/foo2.txt"},
+ },
+ {
+ moduleName: "bar3",
+ sourceTextFileDirs: []string{"c/foo3.txt", "a/foo1.txt", "b/foo2.txt", "d/foo4.txt", "api1/current.txt", "api2/current.txt"},
+ },
+ }
+ for _, c := range testcases {
+ m := ctx.ModuleForTests(c.moduleName, "android_common")
+ manifest := m.Output("metalava.sbox.textproto")
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest)
+ manifestCommand := sboxProto.Commands[0].GetCommand()
+ sourceFilesFlag := "--source-files " + strings.Join(c.sourceTextFileDirs, " ")
+ android.AssertStringDoesContain(t, "source text files not present", manifestCommand, sourceFilesFlag)
+ }
+}
+
func TestJavaApiLibraryJarGeneration(t *testing.T) {
provider_bp_a := `
java_api_contribution {
@@ -1901,7 +1993,8 @@
api_file: "foo1.txt",
}
`
- provider_bp_b := `java_api_contribution {
+ provider_bp_b := `
+ java_api_contribution {
name: "foo2",
api_file: "foo2.txt",
}
@@ -1946,6 +2039,81 @@
}
}
+func TestJavaApiLibraryLibsLink(t *testing.T) {
+ provider_bp_a := `
+ java_api_contribution {
+ name: "foo1",
+ api_file: "foo1.txt",
+ }
+ `
+ provider_bp_b := `
+ java_api_contribution {
+ name: "foo2",
+ api_file: "foo2.txt",
+ }
+ `
+ lib_bp_a := `
+ java_library {
+ name: "lib1",
+ srcs: ["Lib.java"],
+ }
+ `
+ lib_bp_b := `
+ java_library {
+ name: "lib2",
+ srcs: ["Lib.java"],
+ }
+ `
+
+ ctx, _ := testJavaWithFS(t, `
+ java_api_library {
+ name: "bar1",
+ api_surface: "public",
+ api_contributions: ["foo1"],
+ libs: ["lib1"],
+ }
+
+ java_api_library {
+ name: "bar2",
+ api_surface: "system",
+ api_contributions: ["foo1", "foo2"],
+ libs: ["lib1", "lib2", "bar1"],
+ }
+ `,
+ map[string][]byte{
+ "a/Android.bp": []byte(provider_bp_a),
+ "b/Android.bp": []byte(provider_bp_b),
+ "c/Android.bp": []byte(lib_bp_a),
+ "c/Lib.java": {},
+ "d/Android.bp": []byte(lib_bp_b),
+ "d/Lib.java": {},
+ })
+
+ testcases := []struct {
+ moduleName string
+ classPathJarNames []string
+ }{
+ {
+ moduleName: "bar1",
+ classPathJarNames: []string{"lib1.jar"},
+ },
+ {
+ moduleName: "bar2",
+ classPathJarNames: []string{"lib1.jar", "lib2.jar", "bar1/android.jar"},
+ },
+ }
+ for _, c := range testcases {
+ m := ctx.ModuleForTests(c.moduleName, "android_common")
+ javacRules := m.Rule("javac")
+ classPathArgs := javacRules.Args["classpath"]
+ for _, jarName := range c.classPathJarNames {
+ if !strings.Contains(classPathArgs, jarName) {
+ t.Errorf("Module output does not contain expected jar %s", jarName)
+ }
+ }
+ }
+}
+
func TestTradefedOptions(t *testing.T) {
result := PrepareForTestWithJavaBuildComponents.RunTestWithBp(t, `
java_test_host {
diff --git a/java/jdeps.go b/java/jdeps.go
index 3734335..a52b867 100644
--- a/java/jdeps.go
+++ b/java/jdeps.go
@@ -52,6 +52,11 @@
return
}
+ // Prevent including both prebuilts and matching source modules when one replaces the other.
+ if !android.IsModulePreferred(module) {
+ return
+ }
+
ideInfoProvider, ok := module.(android.IDEInfo)
if !ok {
return
diff --git a/mk2rbc/android_products_test.go b/mk2rbc/android_products_test.go
index f8c930a..5f55f6a 100644
--- a/mk2rbc/android_products_test.go
+++ b/mk2rbc/android_products_test.go
@@ -29,7 +29,6 @@
}
expectedProducts := map[string]string{
"aosp_cf_x86_tv": abspath("vsoc_x86/tv/device.mk"),
- "aosp_tv_arm": abspath("aosp_tv_arm.mk"),
"aosp_tv_arm64": abspath("aosp_tv_arm64.mk"),
}
if !reflect.DeepEqual(actualProducts, expectedProducts) {
diff --git a/mk2rbc/test/android_products.mk.test b/mk2rbc/test/android_products.mk.test
index a2220ed..400ec35 100644
--- a/mk2rbc/test/android_products.mk.test
+++ b/mk2rbc/test/android_products.mk.test
@@ -1,4 +1,3 @@
PRODUCT_MAKEFILES := \
- $(LOCAL_DIR)/aosp_tv_arm.mk \
$(LOCAL_DIR)/aosp_tv_arm64.mk \
aosp_cf_x86_tv:$(LOCAL_DIR)/vsoc_x86/tv/device.mk
\ No newline at end of file
diff --git a/rust/compiler.go b/rust/compiler.go
index 6055158..8ec42f0 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -15,6 +15,7 @@
package rust
import (
+ "android/soong/cc"
"fmt"
"path/filepath"
"strings"
@@ -307,19 +308,7 @@
flags.EmitXrefs = ctx.Config().EmitXrefRules()
if ctx.Host() && !ctx.Windows() {
- rpathPrefix := `\$$ORIGIN/`
- if ctx.Darwin() {
- rpathPrefix = "@loader_path/"
- }
-
- var rpath string
- if ctx.toolchain().Is64Bit() {
- rpath = "lib64"
- } else {
- rpath = "lib"
- }
- flags.LinkFlags = append(flags.LinkFlags, "-Wl,-rpath,"+rpathPrefix+rpath)
- flags.LinkFlags = append(flags.LinkFlags, "-Wl,-rpath,"+rpathPrefix+"../"+rpath)
+ flags.LinkFlags = append(flags.LinkFlags, cc.RpathFlags(ctx)...)
}
return flags
diff --git a/rust/config/global.go b/rust/config/global.go
index 81aec7e..26e2d06 100644
--- a/rust/config/global.go
+++ b/rust/config/global.go
@@ -24,7 +24,7 @@
var pctx = android.NewPackageContext("android/soong/rust/config")
var (
- RustDefaultVersion = "1.64.0"
+ RustDefaultVersion = "1.65.0"
RustDefaultBase = "prebuilts/rust/"
DefaultEdition = "2021"
Stdlibs = []string{
diff --git a/rust/test.go b/rust/test.go
index 4f922b4..4b5296e 100644
--- a/rust/test.go
+++ b/rust/test.go
@@ -200,6 +200,7 @@
if ctx.Device() {
flags.RustFlags = append(flags.RustFlags, "-Z panic_abort_tests")
}
+
return flags
}
diff --git a/scripts/conv_linker_config.py b/scripts/conv_linker_config.py
index e46efe4..3d7c0fa 100644
--- a/scripts/conv_linker_config.py
+++ b/scripts/conv_linker_config.py
@@ -27,13 +27,15 @@
def Proto(args):
- json_content = ''
- with open(args.source) as f:
- for line in f:
- if not line.lstrip().startswith('//'):
- json_content += line
- obj = json.loads(json_content, object_pairs_hook=collections.OrderedDict)
- pb = ParseDict(obj, linker_config_pb2.LinkerConfig())
+ pb = linker_config_pb2.LinkerConfig()
+ for input in args.source.split(':'):
+ json_content = ''
+ with open(input) as f:
+ for line in f:
+ if not line.lstrip().startswith('//'):
+ json_content += line
+ obj = json.loads(json_content, object_pairs_hook=collections.OrderedDict)
+ ParseDict(obj, pb)
with open(args.output, 'wb') as f:
f.write(pb.SerializeToString())
@@ -104,7 +106,7 @@
'--source',
required=True,
type=str,
- help='Source linker configuration file in JSON.')
+ help='Colon-separated list of linker configuration files in JSON.')
parser_proto.add_argument(
'-o',
'--output',
diff --git a/scripts/hiddenapi/signature_trie.py b/scripts/hiddenapi/signature_trie.py
index 3650fa1..2ff0c5f 100644
--- a/scripts/hiddenapi/signature_trie.py
+++ b/scripts/hiddenapi/signature_trie.py
@@ -150,10 +150,6 @@
f"wildcard '{last_element}' and "
f"member signature '{member[0]}'")
wildcard = [last_element]
- elif last_element.islower():
- raise Exception(f"Invalid signature '{signature}': last element "
- f"'{last_element}' is lower case but should be an "
- f"upper case class name or wildcard")
else:
packages = elements[0:-1]
# Split the class name into outer / inner classes
diff --git a/scripts/hiddenapi/signature_trie_test.py b/scripts/hiddenapi/signature_trie_test.py
index 6d4e660..bd4a9a8 100755
--- a/scripts/hiddenapi/signature_trie_test.py
+++ b/scripts/hiddenapi/signature_trie_test.py
@@ -117,14 +117,6 @@
self.assertEqual(elements, self.signature_to_elements(signature))
self.assertEqual(signature, self.elements_to_signature(elements))
- def test_invalid_no_class_or_wildcard(self):
- signature = "java/lang"
- with self.assertRaises(Exception) as context:
- self.signature_to_elements(signature)
- self.assertIn(
- "last element 'lang' is lower case but should be an "
- "upper case class name or wildcard", str(context.exception))
-
def test_non_standard_class_name(self):
elements = [
("package", "javax"),
diff --git a/tests/apex_cc_module_arch_variant_tests.sh b/tests/apex_cc_module_arch_variant_tests.sh
new file mode 100755
index 0000000..97e6576
--- /dev/null
+++ b/tests/apex_cc_module_arch_variant_tests.sh
@@ -0,0 +1,94 @@
+#!/bin/bash
+
+# Copyright (C) 2022 The Android Open Source Project
+#
+# 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.
+
+set -uo pipefail
+
+# Integration test for verifying arch variant cflags set on cc modules included
+# in Bazel-built apexes in the real source tree.
+
+if [ ! -e "build/make/core/Makefile" ]; then
+ echo "$0 must be run from the top of the Android source tree."
+ exit 1
+fi
+
+############
+# Test Setup
+############
+
+OUTPUT_DIR="$(mktemp -d tmp.XXXXXX)"
+BAZEL_OUTPUT_DIR="$OUTPUT_DIR/bazel"
+
+export TARGET_PRODUCT="aosp_arm64"
+[ "$#" -ge 1 ] && export TARGET_PRODUCT="$1"
+ARCH_VARIANT_CFLAG="armv8-a"
+[ "$#" -ge 2 ] && ARCH_VARIANT_CFLAG="$2"
+CPU_VARIANT_CFLAG=""
+[ "$#" -ge 3 ] && CPU_VARIANT_CFLAG="$3"
+
+function call_bazel() {
+ build/bazel/bin/bazel --output_base="$BAZEL_OUTPUT_DIR" $@
+}
+
+function cleanup {
+ # call bazel clean because some bazel outputs don't have w bits.
+ call_bazel clean
+ rm -rf "${OUTPUT_DIR}"
+}
+trap cleanup EXIT
+
+######################
+# Run bp2build / Bazel
+######################
+build/soong/soong_ui.bash --make-mode BP2BUILD_VERBOSE=1 --skip-soong-tests bp2build
+
+# Number of CppCompile actions with arch variant flag
+actions_with_arch_variant_num=$(call_bazel aquery --config=bp2build --config=ci --config=android \
+ 'mnemonic("CppCompile", deps(//build/bazel/examples/apex/minimal:build.bazel.examples.apex.minimal.apex))' | grep -c "\-march=$ARCH_VARIANT_CFLAG")
+
+# Number of all CppCompile actions
+all_cppcompile_actions_num=0
+aquery_summary=$(call_bazel aquery --config=bp2build --config=ci --config=android --output=summary \
+ 'mnemonic("CppCompile", deps(//build/bazel/examples/apex/minimal:build.bazel.examples.apex.minimal.apex))' \
+ | egrep -o '.*opt-ST.*: ([0-9]+)$' \
+ | cut -d: -f2 -)
+
+while read -r num;
+do
+ all_cppcompile_actions_num=$(($all_cppcompile_actions_num + $num))
+done <<< "$aquery_summary"
+
+if [ $actions_with_arch_variant_num -eq $all_cppcompile_actions_num ]
+then
+ echo "Pass: arch variant is set."
+else
+ echo "Error: number of CppCompile actions with arch variant set: actual=$actions_with_arch_variant_num, expected=$all_cppcompile_actions_num"
+ exit 1
+fi
+
+if [ $CPU_VARIANT_CFLAG ]
+then
+ # Number of CppCompiler actions with cpu variant flag
+ actions_with_cpu_variant_num=$(call_bazel aquery --config=bp2build --config=ci --config=android \
+ 'mnemonic("CppCompile", deps(//build/bazel/examples/apex/minimal:build.bazel.examples.apex.minimal.apex))' | grep -c "\-mcpu=$CPU_VARIANT_CFLAG")
+
+ if [ $actions_with_cpu_variant_num -eq $all_cppcompile_actions_num ]
+ then
+ echo "Pass: cpu variant is set."
+ else
+ echo "Error: number of CppCompile actions with cpu variant set: actual=$actions_with_cpu_variant_num, expected=$all_cppcompile_actions_num"
+ exit 1
+ fi
+fi
\ No newline at end of file
diff --git a/tests/apex_comparison_tests.sh b/tests/apex_comparison_tests.sh
index 412f84a..5007078 100755
--- a/tests/apex_comparison_tests.sh
+++ b/tests/apex_comparison_tests.sh
@@ -74,7 +74,7 @@
# # Build debugfs separately, as it's not a dep of apexer, but needs to be an explicit arg.
call_bazel build --config=bp2build --config=linux_x86_64 //external/e2fsprogs/debugfs //system/apex/tools:deapexer
DEBUGFS_PATH="$(realpath $(call_bazel cquery --config=bp2build --config=linux_x86_64 --config=ci --output=files //external/e2fsprogs/debugfs))"
-DEAPEXER="$(realpath $(call_bazel cquery --config=bp2build --config=linux_x86_64 --config=ci --output=files //system/apex/tools:deapexer))"
+DEAPEXER="bazel-bin/system/apex/tools/deapexer"
DEAPEXER="$DEAPEXER --debugfs_path=$DEBUGFS_PATH"
#######
diff --git a/tests/bootstrap_test.sh b/tests/bootstrap_test.sh
index 17b4419..f3bad73 100755
--- a/tests/bootstrap_test.sh
+++ b/tests/bootstrap_test.sh
@@ -75,7 +75,6 @@
grep -q "^# Module:.*my_great_binary_host" out/soong/build.ninja || fail "new module not found"
}
-
function test_add_android_bp() {
setup
run_soong
@@ -313,7 +312,6 @@
}
-
function test_add_file_to_soong_build() {
setup
run_soong
@@ -736,7 +734,6 @@
}
-
function test_bp2build_bazel_workspace_structure {
setup
@@ -802,7 +799,7 @@
|| fail "${GENERATED_BUILD_FILE_NAME} files symlinked to the wrong place"
}
-function test_bp2build_reports_multiple_errors {
+function test_bp2build_fails_fast {
setup
mkdir -p "a/${GENERATED_BUILD_FILE_NAME}"
@@ -830,7 +827,7 @@
fi
grep -q "a/${GENERATED_BUILD_FILE_NAME}' exist" "$MOCK_TOP/errors" || fail "Error for a/${GENERATED_BUILD_FILE_NAME} not found"
- grep -q "b/${GENERATED_BUILD_FILE_NAME}' exist" "$MOCK_TOP/errors" || fail "Error for b/${GENERATED_BUILD_FILE_NAME} not found"
+ grep -q -v "b/${GENERATED_BUILD_FILE_NAME}' exist" "$MOCK_TOP/errors" || fail "Error for b/${GENERATED_BUILD_FILE_NAME} found but not expected"
}
function test_bp2build_back_and_forth_null_build {
diff --git a/tests/bp2build_bazel_test.sh b/tests/bp2build_bazel_test.sh
index 8c2ce48..6477dac 100755
--- a/tests/bp2build_bazel_test.sh
+++ b/tests/bp2build_bazel_test.sh
@@ -231,4 +231,11 @@
fi
}
+# Smoke test to verify api_bp2build worksapce does not contain any errors
+function test_api_bp2build_empty_build() {
+ setup
+ run_soong api_bp2build
+ run_bazel build --config=android --config=api_bp2build //:empty
+}
+
scan_and_run_tests
diff --git a/tests/run_integration_tests.sh b/tests/run_integration_tests.sh
index 7a71b27..eb76a46 100755
--- a/tests/run_integration_tests.sh
+++ b/tests/run_integration_tests.sh
@@ -14,3 +14,7 @@
# mock client.
"$TOP/build/soong/tests/apex_comparison_tests.sh"
"$TOP/build/soong/tests/apex_comparison_tests.sh" "module_arm64only"
+
+"$TOP/build/soong/tests/apex_cc_module_arch_variant_tests.sh"
+"$TOP/build/soong/tests/apex_cc_module_arch_variant_tests.sh" "aosp_arm" "armv7-a"
+"$TOP/build/soong/tests/apex_cc_module_arch_variant_tests.sh" "aosp_cf_arm64_phone" "armv8-a" "cortex-a53"
\ No newline at end of file
diff --git a/ui/build/config.go b/ui/build/config.go
index 61f6b1c..cb7fe1e 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -147,8 +147,10 @@
}
}
-// fetchEnvConfig optionally fetches environment config from an
-// experiments system to control Soong features dynamically.
+// fetchEnvConfig optionally fetches a configuration file that can then subsequently be
+// loaded into Soong environment to control certain aspects of build behavior (e.g., enabling RBE).
+// If a configuration file already exists on disk, the fetch is run in the background
+// so as to NOT block the rest of the build execution.
func fetchEnvConfig(ctx Context, config *configImpl, envConfigName string) error {
configName := envConfigName + "." + jsonSuffix
expConfigFetcher := &smpb.ExpConfigFetcher{Filename: &configName}
@@ -174,8 +176,13 @@
return fmt.Errorf("configuration fetcher binary %v is not executable: %v", configFetcher, s.Mode())
}
+ configExists := false
+ outConfigFilePath := filepath.Join(config.OutDir(), configName)
+ if _, err := os.Stat(outConfigFilePath); err == nil {
+ configExists = true
+ }
+
tCtx, cancel := context.WithTimeout(ctx, envConfigFetchTimeout)
- defer cancel()
fetchStart := time.Now()
cmd := exec.CommandContext(tCtx, configFetcher, "-output_config_dir", config.OutDir(),
"-output_config_name", configName)
@@ -185,33 +192,45 @@
return err
}
- if err := cmd.Wait(); err != nil {
- status := smpb.ExpConfigFetcher_ERROR
- expConfigFetcher.Status = &status
- return err
- }
- fetchEnd := time.Now()
- expConfigFetcher.Micros = proto.Uint64(uint64(fetchEnd.Sub(fetchStart).Microseconds()))
- outConfigFilePath := filepath.Join(config.OutDir(), configName)
- expConfigFetcher.Filename = proto.String(outConfigFilePath)
- if _, err := os.Stat(outConfigFilePath); err == nil {
+ fetchCfg := func() error {
+ if err := cmd.Wait(); err != nil {
+ status := smpb.ExpConfigFetcher_ERROR
+ expConfigFetcher.Status = &status
+ return err
+ }
+ fetchEnd := time.Now()
+ expConfigFetcher.Micros = proto.Uint64(uint64(fetchEnd.Sub(fetchStart).Microseconds()))
+ expConfigFetcher.Filename = proto.String(outConfigFilePath)
+
+ if _, err := os.Stat(outConfigFilePath); err != nil {
+ status := smpb.ExpConfigFetcher_NO_CONFIG
+ expConfigFetcher.Status = &status
+ return err
+ }
status := smpb.ExpConfigFetcher_CONFIG
expConfigFetcher.Status = &status
- } else {
- status := smpb.ExpConfigFetcher_NO_CONFIG
- expConfigFetcher.Status = &status
- }
- return nil
-}
-
-func loadEnvConfig(ctx Context, config *configImpl) error {
- bc := os.Getenv("ANDROID_BUILD_ENVIRONMENT_CONFIG")
- if bc == "" {
return nil
}
- if err := fetchEnvConfig(ctx, config, bc); err != nil {
- ctx.Verbosef("Failed to fetch config file: %v\n", err)
+ // If a config file does not exist, wait for the config file to be fetched. Otherwise
+ // fetch the config file in the background and return immediately.
+ if !configExists {
+ defer cancel()
+ return fetchCfg()
+ }
+
+ go func() {
+ defer cancel()
+ if err := fetchCfg(); err != nil {
+ ctx.Verbosef("Failed to fetch config file %v: %v\n", configName, err)
+ }
+ }()
+ return nil
+}
+
+func loadEnvConfig(ctx Context, config *configImpl, bc string) error {
+ if bc == "" {
+ return nil
}
configDirs := []string{
@@ -262,6 +281,12 @@
environ: OsEnvironment(),
sandboxConfig: &SandboxConfig{},
}
+ srcDir := absPath(ctx, ".")
+ bc := os.Getenv("ANDROID_BUILD_ENVIRONMENT_CONFIG")
+ if err := loadEnvConfig(ctx, ret, bc); err != nil {
+ ctx.Fatalln("Failed to parse env config files: %v", err)
+ }
+ ret.metricsUploader = GetMetricsUploader(srcDir, ret.environ)
return Config{ret}
}
@@ -294,8 +319,15 @@
// loadEnvConfig needs to know what the OUT_DIR is, so it should
// be called after we determine the appropriate out directory.
- if err := loadEnvConfig(ctx, ret); err != nil {
- ctx.Fatalln("Failed to parse env config files: %v", err)
+ bc := os.Getenv("ANDROID_BUILD_ENVIRONMENT_CONFIG")
+
+ if bc != "" {
+ if err := fetchEnvConfig(ctx, ret, bc); err != nil {
+ ctx.Verbosef("Failed to fetch config file: %v\n", err)
+ }
+ if err := loadEnvConfig(ctx, ret, bc); err != nil {
+ ctx.Fatalln("Failed to parse env config files: %v", err)
+ }
}
if distDir, ok := ret.environ.Get("DIST_DIR"); ok {
diff --git a/ui/metrics/bp2build_metrics_proto/bp2build_metrics.pb.go b/ui/metrics/bp2build_metrics_proto/bp2build_metrics.pb.go
index 93f3471..4821043 100644
--- a/ui/metrics/bp2build_metrics_proto/bp2build_metrics.pb.go
+++ b/ui/metrics/bp2build_metrics_proto/bp2build_metrics.pb.go
@@ -14,8 +14,8 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
-// protoc-gen-go v1.27.1
-// protoc v3.9.1
+// protoc-gen-go v1.28.0
+// protoc v3.21.7
// source: bp2build_metrics.proto
package bp2build_metrics_proto
@@ -45,6 +45,10 @@
HandCraftedModuleCount uint64 `protobuf:"varint,2,opt,name=handCraftedModuleCount,proto3" json:"handCraftedModuleCount,omitempty"`
// Total number of unconverted Soong modules
UnconvertedModuleCount uint64 `protobuf:"varint,3,opt,name=unconvertedModuleCount,proto3" json:"unconvertedModuleCount,omitempty"`
+ // Counts of symlinks in synthetic bazel workspace
+ WorkspaceSymlinkCount uint64 `protobuf:"varint,9,opt,name=workspaceSymlinkCount,proto3" json:"workspaceSymlinkCount,omitempty"`
+ // Counts of mkdir calls during creation of synthetic bazel workspace
+ WorkspaceMkDirCount uint64 `protobuf:"varint,10,opt,name=workspaceMkDirCount,proto3" json:"workspaceMkDirCount,omitempty"`
// Counts of generated Bazel targets per Bazel rule class
RuleClassCount map[string]uint64 `protobuf:"bytes,4,rep,name=ruleClassCount,proto3" json:"ruleClassCount,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
// List of converted modules
@@ -111,6 +115,20 @@
return 0
}
+func (x *Bp2BuildMetrics) GetWorkspaceSymlinkCount() uint64 {
+ if x != nil {
+ return x.WorkspaceSymlinkCount
+ }
+ return 0
+}
+
+func (x *Bp2BuildMetrics) GetWorkspaceMkDirCount() uint64 {
+ if x != nil {
+ return x.WorkspaceMkDirCount
+ }
+ return 0
+}
+
func (x *Bp2BuildMetrics) GetRuleClassCount() map[string]uint64 {
if x != nil {
return x.RuleClassCount
@@ -221,7 +239,7 @@
0x0a, 0x16, 0x62, 0x70, 0x32, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69,
0x63, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1c, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x5f,
0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x62, 0x70, 0x32, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x6d,
- 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x22, 0xe9, 0x06, 0x0a, 0x0f, 0x42, 0x70, 0x32, 0x42, 0x75,
+ 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x22, 0xd1, 0x07, 0x0a, 0x0f, 0x42, 0x70, 0x32, 0x42, 0x75,
0x69, 0x6c, 0x64, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x12, 0x32, 0x0a, 0x14, 0x67, 0x65,
0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x43, 0x6f, 0x75,
0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x14, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61,
@@ -232,60 +250,66 @@
0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x36, 0x0a, 0x16, 0x75, 0x6e, 0x63, 0x6f, 0x6e, 0x76,
0x65, 0x72, 0x74, 0x65, 0x64, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74,
0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x16, 0x75, 0x6e, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72,
- 0x74, 0x65, 0x64, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x69,
- 0x0a, 0x0e, 0x72, 0x75, 0x6c, 0x65, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74,
- 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x41, 0x2e, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x5f, 0x62,
- 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x62, 0x70, 0x32, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x6d, 0x65,
- 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x42, 0x70, 0x32, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x4d, 0x65,
- 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x52, 0x75, 0x6c, 0x65, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x43,
- 0x6f, 0x75, 0x6e, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0e, 0x72, 0x75, 0x6c, 0x65, 0x43,
- 0x6c, 0x61, 0x73, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2a, 0x0a, 0x10, 0x63, 0x6f, 0x6e,
- 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x05, 0x20,
- 0x03, 0x28, 0x09, 0x52, 0x10, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x4d, 0x6f,
- 0x64, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x87, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72,
- 0x74, 0x65, 0x64, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x43, 0x6f, 0x75,
- 0x6e, 0x74, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x4b, 0x2e, 0x73, 0x6f, 0x6f, 0x6e, 0x67,
- 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x62, 0x70, 0x32, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f,
- 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x42, 0x70, 0x32, 0x42, 0x75, 0x69, 0x6c, 0x64,
- 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65,
- 0x64, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74,
- 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x18, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x64,
- 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12,
- 0x7b, 0x0a, 0x14, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x54, 0x79,
- 0x70, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x47, 0x2e,
- 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x62, 0x70, 0x32, 0x62,
- 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x42, 0x70, 0x32,
- 0x42, 0x75, 0x69, 0x6c, 0x64, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x54, 0x6f, 0x74,
- 0x61, 0x6c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x43, 0x6f, 0x75, 0x6e,
- 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x14, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x4d, 0x6f, 0x64,
- 0x75, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x3b, 0x0a, 0x06,
- 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73,
- 0x6f, 0x6f, 0x6e, 0x67, 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x62, 0x70, 0x32, 0x62, 0x75,
- 0x69, 0x6c, 0x64, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e,
- 0x74, 0x52, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x1a, 0x41, 0x0a, 0x13, 0x52, 0x75, 0x6c,
- 0x65, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79,
- 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b,
- 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
- 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x4b, 0x0a, 0x1d,
+ 0x74, 0x65, 0x64, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x34,
+ 0x0a, 0x15, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x79, 0x6d, 0x6c, 0x69,
+ 0x6e, 0x6b, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x15, 0x77,
+ 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x53, 0x79, 0x6d, 0x6c, 0x69, 0x6e, 0x6b, 0x43,
+ 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x30, 0x0a, 0x13, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63,
+ 0x65, 0x4d, 0x6b, 0x44, 0x69, 0x72, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28,
+ 0x04, 0x52, 0x13, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4d, 0x6b, 0x44, 0x69,
+ 0x72, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x69, 0x0a, 0x0e, 0x72, 0x75, 0x6c, 0x65, 0x43, 0x6c,
+ 0x61, 0x73, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x41,
+ 0x2e, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x62, 0x70, 0x32,
+ 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x42, 0x70,
+ 0x32, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x52, 0x75,
+ 0x6c, 0x65, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x45, 0x6e, 0x74, 0x72,
+ 0x79, 0x52, 0x0e, 0x72, 0x75, 0x6c, 0x65, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x43, 0x6f, 0x75, 0x6e,
+ 0x74, 0x12, 0x2a, 0x0a, 0x10, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x4d, 0x6f,
+ 0x64, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x63, 0x6f, 0x6e,
+ 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x87, 0x01,
+ 0x0a, 0x18, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x4d, 0x6f, 0x64, 0x75, 0x6c,
+ 0x65, 0x54, 0x79, 0x70, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b,
+ 0x32, 0x4b, 0x2e, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x62,
+ 0x70, 0x32, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e,
+ 0x42, 0x70, 0x32, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e,
0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x54,
- 0x79, 0x70, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a,
- 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12,
- 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05,
- 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x47, 0x0a, 0x19, 0x54, 0x6f, 0x74,
- 0x61, 0x6c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x43, 0x6f, 0x75, 0x6e,
- 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20,
- 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75,
- 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02,
- 0x38, 0x01, 0x22, 0x57, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e,
- 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12,
- 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20,
- 0x01, 0x28, 0x04, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1b,
- 0x0a, 0x09, 0x72, 0x65, 0x61, 0x6c, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28,
- 0x04, 0x52, 0x08, 0x72, 0x65, 0x61, 0x6c, 0x54, 0x69, 0x6d, 0x65, 0x42, 0x31, 0x5a, 0x2f, 0x61,
- 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x75, 0x69, 0x2f,
- 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2f, 0x62, 0x70, 0x32, 0x62, 0x75, 0x69, 0x6c, 0x64,
- 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06,
- 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+ 0x79, 0x70, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x18, 0x63,
+ 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x54, 0x79,
+ 0x70, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x7b, 0x0a, 0x14, 0x74, 0x6f, 0x74, 0x61, 0x6c,
+ 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18,
+ 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x47, 0x2e, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x5f, 0x62, 0x75,
+ 0x69, 0x6c, 0x64, 0x5f, 0x62, 0x70, 0x32, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x6d, 0x65, 0x74,
+ 0x72, 0x69, 0x63, 0x73, 0x2e, 0x42, 0x70, 0x32, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x4d, 0x65, 0x74,
+ 0x72, 0x69, 0x63, 0x73, 0x2e, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65,
+ 0x54, 0x79, 0x70, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x14,
+ 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x43,
+ 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x3b, 0x0a, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x08,
+ 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x5f, 0x62, 0x75, 0x69,
+ 0x6c, 0x64, 0x5f, 0x62, 0x70, 0x32, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x6d, 0x65, 0x74, 0x72,
+ 0x69, 0x63, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74,
+ 0x73, 0x1a, 0x41, 0x0a, 0x13, 0x52, 0x75, 0x6c, 0x65, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x43, 0x6f,
+ 0x75, 0x6e, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18,
+ 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61,
+ 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
+ 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x4b, 0x0a, 0x1d, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65,
+ 0x64, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74,
+ 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01,
+ 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
+ 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38,
+ 0x01, 0x1a, 0x47, 0x0a, 0x19, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65,
+ 0x54, 0x79, 0x70, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10,
+ 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79,
+ 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52,
+ 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x57, 0x0a, 0x05, 0x45, 0x76,
+ 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
+ 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74,
+ 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x73, 0x74, 0x61,
+ 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x65, 0x61, 0x6c, 0x5f, 0x74,
+ 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x72, 0x65, 0x61, 0x6c, 0x54,
+ 0x69, 0x6d, 0x65, 0x42, 0x31, 0x5a, 0x2f, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73,
+ 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x75, 0x69, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2f,
+ 0x62, 0x70, 0x32, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73,
+ 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
diff --git a/ui/metrics/bp2build_metrics_proto/bp2build_metrics.proto b/ui/metrics/bp2build_metrics_proto/bp2build_metrics.proto
index 19a7827..9ff4ae2 100644
--- a/ui/metrics/bp2build_metrics_proto/bp2build_metrics.proto
+++ b/ui/metrics/bp2build_metrics_proto/bp2build_metrics.proto
@@ -27,6 +27,12 @@
// Total number of unconverted Soong modules
uint64 unconvertedModuleCount = 3;
+ // Counts of symlinks in synthetic bazel workspace
+ uint64 workspaceSymlinkCount= 9;
+
+ // Counts of mkdir calls during creation of synthetic bazel workspace
+ uint64 workspaceMkDirCount= 10;
+
// Counts of generated Bazel targets per Bazel rule class
map<string, uint64> ruleClassCount = 4;
diff --git a/ui/metrics/bp2build_progress_metrics_proto/BUILD.bazel b/ui/metrics/bp2build_progress_metrics_proto/BUILD.bazel
index 356b188..f6c6df8 100644
--- a/ui/metrics/bp2build_progress_metrics_proto/BUILD.bazel
+++ b/ui/metrics/bp2build_progress_metrics_proto/BUILD.bazel
@@ -22,6 +22,6 @@
py_proto_library(
name = "bp2build_py_proto",
+ visibility = ["//build/bazel/scripts/bp2build_progress:__pkg__"],
deps = [":bp2build_proto"],
- visibility = ["//build/bazel/scripts/bp2build-progress:__pkg__"],
)