Merge "Rename UpdatableSystemServerJars to ApexSystemServerJars."
diff --git a/android/bazel.go b/android/bazel.go
index 75b13c9..26e7deb 100644
--- a/android/bazel.go
+++ b/android/bazel.go
@@ -163,6 +163,8 @@
"system/core/property_service/libpropertyinfoparser": Bp2BuildDefaultTrueRecursively,
"system/libbase": Bp2BuildDefaultTrueRecursively,
"system/logging/liblog": Bp2BuildDefaultTrueRecursively,
+ "system/timezone/apex": Bp2BuildDefaultTrueRecursively,
+ "system/timezone/output_data": Bp2BuildDefaultTrueRecursively,
"external/jemalloc_new": Bp2BuildDefaultTrueRecursively,
"external/fmtlib": Bp2BuildDefaultTrueRecursively,
"external/arm-optimized-routines": Bp2BuildDefaultTrueRecursively,
diff --git a/apex/apex.go b/apex/apex.go
index 0857946..149f782 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -3197,6 +3197,7 @@
Installable bazel.BoolAttribute
Native_shared_libs bazel.LabelListAttribute
Binaries bazel.StringListAttribute
+ Prebuilts bazel.LabelListAttribute
}
type bazelApexBundle struct {
@@ -3262,6 +3263,10 @@
nativeSharedLibsLabelList := android.BazelLabelForModuleDeps(ctx, nativeSharedLibs)
nativeSharedLibsLabelListAttribute := bazel.MakeLabelListAttribute(nativeSharedLibsLabelList)
+ prebuilts := module.properties.Prebuilts
+ prebuiltsLabelList := android.BazelLabelForModuleDeps(ctx, prebuilts)
+ prebuiltsLabelListAttribute := bazel.MakeLabelListAttribute(prebuiltsLabelList)
+
binaries := module.properties.ApexNativeDependencies.Binaries
binariesStringListAttribute := bazel.MakeStringListAttribute(binaries)
@@ -3286,6 +3291,7 @@
Installable: installableAttribute,
Native_shared_libs: nativeSharedLibsLabelListAttribute,
Binaries: binariesStringListAttribute,
+ Prebuilts: prebuiltsLabelListAttribute,
}
props := bazel.BazelTargetModuleProperties{
diff --git a/bp2build/Android.bp b/bp2build/Android.bp
index 6ab062e..9ec637a 100644
--- a/bp2build/Android.bp
+++ b/bp2build/Android.bp
@@ -23,11 +23,13 @@
"soong-bazel",
"soong-cc",
"soong-cc-config",
+ "soong-etc",
"soong-genrule",
"soong-python",
"soong-sh",
],
testSrcs: [
+ "android_app_certificate_conversion_test.go",
"apex_conversion_test.go",
"apex_key_conversion_test.go",
"build_conversion_test.go",
@@ -37,6 +39,7 @@
"cc_library_static_conversion_test.go",
"cc_object_conversion_test.go",
"conversion_test.go",
+ "prebuilt_etc_conversion_test.go",
"python_binary_conversion_test.go",
"sh_conversion_test.go",
"testing.go",
diff --git a/bp2build/android_app_certificate_conversion_test.go b/bp2build/android_app_certificate_conversion_test.go
new file mode 100644
index 0000000..022c687
--- /dev/null
+++ b/bp2build/android_app_certificate_conversion_test.go
@@ -0,0 +1,49 @@
+// Copyright 2021 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 bp2build
+
+import (
+ "android/soong/android"
+ "android/soong/java"
+
+ "testing"
+)
+
+func runAndroidAppCertificateTestCase(t *testing.T, tc bp2buildTestCase) {
+ t.Helper()
+ runBp2BuildTestCase(t, registerAndroidAppCertificateModuleTypes, tc)
+}
+
+func registerAndroidAppCertificateModuleTypes(ctx android.RegistrationContext) {
+}
+
+func TestAndroidAppCertificateSimple(t *testing.T) {
+ runAndroidAppCertificateTestCase(t, bp2buildTestCase{
+ description: "Android app certificate - simple example",
+ moduleTypeUnderTest: "android_app_certificate",
+ moduleTypeUnderTestFactory: java.AndroidAppCertificateFactory,
+ moduleTypeUnderTestBp2BuildMutator: java.AndroidAppCertificateBp2Build,
+ filesystem: map[string]string{},
+ blueprint: `
+android_app_certificate {
+ name: "com.android.apogee.cert",
+ certificate: "chamber_of_secrets_dir",
+}
+`,
+ expectedBazelTargets: []string{`android_app_certificate(
+ name = "com.android.apogee.cert",
+ certificate = "chamber_of_secrets_dir",
+)`}})
+}
diff --git a/bp2build/apex_conversion_test.go b/bp2build/apex_conversion_test.go
index e2e08bd..456f18a 100644
--- a/bp2build/apex_conversion_test.go
+++ b/bp2build/apex_conversion_test.go
@@ -69,6 +69,18 @@
bazel_module: { bp2build_available: false },
}
+// TODO(b/194878861): Add bp2build support for prebuilt_etc
+cc_library {
+ name: "pretend_prebuilt_1",
+ bazel_module: { bp2build_available: false },
+}
+
+// TODO(b/194878861): Add bp2build support for prebuilt_etc
+cc_library {
+ name: "pretend_prebuilt_2",
+ bazel_module: { bp2build_available: false },
+}
+
filegroup {
name: "com.android.apogee-file_contexts",
srcs: [
@@ -95,6 +107,10 @@
"binary_1",
"binary_2",
],
+ prebuilts: [
+ "pretend_prebuilt_1",
+ "pretend_prebuilt_2",
+ ],
}
`,
expectedBazelTargets: []string{`apex(
@@ -114,6 +130,10 @@
":native_shared_lib_1",
":native_shared_lib_2",
],
+ prebuilts = [
+ ":pretend_prebuilt_1",
+ ":pretend_prebuilt_2",
+ ],
updatable = False,
)`}})
}
diff --git a/bp2build/prebuilt_etc_conversion_test.go b/bp2build/prebuilt_etc_conversion_test.go
new file mode 100644
index 0000000..4e25d1b
--- /dev/null
+++ b/bp2build/prebuilt_etc_conversion_test.go
@@ -0,0 +1,55 @@
+// Copyright 2021 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 bp2build
+
+import (
+ "android/soong/android"
+ "android/soong/etc"
+
+ "testing"
+)
+
+func runPrebuiltEtcTestCase(t *testing.T, tc bp2buildTestCase) {
+ t.Helper()
+ runBp2BuildTestCase(t, registerPrebuiltEtcModuleTypes, tc)
+}
+
+func registerPrebuiltEtcModuleTypes(ctx android.RegistrationContext) {
+}
+
+func TestPrebuiltEtcSimple(t *testing.T) {
+ runPrebuiltEtcTestCase(t, bp2buildTestCase{
+ description: "prebuilt_etc - simple example",
+ moduleTypeUnderTest: "prebuilt_etc",
+ moduleTypeUnderTestFactory: etc.PrebuiltEtcFactory,
+ moduleTypeUnderTestBp2BuildMutator: etc.PrebuiltEtcBp2Build,
+ filesystem: map[string]string{},
+ blueprint: `
+prebuilt_etc {
+ name: "apex_tz_version",
+ src: "version/tz_version",
+ filename: "tz_version",
+ sub_dir: "tz",
+ installable: false,
+}
+`,
+ expectedBazelTargets: []string{`prebuilt_etc(
+ name = "apex_tz_version",
+ filename = "tz_version",
+ installable = False,
+ src = "version/tz_version",
+ sub_dir = "tz",
+)`}})
+}
diff --git a/cc/config/x86_darwin_host.go b/cc/config/x86_darwin_host.go
index d8e70e1..23fe1ab 100644
--- a/cc/config/x86_darwin_host.go
+++ b/cc/config/x86_darwin_host.go
@@ -49,6 +49,7 @@
"-Wl,-syslibroot,${macSdkRoot}",
"-mmacosx-version-min=${macMinVersion}",
"-m64",
+ "-mlinker-version=305",
}
darwinSupportedSdkVersions = []string{
diff --git a/etc/Android.bp b/etc/Android.bp
index 06a2fa1..c670236 100644
--- a/etc/Android.bp
+++ b/etc/Android.bp
@@ -13,9 +13,11 @@
],
srcs: [
"prebuilt_etc.go",
+ "snapshot_etc.go",
],
testSrcs: [
"prebuilt_etc_test.go",
+ "snapshot_etc_test.go",
],
pluginFor: ["soong_build"],
}
diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go
index 4107916..8aeb0dd 100644
--- a/etc/prebuilt_etc.go
+++ b/etc/prebuilt_etc.go
@@ -36,6 +36,7 @@
"github.com/google/blueprint/proptools"
"android/soong/android"
+ "android/soong/bazel"
"android/soong/snapshot"
)
@@ -61,6 +62,8 @@
ctx.RegisterModuleType("prebuilt_rfsa", PrebuiltRFSAFactory)
ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
+
+ android.RegisterBp2BuildMutator("prebuilt_etc", PrebuiltEtcBp2Build)
}
var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
@@ -131,6 +134,7 @@
type PrebuiltEtc struct {
android.ModuleBase
android.DefaultableModuleBase
+ android.BazelModuleBase
snapshot.VendorSnapshotModuleInterface
snapshot.RecoverySnapshotModuleInterface
@@ -406,6 +410,7 @@
// This module is device-only
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
android.InitDefaultableModule(module)
+ android.InitBazelModule(module)
return module
}
@@ -647,3 +652,82 @@
return snapshotOutputs
}
+
+// For Bazel / bp2build
+
+type bazelPrebuiltEtcAttributes struct {
+ Src bazel.LabelAttribute
+ Filename string
+ Sub_dir string
+ Installable bazel.BoolAttribute
+}
+
+type bazelPrebuiltEtc struct {
+ android.BazelTargetModuleBase
+ bazelPrebuiltEtcAttributes
+}
+
+func BazelPrebuiltEtcFactory() android.Module {
+ module := &bazelPrebuiltEtc{}
+ module.AddProperties(&module.bazelPrebuiltEtcAttributes)
+ android.InitBazelTargetModule(module)
+ return module
+}
+
+func PrebuiltEtcBp2Build(ctx android.TopDownMutatorContext) {
+ module, ok := ctx.Module().(*PrebuiltEtc)
+ if !ok {
+ // Not an prebuilt_etc
+ return
+ }
+ if !module.ConvertWithBp2build(ctx) {
+ return
+ }
+ if ctx.ModuleType() != "prebuilt_etc" {
+ return
+ }
+
+ prebuiltEtcBp2BuildInternal(ctx, module)
+}
+
+func prebuiltEtcBp2BuildInternal(ctx android.TopDownMutatorContext, module *PrebuiltEtc) {
+ var srcLabelAttribute bazel.LabelAttribute
+ if module.properties.Src != nil {
+ srcLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, *module.properties.Src))
+ }
+
+ var filename string
+ if module.properties.Filename != nil {
+ filename = *module.properties.Filename
+ }
+
+ var subDir string
+ if module.subdirProperties.Sub_dir != nil {
+ subDir = *module.subdirProperties.Sub_dir
+ }
+
+ var installableBoolAttribute bazel.BoolAttribute
+ if module.properties.Installable != nil {
+ installableBoolAttribute.Value = module.properties.Installable
+ }
+
+ attrs := &bazelPrebuiltEtcAttributes{
+ Src: srcLabelAttribute,
+ Filename: filename,
+ Sub_dir: subDir,
+ Installable: installableBoolAttribute,
+ }
+
+ props := bazel.BazelTargetModuleProperties{
+ Rule_class: "prebuilt_etc",
+ Bzl_load_location: "//build/bazel/rules:prebuilt_etc.bzl",
+ }
+
+ ctx.CreateBazelTargetModule(BazelPrebuiltEtcFactory, module.Name(), props, attrs)
+}
+
+func (m *bazelPrebuiltEtc) Name() string {
+ return m.BaseModuleName()
+}
+
+func (m *bazelPrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {}
diff --git a/etc/snapshot_etc.go b/etc/snapshot_etc.go
new file mode 100644
index 0000000..9a25d5a
--- /dev/null
+++ b/etc/snapshot_etc.go
@@ -0,0 +1,186 @@
+// Copyright 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package etc
+
+// This file implements snapshot module of 'prebuilt_etc' type
+// 'snapshot_etc' module defines android.PrebuiltInterface so it can be handled
+// as prebuilt of 'prebuilt_etc' type.
+// Properties of 'snapshot_etc' follows properties from snapshotJsonFlags type
+
+import (
+ "android/soong/android"
+ "fmt"
+ "strings"
+
+ "github.com/google/blueprint"
+ "github.com/google/blueprint/proptools"
+)
+
+func RegisterSnapshotEtcModule(ctx android.RegistrationContext) {
+ ctx.RegisterModuleType("snapshot_etc", SnapshotEtcFactory)
+}
+
+func init() {
+ RegisterSnapshotEtcModule(android.InitRegistrationContext)
+}
+
+// snapshot_etc is a prebuilt module type to be installed under etc which is auto-generated by
+// development/vendor_snapshot/update.py. This module will override prebuilt_etc module with same
+// name when 'prefer' property is true.
+func SnapshotEtcFactory() android.Module {
+ module := &SnapshotEtc{}
+ module.AddProperties(&module.properties)
+
+ var srcsSupplier = func(_ android.BaseModuleContext, prebuilt android.Module) []string {
+ s, ok := prebuilt.(*SnapshotEtc)
+ if !ok || s.properties.Src == nil {
+ return []string{}
+ }
+
+ return []string{*s.properties.Src}
+ }
+
+ android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
+ android.InitPrebuiltModuleWithSrcSupplier(module, srcsSupplier, "src")
+ return module
+}
+
+type snapshotEtcProperties struct {
+ Src *string `android:"path,arch_variant"` // Source of snapshot_etc file
+ Filename *string `android:"arch_variant"` // Target file name when it differs from module name
+ Relative_install_path *string `android:"arch_variant"` // Relative install path when it should be installed subdirectory of etc
+}
+
+type SnapshotEtc struct {
+ android.ModuleBase
+ prebuilt android.Prebuilt
+ properties snapshotEtcProperties
+
+ outputFilePath android.OutputPath
+ installDirPath android.InstallPath
+}
+
+func (s *SnapshotEtc) Prebuilt() *android.Prebuilt {
+ return &s.prebuilt
+}
+
+func (s *SnapshotEtc) Name() string {
+ return s.prebuilt.Name(s.BaseModuleName())
+}
+
+func (s *SnapshotEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ if s.properties.Src == nil {
+ ctx.PropertyErrorf("src", "missing prebuilt source file")
+ return
+ }
+
+ sourceFilePath := s.prebuilt.SingleSourcePath(ctx)
+
+ // Determine the output file basename.
+ // If Filename is set, use the name specified by the property.
+ // Otherwise use the module name.
+ filename := proptools.String(s.properties.Filename)
+ if filename == "" {
+ filename = ctx.ModuleName()
+ }
+
+ s.outputFilePath = android.PathForModuleOut(ctx, filename).OutputPath
+
+ if strings.Contains(filename, "/") {
+ ctx.PropertyErrorf("filename", "filename cannot contain separator '/'")
+ return
+ }
+
+ subDir := ""
+ if s.properties.Relative_install_path != nil {
+ subDir = *s.properties.Relative_install_path
+ }
+
+ s.installDirPath = android.PathForModuleInstall(ctx, "etc", subDir)
+
+ // This ensures that outputFilePath has the correct name for others to
+ // use, as the source file may have a different name.
+ ctx.Build(pctx, android.BuildParams{
+ Rule: android.Cp,
+ Input: sourceFilePath,
+ Output: s.outputFilePath,
+ Description: "Install snapshot etc module " + s.BaseModuleName(),
+ })
+
+ ctx.InstallFile(s.installDirPath, s.outputFilePath.Base(), sourceFilePath)
+}
+
+func (p *SnapshotEtc) AndroidMkEntries() []android.AndroidMkEntries {
+ return []android.AndroidMkEntries{{
+ Class: "ETC",
+ OutputFile: android.OptionalPathForPath(p.outputFilePath),
+ ExtraEntries: []android.AndroidMkExtraEntriesFunc{
+ func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
+ entries.SetString("LOCAL_MODULE_TAGS", "optional")
+ entries.SetString("LOCAL_MODULE_PATH", p.installDirPath.ToMakePath().String())
+ entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePath.Base())
+ },
+ },
+ }}
+}
+
+type snapshotEtcDependencyTag struct {
+ blueprint.DependencyTag
+}
+
+var tag = snapshotEtcDependencyTag{}
+
+func (s *SnapshotEtc) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
+ return !s.ModuleBase.InstallInRecovery() && !s.ModuleBase.InstallInRamdisk() &&
+ !s.ModuleBase.InstallInVendorRamdisk() && !s.ModuleBase.InstallInDebugRamdisk()
+}
+
+func (p *SnapshotEtc) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
+ return p.ModuleBase.InstallInRamdisk()
+}
+
+func (p *SnapshotEtc) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
+ return p.ModuleBase.InstallInVendorRamdisk()
+}
+
+func (p *SnapshotEtc) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
+ return p.ModuleBase.InstallInDebugRamdisk()
+}
+
+func (p *SnapshotEtc) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
+ return p.ModuleBase.InstallInRecovery()
+}
+
+func (p *SnapshotEtc) ExtraImageVariations(ctx android.BaseModuleContext) []string {
+ return nil
+}
+
+func (p *SnapshotEtc) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
+}
+
+func (p *SnapshotEtc) ImageMutatorBegin(ctx android.BaseModuleContext) {}
+
+func (p *SnapshotEtc) OutputFiles(tag string) (android.Paths, error) {
+ switch tag {
+ case "":
+ return android.Paths{p.outputFilePath}, nil
+ default:
+ return nil, fmt.Errorf("unsupported module reference tag %q", tag)
+ }
+
+}
+
+var _ android.PrebuiltInterface = (*SnapshotEtc)(nil)
+var _ android.ImageInterface = (*SnapshotEtc)(nil)
+var _ android.OutputFileProducer = (*SnapshotEtc)(nil)
diff --git a/etc/snapshot_etc_test.go b/etc/snapshot_etc_test.go
new file mode 100644
index 0000000..b9d5504
--- /dev/null
+++ b/etc/snapshot_etc_test.go
@@ -0,0 +1,185 @@
+// Copyright 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package etc
+
+import (
+ "android/soong/android"
+ "testing"
+
+ "github.com/google/blueprint"
+)
+
+var registerSourceModule = func(ctx android.RegistrationContext) {
+ ctx.RegisterModuleType("source", newSourceModule)
+}
+
+type sourceModuleProperties struct {
+ Deps []string `android:"path,arch_variant"`
+}
+
+type sourceModule struct {
+ android.ModuleBase
+ android.OverridableModuleBase
+
+ properties sourceModuleProperties
+ dependsOnSourceModule, dependsOnPrebuiltModule bool
+ deps android.Paths
+ src android.Path
+}
+
+func newSourceModule() android.Module {
+ m := &sourceModule{}
+ m.AddProperties(&m.properties)
+ android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibFirst)
+ android.InitOverridableModule(m, nil)
+ return m
+}
+
+func (s *sourceModule) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) {
+ // s.properties.Deps are annotated with android:path, so they are
+ // automatically added to the dependency by pathDeps mutator
+}
+
+func (s *sourceModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ s.deps = android.PathsForModuleSrc(ctx, s.properties.Deps)
+ s.src = android.PathForModuleSrc(ctx, "source_file")
+}
+
+func (s *sourceModule) Srcs() android.Paths {
+ return android.Paths{s.src}
+}
+
+var prepareForSnapshotEtcTest = android.GroupFixturePreparers(
+ android.PrepareForTestWithArchMutator,
+ android.PrepareForTestWithPrebuilts,
+ PrepareForTestWithPrebuiltEtc,
+ android.FixtureRegisterWithContext(RegisterSnapshotEtcModule),
+ android.FixtureRegisterWithContext(registerSourceModule),
+ android.FixtureMergeMockFs(android.MockFS{
+ "foo.conf": nil,
+ "bar.conf": nil,
+ }),
+)
+
+func TestSnapshotWithFilename(t *testing.T) {
+ var androidBp = `
+ snapshot_etc {
+ name: "etc_module",
+ src: "foo.conf",
+ filename: "bar.conf",
+ }
+ `
+
+ result := prepareForSnapshotEtcTest.RunTestWithBp(t, androidBp)
+ for _, variant := range result.ModuleVariantsForTests("etc_module") {
+ module := result.ModuleForTests("etc_module", variant)
+ s, ok := module.Module().(*SnapshotEtc)
+ if !ok {
+ t.Errorf("Expected snapshot_etc module type")
+ }
+ if s.outputFilePath.Base() != "bar.conf" {
+ t.Errorf("Output file path does not match with specified filename")
+ }
+ }
+}
+
+func TestSnapshotEtcWithOrigin(t *testing.T) {
+ var androidBp = `
+ prebuilt_etc {
+ name: "etc_module",
+ src: "foo.conf",
+ }
+
+ snapshot_etc {
+ name: "etc_module",
+ src: "bar.conf",
+ }
+
+ source {
+ name: "source",
+ deps: [":etc_module"],
+ }
+ `
+
+ result := prepareForSnapshotEtcTest.RunTestWithBp(t, androidBp)
+
+ for _, variant := range result.ModuleVariantsForTests("source") {
+ source := result.ModuleForTests("source", variant)
+
+ result.VisitDirectDeps(source.Module(), func(m blueprint.Module) {
+ if _, ok := m.(*PrebuiltEtc); !ok {
+ t.Errorf("Original prebuilt_etc module expected.")
+ }
+ })
+ }
+}
+
+func TestSnapshotEtcWithOriginAndPrefer(t *testing.T) {
+ var androidBp = `
+ prebuilt_etc {
+ name: "etc_module",
+ src: "foo.conf",
+ }
+
+ snapshot_etc {
+ name: "etc_module",
+ src: "bar.conf",
+ prefer: true,
+ }
+
+ source {
+ name: "source",
+ deps: [":etc_module"],
+ }
+ `
+
+ result := prepareForSnapshotEtcTest.RunTestWithBp(t, androidBp)
+
+ for _, variant := range result.ModuleVariantsForTests("source") {
+ source := result.ModuleForTests("source", variant)
+
+ result.VisitDirectDeps(source.Module(), func(m blueprint.Module) {
+ if _, ok := m.(*SnapshotEtc); !ok {
+ t.Errorf("Preferred snapshot_etc module expected.")
+ }
+ })
+ }
+}
+
+func TestSnapshotEtcWithoutOrigin(t *testing.T) {
+ var androidBp = `
+ snapshot_etc {
+ name: "etc_module",
+ src: "bar.conf",
+ }
+
+ source {
+ name: "source",
+ deps: [":etc_module"],
+ }
+ `
+
+ result := prepareForSnapshotEtcTest.RunTestWithBp(t, androidBp)
+
+ for _, variant := range result.ModuleVariantsForTests("source") {
+ source := result.ModuleForTests("source", variant)
+
+ result.VisitDirectDeps(source.Module(), func(m blueprint.Module) {
+ if _, ok := m.(*SnapshotEtc); !ok {
+ t.Errorf("Only source snapshot_etc module expected.")
+ }
+ })
+ }
+}
diff --git a/java/Android.bp b/java/Android.bp
index e5b8f96..9ffa123 100644
--- a/java/Android.bp
+++ b/java/Android.bp
@@ -10,6 +10,7 @@
"blueprint-pathtools",
"soong",
"soong-android",
+ "soong-bazel",
"soong-cc",
"soong-dexpreopt",
"soong-genrule",
diff --git a/java/app.go b/java/app.go
index c69210f..35ed27f 100755
--- a/java/app.go
+++ b/java/app.go
@@ -26,6 +26,7 @@
"github.com/google/blueprint/proptools"
"android/soong/android"
+ "android/soong/bazel"
"android/soong/cc"
"android/soong/dexpreopt"
"android/soong/tradefed"
@@ -42,6 +43,8 @@
ctx.RegisterModuleType("android_app_certificate", AndroidAppCertificateFactory)
ctx.RegisterModuleType("override_android_app", OverrideAndroidAppModuleFactory)
ctx.RegisterModuleType("override_android_test", OverrideAndroidTestModuleFactory)
+
+ android.RegisterBp2BuildMutator("android_app_certificate", AndroidAppCertificateBp2Build)
}
// AndroidManifest.xml merging
@@ -1371,3 +1374,61 @@
outputFile := android.PathForModuleOut(ctx, "verify_uses_libraries", apk.Base())
return outputFile
}
+
+// For Bazel / bp2build
+
+type bazelAndroidAppCertificateAttributes struct {
+ Certificate string
+}
+
+type bazelAndroidAppCertificate struct {
+ android.BazelTargetModuleBase
+ bazelAndroidAppCertificateAttributes
+}
+
+func BazelAndroidAppCertificateFactory() android.Module {
+ module := &bazelAndroidAppCertificate{}
+ module.AddProperties(&module.bazelAndroidAppCertificateAttributes)
+ android.InitBazelTargetModule(module)
+ return module
+}
+
+func AndroidAppCertificateBp2Build(ctx android.TopDownMutatorContext) {
+ module, ok := ctx.Module().(*AndroidAppCertificate)
+ if !ok {
+ // Not an Android app certificate
+ return
+ }
+ if !module.ConvertWithBp2build(ctx) {
+ return
+ }
+ if ctx.ModuleType() != "android_app_certificate" {
+ return
+ }
+
+ androidAppCertificateBp2BuildInternal(ctx, module)
+}
+
+func androidAppCertificateBp2BuildInternal(ctx android.TopDownMutatorContext, module *AndroidAppCertificate) {
+ var certificate string
+ if module.properties.Certificate != nil {
+ certificate = *module.properties.Certificate
+ }
+
+ attrs := &bazelAndroidAppCertificateAttributes{
+ Certificate: certificate,
+ }
+
+ props := bazel.BazelTargetModuleProperties{
+ Rule_class: "android_app_certificate",
+ Bzl_load_location: "//build/bazel/rules:android_app_certificate.bzl",
+ }
+
+ ctx.CreateBazelTargetModule(BazelAndroidAppCertificateFactory, module.Name(), props, attrs)
+}
+
+func (m *bazelAndroidAppCertificate) Name() string {
+ return m.BaseModuleName()
+}
+
+func (m *bazelAndroidAppCertificate) GenerateAndroidBuildActions(ctx android.ModuleContext) {}
diff --git a/mk2rbc/mk2rbc.go b/mk2rbc/mk2rbc.go
index 317b40d..86e647d 100644
--- a/mk2rbc/mk2rbc.go
+++ b/mk2rbc/mk2rbc.go
@@ -1079,7 +1079,7 @@
if expr.name == "call" {
words = args.SplitN(",", 2)
if words[0].Empty() || !words[0].Const() {
- return ctx.newBadExpr(nil, "cannot handle %s", refDump)
+ return ctx.newBadExpr(node, "cannot handle %s", refDump)
}
expr.name = words[0].Dump()
if len(words) < 2 {
diff --git a/rust/builder.go b/rust/builder.go
index 523428d..6c44166 100644
--- a/rust/builder.go
+++ b/rust/builder.go
@@ -332,6 +332,9 @@
rustdocFlags = append(rustdocFlags, makeLibFlags(deps)...)
docTimestampFile := android.PathForModuleOut(ctx, "rustdoc.timestamp")
+ // Silence warnings about renamed lints
+ rustdocFlags = append(rustdocFlags, " -A renamed_and_removed_lints")
+
// Yes, the same out directory is used simultaneously by all rustdoc builds.
// This is what cargo does. The docs for individual crates get generated to
// a subdirectory named for the crate, and rustdoc synchronizes writes to
diff --git a/rust/config/global.go b/rust/config/global.go
index 39ed992..c390711 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.52.1"
+ RustDefaultVersion = "1.53.0"
RustDefaultBase = "prebuilts/rust/"
DefaultEdition = "2018"
Stdlibs = []string{