Merge "[cc/sanitize] Re-enable new pass manager for fuzzer targets"
diff --git a/android/Android.bp b/android/Android.bp
index cfa2be3..a20aedc 100644
--- a/android/Android.bp
+++ b/android/Android.bp
@@ -113,6 +113,7 @@
"paths_test.go",
"prebuilt_test.go",
"rule_builder_test.go",
+ "sdk_version_test.go",
"sdk_test.go",
"singleton_module_test.go",
"soong_config_modules_test.go",
diff --git a/android/apex.go b/android/apex.go
index 6b4054d..d5fd922 100644
--- a/android/apex.go
+++ b/android/apex.go
@@ -878,12 +878,8 @@
"kotlinx-coroutines-android-nodeps": 30,
"kotlinx-coroutines-core": 28,
"kotlinx-coroutines-core-nodeps": 30,
- "libasyncio": 30,
"libbrotli": 30,
- "libbuildversion": 30,
"libcrypto_static": 30,
- "libcrypto_utils": 30,
- "libdiagnose_usb": 30,
"libeigen": 30,
"liblz4": 30,
"libmdnssd": 30,
@@ -893,7 +889,6 @@
"libprocpartition": 30,
"libprotobuf-java-lite": 30,
"libprotoutil": 30,
- "libsync": 30,
"libtextclassifier_hash_headers": 30,
"libtextclassifier_hash_static": 30,
"libtflite_kernel_utils": 30,
@@ -913,16 +908,17 @@
//
// Return true if the `to` module should be visited, false otherwise.
type PayloadDepsCallback func(ctx ModuleContext, from blueprint.Module, to ApexModule, externalDep bool) bool
+type WalkPayloadDepsFunc func(ctx ModuleContext, do PayloadDepsCallback)
-// UpdatableModule represents updatable APEX/APK
-type UpdatableModule interface {
+// ModuleWithMinSdkVersionCheck represents a module that implements min_sdk_version checks
+type ModuleWithMinSdkVersionCheck interface {
Module
- WalkPayloadDeps(ctx ModuleContext, do PayloadDepsCallback)
+ CheckMinSdkVersion(ctx ModuleContext)
}
// CheckMinSdkVersion checks if every dependency of an updatable module sets min_sdk_version
// accordingly
-func CheckMinSdkVersion(m UpdatableModule, ctx ModuleContext, minSdkVersion ApiLevel) {
+func CheckMinSdkVersion(ctx ModuleContext, minSdkVersion ApiLevel, walk WalkPayloadDepsFunc) {
// do not enforce min_sdk_version for host
if ctx.Host() {
return
@@ -938,7 +934,7 @@
return
}
- m.WalkPayloadDeps(ctx, func(ctx ModuleContext, from blueprint.Module, to ApexModule, externalDep bool) bool {
+ walk(ctx, func(ctx ModuleContext, from blueprint.Module, to ApexModule, externalDep bool) bool {
if externalDep {
// external deps are outside the payload boundary, which is "stable"
// interface. We don't have to check min_sdk_version for external
diff --git a/android/api_levels.go b/android/api_levels.go
index c1b3ba2..1fbbc15 100644
--- a/android/api_levels.go
+++ b/android/api_levels.go
@@ -192,8 +192,8 @@
// * "30" -> "30"
// * "R" -> "30"
// * "S" -> "S"
-func ReplaceFinalizedCodenames(ctx PathContext, raw string) string {
- num, ok := getFinalCodenamesMap(ctx.Config())[raw]
+func ReplaceFinalizedCodenames(config Config, raw string) string {
+ num, ok := getFinalCodenamesMap(config)[raw]
if !ok {
return raw
}
@@ -201,7 +201,7 @@
return strconv.Itoa(num)
}
-// Converts the given string `raw` to an ApiLevel, possibly returning an error.
+// ApiLevelFromUser converts the given string `raw` to an ApiLevel, possibly returning an error.
//
// `raw` must be non-empty. Passing an empty string results in a panic.
//
@@ -216,6 +216,12 @@
// Inputs that are not "current", known previews, or convertible to an integer
// will return an error.
func ApiLevelFromUser(ctx PathContext, raw string) (ApiLevel, error) {
+ return ApiLevelFromUserWithConfig(ctx.Config(), raw)
+}
+
+// ApiLevelFromUserWithConfig implements ApiLevelFromUser, see comments for
+// ApiLevelFromUser for more details.
+func ApiLevelFromUserWithConfig(config Config, raw string) (ApiLevel, error) {
if raw == "" {
panic("API level string must be non-empty")
}
@@ -224,13 +230,13 @@
return FutureApiLevel, nil
}
- for _, preview := range ctx.Config().PreviewApiLevels() {
+ for _, preview := range config.PreviewApiLevels() {
if raw == preview.String() {
return preview, nil
}
}
- canonical := ReplaceFinalizedCodenames(ctx, raw)
+ canonical := ReplaceFinalizedCodenames(config, raw)
asInt, err := strconv.Atoi(canonical)
if err != nil {
return NoneApiLevel, fmt.Errorf("%q could not be parsed as an integer and is not a recognized codename", canonical)
diff --git a/android/bazel.go b/android/bazel.go
index 9278008..c3efb0a 100644
--- a/android/bazel.go
+++ b/android/bazel.go
@@ -232,6 +232,8 @@
"build/bazel/examples/apex/minimal": Bp2BuildDefaultTrueRecursively,
"build/soong": Bp2BuildDefaultTrue,
"build/soong/cc/libbuildversion": Bp2BuildDefaultTrue, // Skip tests subdir
+ "build/soong/cc/ndkstubgen": Bp2BuildDefaultTrue,
+ "build/soong/cc/symbolfile": Bp2BuildDefaultTrue,
"cts/common/device-side/nativetesthelper/jni": Bp2BuildDefaultTrueRecursively,
"development/sdk": Bp2BuildDefaultTrueRecursively,
"external/arm-optimized-routines": Bp2BuildDefaultTrueRecursively,
@@ -336,9 +338,8 @@
"host_bionic_linker_asm", // depends on extract_linker, a go binary.
"host_bionic_linker_script", // depends on extract_linker, a go binary.
- "pbtombstone", // depends on libprotobuf-cpp-lite, libtombstone_proto
- "crash_dump", // depends on unconverted module libprotobuf-cpp-lite
- "libprotobuf-cpp-full", "libprotobuf-cpp-lite", // Unsupported product&vendor suffix. b/204811222 and b/204810610.
+ "pbtombstone", // depends on libprotobuf-cpp-lite, libtombstone_proto
+ "crash_dump", // depends on unconverted module libprotobuf-cpp-lite
"libunwindstack_local", "libunwindstack_utils", // depends on unconverted module libunwindstack
"libunwindstack", // depends on libdexfile_support, of unsupported module type art_cc_library_static
@@ -373,19 +374,10 @@
// APEX support
"com.android.runtime", // http://b/194746715, apex, depends on 'libc_malloc_debug'
- "libadb_crypto", // Depends on libadb_protos
- "libadb_crypto_static", // Depends on libadb_protos_static
- "libadb_pairing_connection", // Depends on libadb_protos
- "libadb_pairing_connection_static", // Depends on libadb_protos_static
- "libadb_pairing_server", // Depends on libadb_protos
- "libadb_pairing_server_static", // Depends on libadb_protos_static
- "libadbd", // Depends on libadbd_core
- "libadbd_core", // Depends on libadb_protos
- "libadbd_services", // Depends on libadb_protos
+ "libadbd_core", // http://b/208481704: requijres use_version_lib
+ "libadbd_services", // http://b/208481704: requires use_version_lib
- "libadb_protos_static", // b/200601772: Requires cc_library proto support
- "libadb_protos", // b/200601772: Requires cc_library proto support
- "libapp_processes_protos_lite", // b/200601772: Requires cc_library proto support
+ "libadbd", // depends on unconverted modules: libadbd_core, libadbd_services
"libgtest_ndk_c++", // b/201816222: Requires sdk_version support.
"libgtest_main_ndk_c++", // b/201816222: Requires sdk_version support.
@@ -415,8 +407,16 @@
"libbrotli", // http://b/198585397, ld.lld: error: bionic/libc/arch-arm64/generic/bionic/memmove.S:95:(.text+0x10): relocation R_AARCH64_CONDBR19 out of range: -1404176 is not in [-1048576, 1048575]; references __memcpy
"minijail_constants_json", // http://b/200899432, bazel-built cc_genrule does not work in mixed build when it is a dependency of another soong module.
- "cap_names.h", // TODO(b/204913827) runfiles need to be handled in mixed builds
- "libcap", // TODO(b/204913827) runfiles need to be handled in mixed builds
+ "cap_names.h", // TODO(b/204913827) runfiles need to be handled in mixed builds
+ "libcap", // TODO(b/204913827) runfiles need to be handled in mixed builds
+ "libprotobuf-cpp-full", "libprotobuf-cpp-lite", // Unsupported product&vendor suffix. b/204811222 and b/204810610.
+
+ // Depends on libprotobuf-cpp-*
+ "libadb_crypto", "libadb_crypto_static", "libadb_pairing_connection",
+ "libadb_pairing_connection_static",
+ "libadb_pairing_server", "libadb_pairing_server_static",
+ "libadb_protos_static", "libadb_protos",
+ "libapp_processes_protos_lite",
}
// Used for quicker lookups
diff --git a/android/config.go b/android/config.go
index ed63ddf..ddad1f5 100644
--- a/android/config.go
+++ b/android/config.go
@@ -765,6 +765,16 @@
return levels
}
+func (c *config) LatestPreviewApiLevel() ApiLevel {
+ level := NoneApiLevel
+ for _, l := range c.PreviewApiLevels() {
+ if l.GreaterThan(level) {
+ level = l
+ }
+ }
+ return level
+}
+
func (c *config) AllSupportedApiLevels() []ApiLevel {
var levels []ApiLevel
levels = append(levels, c.FinalApiLevels()...)
diff --git a/android/module.go b/android/module.go
index 4a388b5..b500f01 100644
--- a/android/module.go
+++ b/android/module.go
@@ -1300,6 +1300,8 @@
func (m *ModuleBase) DepsMutator(BottomUpMutatorContext) {}
+// AddProperties "registers" the provided props
+// each value in props MUST be a pointer to a struct
func (m *ModuleBase) AddProperties(props ...interface{}) {
m.registerProps = append(m.registerProps, props...)
}
@@ -1702,7 +1704,7 @@
}
func (m *ModuleBase) InstallBypassMake() bool {
- return false
+ return true
}
func (m *ModuleBase) InstallForceOS() (*OsType, *ArchType) {
diff --git a/android/mutator.go b/android/mutator.go
index 461cb17..bf1cf80 100644
--- a/android/mutator.go
+++ b/android/mutator.go
@@ -221,6 +221,13 @@
// See http://b/192523357
var bp2buildLock sync.Mutex
+// A minimal context for Bp2build conversion
+type Bp2buildMutatorContext interface {
+ BazelConversionPathContext
+
+ CreateBazelTargetModule(bazel.BazelTargetModuleProperties, CommonAttributes, interface{})
+}
+
// RegisterBp2BuildMutator registers specially crafted mutators for
// converting Blueprint/Android modules into special modules that can
// be code-generated into Bazel BUILD targets.
@@ -529,28 +536,6 @@
mod.base().addBp2buildInfo(info)
}
-func (t *topDownMutatorContext) appendPrependHelper(props []interface{},
- extendFn func([]interface{}, interface{}, proptools.ExtendPropertyFilterFunc) error) {
- for _, p := range props {
- err := extendFn(t.Module().base().customizableProperties, p, nil)
- if err != nil {
- if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
- t.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
- } else {
- panic(err)
- }
- }
- }
-}
-
-func (t *topDownMutatorContext) AppendProperties(props ...interface{}) {
- t.appendPrependHelper(props, proptools.AppendMatchingProperties)
-}
-
-func (t *topDownMutatorContext) PrependProperties(props ...interface{}) {
- t.appendPrependHelper(props, proptools.PrependMatchingProperties)
-}
-
// android.topDownMutatorContext either has to embed blueprint.TopDownMutatorContext, in which case every method that
// has an overridden version in android.BaseModuleContext has to be manually forwarded to BaseModuleContext to avoid
// ambiguous method errors, or it has to store a blueprint.TopDownMutatorContext non-embedded, in which case every
diff --git a/android/proto.go b/android/proto.go
index 0be7893..64d4d05 100644
--- a/android/proto.go
+++ b/android/proto.go
@@ -15,12 +15,17 @@
package android
import (
+ "android/soong/bazel"
"strings"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
)
+const (
+ canonicalPathFromRootDefault = true
+)
+
// TODO(ccross): protos are often used to communicate between multiple modules. If the only
// way to convert a proto to source is to reference it as a source file, and external modules cannot
// reference source files in other modules, then every module that owns a proto file will need to
@@ -90,7 +95,7 @@
Flags: flags,
Deps: deps,
OutTypeFlag: protoOutFlag,
- CanonicalPathFromRoot: proptools.BoolDefault(p.Proto.Canonical_path_from_root, true),
+ CanonicalPathFromRoot: proptools.BoolDefault(p.Proto.Canonical_path_from_root, canonicalPathFromRootDefault),
Dir: PathForModuleGen(ctx, "proto"),
SubDir: PathForModuleGen(ctx, "proto", ctx.ModuleDir()),
}
@@ -146,3 +151,57 @@
rule.Command().
BuiltTool("dep_fixer").Flag(depFile.String())
}
+
+// Bp2buildProtoInfo contains information necessary to pass on to language specific conversion.
+type Bp2buildProtoInfo struct {
+ Type *string
+ Name string
+}
+
+type protoAttrs struct {
+ Srcs bazel.LabelListAttribute
+ Strip_import_prefix *string
+}
+
+// Bp2buildProtoProperties converts proto properties, creating a proto_library and returning the
+// information necessary for language-specific handling.
+func Bp2buildProtoProperties(ctx Bp2buildMutatorContext, module Module, srcs bazel.LabelListAttribute) (Bp2buildProtoInfo, bool) {
+ var info Bp2buildProtoInfo
+ if srcs.IsEmpty() {
+ return info, false
+ }
+ m := module.base()
+
+ info.Name = m.Name() + "_proto"
+ attrs := protoAttrs{
+ Srcs: srcs,
+ }
+
+ for axis, configToProps := range m.GetArchVariantProperties(ctx, &ProtoProperties{}) {
+ for _, rawProps := range configToProps {
+ var props *ProtoProperties
+ var ok bool
+ if props, ok = rawProps.(*ProtoProperties); !ok {
+ ctx.ModuleErrorf("Could not cast ProtoProperties to expected type")
+ }
+ if axis == bazel.NoConfigAxis {
+ info.Type = props.Proto.Type
+
+ if proptools.BoolDefault(props.Proto.Canonical_path_from_root, canonicalPathFromRootDefault) {
+ // an empty string indicates to strips the package path
+ path := ""
+ attrs.Strip_import_prefix = &path
+ }
+ } else if props.Proto.Type != info.Type && props.Proto.Type != nil {
+ ctx.ModuleErrorf("Cannot handle arch-variant types for protos at this time.")
+ }
+ }
+ }
+
+ ctx.CreateBazelTargetModule(
+ bazel.BazelTargetModuleProperties{Rule_class: "proto_library"},
+ CommonAttributes{Name: info.Name},
+ &attrs)
+
+ return info, true
+}
diff --git a/android/sdk_version.go b/android/sdk_version.go
index 1813e7e..2004c92 100644
--- a/android/sdk_version.go
+++ b/android/sdk_version.go
@@ -117,7 +117,7 @@
return false
}
-// PrebuiltSdkAvailableForUnbundledBuilt tells whether this SdkSpec can have a prebuilt SDK
+// PrebuiltSdkAvailableForUnbundledBuild tells whether this SdkSpec can have a prebuilt SDK
// that can be used for unbundled builds.
func (s SdkSpec) PrebuiltSdkAvailableForUnbundledBuild() bool {
// "", "none", and "core_platform" are not available for unbundled build
@@ -212,6 +212,10 @@
)
func SdkSpecFrom(ctx EarlyModuleContext, str string) SdkSpec {
+ return SdkSpecFromWithConfig(ctx.Config(), str)
+}
+
+func SdkSpecFromWithConfig(config Config, str string) SdkSpec {
switch str {
// special cases first
case "":
@@ -252,7 +256,7 @@
return SdkSpec{SdkInvalid, NoneApiLevel, str}
}
- apiLevel, err := ApiLevelFromUser(ctx, versionString)
+ apiLevel, err := ApiLevelFromUserWithConfig(config, versionString)
if err != nil {
return SdkSpec{SdkInvalid, apiLevel, str}
}
diff --git a/android/sdk_version_test.go b/android/sdk_version_test.go
new file mode 100644
index 0000000..ec81782
--- /dev/null
+++ b/android/sdk_version_test.go
@@ -0,0 +1,89 @@
+// Copyright 2015 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package android
+
+import (
+ "testing"
+)
+
+func TestSdkSpecFrom(t *testing.T) {
+ testCases := []struct {
+ input string
+ expected string
+ }{
+ {
+ input: "",
+ expected: "private_current",
+ },
+ {
+ input: "none",
+ expected: "none_(no version)",
+ },
+ {
+ input: "core_platform",
+ expected: "core_platform_current",
+ },
+ {
+ input: "_",
+ expected: "invalid_(no version)",
+ },
+ {
+ input: "_31",
+ expected: "invalid_(no version)",
+ },
+ {
+ input: "system_R",
+ expected: "system_30",
+ },
+ {
+ input: "test_31",
+ expected: "test_31",
+ },
+ {
+ input: "module_current",
+ expected: "module-lib_current",
+ },
+ {
+ input: "31",
+ expected: "public_31",
+ },
+ {
+ input: "S",
+ expected: "public_31",
+ },
+ {
+ input: "current",
+ expected: "public_current",
+ },
+ {
+ input: "Tiramisu",
+ expected: "public_Tiramisu",
+ },
+ }
+
+ config := NullConfig("", "")
+
+ config.productVariables = productVariables{
+ Platform_sdk_version: intPtr(31),
+ Platform_sdk_codename: stringPtr("Tiramisu"),
+ Platform_version_active_codenames: []string{"Tiramisu"},
+ }
+
+ for _, tc := range testCases {
+ if got := SdkSpecFromWithConfig(config, tc.input).String(); tc.expected != got {
+ t.Errorf("Expected %v, got %v", tc.expected, got)
+ }
+ }
+}
diff --git a/apex/apex.go b/apex/apex.go
index c1a4b40..2ca26a2 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -111,6 +111,9 @@
// List of java libraries that are embedded inside this APEX bundle.
Java_libs []string
+ // List of sh binaries that are embedded inside this APEX bundle.
+ Sh_binaries []string
+
// List of platform_compat_config files that are embedded inside this APEX bundle.
Compat_configs []string
@@ -127,6 +130,13 @@
// symlinking to the system libs. Default is true.
Updatable *bool
+ // Marks that this APEX is designed to be updatable in the future, although it's not
+ // updatable yet. This is used to mimic some of the build behaviors that are applied only to
+ // updatable APEXes. Currently, this disables the size optimization, so that the size of
+ // APEX will not increase when the APEX is actually marked as truly updatable. Default is
+ // false.
+ Future_updatable *bool
+
// Whether this APEX can use platform APIs or not. Can be set to true only when `updatable:
// false`. Default is false.
Platform_apis *bool
@@ -618,6 +628,7 @@
sharedLibTag = dependencyTag{name: "sharedLib", payload: true}
testForTag = dependencyTag{name: "test for"}
testTag = dependencyTag{name: "test", payload: true}
+ shBinaryTag = dependencyTag{name: "shBinary", payload: true}
)
// TODO(jiyong): shorten this function signature
@@ -762,6 +773,10 @@
for _, d := range depsList {
addDependenciesForNativeModules(ctx, d, target, imageVariation)
}
+ ctx.AddFarVariationDependencies([]blueprint.Variation{
+ {Mutator: "os", Variation: target.OsVariation()},
+ {Mutator: "arch", Variation: target.ArchVariation()},
+ }, shBinaryTag, a.properties.Sh_binaries...)
}
// Common-arch dependencies come next
@@ -1298,6 +1313,10 @@
return proptools.BoolDefault(a.properties.Updatable, true)
}
+func (a *apexBundle) FutureUpdatable() bool {
+ return proptools.BoolDefault(a.properties.Future_updatable, false)
+}
+
func (a *apexBundle) UsePlatformApis() bool {
return proptools.BoolDefault(a.properties.Platform_apis, false)
}
@@ -1482,6 +1501,9 @@
func apexFileForShBinary(ctx android.BaseModuleContext, sh *sh.ShBinary) apexFile {
dirInApex := filepath.Join("bin", sh.SubDir())
+ if sh.Target().NativeBridge == android.NativeBridgeEnabled {
+ dirInApex = filepath.Join(dirInApex, sh.Target().NativeBridgeRelativePath)
+ }
fileToCopy := sh.OutputFile()
af := newApexFile(ctx, fileToCopy, sh.BaseModuleName(), dirInApex, shBinary, sh)
af.symlinks = sh.Symlinks()
@@ -1659,7 +1681,7 @@
// 1) do some validity checks such as apex_available, min_sdk_version, etc.
a.checkApexAvailability(ctx)
a.checkUpdatable(ctx)
- a.checkMinSdkVersion(ctx)
+ a.CheckMinSdkVersion(ctx)
a.checkStaticLinkingToStubLibraries(ctx)
a.checkStaticExecutables(ctx)
if len(a.properties.Tests) > 0 && !a.testApex {
@@ -1710,6 +1732,7 @@
return true // track transitive dependencies
} else if r, ok := child.(*rust.Module); ok {
fi := apexFileForRustLibrary(ctx, r)
+ fi.isJniLib = isJniLib
filesInfo = append(filesInfo, fi)
} else {
propertyName := "native_shared_libs"
@@ -1722,8 +1745,6 @@
if cc, ok := child.(*cc.Module); ok {
filesInfo = append(filesInfo, apexFileForExecutable(ctx, cc))
return true // track transitive dependencies
- } else if sh, ok := child.(*sh.ShBinary); ok {
- filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh))
} else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() {
filesInfo = append(filesInfo, apexFileForPyBinary(ctx, py))
} else if gb, ok := child.(bootstrap.GoBinaryTool); ok && a.Host() {
@@ -1732,7 +1753,13 @@
filesInfo = append(filesInfo, apexFileForRustExecutable(ctx, rust))
return true // track transitive dependencies
} else {
- ctx.PropertyErrorf("binaries", "%q is neither cc_binary, rust_binary, (embedded) py_binary, (host) blueprint_go_binary, (host) bootstrap_go_binary, nor sh_binary", depName)
+ ctx.PropertyErrorf("binaries", "%q is neither cc_binary, rust_binary, (embedded) py_binary, (host) blueprint_go_binary, nor (host) bootstrap_go_binary", depName)
+ }
+ case shBinaryTag:
+ if sh, ok := child.(*sh.ShBinary); ok {
+ filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh))
+ } else {
+ ctx.PropertyErrorf("sh_binaries", "%q is not a sh_binary module", depName)
}
case bcpfTag:
{
@@ -2089,10 +2116,11 @@
}
forced := ctx.Config().ForceApexSymlinkOptimization()
+ updatable := a.Updatable() || a.FutureUpdatable()
// We don't need the optimization for updatable APEXes, as it might give false signal
// to the system health when the APEXes are still bundled (b/149805758).
- if !forced && a.Updatable() && a.properties.ApexType == imageApex {
+ if !forced && updatable && a.properties.ApexType == imageApex {
a.linkToSystemLib = false
}
@@ -2286,13 +2314,13 @@
// Entures that min_sdk_version of the included modules are equal or less than the min_sdk_version
// of this apexBundle.
-func (a *apexBundle) checkMinSdkVersion(ctx android.ModuleContext) {
+func (a *apexBundle) CheckMinSdkVersion(ctx android.ModuleContext) {
if a.testApex || a.vndkApex {
return
}
// apexBundle::minSdkVersion reports its own errors.
minSdkVersion := a.minSdkVersion(ctx)
- android.CheckMinSdkVersion(a, ctx, minSdkVersion)
+ android.CheckMinSdkVersion(ctx, minSdkVersion, a.WalkPayloadDeps)
}
func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) android.ApiLevel {
@@ -2361,6 +2389,12 @@
if a.UsePlatformApis() {
ctx.PropertyErrorf("updatable", "updatable APEXes can't use platform APIs")
}
+ if a.SocSpecific() || a.DeviceSpecific() {
+ ctx.PropertyErrorf("updatable", "vendor APEXes are not updatable")
+ }
+ if a.FutureUpdatable() {
+ ctx.PropertyErrorf("future_updatable", "Already updatable. Remove `future_updatable: true:`")
+ }
a.checkJavaStableSdkVersion(ctx)
a.checkClasspathFragments(ctx)
}
@@ -3185,7 +3219,7 @@
File_contexts bazel.LabelAttribute
Key bazel.LabelAttribute
Certificate bazel.LabelAttribute
- Min_sdk_version string
+ Min_sdk_version *string
Updatable bazel.BoolAttribute
Installable bazel.BoolAttribute
Native_shared_libs bazel.LabelListAttribute
@@ -3225,9 +3259,9 @@
fileContextsLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *module.properties.File_contexts))
}
- var minSdkVersion string
+ var minSdkVersion *string
if module.properties.Min_sdk_version != nil {
- minSdkVersion = *module.properties.Min_sdk_version
+ minSdkVersion = module.properties.Min_sdk_version
}
var keyLabelAttribute bazel.LabelAttribute
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 130581c..b805cd9 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -4250,7 +4250,7 @@
apex {
name: "myapex",
key: "myapex.key",
- binaries: ["myscript"],
+ sh_binaries: ["myscript"],
updatable: false,
}
@@ -7075,6 +7075,23 @@
`)
}
+func TestUpdatable_cannot_be_vendor_apex(t *testing.T) {
+ testApexError(t, `"myapex" .*: updatable: vendor APEXes are not updatable`, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ updatable: true,
+ soc_specific: true,
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+ `)
+}
+
func TestUpdatable_should_not_set_generate_classpaths_proto(t *testing.T) {
testApexError(t, `"mysystemserverclasspathfragment" .* it must not set generate_classpaths_proto to false`, `
apex {
diff --git a/apex/systemserver_classpath_fragment_test.go b/apex/systemserver_classpath_fragment_test.go
index 412fa0e..d037664 100644
--- a/apex/systemserver_classpath_fragment_test.go
+++ b/apex/systemserver_classpath_fragment_test.go
@@ -231,3 +231,95 @@
`prebuilt_foo`,
})
}
+
+func TestSystemserverclasspathFragmentStandaloneContents(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForTestWithSystemserverclasspathFragment,
+ prepareForTestWithMyapex,
+ dexpreopt.FixtureSetApexStandaloneSystemServerJars("myapex:foo"),
+ ).RunTestWithBp(t, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ systemserverclasspath_fragments: [
+ "mysystemserverclasspathfragment",
+ ],
+ updatable: false,
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+
+ java_library {
+ name: "foo",
+ srcs: ["b.java"],
+ installable: true,
+ apex_available: [
+ "myapex",
+ ],
+ }
+
+ systemserverclasspath_fragment {
+ name: "mysystemserverclasspathfragment",
+ standalone_contents: [
+ "foo",
+ ],
+ apex_available: [
+ "myapex",
+ ],
+ }
+ `)
+
+ ensureExactContents(t, result.TestContext, "myapex", "android_common_myapex_image", []string{
+ "etc/classpaths/systemserverclasspath.pb",
+ "javalib/foo.jar",
+ })
+}
+
+func TestPrebuiltStandaloneSystemserverclasspathFragmentContents(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForTestWithSystemserverclasspathFragment,
+ prepareForTestWithMyapex,
+ dexpreopt.FixtureSetApexStandaloneSystemServerJars("myapex:foo"),
+ ).RunTestWithBp(t, `
+ prebuilt_apex {
+ name: "myapex",
+ arch: {
+ arm64: {
+ src: "myapex-arm64.apex",
+ },
+ arm: {
+ src: "myapex-arm.apex",
+ },
+ },
+ exported_systemserverclasspath_fragments: ["mysystemserverclasspathfragment"],
+ }
+
+ java_import {
+ name: "foo",
+ jars: ["foo.jar"],
+ apex_available: [
+ "myapex",
+ ],
+ }
+
+ prebuilt_systemserverclasspath_fragment {
+ name: "mysystemserverclasspathfragment",
+ prefer: true,
+ standalone_contents: [
+ "foo",
+ ],
+ apex_available: [
+ "myapex",
+ ],
+ }
+ `)
+
+ java.CheckModuleDependencies(t, result.TestContext, "mysystemserverclasspathfragment", "android_common_myapex", []string{
+ `myapex.deapexer`,
+ `prebuilt_foo`,
+ })
+}
diff --git a/bazel/properties.go b/bazel/properties.go
index b370bbf..bbaa33e 100644
--- a/bazel/properties.go
+++ b/bazel/properties.go
@@ -107,6 +107,14 @@
return dirs
}
+// Add inserts the label Label at the end of the LabelList.
+func (ll *LabelList) Add(label *Label) {
+ if label == nil {
+ return
+ }
+ ll.Includes = append(ll.Includes, *label)
+}
+
// Append appends the fields of other labelList to the corresponding fields of ll.
func (ll *LabelList) Append(other LabelList) {
if len(ll.Includes) > 0 || len(other.Includes) > 0 {
@@ -366,6 +374,17 @@
// labelListSelectValues supports config-specific label_list typed Bazel attribute values.
type labelListSelectValues map[string]LabelList
+func (ll labelListSelectValues) addSelects(label labelSelectValues) {
+ for k, v := range label {
+ if label == nil {
+ continue
+ }
+ l := ll[k]
+ (&l).Add(v)
+ ll[k] = l
+ }
+}
+
func (ll labelListSelectValues) appendSelects(other labelListSelectValues) {
for k, v := range other {
l := ll[k]
@@ -500,6 +519,25 @@
lla.ConfigurableValues.Append(other.ConfigurableValues)
}
+// Add inserts the labels for each axis of LabelAttribute at the end of corresponding axis's
+// LabelList within the LabelListAttribute
+func (lla *LabelListAttribute) Add(label *LabelAttribute) {
+ if label == nil {
+ return
+ }
+
+ lla.Value.Add(label.Value)
+ if lla.ConfigurableValues == nil && label.ConfigurableValues != nil {
+ lla.ConfigurableValues = make(configurableLabelLists)
+ }
+ for axis, _ := range label.ConfigurableValues {
+ if _, exists := lla.ConfigurableValues[axis]; !exists {
+ lla.ConfigurableValues[axis] = make(labelListSelectValues)
+ }
+ lla.ConfigurableValues[axis].addSelects(label.ConfigurableValues[axis])
+ }
+}
+
// HasConfigurableValues returns true if the attribute contains axis-specific label list values.
func (lla LabelListAttribute) HasConfigurableValues() bool {
return len(lla.ConfigurableValues) > 0
@@ -566,7 +604,7 @@
// LabelMapper is a function that takes a OtherModuleContext and returns a (potentially changed)
// label and whether it was changed.
-type LabelMapper func(OtherModuleContext, string) (string, bool)
+type LabelMapper func(OtherModuleContext, Label) (string, bool)
// LabelPartition contains descriptions of a partition for labels
type LabelPartition struct {
@@ -588,7 +626,7 @@
// not.
func (lf LabelPartition) filter(ctx OtherModuleContext, label Label) *Label {
if lf.LabelMapper != nil {
- if newLabel, changed := lf.LabelMapper(ctx, label.Label); changed {
+ if newLabel, changed := lf.LabelMapper(ctx, label); changed {
return &Label{newLabel, label.OriginalModuleName}
}
}
diff --git a/bazel/properties_test.go b/bazel/properties_test.go
index 7a7d6f3..c7f9776 100644
--- a/bazel/properties_test.go
+++ b/bazel/properties_test.go
@@ -313,16 +313,16 @@
// labelAddSuffixForTypeMapper returns a LabelMapper that adds suffix to label name for modules of
// typ
func labelAddSuffixForTypeMapper(suffix, typ string) LabelMapper {
- return func(omc OtherModuleContext, label string) (string, bool) {
- m, ok := omc.ModuleFromName(label)
+ return func(omc OtherModuleContext, label Label) (string, bool) {
+ m, ok := omc.ModuleFromName(label.Label)
if !ok {
- return label, false
+ return label.Label, false
}
mTyp := omc.OtherModuleType(m)
if typ == mTyp {
- return label + suffix, true
+ return label.Label + suffix, true
}
- return label, false
+ return label.Label, false
}
}
diff --git a/bp2build/build_conversion.go b/bp2build/build_conversion.go
index 10ee582..eb60cd1 100644
--- a/bp2build/build_conversion.go
+++ b/bp2build/build_conversion.go
@@ -698,9 +698,9 @@
} else {
return true
}
- // Always print bools, if you want a bool attribute to be able to take the default value, use a
- // bool pointer instead
- case reflect.Bool:
+ // Always print bool/strings, if you want a bool/string attribute to be able to take the default value, use a
+ // pointer instead
+ case reflect.Bool, reflect.String:
return false
default:
if !value.IsValid() {
diff --git a/bp2build/build_conversion_test.go b/bp2build/build_conversion_test.go
index 983604b..95a26a9 100644
--- a/bp2build/build_conversion_test.go
+++ b/bp2build/build_conversion_test.go
@@ -41,6 +41,7 @@
soong_module_deps = [
],
bool_prop = False,
+ string_prop = "",
)`,
},
{
@@ -58,6 +59,7 @@
soong_module_deps = [
],
bool_prop = True,
+ string_prop = "",
)`,
},
{
@@ -76,6 +78,7 @@
],
bool_prop = False,
owner = "a_string_with\"quotes\"_and_\\backslashes\\\\",
+ string_prop = "",
)`,
},
{
@@ -94,6 +97,7 @@
],
bool_prop = False,
required = ["bar"],
+ string_prop = "",
)`,
},
{
@@ -111,6 +115,7 @@
soong_module_deps = [
],
bool_prop = False,
+ string_prop = "",
target_required = [
"qux",
"bazqux",
@@ -147,6 +152,7 @@
"tag": ".bar",
"targets": ["goal_bar"],
}],
+ string_prop = "",
)`,
},
{
@@ -179,6 +185,7 @@
}],
owner = "custom_owner",
required = ["bar"],
+ string_prop = "",
target_required = [
"qux",
"bazqux",
@@ -223,11 +230,24 @@
func TestGenerateBazelTargetModules(t *testing.T) {
testCases := []bp2buildTestCase{
{
+ description: "string ptr props",
+ blueprint: `custom {
+ name: "foo",
+ string_ptr_prop: "",
+ bazel_module: { bp2build_available: true },
+}`,
+ expectedBazelTargets: []string{
+ makeBazelTarget("custom", "foo", attrNameToString{
+ "string_ptr_prop": `""`,
+ }),
+ },
+ },
+ {
description: "string props",
blueprint: `custom {
name: "foo",
string_list_prop: ["a", "b"],
- string_prop: "a",
+ string_ptr_prop: "a",
bazel_module: { bp2build_available: true },
}`,
expectedBazelTargets: []string{
@@ -236,7 +256,7 @@
"a",
"b",
]`,
- "string_prop": `"a"`,
+ "string_ptr_prop": `"a"`,
}),
},
},
@@ -245,7 +265,7 @@
blueprint: `custom {
name: "foo",
string_list_prop: ["\t", "\n"],
- string_prop: "a\t\n\r",
+ string_ptr_prop: "a\t\n\r",
bazel_module: { bp2build_available: true },
}`,
expectedBazelTargets: []string{
@@ -254,7 +274,7 @@
"\t",
"\n",
]`,
- "string_prop": `"a\t\n\r"`,
+ "string_ptr_prop": `"a\t\n\r"`,
}),
},
},
diff --git a/bp2build/cc_binary_conversion_test.go b/bp2build/cc_binary_conversion_test.go
index f9abcba..2446850 100644
--- a/bp2build/cc_binary_conversion_test.go
+++ b/bp2build/cc_binary_conversion_test.go
@@ -24,8 +24,7 @@
)
const (
- ccBinaryTypePlaceHolder = "{rule_name}"
- compatibleWithPlaceHolder = "{target_compatible_with}"
+ ccBinaryTypePlaceHolder = "{rule_name}"
)
type testBazelTarget struct {
@@ -84,12 +83,15 @@
func runCcHostBinaryTestCase(t *testing.T, tc ccBinaryBp2buildTestCase) {
t.Helper()
testCase := tc
- for i, t := range testCase.targets {
- t.attrs["target_compatible_with"] = `select({
+ for i, tar := range testCase.targets {
+ if tar.typ != "cc_binary" {
+ continue
+ }
+ tar.attrs["target_compatible_with"] = `select({
"//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
"//conditions:default": [],
})`
- testCase.targets[i] = t
+ testCase.targets[i] = tar
}
moduleTypeUnderTest := "cc_binary_host"
t.Run(testCase.description, func(t *testing.T) {
@@ -448,3 +450,51 @@
})
}
}
+
+func TestCcBinarySharedProto(t *testing.T) {
+ runCcBinaryTests(t, ccBinaryBp2buildTestCase{
+ blueprint: soongCcProtoLibraries + `{rule_name} {
+ name: "foo",
+ srcs: ["foo.proto"],
+ proto: {
+ canonical_path_from_root: false,
+ },
+ include_build_directory: false,
+}`,
+ targets: []testBazelTarget{
+ {"proto_library", "foo_proto", attrNameToString{
+ "srcs": `["foo.proto"]`,
+ }}, {"cc_lite_proto_library", "foo_cc_proto_lite", attrNameToString{
+ "deps": `[":foo_proto"]`,
+ }}, {"cc_binary", "foo", attrNameToString{
+ "dynamic_deps": `[":libprotobuf-cpp-lite"]`,
+ "whole_archive_deps": `[":foo_cc_proto_lite"]`,
+ }},
+ },
+ })
+}
+
+func TestCcBinaryStaticProto(t *testing.T) {
+ runCcBinaryTests(t, ccBinaryBp2buildTestCase{
+ blueprint: soongCcProtoLibraries + `{rule_name} {
+ name: "foo",
+ srcs: ["foo.proto"],
+ static_executable: true,
+ proto: {
+ canonical_path_from_root: false,
+ },
+ include_build_directory: false,
+}`,
+ targets: []testBazelTarget{
+ {"proto_library", "foo_proto", attrNameToString{
+ "srcs": `["foo.proto"]`,
+ }}, {"cc_lite_proto_library", "foo_cc_proto_lite", attrNameToString{
+ "deps": `[":foo_proto"]`,
+ }}, {"cc_binary", "foo", attrNameToString{
+ "deps": `[":libprotobuf-cpp-lite"]`,
+ "whole_archive_deps": `[":foo_cc_proto_lite"]`,
+ "linkshared": `False`,
+ }},
+ },
+ })
+}
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index d23ea01..8c8898e 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -39,6 +39,19 @@
native_bridge_supported: true,
src: "",
}`
+
+ soongCcProtoLibraries = `
+cc_library {
+ name: "libprotobuf-cpp-lite",
+ bazel_module: { bp2build_available: false },
+}
+
+cc_library {
+ name: "libprotobuf-cpp-full",
+ bazel_module: { bp2build_available: false },
+}`
+
+ soongCcProtoPreamble = soongCcLibraryPreamble + soongCcProtoLibraries
)
func runCcLibraryTestCase(t *testing.T, tc bp2buildTestCase) {
@@ -1829,3 +1842,187 @@
})
}
}
+
+func TestCcLibraryProtoSimple(t *testing.T) {
+ runCcLibraryTestCase(t, bp2buildTestCase{
+ moduleTypeUnderTest: "cc_library",
+ moduleTypeUnderTestFactory: cc.LibraryFactory,
+ moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
+ blueprint: soongCcProtoPreamble + `cc_library {
+ name: "foo",
+ srcs: ["foo.proto"],
+ include_build_directory: false,
+}`,
+ expectedBazelTargets: []string{
+ makeBazelTarget("proto_library", "foo_proto", attrNameToString{
+ "srcs": `["foo.proto"]`,
+ "strip_import_prefix": `""`,
+ }), makeBazelTarget("cc_lite_proto_library", "foo_cc_proto_lite", attrNameToString{
+ "deps": `[":foo_proto"]`,
+ }), makeBazelTarget("cc_library", "foo", attrNameToString{
+ "implementation_whole_archive_deps": `[":foo_cc_proto_lite"]`,
+ "shared": `{
+ "dynamic_deps": [":libprotobuf-cpp-lite"],
+ }`,
+ "static": `{
+ "deps": [":libprotobuf-cpp-lite"],
+ }`,
+ }),
+ },
+ })
+}
+
+func TestCcLibraryProtoNoCanonicalPathFromRoot(t *testing.T) {
+ runCcLibraryTestCase(t, bp2buildTestCase{
+ moduleTypeUnderTest: "cc_library",
+ moduleTypeUnderTestFactory: cc.LibraryFactory,
+ moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
+ blueprint: soongCcProtoPreamble + `cc_library {
+ name: "foo",
+ srcs: ["foo.proto"],
+ proto: { canonical_path_from_root: false},
+ include_build_directory: false,
+}`,
+ expectedBazelTargets: []string{
+ makeBazelTarget("proto_library", "foo_proto", attrNameToString{
+ "srcs": `["foo.proto"]`,
+ }), makeBazelTarget("cc_lite_proto_library", "foo_cc_proto_lite", attrNameToString{
+ "deps": `[":foo_proto"]`,
+ }), makeBazelTarget("cc_library", "foo", attrNameToString{
+ "implementation_whole_archive_deps": `[":foo_cc_proto_lite"]`,
+ "shared": `{
+ "dynamic_deps": [":libprotobuf-cpp-lite"],
+ }`,
+ "static": `{
+ "deps": [":libprotobuf-cpp-lite"],
+ }`,
+ }),
+ },
+ })
+}
+
+func TestCcLibraryProtoExplicitCanonicalPathFromRoot(t *testing.T) {
+ runCcLibraryTestCase(t, bp2buildTestCase{
+ moduleTypeUnderTest: "cc_library",
+ moduleTypeUnderTestFactory: cc.LibraryFactory,
+ moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
+ blueprint: soongCcProtoPreamble + `cc_library {
+ name: "foo",
+ srcs: ["foo.proto"],
+ proto: { canonical_path_from_root: true},
+ include_build_directory: false,
+}`,
+ expectedBazelTargets: []string{
+ makeBazelTarget("proto_library", "foo_proto", attrNameToString{
+ "srcs": `["foo.proto"]`,
+ "strip_import_prefix": `""`,
+ }), makeBazelTarget("cc_lite_proto_library", "foo_cc_proto_lite", attrNameToString{
+ "deps": `[":foo_proto"]`,
+ }), makeBazelTarget("cc_library", "foo", attrNameToString{
+ "implementation_whole_archive_deps": `[":foo_cc_proto_lite"]`,
+ "shared": `{
+ "dynamic_deps": [":libprotobuf-cpp-lite"],
+ }`,
+ "static": `{
+ "deps": [":libprotobuf-cpp-lite"],
+ }`,
+ }),
+ },
+ })
+}
+
+func TestCcLibraryProtoFull(t *testing.T) {
+ runCcLibraryTestCase(t, bp2buildTestCase{
+ moduleTypeUnderTest: "cc_library",
+ moduleTypeUnderTestFactory: cc.LibraryFactory,
+ moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
+ blueprint: soongCcProtoPreamble + `cc_library {
+ name: "foo",
+ srcs: ["foo.proto"],
+ proto: {
+ canonical_path_from_root: false,
+ type: "full",
+ },
+ include_build_directory: false,
+}`,
+ expectedBazelTargets: []string{
+ makeBazelTarget("proto_library", "foo_proto", attrNameToString{
+ "srcs": `["foo.proto"]`,
+ }), makeBazelTarget("cc_proto_library", "foo_cc_proto", attrNameToString{
+ "deps": `[":foo_proto"]`,
+ }), makeBazelTarget("cc_library", "foo", attrNameToString{
+ "implementation_whole_archive_deps": `[":foo_cc_proto"]`,
+ "shared": `{
+ "dynamic_deps": [":libprotobuf-cpp-full"],
+ }`,
+ "static": `{
+ "deps": [":libprotobuf-cpp-full"],
+ }`,
+ }),
+ },
+ })
+}
+
+func TestCcLibraryProtoLite(t *testing.T) {
+ runCcLibraryTestCase(t, bp2buildTestCase{
+ moduleTypeUnderTest: "cc_library",
+ moduleTypeUnderTestFactory: cc.LibraryFactory,
+ moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
+ blueprint: soongCcProtoPreamble + `cc_library {
+ name: "foo",
+ srcs: ["foo.proto"],
+ proto: {
+ canonical_path_from_root: false,
+ type: "lite",
+ },
+ include_build_directory: false,
+}`,
+ expectedBazelTargets: []string{
+ makeBazelTarget("proto_library", "foo_proto", attrNameToString{
+ "srcs": `["foo.proto"]`,
+ }), makeBazelTarget("cc_lite_proto_library", "foo_cc_proto_lite", attrNameToString{
+ "deps": `[":foo_proto"]`,
+ }), makeBazelTarget("cc_library", "foo", attrNameToString{
+ "implementation_whole_archive_deps": `[":foo_cc_proto_lite"]`,
+ "shared": `{
+ "dynamic_deps": [":libprotobuf-cpp-lite"],
+ }`,
+ "static": `{
+ "deps": [":libprotobuf-cpp-lite"],
+ }`,
+ }),
+ },
+ })
+}
+
+func TestCcLibraryProtoExportHeaders(t *testing.T) {
+ runCcLibraryTestCase(t, bp2buildTestCase{
+ moduleTypeUnderTest: "cc_library",
+ moduleTypeUnderTestFactory: cc.LibraryFactory,
+ moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
+ blueprint: soongCcProtoPreamble + `cc_library {
+ name: "foo",
+ srcs: ["foo.proto"],
+ proto: {
+ canonical_path_from_root: false,
+ export_proto_headers: true,
+ },
+ include_build_directory: false,
+}`,
+ expectedBazelTargets: []string{
+ makeBazelTarget("proto_library", "foo_proto", attrNameToString{
+ "srcs": `["foo.proto"]`,
+ }), makeBazelTarget("cc_lite_proto_library", "foo_cc_proto_lite", attrNameToString{
+ "deps": `[":foo_proto"]`,
+ }), makeBazelTarget("cc_library", "foo", attrNameToString{
+ "whole_archive_deps": `[":foo_cc_proto_lite"]`,
+ "shared": `{
+ "dynamic_deps": [":libprotobuf-cpp-lite"],
+ }`,
+ "static": `{
+ "deps": [":libprotobuf-cpp-lite"],
+ }`,
+ }),
+ },
+ })
+}
diff --git a/bp2build/cc_library_shared_conversion_test.go b/bp2build/cc_library_shared_conversion_test.go
index 4ec95c3..e0331be 100644
--- a/bp2build/cc_library_shared_conversion_test.go
+++ b/bp2build/cc_library_shared_conversion_test.go
@@ -33,6 +33,7 @@
ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory)
ctx.RegisterModuleType("cc_library_headers", cc.LibraryHeaderFactory)
ctx.RegisterModuleType("cc_library_static", cc.LibraryStaticFactory)
+ ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
}
func runCcLibrarySharedTestCase(t *testing.T, tc bp2buildTestCase) {
@@ -425,3 +426,27 @@
expectedErr: fmt.Errorf("Android.bp:16:1: module \"foo_shared\": nocrt is not supported for arch variants"),
})
}
+
+func TestCcLibrarySharedProto(t *testing.T) {
+ runCcLibrarySharedTestCase(t, bp2buildTestCase{
+ blueprint: soongCcProtoPreamble + `cc_library_shared {
+ name: "foo",
+ srcs: ["foo.proto"],
+ proto: {
+ canonical_path_from_root: false,
+ export_proto_headers: true,
+ },
+ include_build_directory: false,
+}`,
+ expectedBazelTargets: []string{
+ makeBazelTarget("proto_library", "foo_proto", attrNameToString{
+ "srcs": `["foo.proto"]`,
+ }), makeBazelTarget("cc_lite_proto_library", "foo_cc_proto_lite", attrNameToString{
+ "deps": `[":foo_proto"]`,
+ }), makeBazelTarget("cc_library_shared", "foo", attrNameToString{
+ "dynamic_deps": `[":libprotobuf-cpp-lite"]`,
+ "whole_archive_deps": `[":foo_cc_proto_lite"]`,
+ }),
+ },
+ })
+}
diff --git a/bp2build/cc_library_static_conversion_test.go b/bp2build/cc_library_static_conversion_test.go
index 2f760d2..02229e5 100644
--- a/bp2build/cc_library_static_conversion_test.go
+++ b/bp2build/cc_library_static_conversion_test.go
@@ -1419,3 +1419,27 @@
},
})
}
+
+func TestCcLibraryStaticProto(t *testing.T) {
+ runCcLibraryStaticTestCase(t, bp2buildTestCase{
+ blueprint: soongCcProtoPreamble + `cc_library_static {
+ name: "foo",
+ srcs: ["foo.proto"],
+ proto: {
+ canonical_path_from_root: false,
+ export_proto_headers: true,
+ },
+ include_build_directory: false,
+}`,
+ expectedBazelTargets: []string{
+ makeBazelTarget("proto_library", "foo_proto", attrNameToString{
+ "srcs": `["foo.proto"]`,
+ }), makeBazelTarget("cc_lite_proto_library", "foo_cc_proto_lite", attrNameToString{
+ "deps": `[":foo_proto"]`,
+ }), makeBazelTarget("cc_library_static", "foo", attrNameToString{
+ "deps": `[":libprotobuf-cpp-lite"]`,
+ "whole_archive_deps": `[":foo_cc_proto_lite"]`,
+ }),
+ },
+ })
+}
diff --git a/bp2build/sh_conversion_test.go b/bp2build/sh_conversion_test.go
index 1ca4a0e..0d87c8d 100644
--- a/bp2build/sh_conversion_test.go
+++ b/bp2build/sh_conversion_test.go
@@ -62,11 +62,15 @@
blueprint: `sh_binary {
name: "foo",
src: "foo.sh",
+ filename: "foo.exe",
+ sub_dir: "sub",
bazel_module: { bp2build_available: true },
}`,
expectedBazelTargets: []string{
makeBazelTarget("sh_binary", "foo", attrNameToString{
- "srcs": `["foo.sh"]`,
+ "srcs": `["foo.sh"]`,
+ "filename": `"foo.exe"`,
+ "sub_dir": `"sub"`,
})},
})
}
diff --git a/bp2build/testing.go b/bp2build/testing.go
index daa9c22..cd84519 100644
--- a/bp2build/testing.go
+++ b/bp2build/testing.go
@@ -149,15 +149,15 @@
}
type nestedProps struct {
- Nested_prop string
+ Nested_prop *string
}
type EmbeddedProps struct {
- Embedded_prop string
+ Embedded_prop *string
}
type OtherEmbeddedProps struct {
- Other_embedded_prop string
+ Other_embedded_prop *string
}
type customProps struct {
@@ -262,17 +262,17 @@
}
type EmbeddedAttr struct {
- Embedded_attr string
+ Embedded_attr *string
}
type OtherEmbeddedAttr struct {
- Other_embedded_attr string
+ Other_embedded_attr *string
}
type customBazelModuleAttributes struct {
EmbeddedAttr
*OtherEmbeddedAttr
- String_prop string
+ String_ptr_prop *string
String_list_prop []string
Arch_paths bazel.LabelListAttribute
}
@@ -296,7 +296,7 @@
paths.ResolveExcludes()
attrs := &customBazelModuleAttributes{
- String_prop: m.props.String_prop,
+ String_ptr_prop: m.props.String_ptr_prop,
String_list_prop: m.props.String_list_prop,
Arch_paths: paths,
}
diff --git a/build_test.bash b/build_test.bash
index b039285..b6d00e2 100755
--- a/build_test.bash
+++ b/build_test.bash
@@ -50,7 +50,9 @@
echo
echo "Free disk space:"
-df -h
+# Ignore df errors because it errors out on gvfsd file systems
+# but still displays most of the useful info we need
+df -h || true
echo
echo "Running Bazel smoke test..."
diff --git a/cc/binary.go b/cc/binary.go
index a5afb07..63657e4 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -18,6 +18,7 @@
"path/filepath"
"github.com/google/blueprint"
+ "github.com/google/blueprint/proptools"
"android/soong/android"
"android/soong/bazel"
@@ -578,9 +579,16 @@
}
baseAttrs := bp2BuildParseBaseProps(ctx, m)
+ binaryLinkerAttrs := bp2buildBinaryLinkerProps(ctx, m)
+
+ if proptools.BoolDefault(binaryLinkerAttrs.Linkshared, true) {
+ baseAttrs.implementationDynamicDeps.Add(baseAttrs.protoDependency)
+ } else {
+ baseAttrs.implementationDeps.Add(baseAttrs.protoDependency)
+ }
attrs := &binaryAttributes{
- binaryLinkerAttrs: bp2buildBinaryLinkerProps(ctx, m),
+ binaryLinkerAttrs: binaryLinkerAttrs,
Srcs: baseAttrs.srcs,
Srcs_c: baseAttrs.cSrcs,
diff --git a/cc/bp2build.go b/cc/bp2build.go
index eabd814..f9bbe87 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -27,9 +27,10 @@
)
const (
- cSrcPartition = "c"
- asSrcPartition = "as"
- cppSrcPartition = "cpp"
+ cSrcPartition = "c"
+ asSrcPartition = "as"
+ cppSrcPartition = "cpp"
+ protoSrcPartition = "proto"
)
// staticOrSharedAttributes are the Bazel-ified versions of StaticOrSharedProperties --
@@ -41,52 +42,53 @@
Hdrs bazel.LabelListAttribute
Copts bazel.StringListAttribute
- Deps bazel.LabelListAttribute
- Implementation_deps bazel.LabelListAttribute
- Dynamic_deps bazel.LabelListAttribute
- Implementation_dynamic_deps bazel.LabelListAttribute
- Whole_archive_deps bazel.LabelListAttribute
+ Deps bazel.LabelListAttribute
+ Implementation_deps bazel.LabelListAttribute
+ Dynamic_deps bazel.LabelListAttribute
+ Implementation_dynamic_deps bazel.LabelListAttribute
+ Whole_archive_deps bazel.LabelListAttribute
+ Implementation_whole_archive_deps bazel.LabelListAttribute
System_dynamic_deps bazel.LabelListAttribute
}
func groupSrcsByExtension(ctx android.BazelConversionPathContext, srcs bazel.LabelListAttribute) bazel.PartitionToLabelListAttribute {
- // Check that a module is a filegroup type named <label>.
- isFilegroupNamed := func(m android.Module, fullLabel string) bool {
- if ctx.OtherModuleType(m) != "filegroup" {
- return false
- }
- labelParts := strings.Split(fullLabel, ":")
- if len(labelParts) > 2 {
- // There should not be more than one colon in a label.
- ctx.ModuleErrorf("%s is not a valid Bazel label for a filegroup", fullLabel)
- }
- return m.Name() == labelParts[len(labelParts)-1]
+ // Check that a module is a filegroup type
+ isFilegroup := func(m blueprint.Module) bool {
+ return ctx.OtherModuleType(m) == "filegroup"
}
// Convert filegroup dependencies into extension-specific filegroups filtered in the filegroup.bzl
// macro.
addSuffixForFilegroup := func(suffix string) bazel.LabelMapper {
- return func(ctx bazel.OtherModuleContext, label string) (string, bool) {
- m, exists := ctx.ModuleFromName(label)
- if !exists {
- return label, false
+ return func(ctx bazel.OtherModuleContext, label bazel.Label) (string, bool) {
+ m, exists := ctx.ModuleFromName(label.OriginalModuleName)
+ labelStr := label.Label
+ if !exists || !isFilegroup(m) {
+ return labelStr, false
}
- aModule, _ := m.(android.Module)
- if !isFilegroupNamed(aModule, label) {
- return label, false
- }
- return label + suffix, true
+ return labelStr + suffix, true
}
}
+ isProtoFilegroup := func(ctx bazel.OtherModuleContext, label bazel.Label) (string, bool) {
+ m, exists := ctx.ModuleFromName(label.OriginalModuleName)
+ labelStr := label.Label
+ if !exists || !isFilegroup(m) {
+ return labelStr, false
+ }
+ likelyProtos := strings.HasSuffix(labelStr, "proto") || strings.HasSuffix(labelStr, "protos")
+ return labelStr, likelyProtos
+ }
+
// TODO(b/190006308): Handle language detection of sources in a Bazel rule.
partitioned := bazel.PartitionLabelListAttribute(ctx, &srcs, bazel.LabelPartitions{
cSrcPartition: bazel.LabelPartition{Extensions: []string{".c"}, LabelMapper: addSuffixForFilegroup("_c_srcs")},
asSrcPartition: bazel.LabelPartition{Extensions: []string{".s", ".S"}, LabelMapper: addSuffixForFilegroup("_as_srcs")},
// C++ is the "catch-all" group, and comprises generated sources because we don't
// know the language of these sources until the genrule is executed.
- cppSrcPartition: bazel.LabelPartition{Extensions: []string{".cpp", ".cc", ".cxx", ".mm"}, LabelMapper: addSuffixForFilegroup("_cpp_srcs"), Keep_remainder: true},
+ cppSrcPartition: bazel.LabelPartition{Extensions: []string{".cpp", ".cc", ".cxx", ".mm"}, LabelMapper: addSuffixForFilegroup("_cpp_srcs"), Keep_remainder: true},
+ protoSrcPartition: bazel.LabelPartition{Extensions: []string{".proto"}, LabelMapper: isProtoFilegroup},
})
return partitioned
@@ -195,6 +197,11 @@
attrs.Srcs_c = partitionedSrcs[cSrcPartition]
attrs.Srcs_as = partitionedSrcs[asSrcPartition]
+ if !partitionedSrcs[protoSrcPartition].IsEmpty() {
+ // TODO(b/208815215): determine whether this is used and add support if necessary
+ ctx.ModuleErrorf("Migrating static/shared only proto srcs is not currently supported")
+ }
+
return attrs
}
@@ -230,6 +237,8 @@
type baseAttributes struct {
compilerAttributes
linkerAttributes
+
+ protoDependency *bazel.LabelAttribute
}
// Convenience struct to hold all attributes parsed from compiler properties.
@@ -257,6 +266,8 @@
localIncludes bazel.StringListAttribute
absoluteIncludes bazel.StringListAttribute
+
+ protoSrcs bazel.LabelListAttribute
}
func parseCommandLineFlags(soongFlags []string) []string {
@@ -337,6 +348,8 @@
ca.srcs.ResolveExcludes()
partitionedSrcs := groupSrcsByExtension(ctx, ca.srcs)
+ ca.protoSrcs = partitionedSrcs[protoSrcPartition]
+
for p, lla := range partitionedSrcs {
// if there are no sources, there is no need for headers
if lla.IsEmpty() {
@@ -388,11 +401,19 @@
}
cStdVal, cppStdVal = maybeReplaceGnuToC(gnu_extensions, cStdVal, cppStdVal)
- return &cStdVal, &cppStdVal
+ var c_std_prop, cpp_std_prop *string
+ if cStdVal != "" {
+ c_std_prop = &cStdVal
+ }
+ if cppStdVal != "" {
+ cpp_std_prop = &cppStdVal
+ }
+
+ return c_std_prop, cpp_std_prop
}
// bp2BuildParseCompilerProps returns copts, srcs and hdrs and other attributes.
-func bp2BuildParseBaseProps(ctx android.BazelConversionPathContext, module *Module) baseAttributes {
+func bp2BuildParseBaseProps(ctx android.Bp2buildMutatorContext, module *Module) baseAttributes {
archVariantCompilerProps := module.GetArchVariantProperties(ctx, &BaseCompilerProperties{})
archVariantLinkerProps := module.GetArchVariantProperties(ctx, &BaseLinkerProperties{})
@@ -448,20 +469,30 @@
(&compilerAttrs).finalize(ctx, implementationHdrs)
(&linkerAttrs).finalize()
+ protoDep := bp2buildProto(ctx, module, compilerAttrs.protoSrcs)
+
+ // bp2buildProto will only set wholeStaticLib or implementationWholeStaticLib, but we don't know
+ // which. This will add the newly generated proto library to the appropriate attribute and nothing
+ // to the other
+ (&linkerAttrs).wholeArchiveDeps.Add(protoDep.wholeStaticLib)
+ (&linkerAttrs).implementationWholeArchiveDeps.Add(protoDep.implementationWholeStaticLib)
+
return baseAttributes{
compilerAttrs,
linkerAttrs,
+ protoDep.protoDep,
}
}
// Convenience struct to hold all attributes parsed from linker properties.
type linkerAttributes struct {
- deps bazel.LabelListAttribute
- implementationDeps bazel.LabelListAttribute
- dynamicDeps bazel.LabelListAttribute
- implementationDynamicDeps bazel.LabelListAttribute
- wholeArchiveDeps bazel.LabelListAttribute
- systemDynamicDeps bazel.LabelListAttribute
+ deps bazel.LabelListAttribute
+ implementationDeps bazel.LabelListAttribute
+ dynamicDeps bazel.LabelListAttribute
+ implementationDynamicDeps bazel.LabelListAttribute
+ wholeArchiveDeps bazel.LabelListAttribute
+ implementationWholeArchiveDeps bazel.LabelListAttribute
+ systemDynamicDeps bazel.LabelListAttribute
linkCrt bazel.BoolAttribute
useLibcrt bazel.BoolAttribute
diff --git a/cc/builder.go b/cc/builder.go
index 72c2fa5..fea65d5 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -549,6 +549,10 @@
return "$" + kind + n
}
+ // clang-tidy checks source files and does not need to link with libraries.
+ // tidyPathDeps should contain pathDeps but not libraries.
+ tidyPathDeps := skipNdkLibraryDeps(ctx, pathDeps)
+
for i, srcFile := range srcFiles {
objFile := android.ObjPathWithExt(ctx, subdir, srcFile, "o")
@@ -672,7 +676,7 @@
Output: tidyFile,
Input: srcFile,
Implicits: cFlagsDeps,
- OrderOnly: pathDeps,
+ OrderOnly: tidyPathDeps,
Args: map[string]string{
"ccCmd": ccCmd,
"cFlags": shareFlags("cFlags", escapeSingleQuotes(moduleToolingFlags)),
diff --git a/cc/libbuildversion/Android.bp b/cc/libbuildversion/Android.bp
index 4debb1c..2cff994 100644
--- a/cc/libbuildversion/Android.bp
+++ b/cc/libbuildversion/Android.bp
@@ -14,6 +14,7 @@
enabled: true,
},
},
+ min_sdk_version: "26",
apex_available: [
"//apex_available:platform",
"//apex_available:anyapex",
diff --git a/cc/library.go b/cc/library.go
index 3dceda0..84aae0d 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -236,12 +236,13 @@
Hdrs bazel.LabelListAttribute
- Deps bazel.LabelListAttribute
- Implementation_deps bazel.LabelListAttribute
- Dynamic_deps bazel.LabelListAttribute
- Implementation_dynamic_deps bazel.LabelListAttribute
- Whole_archive_deps bazel.LabelListAttribute
- System_dynamic_deps bazel.LabelListAttribute
+ Deps bazel.LabelListAttribute
+ Implementation_deps bazel.LabelListAttribute
+ Dynamic_deps bazel.LabelListAttribute
+ Implementation_dynamic_deps bazel.LabelListAttribute
+ Whole_archive_deps bazel.LabelListAttribute
+ Implementation_whole_archive_deps bazel.LabelListAttribute
+ System_dynamic_deps bazel.LabelListAttribute
Export_includes bazel.StringListAttribute
Export_system_includes bazel.StringListAttribute
@@ -303,6 +304,9 @@
srcs := compilerAttrs.srcs
+ sharedAttrs.Dynamic_deps.Add(baseAttributes.protoDependency)
+ staticAttrs.Deps.Add(baseAttributes.protoDependency)
+
asFlags := compilerAttrs.asFlags
if compilerAttrs.asSrcs.IsEmpty() && sharedAttrs.Srcs_as.IsEmpty() && staticAttrs.Srcs_as.IsEmpty() {
// Skip asflags for BUILD file simplicity if there are no assembly sources.
@@ -320,23 +324,24 @@
Conlyflags: compilerAttrs.conlyFlags,
Asflags: asFlags,
- Implementation_deps: linkerAttrs.implementationDeps,
- Deps: linkerAttrs.deps,
- Implementation_dynamic_deps: linkerAttrs.implementationDynamicDeps,
- Dynamic_deps: linkerAttrs.dynamicDeps,
- Whole_archive_deps: linkerAttrs.wholeArchiveDeps,
- System_dynamic_deps: linkerAttrs.systemDynamicDeps,
- Export_includes: exportedIncludes.Includes,
- Export_system_includes: exportedIncludes.SystemIncludes,
- Local_includes: compilerAttrs.localIncludes,
- Absolute_includes: compilerAttrs.absoluteIncludes,
- Linkopts: linkerAttrs.linkopts,
- Link_crt: linkerAttrs.linkCrt,
- Use_libcrt: linkerAttrs.useLibcrt,
- Rtti: compilerAttrs.rtti,
- Stl: compilerAttrs.stl,
- Cpp_std: compilerAttrs.cppStd,
- C_std: compilerAttrs.cStd,
+ Implementation_deps: linkerAttrs.implementationDeps,
+ Deps: linkerAttrs.deps,
+ Implementation_dynamic_deps: linkerAttrs.implementationDynamicDeps,
+ Dynamic_deps: linkerAttrs.dynamicDeps,
+ Whole_archive_deps: linkerAttrs.wholeArchiveDeps,
+ Implementation_whole_archive_deps: linkerAttrs.implementationWholeArchiveDeps,
+ System_dynamic_deps: linkerAttrs.systemDynamicDeps,
+ Export_includes: exportedIncludes.Includes,
+ Export_system_includes: exportedIncludes.SystemIncludes,
+ Local_includes: compilerAttrs.localIncludes,
+ Absolute_includes: compilerAttrs.absoluteIncludes,
+ Linkopts: linkerAttrs.linkopts,
+ Link_crt: linkerAttrs.linkCrt,
+ Use_libcrt: linkerAttrs.useLibcrt,
+ Rtti: compilerAttrs.rtti,
+ Stl: compilerAttrs.stl,
+ Cpp_std: compilerAttrs.cppStd,
+ C_std: compilerAttrs.cStd,
Additional_linker_inputs: linkerAttrs.additionalLinkerInputs,
@@ -2405,16 +2410,18 @@
Copts: compilerAttrs.copts,
Hdrs: compilerAttrs.hdrs,
- Deps: linkerAttrs.deps,
- Implementation_deps: linkerAttrs.implementationDeps,
- Dynamic_deps: linkerAttrs.dynamicDeps,
- Implementation_dynamic_deps: linkerAttrs.implementationDynamicDeps,
- Whole_archive_deps: linkerAttrs.wholeArchiveDeps,
- System_dynamic_deps: linkerAttrs.systemDynamicDeps,
+ Deps: linkerAttrs.deps,
+ Implementation_deps: linkerAttrs.implementationDeps,
+ Dynamic_deps: linkerAttrs.dynamicDeps,
+ Implementation_dynamic_deps: linkerAttrs.implementationDynamicDeps,
+ Whole_archive_deps: linkerAttrs.wholeArchiveDeps,
+ Implementation_whole_archive_deps: linkerAttrs.implementationWholeArchiveDeps,
+ System_dynamic_deps: linkerAttrs.systemDynamicDeps,
}
var attrs interface{}
if isStatic {
+ commonAttrs.Deps.Add(baseAttributes.protoDependency)
attrs = &bazelCcLibraryStaticAttributes{
staticOrSharedAttributes: commonAttrs,
@@ -2435,6 +2442,8 @@
Features: linkerAttrs.features,
}
} else {
+ commonAttrs.Dynamic_deps.Add(baseAttributes.protoDependency)
+
attrs = &bazelCcLibrarySharedAttributes{
staticOrSharedAttributes: commonAttrs,
diff --git a/cc/library_headers_test.go b/cc/library_headers_test.go
index 9789ab0..3e448ba 100644
--- a/cc/library_headers_test.go
+++ b/cc/library_headers_test.go
@@ -16,7 +16,6 @@
import (
"fmt"
- "strings"
"testing"
"android/soong/android"
@@ -25,44 +24,37 @@
)
func TestLibraryHeaders(t *testing.T) {
- ctx := testCc(t, `
- cc_library_headers {
- name: "headers",
- export_include_dirs: ["my_include"],
- }
- cc_library_static {
- name: "lib",
- srcs: ["foo.c"],
- header_libs: ["headers"],
- }
- `)
+ bp := `
+ %s {
+ name: "headers",
+ export_include_dirs: ["my_include"],
+ }
+ cc_library_static {
+ name: "lib",
+ srcs: ["foo.c"],
+ header_libs: ["headers"],
+ }
+ `
- // test if header search paths are correctly added
- cc := ctx.ModuleForTests("lib", "android_arm64_armv8-a_static").Rule("cc")
- cflags := cc.Args["cFlags"]
- if !strings.Contains(cflags, " -Imy_include ") {
- t.Errorf("cflags for libsystem must contain -Imy_include, but was %#v.", cflags)
- }
-}
+ for _, headerModule := range []string{"cc_library_headers", "cc_prebuilt_library_headers"} {
+ t.Run(headerModule, func(t *testing.T) {
+ ctx := testCc(t, fmt.Sprintf(bp, headerModule))
-func TestPrebuiltLibraryHeaders(t *testing.T) {
- ctx := testCc(t, `
- cc_prebuilt_library_headers {
- name: "headers",
- export_include_dirs: ["my_include"],
- }
- cc_library_static {
- name: "lib",
- srcs: ["foo.c"],
- header_libs: ["headers"],
- }
- `)
+ // test if header search paths are correctly added
+ cc := ctx.ModuleForTests("lib", "android_arm64_armv8-a_static").Rule("cc")
+ android.AssertStringDoesContain(t, "cFlags for lib module", cc.Args["cFlags"], " -Imy_include ")
- // test if header search paths are correctly added
- cc := ctx.ModuleForTests("lib", "android_arm64_armv8-a_static").Rule("cc")
- cflags := cc.Args["cFlags"]
- if !strings.Contains(cflags, " -Imy_include ") {
- t.Errorf("cflags for libsystem must contain -Imy_include, but was %#v.", cflags)
+ // Test that there's a valid AndroidMk entry.
+ headers := ctx.ModuleForTests("headers", "android_arm64_armv8-a").Module()
+ e := android.AndroidMkEntriesForTest(t, ctx, headers)[0]
+
+ // This duplicates the tests done in AndroidMkEntries.write. It would be
+ // better to test its output, but there are no test functions that capture that.
+ android.AssertBoolEquals(t, "AndroidMkEntries.Disabled", false, e.Disabled)
+ android.AssertBoolEquals(t, "AndroidMkEntries.OutputFile.Valid()", true, e.OutputFile.Valid())
+
+ android.AssertStringListContains(t, "LOCAL_EXPORT_CFLAGS for headers module", e.EntryMap["LOCAL_EXPORT_CFLAGS"], "-Imy_include")
+ })
}
}
diff --git a/cc/ndk_sysroot.go b/cc/ndk_sysroot.go
index fd458d9..ee11db1 100644
--- a/cc/ndk_sysroot.go
+++ b/cc/ndk_sysroot.go
@@ -82,12 +82,33 @@
return android.PathForOutput(ctx, "ndk_base.timestamp")
}
+// The headers timestamp file depends only on the NDK headers.
+// This is used mainly for .tidy files that do not need any stub libraries.
+func getNdkHeadersTimestampFile(ctx android.PathContext) android.WritablePath {
+ return android.PathForOutput(ctx, "ndk_headers.timestamp")
+}
+
// The full timestamp file depends on the base timestamp *and* the static
// libraries.
func getNdkFullTimestampFile(ctx android.PathContext) android.WritablePath {
return android.PathForOutput(ctx, "ndk.timestamp")
}
+// Replace ndk_base.timestamp and ndk.timestamp with ndk_headers.timestamp.
+func skipNdkLibraryDeps(ctx android.ModuleContext, paths android.Paths) android.Paths {
+ var newPaths android.Paths
+ baseTimestamp := getNdkBaseTimestampFile(ctx)
+ fullTimestamp := getNdkFullTimestampFile(ctx)
+ headersTimestamp := getNdkHeadersTimestampFile(ctx)
+ for _, path := range paths {
+ if path == baseTimestamp || path == fullTimestamp {
+ path = headersTimestamp
+ }
+ newPaths = append(newPaths, path)
+ }
+ return newPaths
+}
+
func NdkSingleton() android.Singleton {
return &ndkSingleton{}
}
@@ -96,6 +117,7 @@
func (n *ndkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
var staticLibInstallPaths android.Paths
+ var headerPaths android.Paths
var installPaths android.Paths
var licensePaths android.Paths
ctx.VisitAllModules(func(module android.Module) {
@@ -104,16 +126,19 @@
}
if m, ok := module.(*headerModule); ok {
+ headerPaths = append(headerPaths, m.installPaths...)
installPaths = append(installPaths, m.installPaths...)
licensePaths = append(licensePaths, m.licensePath)
}
if m, ok := module.(*versionedHeaderModule); ok {
+ headerPaths = append(headerPaths, m.installPaths...)
installPaths = append(installPaths, m.installPaths...)
licensePaths = append(licensePaths, m.licensePath)
}
if m, ok := module.(*preprocessedHeadersModule); ok {
+ headerPaths = append(headerPaths, m.installPaths...)
installPaths = append(installPaths, m.installPaths...)
licensePaths = append(licensePaths, m.licensePath)
}
@@ -153,6 +178,12 @@
Validation: getNdkAbiDiffTimestampFile(ctx),
})
+ ctx.Build(pctx, android.BuildParams{
+ Rule: android.Touch,
+ Output: getNdkHeadersTimestampFile(ctx),
+ Implicits: headerPaths,
+ })
+
fullDepPaths := append(staticLibInstallPaths, getNdkBaseTimestampFile(ctx))
// There's a phony "ndk" rule defined in core/main.mk that depends on this.
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index a279054..c303fda 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -197,7 +197,13 @@
if p.header() {
ctx.SetProvider(HeaderLibraryInfoProvider, HeaderLibraryInfo{})
- return nil
+ // Need to return an output path so that the AndroidMk logic doesn't skip
+ // the prebuilt header. For compatibility, in case Android.mk files use a
+ // header lib in LOCAL_STATIC_LIBRARIES, create an empty ar file as
+ // placeholder, just like non-prebuilt header modules do in linkStatic().
+ ph := android.PathForModuleOut(ctx, ctx.ModuleName()+staticLibraryExtension)
+ transformObjToStaticLib(ctx, nil, nil, builderFlags{}, ph, nil, nil)
+ return ph
}
return nil
diff --git a/cc/proto.go b/cc/proto.go
index 4466144..f3410bc 100644
--- a/cc/proto.go
+++ b/cc/proto.go
@@ -16,8 +16,14 @@
import (
"github.com/google/blueprint/pathtools"
+ "github.com/google/blueprint/proptools"
"android/soong/android"
+ "android/soong/bazel"
+)
+
+const (
+ protoTypeDefault = "lite"
)
// genProto creates a rule to convert a .proto file to generated .pb.cc and .pb.h files and returns
@@ -63,7 +69,7 @@
var lib string
if String(p.Proto.Plugin) == "" {
- switch String(p.Proto.Type) {
+ switch proptools.StringDefault(p.Proto.Type, protoTypeDefault) {
case "full":
if ctx.useSdk() {
lib = "libprotobuf-cpp-full-ndk"
@@ -71,7 +77,7 @@
} else {
lib = "libprotobuf-cpp-full"
}
- case "lite", "":
+ case "lite":
if ctx.useSdk() {
lib = "libprotobuf-cpp-lite-ndk"
static = true
@@ -157,3 +163,69 @@
return flags
}
+
+type protoAttributes struct {
+ Deps bazel.LabelListAttribute
+}
+
+type bp2buildProtoDeps struct {
+ wholeStaticLib *bazel.LabelAttribute
+ implementationWholeStaticLib *bazel.LabelAttribute
+ protoDep *bazel.LabelAttribute
+}
+
+func bp2buildProto(ctx android.Bp2buildMutatorContext, m *Module, protoSrcs bazel.LabelListAttribute) bp2buildProtoDeps {
+ var ret bp2buildProtoDeps
+
+ protoInfo, ok := android.Bp2buildProtoProperties(ctx, m, protoSrcs)
+ if !ok {
+ return ret
+ }
+
+ var depName string
+ typ := proptools.StringDefault(protoInfo.Type, protoTypeDefault)
+ var rule_class string
+ suffix := "_cc_proto"
+ switch typ {
+ case "lite":
+ suffix += "_lite"
+ rule_class = "cc_lite_proto_library"
+ depName = "libprotobuf-cpp-lite"
+ case "full":
+ rule_class = "cc_proto_library"
+ depName = "libprotobuf-cpp-full"
+ default:
+ ctx.PropertyErrorf("proto.type", "cannot handle conversion at this time: %q", typ)
+ }
+
+ dep := android.BazelLabelForModuleDepSingle(ctx, depName)
+ ret.protoDep = &bazel.LabelAttribute{Value: &dep}
+
+ protoLabel := bazel.Label{Label: ":" + protoInfo.Name}
+ var protoAttrs protoAttributes
+ protoAttrs.Deps.SetValue(bazel.LabelList{Includes: []bazel.Label{protoLabel}})
+
+ name := m.Name() + suffix
+
+ ctx.CreateBazelTargetModule(
+ bazel.BazelTargetModuleProperties{
+ Rule_class: rule_class,
+ Bzl_load_location: "//build/bazel/rules:cc_proto.bzl",
+ },
+ android.CommonAttributes{Name: name},
+ &protoAttrs)
+
+ var privateHdrs bool
+ if lib, ok := m.linker.(*libraryDecorator); ok {
+ privateHdrs = !proptools.Bool(lib.Properties.Proto.Export_proto_headers)
+ }
+
+ labelAttr := &bazel.LabelAttribute{Value: &bazel.Label{Label: ":" + name}}
+ if privateHdrs {
+ ret.implementationWholeStaticLib = labelAttr
+ } else {
+ ret.wholeStaticLib = labelAttr
+ }
+
+ return ret
+}
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index dfc4eae..c81d4bc 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -386,7 +386,7 @@
// - won't be overwritten by corresponding bp2build generated files
//
// And return their paths so they can be left out of the Bazel workspace dir (i.e. ignored)
-func getPathsToIgnoredBuildFiles(topDir string, generatedRoot string, srcDirBazelFiles []string) []string {
+func getPathsToIgnoredBuildFiles(topDir string, generatedRoot string, srcDirBazelFiles []string, verbose bool) []string {
paths := make([]string, 0)
for _, srcDirBazelFileRelativePath := range srcDirBazelFiles {
@@ -416,7 +416,9 @@
// BUILD file clash resolution happens later in the symlink forest creation
continue
}
- fmt.Fprintf(os.Stderr, "Ignoring existing BUILD file: %s\n", srcDirBazelFileRelativePath)
+ if verbose {
+ fmt.Fprintf(os.Stderr, "Ignoring existing BUILD file: %s\n", srcDirBazelFileRelativePath)
+ }
paths = append(paths, srcDirBazelFileRelativePath)
}
@@ -523,7 +525,7 @@
os.Exit(1)
}
- pathsToIgnoredBuildFiles := getPathsToIgnoredBuildFiles(topDir, generatedRoot, existingBazelRelatedFiles)
+ pathsToIgnoredBuildFiles := getPathsToIgnoredBuildFiles(topDir, generatedRoot, existingBazelRelatedFiles, configuration.IsEnvTrue("BP2BUILD_VERBOSE"))
excludes = append(excludes, pathsToIgnoredBuildFiles...)
excludes = append(excludes, getTemporaryExcludes()...)
diff --git a/compliance/build_license_metadata/Android.bp b/compliance/build_license_metadata/Android.bp
index 5000346..4826526 100644
--- a/compliance/build_license_metadata/Android.bp
+++ b/compliance/build_license_metadata/Android.bp
@@ -25,5 +25,6 @@
"license_metadata_proto",
"golang-protobuf-proto",
"golang-protobuf-encoding-prototext",
+ "soong-response",
],
}
diff --git a/compliance/build_license_metadata/build_license_metadata.go b/compliance/build_license_metadata/build_license_metadata.go
index 8b1fe58..53d2407 100644
--- a/compliance/build_license_metadata/build_license_metadata.go
+++ b/compliance/build_license_metadata/build_license_metadata.go
@@ -26,28 +26,12 @@
"google.golang.org/protobuf/proto"
"android/soong/compliance/license_metadata_proto"
+ "android/soong/response"
)
-var (
- packageName = flag.String("p", "", "license package name")
- moduleType = newMultiString("mt", "module type")
- moduleClass = newMultiString("mc", "module class")
- kinds = newMultiString("k", "license kinds")
- conditions = newMultiString("c", "license conditions")
- notices = newMultiString("n", "license notice file")
- deps = newMultiString("d", "license metadata file dependency")
- sources = newMultiString("s", "source (input) dependency")
- built = newMultiString("t", "built targets")
- installed = newMultiString("i", "installed targets")
- roots = newMultiString("r", "root directory of project")
- installedMap = newMultiString("m", "map dependent targets to their installed names")
- isContainer = flag.Bool("is_container", false, "preserved dependent target name when given")
- outFile = flag.String("o", "", "output file")
-)
-
-func newMultiString(name, usage string) *multiString {
+func newMultiString(flags *flag.FlagSet, name, usage string) *multiString {
var f multiString
- flag.Var(&f, name, usage)
+ flags.Var(&f, name, usage)
return &f
}
@@ -57,7 +41,45 @@
func (ms *multiString) Set(s string) error { *ms = append(*ms, s); return nil }
func main() {
- flag.Parse()
+ var expandedArgs []string
+ for _, arg := range os.Args[1:] {
+ if strings.HasPrefix(arg, "@") {
+ f, err := os.Open(strings.TrimPrefix(arg, "@"))
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+
+ respArgs, err := response.ReadRspFile(f)
+ f.Close()
+ if err != nil {
+ fmt.Fprintln(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+ expandedArgs = append(expandedArgs, respArgs...)
+ } else {
+ expandedArgs = append(expandedArgs, arg)
+ }
+ }
+
+ flags := flag.NewFlagSet("flags", flag.ExitOnError)
+
+ packageName := flags.String("p", "", "license package name")
+ moduleType := newMultiString(flags, "mt", "module type")
+ kinds := newMultiString(flags, "k", "license kinds")
+ moduleClass := newMultiString(flags, "mc", "module class")
+ conditions := newMultiString(flags, "c", "license conditions")
+ notices := newMultiString(flags, "n", "license notice file")
+ deps := newMultiString(flags, "d", "license metadata file dependency")
+ sources := newMultiString(flags, "s", "source (input) dependency")
+ built := newMultiString(flags, "t", "built targets")
+ installed := newMultiString(flags, "i", "installed targets")
+ roots := newMultiString(flags, "r", "root directory of project")
+ installedMap := newMultiString(flags, "m", "map dependent targets to their installed names")
+ isContainer := flags.Bool("is_container", false, "preserved dependent target name when given")
+ outFile := flags.String("o", "", "output file")
+
+ flags.Parse(expandedArgs)
metadata := license_metadata_proto.LicenseMetadata{}
metadata.PackageName = proto.String(*packageName)
diff --git a/dexpreopt/config.go b/dexpreopt/config.go
index de3666a..6d6b41d 100644
--- a/dexpreopt/config.go
+++ b/dexpreopt/config.go
@@ -49,10 +49,12 @@
ArtApexJars android.ConfiguredJarList // modules for jars that are in the ART APEX
- SystemServerJars android.ConfiguredJarList // jars that form the system server
- SystemServerApps []string // apps that are loaded into system server
- ApexSystemServerJars android.ConfiguredJarList // jars within apex that are loaded into system server
- SpeedApps []string // apps that should be speed optimized
+ SystemServerJars android.ConfiguredJarList // system_server classpath jars on the platform
+ SystemServerApps []string // apps that are loaded into system server
+ ApexSystemServerJars android.ConfiguredJarList // system_server classpath jars delivered via apex
+ StandaloneSystemServerJars android.ConfiguredJarList // jars on the platform that system_server loads dynamically using separate classloaders
+ ApexStandaloneSystemServerJars android.ConfiguredJarList // jars delivered via apex that system_server loads dynamically using separate classloaders
+ SpeedApps []string // apps that should be speed optimized
BrokenSuboptimalOrderOfSystemServerJars bool // if true, sub-optimal order does not cause a build error
@@ -619,6 +621,8 @@
SystemServerJars: android.EmptyConfiguredJarList(),
SystemServerApps: nil,
ApexSystemServerJars: android.EmptyConfiguredJarList(),
+ StandaloneSystemServerJars: android.EmptyConfiguredJarList(),
+ ApexStandaloneSystemServerJars: android.EmptyConfiguredJarList(),
SpeedApps: nil,
PreoptFlags: nil,
DefaultCompilerFilter: "",
diff --git a/dexpreopt/testing.go b/dexpreopt/testing.go
index 8f5c315..2fba01a 100644
--- a/dexpreopt/testing.go
+++ b/dexpreopt/testing.go
@@ -125,6 +125,13 @@
})
}
+// FixtureSetStandaloneSystemServerJars sets the StandaloneSystemServerJars property.
+func FixtureSetStandaloneSystemServerJars(jars ...string) android.FixturePreparer {
+ return FixtureModifyGlobalConfig(func(dexpreoptConfig *GlobalConfig) {
+ dexpreoptConfig.StandaloneSystemServerJars = android.CreateTestConfiguredJarList(jars)
+ })
+}
+
// FixtureSetSystemServerJars sets the SystemServerJars property.
func FixtureSetSystemServerJars(jars ...string) android.FixturePreparer {
return FixtureModifyGlobalConfig(func(dexpreoptConfig *GlobalConfig) {
@@ -139,6 +146,14 @@
})
}
+// FixtureSetApexStandaloneSystemServerJars sets the ApexStandaloneSystemServerJars property in the
+// global config.
+func FixtureSetApexStandaloneSystemServerJars(jars ...string) android.FixturePreparer {
+ return FixtureModifyGlobalConfig(func(dexpreoptConfig *GlobalConfig) {
+ dexpreoptConfig.ApexStandaloneSystemServerJars = android.CreateTestConfiguredJarList(jars)
+ })
+}
+
// FixtureSetPreoptWithUpdatableBcp sets the PreoptWithUpdatableBcp property in the global config.
func FixtureSetPreoptWithUpdatableBcp(value bool) android.FixturePreparer {
return FixtureModifyGlobalConfig(func(dexpreoptConfig *GlobalConfig) {
diff --git a/java/android_manifest.go b/java/android_manifest.go
index 38065f1..3a1f5fc 100644
--- a/java/android_manifest.go
+++ b/java/android_manifest.go
@@ -16,6 +16,7 @@
import (
"fmt"
+ "strconv"
"strings"
"github.com/google/blueprint"
@@ -42,6 +43,20 @@
},
"args", "libs")
+// targetSdkVersion for manifest_fixer
+// When TARGET_BUILD_APPS is not empty, this method returns the unreleased(future) API level
+// This enables release builds (that run with TARGET_BUILD_APPS=[val...]) to target APIs that have not yet been finalized as part of an SDK
+func targetSdkVersionForManifestFixer(ctx android.ModuleContext, sdkContext android.SdkContext) string {
+ if ctx.Config().UnbundledBuildApps() {
+ return strconv.Itoa(android.FutureApiLevel.FinalOrFutureInt())
+ }
+ targetSdkVersion, err := sdkContext.TargetSdkVersion(ctx).EffectiveVersionString(ctx)
+ if err != nil {
+ ctx.ModuleErrorf("invalid targetSdkVersion: %s", err)
+ }
+ return targetSdkVersion
+}
+
// Uses manifest_fixer.py to inject minSdkVersion, etc. into an AndroidManifest.xml
func manifestFixer(ctx android.ModuleContext, manifest android.Path, sdkContext android.SdkContext,
classLoaderContexts dexpreopt.ClassLoaderContextMap, isLibrary, useEmbeddedNativeLibs, usesNonSdkApis,
@@ -89,10 +104,7 @@
args = append(args, "--logging-parent", loggingParent)
}
var deps android.Paths
- targetSdkVersion, err := sdkContext.TargetSdkVersion(ctx).EffectiveVersionString(ctx)
- if err != nil {
- ctx.ModuleErrorf("invalid targetSdkVersion: %s", err)
- }
+ targetSdkVersion := targetSdkVersionForManifestFixer(ctx, sdkContext)
if UseApiFingerprint(ctx) && ctx.ModuleName() != "framework-res" {
targetSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String())
deps = append(deps, ApiFingerprintPath(ctx))
diff --git a/java/app.go b/java/app.go
index c08ec06..bf76a50 100755
--- a/java/app.go
+++ b/java/app.go
@@ -291,7 +291,7 @@
if minSdkVersion, err := a.MinSdkVersion(ctx).EffectiveVersion(ctx); err == nil {
a.checkJniLibsSdkVersion(ctx, minSdkVersion)
- android.CheckMinSdkVersion(a, ctx, minSdkVersion)
+ android.CheckMinSdkVersion(ctx, minSdkVersion, a.WalkPayloadDeps)
} else {
ctx.PropertyErrorf("min_sdk_version", "%s", err.Error())
}
diff --git a/java/base.go b/java/base.go
index d9b1260..2f90db2 100644
--- a/java/base.go
+++ b/java/base.go
@@ -197,6 +197,10 @@
// Defaults to sdk_version if not set. See sdk_version for possible values.
Min_sdk_version *string
+ // if not blank, set the maximum version of the sdk that the compiled artifacts will run against.
+ // Defaults to empty string "". See sdk_version for possible values.
+ Max_sdk_version *string
+
// if not blank, set the targetSdkVersion in the AndroidManifest.xml.
// Defaults to sdk_version if not set. See sdk_version for possible values.
Target_sdk_version *string
@@ -460,6 +464,7 @@
sdkVersion android.SdkSpec
minSdkVersion android.SdkSpec
+ maxSdkVersion android.SdkSpec
}
func (j *Module) CheckStableSdkVersion(ctx android.BaseModuleContext) error {
@@ -617,6 +622,13 @@
return j.SdkVersion(ctx)
}
+func (j *Module) MaxSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
+ maxSdkVersion := proptools.StringDefault(j.deviceProperties.Max_sdk_version, "")
+ // SdkSpecFrom returns SdkSpecPrivate for this, which may be confusing.
+ // TODO(b/208456999): ideally MaxSdkVersion should be an ApiLevel and not SdkSpec.
+ return android.SdkSpecFrom(ctx, maxSdkVersion)
+}
+
func (j *Module) MinSdkVersionString() string {
return j.minSdkVersion.Raw
}
diff --git a/java/classpath_fragment.go b/java/classpath_fragment.go
index f63d81d..e77971b 100644
--- a/java/classpath_fragment.go
+++ b/java/classpath_fragment.go
@@ -25,7 +25,7 @@
"android/soong/android"
)
-// Build rules and utilities to generate individual packages/modules/SdkExtensions/proto/classpaths.proto
+// Build rules and utilities to generate individual packages/modules/common/proto/classpaths.proto
// config files based on build configuration to embed into /system and /apex on a device.
//
// See `derive_classpath` service that reads the configs at runtime and defines *CLASSPATH variables
@@ -34,14 +34,15 @@
type classpathType int
const (
- // Matches definition in packages/modules/SdkExtensions/proto/classpaths.proto
+ // Matches definition in packages/modules/common/proto/classpaths.proto
BOOTCLASSPATH classpathType = iota
DEX2OATBOOTCLASSPATH
SYSTEMSERVERCLASSPATH
+ STANDALONE_SYSTEMSERVER_JARS
)
func (c classpathType) String() string {
- return [...]string{"BOOTCLASSPATH", "DEX2OATBOOTCLASSPATH", "SYSTEMSERVERCLASSPATH"}[c]
+ return [...]string{"BOOTCLASSPATH", "DEX2OATBOOTCLASSPATH", "SYSTEMSERVERCLASSPATH", "STANDALONE_SYSTEMSERVER_JARS"}[c]
}
type classpathFragmentProperties struct {
@@ -84,11 +85,10 @@
// Matches definition of Jar in packages/modules/SdkExtensions/proto/classpaths.proto
type classpathJar struct {
- path string
- classpath classpathType
- // TODO(satayev): propagate min/max sdk versions for the jars
- minSdkVersion int32
- maxSdkVersion int32
+ path string
+ classpath classpathType
+ minSdkVersion string
+ maxSdkVersion string
}
// gatherPossibleApexModuleNamesAndStems returns a set of module and stem names from the
@@ -120,10 +120,32 @@
jars := make([]classpathJar, 0, len(paths)*len(classpaths))
for i := 0; i < len(paths); i++ {
for _, classpathType := range classpaths {
- jars = append(jars, classpathJar{
+ jar := classpathJar{
classpath: classpathType,
path: paths[i],
+ }
+ ctx.VisitDirectDepsIf(func(m android.Module) bool {
+ return m.Name() == configuredJars.Jar(i)
+ }, func(m android.Module) {
+ if s, ok := m.(*SdkLibrary); ok {
+ // TODO(208456999): instead of mapping "current" to latest, min_sdk_version should never be set to "current"
+ if s.minSdkVersion.Specified() {
+ if s.minSdkVersion.ApiLevel.IsCurrent() {
+ jar.minSdkVersion = ctx.Config().LatestPreviewApiLevel().String()
+ } else {
+ jar.minSdkVersion = s.minSdkVersion.ApiLevel.String()
+ }
+ }
+ if s.maxSdkVersion.Specified() {
+ if s.maxSdkVersion.ApiLevel.IsCurrent() {
+ jar.maxSdkVersion = ctx.Config().LatestPreviewApiLevel().String()
+ } else {
+ jar.maxSdkVersion = s.maxSdkVersion.ApiLevel.String()
+ }
+ }
+ }
})
+ jars = append(jars, jar)
}
}
return jars
@@ -136,15 +158,15 @@
c.outputFilepath = android.PathForModuleOut(ctx, outputFilename).OutputPath
c.installDirPath = android.PathForModuleInstall(ctx, "etc", "classpaths")
- generatedJson := android.PathForModuleOut(ctx, outputFilename+".json")
- writeClasspathsJson(ctx, generatedJson, jars)
+ generatedTextproto := android.PathForModuleOut(ctx, outputFilename+".textproto")
+ writeClasspathsTextproto(ctx, generatedTextproto, jars)
rule := android.NewRuleBuilder(pctx, ctx)
rule.Command().
BuiltTool("conv_classpaths_proto").
Flag("encode").
- Flag("--format=json").
- FlagWithInput("--input=", generatedJson).
+ Flag("--format=textproto").
+ FlagWithInput("--input=", generatedTextproto).
FlagWithOutput("--output=", c.outputFilepath)
rule.Build("classpath_fragment", "Compiling "+c.outputFilepath.String())
@@ -159,24 +181,18 @@
ctx.SetProvider(ClasspathFragmentProtoContentInfoProvider, classpathProtoInfo)
}
-func writeClasspathsJson(ctx android.ModuleContext, output android.WritablePath, jars []classpathJar) {
+func writeClasspathsTextproto(ctx android.ModuleContext, output android.WritablePath, jars []classpathJar) {
var content strings.Builder
- fmt.Fprintf(&content, "{\n")
- fmt.Fprintf(&content, "\"jars\": [\n")
- for idx, jar := range jars {
- fmt.Fprintf(&content, "{\n")
- fmt.Fprintf(&content, "\"path\": \"%s\",\n", jar.path)
- fmt.Fprintf(&content, "\"classpath\": \"%s\"\n", jar.classpath)
-
- if idx < len(jars)-1 {
- fmt.Fprintf(&content, "},\n")
- } else {
- fmt.Fprintf(&content, "}\n")
- }
+ for _, jar := range jars {
+ fmt.Fprintf(&content, "jars {\n")
+ fmt.Fprintf(&content, "path: \"%s\"\n", jar.path)
+ fmt.Fprintf(&content, "classpath: %s\n", jar.classpath)
+ fmt.Fprintf(&content, "min_sdk_version: \"%s\"\n", jar.minSdkVersion)
+ fmt.Fprintf(&content, "max_sdk_version: \"%s\"\n", jar.maxSdkVersion)
+ fmt.Fprintf(&content, "}\n")
}
- fmt.Fprintf(&content, "]\n")
- fmt.Fprintf(&content, "}\n")
+
android.WriteFileRule(ctx, output, content.String())
}
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index 7c081b6..f3a53ee 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -122,13 +122,7 @@
}
func (d *dexpreopter) dexpreoptDisabled(ctx android.BaseModuleContext) bool {
- global := dexpreopt.GetGlobalConfig(ctx)
-
- if global.DisablePreopt {
- return true
- }
-
- if inList(moduleName(ctx), global.DisablePreoptModules) {
+ if !ctx.Device() {
return true
}
@@ -144,7 +138,17 @@
return true
}
- if ctx.Host() {
+ if !android.IsModulePreferred(ctx.Module()) {
+ return true
+ }
+
+ global := dexpreopt.GetGlobalConfig(ctx)
+
+ if global.DisablePreopt {
+ return true
+ }
+
+ if inList(moduleName(ctx), global.DisablePreoptModules) {
return true
}
@@ -161,10 +165,6 @@
}
}
- if !android.IsModulePreferred(ctx.Module()) {
- return true
- }
-
// TODO: contains no java code
return false
diff --git a/java/java.go b/java/java.go
index 2f9e03a..a9f3d1a 100644
--- a/java/java.go
+++ b/java/java.go
@@ -447,6 +447,7 @@
JAVA_VERSION_7 = 7
JAVA_VERSION_8 = 8
JAVA_VERSION_9 = 9
+ JAVA_VERSION_11 = 11
)
func (v javaVersion) String() string {
@@ -459,6 +460,8 @@
return "1.8"
case JAVA_VERSION_9:
return "1.9"
+ case JAVA_VERSION_11:
+ return "11"
default:
return "unsupported"
}
@@ -479,8 +482,10 @@
return JAVA_VERSION_8
case "1.9", "9":
return JAVA_VERSION_9
- case "10", "11":
- ctx.PropertyErrorf("java_version", "Java language levels above 9 are not supported")
+ case "11":
+ return JAVA_VERSION_11
+ case "10":
+ ctx.PropertyErrorf("java_version", "Java language levels 10 is not supported")
return JAVA_VERSION_UNSUPPORTED
default:
ctx.PropertyErrorf("java_version", "Unrecognized Java language level")
@@ -545,6 +550,7 @@
func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.sdkVersion = j.SdkVersion(ctx)
j.minSdkVersion = j.MinSdkVersion(ctx)
+ j.maxSdkVersion = j.MaxSdkVersion(ctx)
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
if !apexInfo.IsForPlatform() {
diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go
index 9fec08a..1e27238 100644
--- a/java/platform_bootclasspath.go
+++ b/java/platform_bootclasspath.go
@@ -68,7 +68,6 @@
func platformBootclasspathFactory() android.SingletonModule {
m := &platformBootclasspathModule{}
m.AddProperties(&m.properties)
- // TODO(satayev): split apex jars into separate configs.
initClasspathFragment(m, BOOTCLASSPATH)
android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon)
return m
diff --git a/java/systemserver_classpath_fragment.go b/java/systemserver_classpath_fragment.go
index e263cc4..2ec33a4 100644
--- a/java/systemserver_classpath_fragment.go
+++ b/java/systemserver_classpath_fragment.go
@@ -58,6 +58,10 @@
func (p *platformSystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
configuredJars := p.configuredJars(ctx)
classpathJars := configuredJarListToClasspathJars(ctx, configuredJars, p.classpathType)
+ standaloneConfiguredJars := p.standaloneConfiguredJars(ctx)
+ standaloneClasspathJars := configuredJarListToClasspathJars(ctx, standaloneConfiguredJars, STANDALONE_SYSTEMSERVER_JARS)
+ configuredJars = configuredJars.AppendList(standaloneConfiguredJars)
+ classpathJars = append(classpathJars, standaloneClasspathJars...)
p.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, configuredJars, classpathJars)
}
@@ -66,6 +70,10 @@
return dexpreopt.GetGlobalConfig(ctx).SystemServerJars
}
+func (p *platformSystemServerClasspathModule) standaloneConfiguredJars(ctx android.ModuleContext) android.ConfiguredJarList {
+ return dexpreopt.GetGlobalConfig(ctx).StandaloneSystemServerJars
+}
+
type SystemServerClasspathModule struct {
android.ModuleBase
android.ApexModuleBase
@@ -84,10 +92,15 @@
}
type systemServerClasspathFragmentProperties struct {
- // The contents of this systemserverclasspath_fragment, could be either java_library, or java_sdk_library.
+ // List of system_server classpath jars, could be either java_library, or java_sdk_library.
//
// The order of this list matters as it is the order that is used in the SYSTEMSERVERCLASSPATH.
Contents []string
+
+ // List of jars that system_server loads dynamically using separate classloaders.
+ //
+ // The order does not matter.
+ Standalone_contents []string
}
func systemServerClasspathFactory() android.Module {
@@ -101,12 +114,16 @@
}
func (s *SystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- if len(s.properties.Contents) == 0 {
- ctx.PropertyErrorf("contents", "empty contents are not allowed")
+ if len(s.properties.Contents) == 0 && len(s.properties.Standalone_contents) == 0 {
+ ctx.PropertyErrorf("contents", "Either contents or standalone_contents needs to be non-empty")
}
configuredJars := s.configuredJars(ctx)
classpathJars := configuredJarListToClasspathJars(ctx, configuredJars, s.classpathType)
+ standaloneConfiguredJars := s.standaloneConfiguredJars(ctx)
+ standaloneClasspathJars := configuredJarListToClasspathJars(ctx, standaloneConfiguredJars, STANDALONE_SYSTEMSERVER_JARS)
+ configuredJars = configuredJars.AppendList(standaloneConfiguredJars)
+ classpathJars = append(classpathJars, standaloneClasspathJars...)
s.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, configuredJars, classpathJars)
// Collect the module directory for IDE info in java/jdeps.go.
@@ -145,6 +162,17 @@
return jars
}
+func (s *SystemServerClasspathModule) standaloneConfiguredJars(ctx android.ModuleContext) android.ConfiguredJarList {
+ global := dexpreopt.GetGlobalConfig(ctx)
+
+ possibleUpdatableModules := gatherPossibleApexModuleNamesAndStems(ctx, s.properties.Standalone_contents, systemServerClasspathFragmentContentDepTag)
+ jars, _ := global.ApexStandaloneSystemServerJars.Filter(possibleUpdatableModules)
+
+ // TODO(jiakaiz): add a check to ensure that the contents are declared in make.
+
+ return jars
+}
+
type systemServerClasspathFragmentContentDependencyTag struct {
blueprint.BaseDependencyTag
}
@@ -192,8 +220,11 @@
func (s *SystemServerClasspathModule) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
module := ctx.Module()
_, isSourceModule := module.(*SystemServerClasspathModule)
+ var deps []string
+ deps = append(deps, s.properties.Contents...)
+ deps = append(deps, s.properties.Standalone_contents...)
- for _, name := range s.properties.Contents {
+ for _, name := range deps {
// A systemserverclasspath_fragment must depend only on other source modules, while the
// prebuilt_systemserverclasspath_fragment_fragment must only depend on other prebuilt modules.
if !isSourceModule {
@@ -206,6 +237,7 @@
// Collect information for opening IDE project files in java/jdeps.go.
func (s *SystemServerClasspathModule) IDEInfo(dpInfo *android.IdeInfo) {
dpInfo.Deps = append(dpInfo.Deps, s.properties.Contents...)
+ dpInfo.Deps = append(dpInfo.Deps, s.properties.Standalone_contents...)
dpInfo.Paths = append(dpInfo.Paths, s.modulePaths...)
}
@@ -233,14 +265,22 @@
type systemServerClasspathFragmentSdkMemberProperties struct {
android.SdkMemberPropertiesBase
- // Contents of the systemserverclasspath fragment
+ // List of system_server classpath jars, could be either java_library, or java_sdk_library.
+ //
+ // The order of this list matters as it is the order that is used in the SYSTEMSERVERCLASSPATH.
Contents []string
+
+ // List of jars that system_server loads dynamically using separate classloaders.
+ //
+ // The order does not matter.
+ Standalone_contents []string
}
func (s *systemServerClasspathFragmentSdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) {
module := variant.(*SystemServerClasspathModule)
s.Contents = module.properties.Contents
+ s.Standalone_contents = module.properties.Standalone_contents
}
func (s *systemServerClasspathFragmentSdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
@@ -250,6 +290,10 @@
if len(s.Contents) > 0 {
propertySet.AddPropertyWithTag("contents", s.Contents, requiredMemberDependency)
}
+
+ if len(s.Standalone_contents) > 0 {
+ propertySet.AddPropertyWithTag("standalone_contents", s.Standalone_contents, requiredMemberDependency)
+ }
}
var _ android.SdkMemberType = (*systemServerClasspathFragmentMemberType)(nil)
diff --git a/java/systemserver_classpath_fragment_test.go b/java/systemserver_classpath_fragment_test.go
index 9ad50dd..ba328e7 100644
--- a/java/systemserver_classpath_fragment_test.go
+++ b/java/systemserver_classpath_fragment_test.go
@@ -99,7 +99,7 @@
func TestSystemServerClasspathFragmentWithoutContents(t *testing.T) {
prepareForTestWithSystemServerClasspath.
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
- `\Qempty contents are not allowed\E`)).
+ `\QEither contents or standalone_contents needs to be non-empty\E`)).
RunTestWithBp(t, `
systemserverclasspath_fragment {
name: "systemserverclasspath-fragment",
diff --git a/mk2rbc/Android.bp b/mk2rbc/Android.bp
index b18bfc7..4fa3eb6 100644
--- a/mk2rbc/Android.bp
+++ b/mk2rbc/Android.bp
@@ -38,7 +38,6 @@
"soong_variables.go",
"types.go",
"variable.go",
- "version_defaults.go",
],
deps: ["androidmk-parser"],
}
diff --git a/mk2rbc/cmd/mk2rbc.go b/mk2rbc/cmd/mk2rbc.go
index bb5a680..d9b4e86 100644
--- a/mk2rbc/cmd/mk2rbc.go
+++ b/mk2rbc/cmd/mk2rbc.go
@@ -80,7 +80,6 @@
var tracedVariables []string
var errorLogger = errorSink{data: make(map[string]datum)}
var makefileFinder = &LinuxMakefileFinder{}
-var versionDefaultsMk = filepath.Join("build", "make", "core", "version_defaults.mk")
func main() {
flag.Usage = func() {
@@ -168,18 +167,14 @@
if len(files) != 1 {
quit(fmt.Errorf("a launcher can be generated only for a single product"))
}
- versionDefaults, err := generateVersionDefaults()
- if err != nil {
- quit(err)
+ if *inputVariables == "" {
+ quit(fmt.Errorf("the product launcher requires an input variables file"))
}
- versionDefaultsPath := outputFilePath(versionDefaultsMk)
- err = writeGenerated(versionDefaultsPath, versionDefaults)
- if err != nil {
- fmt.Fprintf(os.Stderr, "%s: %s", files[0], err)
- ok = false
+ if !convertOne(*inputVariables) {
+ quit(fmt.Errorf("the product launcher input variables file failed to convert"))
}
- err = writeGenerated(*launcher, mk2rbc.Launcher(outputFilePath(files[0]), versionDefaultsPath,
+ err := writeGenerated(*launcher, mk2rbc.Launcher(outputFilePath(files[0]), outputFilePath(*inputVariables),
mk2rbc.MakePath2ModuleName(files[0])))
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %s", files[0], err)
@@ -213,15 +208,6 @@
}
}
-func generateVersionDefaults() (string, error) {
- versionSettings, err := mk2rbc.ParseVersionDefaults(filepath.Join(*rootDir, versionDefaultsMk))
- if err != nil {
- return "", err
- }
- return mk2rbc.VersionDefaults(versionSettings), nil
-
-}
-
func quit(s interface{}) {
fmt.Fprintln(os.Stderr, s)
os.Exit(2)
diff --git a/mk2rbc/mk2rbc.go b/mk2rbc/mk2rbc.go
index 4b9779c..15e5963 100644
--- a/mk2rbc/mk2rbc.go
+++ b/mk2rbc/mk2rbc.go
@@ -1695,12 +1695,12 @@
return starScript, nil
}
-func Launcher(mainModuleUri, versionDefaultsUri, mainModuleName string) string {
+func Launcher(mainModuleUri, inputVariablesUri, mainModuleName string) string {
var buf bytes.Buffer
fmt.Fprintf(&buf, "load(%q, %q)\n", baseUri, baseName)
- fmt.Fprintf(&buf, "load(%q, \"version_defaults\")\n", versionDefaultsUri)
+ fmt.Fprintf(&buf, "load(%q, input_variables_init = \"init\")\n", inputVariablesUri)
fmt.Fprintf(&buf, "load(%q, \"init\")\n", mainModuleUri)
- fmt.Fprintf(&buf, "%s(%s(%q, init, version_defaults))\n", cfnPrintVars, cfnMain, mainModuleName)
+ fmt.Fprintf(&buf, "%s(%s(%q, init, input_variables_init))\n", cfnPrintVars, cfnMain, mainModuleName)
return buf.String()
}
diff --git a/mk2rbc/version_defaults.go b/mk2rbc/version_defaults.go
deleted file mode 100644
index 64645d7..0000000
--- a/mk2rbc/version_defaults.go
+++ /dev/null
@@ -1,113 +0,0 @@
-// Copyright 2021 Google LLC
-//
-// 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 mk2rbc
-
-import (
- "bytes"
- "fmt"
- "io/ioutil"
- "os"
- "sort"
- "strconv"
- "strings"
-
- mkparser "android/soong/androidmk/parser"
-)
-
-const codenamePrefix = "PLATFORM_VERSION_CODENAME."
-
-// ParseVersionDefaults extracts version settings from the given file
-// and returns the map.
-func ParseVersionDefaults(path string) (map[string]string, error) {
- contents, err := ioutil.ReadFile(path)
- if err != nil {
- return nil, err
- }
- parser := mkparser.NewParser(path, bytes.NewBuffer(contents))
- nodes, errs := parser.Parse()
- if len(errs) > 0 {
- for _, e := range errs {
- fmt.Fprintln(os.Stderr, "ERROR:", e)
- }
- return nil, fmt.Errorf("cannot parse %s", path)
- }
-
- result := map[string]string{
- "DEFAULT_PLATFORM_VERSION": "",
- "MAX_PLATFORM_VERSION": "",
- "MIN_PLATFORM_VERSION": "A",
- "PLATFORM_BASE_SDK_EXTENSION_VERSION": "",
- "PLATFORM_SDK_EXTENSION_VERSION": "",
- "PLATFORM_SDK_VERSION": "",
- "PLATFORM_SECURITY_PATCH": "",
- "PLATFORM_VERSION_LAST_STABLE": "",
- }
- for _, node := range nodes {
- asgn, ok := node.(*mkparser.Assignment)
- if !(ok && asgn.Name.Const()) {
- continue
- }
- s := asgn.Name.Strings[0]
- _, ok = result[s]
- if !ok {
- ok = strings.HasPrefix(s, codenamePrefix)
- }
- if !ok {
- continue
- }
- v := asgn.Value
- if !v.Const() {
- return nil, fmt.Errorf("the value of %s should be constant", s)
- }
- result[s] = strings.TrimSpace(v.Strings[0])
- }
- return result, nil
-}
-
-func genericValue(s string) interface{} {
- if ival, err := strconv.ParseInt(s, 0, 0); err == nil {
- return ival
- }
- return s
-}
-
-// VersionDefaults generates the contents of the version_defaults.rbc file
-func VersionDefaults(values map[string]string) string {
- var sink bytes.Buffer
- var lines []string
- var codenames []string
- for name, value := range values {
- if strings.HasPrefix(name, codenamePrefix) {
- codenames = append(codenames,
- fmt.Sprintf("%q: %q", strings.TrimPrefix(name, codenamePrefix), value))
- } else {
- // Print numbers as such
- lines = append(lines, fmt.Sprintf(" %s = %#v,\n",
- strings.ToLower(name), genericValue(value)))
- }
- }
-
- sort.Strings(lines)
- sort.Strings(codenames)
-
- sink.WriteString("version_defaults = struct(\n")
- for _, l := range lines {
- sink.WriteString(l)
- }
- sink.WriteString(" codenames = { ")
- sink.WriteString(strings.Join(codenames, ", "))
- sink.WriteString(" }\n)\n")
- return sink.String()
-}
diff --git a/mk2rbc/version_defaults_test.go b/mk2rbc/version_defaults_test.go
deleted file mode 100644
index c78fa32..0000000
--- a/mk2rbc/version_defaults_test.go
+++ /dev/null
@@ -1,60 +0,0 @@
-package mk2rbc
-
-import (
- "path/filepath"
- "reflect"
- "strings"
- "testing"
-)
-
-func TestParseVersionDefaults(t *testing.T) {
- testDir := getTestDirectory()
- abspath := func(relPath string) string { return filepath.Join(testDir, relPath) }
- actualProducts, err := ParseVersionDefaults(abspath("version_defaults.mk.test"))
- if err != nil {
- t.Fatal(err)
- }
- expectedProducts := map[string]string{
- "DEFAULT_PLATFORM_VERSION": "TP1A",
- "MAX_PLATFORM_VERSION": "TP1A",
- "MIN_PLATFORM_VERSION": "TP1A",
- "PLATFORM_BASE_SDK_EXTENSION_VERSION": "0",
- "PLATFORM_SDK_EXTENSION_VERSION": "1",
- "PLATFORM_SDK_VERSION": "31",
- "PLATFORM_SECURITY_PATCH": "2021-10-05",
- "PLATFORM_VERSION_LAST_STABLE": "12",
- "PLATFORM_VERSION_CODENAME.SP2A": "Sv2",
- "PLATFORM_VERSION_CODENAME.TP1A": "Tiramisu",
- }
- if !reflect.DeepEqual(actualProducts, expectedProducts) {
- t.Errorf("\nExpected: %v\n Actual: %v", expectedProducts, actualProducts)
- }
-}
-
-func TestVersionDefaults(t *testing.T) {
- testDir := getTestDirectory()
- abspath := func(relPath string) string { return filepath.Join(testDir, relPath) }
- actualProducts, err := ParseVersionDefaults(abspath("version_defaults.mk.test"))
- if err != nil {
- t.Fatal(err)
- }
- expectedString := `version_defaults = struct(
- default_platform_version = "TP1A",
- max_platform_version = "TP1A",
- min_platform_version = "TP1A",
- platform_base_sdk_extension_version = 0,
- platform_sdk_extension_version = 1,
- platform_sdk_version = 31,
- platform_security_patch = "2021-10-05",
- platform_version_last_stable = 12,
- codenames = { "SP2A": "Sv2", "TP1A": "Tiramisu" }
-)
-`
- actualString := VersionDefaults(actualProducts)
- if !reflect.DeepEqual(actualString, expectedString) {
- t.Errorf("\nExpected: %v\nActual:\n%v",
- strings.ReplaceAll(expectedString, "\n", "\n"),
- strings.ReplaceAll(actualString, "\n", "\n"))
- }
-
-}
diff --git a/python/androidmk.go b/python/androidmk.go
index 13b4172..ccc85ec 100644
--- a/python/androidmk.go
+++ b/python/androidmk.go
@@ -75,12 +75,6 @@
}
func (installer *pythonInstaller) AndroidMk(base *Module, entries *android.AndroidMkEntries) {
- // Soong installation is only supported for host modules. Have Make
- // installation trigger Soong installation.
- if base.Target().Os.Class == android.Host {
- entries.OutputFile = android.OptionalPathForPath(installer.path)
- }
-
entries.Required = append(entries.Required, "libc++")
entries.ExtraEntries = append(entries.ExtraEntries,
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
diff --git a/python/binary.go b/python/binary.go
index bf6167c..af02de6 100644
--- a/python/binary.go
+++ b/python/binary.go
@@ -35,10 +35,10 @@
}
type bazelPythonBinaryAttributes struct {
- Main string
+ Main *string
Srcs bazel.LabelListAttribute
Deps bazel.LabelListAttribute
- Python_version string
+ Python_version *string
}
func PythonBinaryBp2Build(ctx android.TopDownMutatorContext) {
@@ -52,12 +52,12 @@
return
}
- var main string
+ var main *string
for _, propIntf := range m.GetProperties() {
if props, ok := propIntf.(*BinaryProperties); ok {
// main is optional.
if props.Main != nil {
- main = *props.Main
+ main = props.Main
break
}
}
@@ -69,13 +69,13 @@
// under Bionic.
py3Enabled := proptools.BoolDefault(m.properties.Version.Py3.Enabled, false)
py2Enabled := proptools.BoolDefault(m.properties.Version.Py2.Enabled, false)
- var python_version string
+ var python_version *string
if py3Enabled && py2Enabled {
panic(fmt.Errorf(
"error for '%s' module: bp2build's python_binary_host converter does not support "+
"converting a module that is enabled for both Python 2 and 3 at the same time.", m.Name()))
} else if py2Enabled {
- python_version = "PY2"
+ python_version = &pyVersion2
} else {
// do nothing, since python_version defaults to PY3.
}
diff --git a/python/library.go b/python/library.go
index d136a4e..9c92ebd 100644
--- a/python/library.go
+++ b/python/library.go
@@ -21,6 +21,7 @@
"android/soong/android"
"android/soong/bazel"
+
"github.com/google/blueprint/proptools"
)
@@ -46,7 +47,7 @@
type bazelPythonLibraryAttributes struct {
Srcs bazel.LabelListAttribute
Deps bazel.LabelListAttribute
- Srcs_version string
+ Srcs_version *string
}
func PythonLibraryHostBp2Build(ctx android.TopDownMutatorContext) {
@@ -74,11 +75,11 @@
// Bionic.
py3Enabled := proptools.BoolDefault(m.properties.Version.Py3.Enabled, true)
py2Enabled := proptools.BoolDefault(m.properties.Version.Py2.Enabled, false)
- var python_version string
+ var python_version *string
if py2Enabled && !py3Enabled {
- python_version = "PY2"
+ python_version = &pyVersion2
} else if !py2Enabled && py3Enabled {
- python_version = "PY3"
+ python_version = &pyVersion3
} else if !py2Enabled && !py3Enabled {
panic(fmt.Errorf(
"error for '%s' module: bp2build's %s converter doesn't understand having "+
@@ -95,8 +96,8 @@
}
props := bazel.BazelTargetModuleProperties{
- // Use the native py_library rule.
- Rule_class: "py_library",
+ Rule_class: "py_library",
+ Bzl_load_location: "//build/bazel/rules/python:library.bzl",
}
ctx.CreateBazelTargetModule(props, android.CommonAttributes{
diff --git a/rust/config/global.go b/rust/config/global.go
index d3826ac..23384e5 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.56.1p1"
+ RustDefaultVersion = "1.57.0"
RustDefaultBase = "prebuilts/rust/"
DefaultEdition = "2018"
Stdlibs = []string{
@@ -47,6 +47,7 @@
"-C opt-level=3",
"-C relocation-model=pic",
"-C overflow-checks=on",
+ "-C force-unwind-tables=yes",
// Use v0 mangling to distinguish from C++ symbols
"-Z symbol-mangling-version=v0",
}
@@ -54,6 +55,8 @@
deviceGlobalRustFlags = []string{
"-C panic=abort",
"-Z link-native-libraries=no",
+ // Generate additional debug info for AutoFDO
+ "-Z debug-info-for-profiling",
}
deviceGlobalLinkFlags = []string{
diff --git a/scripts/Android.bp b/scripts/Android.bp
index 730d756..4c847a1 100644
--- a/scripts/Android.bp
+++ b/scripts/Android.bp
@@ -47,15 +47,6 @@
srcs: [
"manifest.py",
],
- version: {
- py2: {
- // TODO(b/203436762) Remove when system/apex/apexer/apexer.py is converted
- enabled: true,
- },
- py3: {
- enabled: true,
- },
- },
visibility: ["//system/apex/apexer:__pkg__"],
}
diff --git a/scripts/rbc-run b/scripts/rbc-run
index 235da75..7243421 100755
--- a/scripts/rbc-run
+++ b/scripts/rbc-run
@@ -2,7 +2,7 @@
# Convert and run one configuration
# Args: a product/board makefile optionally followed by additional arguments
# that will be passed to rbcrun.
-[[ $# -gt 0 && -f "$1" ]] || { echo "Usage: ${0##*/} product.mk [Additional rbcrun arguments]" >&2; exit 1; }
+[[ $# -gt 1 && -f "$1" && -f "$2" ]] || { echo "Usage: ${0##*/} product.mk input_variables.mk [Additional rbcrun arguments]" >&2; exit 1; }
set -eu
declare -r output_root="${OUT_DIR:-out}"
@@ -10,7 +10,8 @@
declare -r converter="${output_root}/soong/mk2rbc"
declare -r launcher="${output_root}/rbc/launcher.rbc"
declare -r makefile="$1"
-shift
-"${converter}" -mode=write -r --outdir "${output_root}/rbc" --launcher="${launcher}" "${makefile}"
+declare -r input_variables="$2"
+shift 2
+"${converter}" -mode=write -r --outdir "${output_root}/rbc" --input_variables "${input_variables}" --launcher="${launcher}" "${makefile}"
"${runner}" RBC_OUT="make,global" RBC_DEBUG="${RBC_DEBUG:-}" $@ "${launcher}"
diff --git a/sh/sh_binary.go b/sh/sh_binary.go
index c32cde0..a87b9cf 100644
--- a/sh/sh_binary.go
+++ b/sh/sh_binary.go
@@ -516,7 +516,9 @@
}
type bazelShBinaryAttributes struct {
- Srcs bazel.LabelListAttribute
+ Srcs bazel.LabelListAttribute
+ Filename string
+ Sub_dir string
// Bazel also supports the attributes below, but (so far) these are not required for Bionic
// deps
// data
@@ -547,12 +549,25 @@
srcs := bazel.MakeLabelListAttribute(
android.BazelLabelForModuleSrc(ctx, []string{*m.properties.Src}))
+ var filename string
+ if m.properties.Filename != nil {
+ filename = *m.properties.Filename
+ }
+
+ var subDir string
+ if m.properties.Sub_dir != nil {
+ subDir = *m.properties.Sub_dir
+ }
+
attrs := &bazelShBinaryAttributes{
- Srcs: srcs,
+ Srcs: srcs,
+ Filename: filename,
+ Sub_dir: subDir,
}
props := bazel.BazelTargetModuleProperties{
- Rule_class: "sh_binary",
+ Rule_class: "sh_binary",
+ Bzl_load_location: "//build/bazel/rules:sh_binary.bzl",
}
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs)