Merge "Integrate bazelenv.sh environment variables into soong_ui environment."
diff --git a/android/Android.bp b/android/Android.bp
index 8f89a59..7bd1450 100644
--- a/android/Android.bp
+++ b/android/Android.bp
@@ -21,7 +21,6 @@
"defaults.go",
"defs.go",
"depset.go",
- "deptag.go",
"expand.go",
"filegroup.go",
"hooks.go",
@@ -69,7 +68,6 @@
"config_test.go",
"csuite_config_test.go",
"depset_test.go",
- "deptag_test.go",
"expand_test.go",
"module_test.go",
"mutator_test.go",
diff --git a/android/arch.go b/android/arch.go
index 16211f8..98ff07a 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -598,10 +598,6 @@
// has dependencies on all the OS variants.
CommonOS = NewOsType("common_os", Generic, false)
- // CommonArch is the Arch for all modules that are os-specific but not arch specific,
- // for example most Java modules.
- CommonArch = Arch{ArchType: Common}
-
osArchTypeMap = map[OsType][]ArchType{
Linux: []ArchType{X86, X86_64},
LinuxBionic: []ArchType{Arm64, X86_64},
@@ -665,7 +661,7 @@
if _, found := commonTargetMap[name]; found {
panic(fmt.Errorf("Found Os type duplicate during OsType registration: %q", name))
} else {
- commonTargetMap[name] = Target{Os: os, Arch: CommonArch}
+ commonTargetMap[name] = Target{Os: os, Arch: Arch{ArchType: Common}}
}
return os
@@ -823,6 +819,9 @@
// Identifies the dependency from CommonOS variant to the os specific variants.
var commonOsToOsSpecificVariantTag = archDepTag{name: "common os to os specific"}
+// Identifies the dependency from arch variant to the common variant for a "common_first" multilib.
+var firstArchToCommonArchDepTag = archDepTag{name: "first arch to common arch"}
+
// Get the OsType specific variants for the current CommonOS variant.
//
// The returned list will only contain enabled OsType specific variants of the
@@ -961,6 +960,12 @@
addTargetProperties(m, targets[i], multiTargets, i == 0)
m.base().setArchProperties(mctx)
}
+
+ if multilib == "common_first" && len(modules) >= 2 {
+ for i := range modules[1:] {
+ mctx.AddInterVariantDependency(firstArchToCommonArchDepTag, modules[i+1], modules[0])
+ }
+ }
}
func addTargetProperties(m Module, target Target, multiTargets []Target, primaryTarget bool) {
diff --git a/android/deptag.go b/android/deptag.go
deleted file mode 100644
index be5c35c..0000000
--- a/android/deptag.go
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2020 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 "github.com/google/blueprint"
-
-// Dependency tags can implement this interface and return true from InstallDepNeeded to annotate
-// that the installed files of the parent should depend on the installed files of the child.
-type InstallNeededDependencyTag interface {
- // If InstallDepNeeded returns true then the installed files of the parent will depend on the
- // installed files of the child.
- InstallDepNeeded() bool
-}
-
-// Dependency tags can embed this struct to annotate that the installed files of the parent should
-// depend on the installed files of the child.
-type InstallAlwaysNeededDependencyTag struct{}
-
-func (i InstallAlwaysNeededDependencyTag) InstallDepNeeded() bool {
- return true
-}
-
-var _ InstallNeededDependencyTag = InstallAlwaysNeededDependencyTag{}
-
-// IsInstallDepNeeded returns true if the dependency tag implements the InstallNeededDependencyTag
-// interface and the InstallDepNeeded returns true, meaning that the installed files of the parent
-// should depend on the installed files of the child.
-func IsInstallDepNeeded(tag blueprint.DependencyTag) bool {
- if i, ok := tag.(InstallNeededDependencyTag); ok {
- return i.InstallDepNeeded()
- }
- return false
-}
diff --git a/android/deptag_test.go b/android/deptag_test.go
deleted file mode 100644
index bdd449e..0000000
--- a/android/deptag_test.go
+++ /dev/null
@@ -1,135 +0,0 @@
-// Copyright 2020 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"
-
- "github.com/google/blueprint"
-)
-
-type testInstallDependencyTagModule struct {
- ModuleBase
- Properties struct {
- Install_deps []string
- Deps []string
- }
-}
-
-func (t *testInstallDependencyTagModule) GenerateAndroidBuildActions(ctx ModuleContext) {
- outputFile := PathForModuleOut(ctx, "out")
- ctx.Build(pctx, BuildParams{
- Rule: Touch,
- Output: outputFile,
- })
- ctx.InstallFile(PathForModuleInstall(ctx), ctx.ModuleName(), outputFile)
-}
-
-var testInstallDependencyTagAlwaysDepTag = struct {
- blueprint.DependencyTag
- InstallAlwaysNeededDependencyTag
-}{}
-
-var testInstallDependencyTagNeverDepTag = struct {
- blueprint.DependencyTag
-}{}
-
-func (t *testInstallDependencyTagModule) DepsMutator(ctx BottomUpMutatorContext) {
- ctx.AddVariationDependencies(nil, testInstallDependencyTagAlwaysDepTag, t.Properties.Install_deps...)
- ctx.AddVariationDependencies(nil, testInstallDependencyTagNeverDepTag, t.Properties.Deps...)
-}
-
-func testInstallDependencyTagModuleFactory() Module {
- module := &testInstallDependencyTagModule{}
- InitAndroidArchModule(module, HostAndDeviceDefault, MultilibCommon)
- module.AddProperties(&module.Properties)
- return module
-}
-
-func TestInstallDependencyTag(t *testing.T) {
- bp := `
- test_module {
- name: "foo",
- deps: ["dep"],
- install_deps: ["install_dep"],
- }
-
- test_module {
- name: "install_dep",
- install_deps: ["transitive"],
- }
-
- test_module {
- name: "transitive",
- }
-
- test_module {
- name: "dep",
- }
- `
-
- config := TestArchConfig(buildDir, nil, bp, nil)
- ctx := NewTestArchContext(config)
-
- ctx.RegisterModuleType("test_module", testInstallDependencyTagModuleFactory)
-
- ctx.Register()
- _, errs := ctx.ParseFileList(".", []string{"Android.bp"})
- FailIfErrored(t, errs)
- _, errs = ctx.PrepareBuildActions(config)
- FailIfErrored(t, errs)
-
- hostFoo := ctx.ModuleForTests("foo", config.BuildOSCommonTarget.String()).Description("install")
- hostInstallDep := ctx.ModuleForTests("install_dep", config.BuildOSCommonTarget.String()).Description("install")
- hostTransitive := ctx.ModuleForTests("transitive", config.BuildOSCommonTarget.String()).Description("install")
- hostDep := ctx.ModuleForTests("dep", config.BuildOSCommonTarget.String()).Description("install")
-
- if g, w := hostFoo.Implicits.Strings(), hostInstallDep.Output.String(); !InList(w, g) {
- t.Errorf("expected host dependency %q, got %q", w, g)
- }
-
- if g, w := hostFoo.Implicits.Strings(), hostTransitive.Output.String(); !InList(w, g) {
- t.Errorf("expected host dependency %q, got %q", w, g)
- }
-
- if g, w := hostInstallDep.Implicits.Strings(), hostTransitive.Output.String(); !InList(w, g) {
- t.Errorf("expected host dependency %q, got %q", w, g)
- }
-
- if g, w := hostFoo.Implicits.Strings(), hostDep.Output.String(); InList(w, g) {
- t.Errorf("expected no host dependency %q, got %q", w, g)
- }
-
- deviceFoo := ctx.ModuleForTests("foo", "android_common").Description("install")
- deviceInstallDep := ctx.ModuleForTests("install_dep", "android_common").Description("install")
- deviceTransitive := ctx.ModuleForTests("transitive", "android_common").Description("install")
- deviceDep := ctx.ModuleForTests("dep", "android_common").Description("install")
-
- if g, w := deviceFoo.OrderOnly.Strings(), deviceInstallDep.Output.String(); !InList(w, g) {
- t.Errorf("expected device dependency %q, got %q", w, g)
- }
-
- if g, w := deviceFoo.OrderOnly.Strings(), deviceTransitive.Output.String(); !InList(w, g) {
- t.Errorf("expected device dependency %q, got %q", w, g)
- }
-
- if g, w := deviceInstallDep.OrderOnly.Strings(), deviceTransitive.Output.String(); !InList(w, g) {
- t.Errorf("expected device dependency %q, got %q", w, g)
- }
-
- if g, w := deviceFoo.OrderOnly.Strings(), deviceDep.Output.String(); InList(w, g) {
- t.Errorf("expected no device dependency %q, got %q", w, g)
- }
-}
diff --git a/android/module.go b/android/module.go
index ef1b0bd..d677406 100644
--- a/android/module.go
+++ b/android/module.go
@@ -1242,18 +1242,14 @@
return m.commonProperties.NamespaceExportedToMake
}
-// computeInstallDeps finds the installed paths of all dependencies that have a dependency
-// tag that is annotated as needing installation via the IsInstallDepNeeded method.
func (m *ModuleBase) computeInstallDeps(ctx blueprint.ModuleContext) InstallPaths {
+
var result InstallPaths
- ctx.WalkDeps(func(child, parent blueprint.Module) bool {
- if a, ok := child.(Module); ok {
- if IsInstallDepNeeded(ctx.OtherModuleDependencyTag(child)) {
- result = append(result, a.FilesToInstall()...)
- return true
- }
+ // TODO(ccross): we need to use WalkDeps and have some way to know which dependencies require installation
+ ctx.VisitDepsDepthFirst(func(m blueprint.Module) {
+ if a, ok := m.(Module); ok {
+ result = append(result, a.FilesToInstall()...)
}
- return false
})
return result
diff --git a/androidmk/androidmk/android.go b/androidmk/androidmk/android.go
index 739a965..4540a1f 100644
--- a/androidmk/androidmk/android.go
+++ b/androidmk/androidmk/android.go
@@ -214,6 +214,8 @@
"LOCAL_PRIVATE_PLATFORM_APIS": "platform_apis",
"LOCAL_JETIFIER_ENABLED": "jetifier",
+
+ "LOCAL_IS_UNIT_TEST": "unit_test",
})
}
diff --git a/cc/androidmk.go b/cc/androidmk.go
index 38269cb..d32e4de 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -370,6 +370,9 @@
entries.SetBool("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", true)
}
entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", test.Properties.Test_mainline_modules...)
+ if Bool(test.Properties.Test_options.Unit_test) {
+ entries.SetBool("LOCAL_IS_UNIT_TEST", true)
+ }
})
androidMkWriteTestData(test.data, ctx, entries)
@@ -505,7 +508,7 @@
})
}
-func (c *vendorSnapshotLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
+func (c *snapshotLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
// Each vendor snapshot is exported to androidMk only when BOARD_VNDK_VERSION != current
// and the version of the prebuilt is same as BOARD_VNDK_VERSION.
if c.shared() {
@@ -549,7 +552,7 @@
})
}
-func (c *vendorSnapshotBinaryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
+func (c *snapshotBinaryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
entries.Class = "EXECUTABLES"
if c.androidMkVendorSuffix {
@@ -563,7 +566,7 @@
})
}
-func (c *vendorSnapshotObjectLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
+func (c *snapshotObjectLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
entries.Class = "STATIC_LIBRARIES"
if c.androidMkVendorSuffix {
diff --git a/cc/cc.go b/cc/cc.go
index 0724a76..a2d6cd9 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -305,10 +305,11 @@
// Normally Soong uses the directory structure to decide which modules
// should be included (framework) or excluded (non-framework) from the
- // vendor snapshot, but this property allows a partner to exclude a
- // module normally thought of as a framework module from the vendor
- // snapshot.
- Exclude_from_vendor_snapshot *bool
+ // different snapshots (vendor, recovery, etc.), but these properties
+ // allow a partner to exclude a module normally thought of as a
+ // framework module from a snapshot.
+ Exclude_from_vendor_snapshot *bool
+ Exclude_from_recovery_snapshot *bool
}
type VendorProperties struct {
@@ -550,15 +551,7 @@
return d.Kind == staticLibraryDependency
}
-// InstallDepNeeded returns true for shared libraries so that shared library dependencies of
-// binaries or other shared libraries are installed as dependencies.
-func (d libraryDependencyTag) InstallDepNeeded() bool {
- return d.shared()
-}
-
-var _ android.InstallNeededDependencyTag = libraryDependencyTag{}
-
-// dependencyTag is used for tagging miscellaneous dependency types that don't fit into
+// dependencyTag is used for tagging miscellanous dependency types that don't fit into
// libraryDependencyTag. Each tag object is created globally and reused for multiple
// dependencies (although since the object contains no references, assigning a tag to a
// variable and modifying it will not modify the original). Users can compare the tag
@@ -568,15 +561,6 @@
name string
}
-// installDependencyTag is used for tagging miscellaneous dependency types that don't fit into
-// libraryDependencyTag, but where the dependency needs to be installed when the parent is
-// installed.
-type installDependencyTag struct {
- blueprint.BaseDependencyTag
- android.InstallAlwaysNeededDependencyTag
- name string
-}
-
var (
genSourceDepTag = dependencyTag{name: "gen source"}
genHeaderDepTag = dependencyTag{name: "gen header"}
@@ -588,7 +572,7 @@
staticVariantTag = dependencyTag{name: "static variant"}
vndkExtDepTag = dependencyTag{name: "vndk extends"}
dataLibDepTag = dependencyTag{name: "data lib"}
- runtimeDepTag = installDependencyTag{name: "runtime lib"}
+ runtimeDepTag = dependencyTag{name: "runtime lib"}
testPerSrcDepTag = dependencyTag{name: "test_per_src"}
stubImplDepTag = dependencyTag{name: "stub_impl"}
)
@@ -615,7 +599,8 @@
}
func IsRuntimeDepTag(depTag blueprint.DependencyTag) bool {
- return depTag == runtimeDepTag
+ ccDepTag, ok := depTag.(dependencyTag)
+ return ok && ccDepTag == runtimeDepTag
}
func IsTestPerSrcDepTag(depTag blueprint.DependencyTag) bool {
@@ -1067,6 +1052,10 @@
return Bool(c.Properties.Exclude_from_vendor_snapshot)
}
+func (c *Module) ExcludeFromRecoverySnapshot() bool {
+ return Bool(c.Properties.Exclude_from_recovery_snapshot)
+}
+
func isBionic(name string) bool {
switch name {
case "libc", "libm", "libdl", "libdl_android", "linker":
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 7c60686..f5ce867 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -1551,6 +1551,8 @@
android.CheckErrorsAgainstExpectations(t, errs, []string{
`module "libvendor\{.+,image:vendor.+,arch:arm64_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`,
`module "libvendor\{.+,image:vendor.+,arch:arm_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`,
+ `module "libvendor\{.+,image:vendor.+,arch:arm64_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`,
+ `module "libvendor\{.+,image:vendor.+,arch:arm_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`,
})
}
@@ -1597,6 +1599,132 @@
})
}
+func TestRecoverySnapshotCapture(t *testing.T) {
+ bp := `
+ cc_library {
+ name: "libvndk",
+ vendor_available: true,
+ recovery_available: true,
+ product_available: true,
+ vndk: {
+ enabled: true,
+ },
+ nocrt: true,
+ }
+
+ cc_library {
+ name: "librecovery",
+ recovery: true,
+ nocrt: true,
+ }
+
+ cc_library {
+ name: "librecovery_available",
+ recovery_available: true,
+ nocrt: true,
+ }
+
+ cc_library_headers {
+ name: "librecovery_headers",
+ recovery_available: true,
+ nocrt: true,
+ }
+
+ cc_binary {
+ name: "recovery_bin",
+ recovery: true,
+ nocrt: true,
+ }
+
+ cc_binary {
+ name: "recovery_available_bin",
+ recovery_available: true,
+ nocrt: true,
+ }
+
+ toolchain_library {
+ name: "libb",
+ recovery_available: true,
+ src: "libb.a",
+ }
+
+ cc_object {
+ name: "obj",
+ recovery_available: true,
+ }
+`
+ config := TestConfig(buildDir, android.Android, nil, bp, nil)
+ config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
+ config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
+ ctx := testCcWithConfig(t, config)
+
+ // Check Recovery snapshot output.
+
+ snapshotDir := "recovery-snapshot"
+ snapshotVariantPath := filepath.Join(buildDir, snapshotDir, "arm64")
+ snapshotSingleton := ctx.SingletonForTests("recovery-snapshot")
+
+ var jsonFiles []string
+
+ for _, arch := range [][]string{
+ []string{"arm64", "armv8-a"},
+ } {
+ archType := arch[0]
+ archVariant := arch[1]
+ archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant)
+
+ // For shared libraries, only recovery_available modules are captured.
+ sharedVariant := fmt.Sprintf("android_recovery_%s_%s_shared", archType, archVariant)
+ sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared")
+ checkSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.so", sharedDir, sharedVariant)
+ checkSnapshot(t, ctx, snapshotSingleton, "librecovery", "librecovery.so", sharedDir, sharedVariant)
+ checkSnapshot(t, ctx, snapshotSingleton, "librecovery_available", "librecovery_available.so", sharedDir, sharedVariant)
+ jsonFiles = append(jsonFiles,
+ filepath.Join(sharedDir, "libvndk.so.json"),
+ filepath.Join(sharedDir, "librecovery.so.json"),
+ filepath.Join(sharedDir, "librecovery_available.so.json"))
+
+ // For static libraries, all recovery:true and recovery_available modules are captured.
+ staticVariant := fmt.Sprintf("android_recovery_%s_%s_static", archType, archVariant)
+ staticDir := filepath.Join(snapshotVariantPath, archDir, "static")
+ checkSnapshot(t, ctx, snapshotSingleton, "libb", "libb.a", staticDir, staticVariant)
+ checkSnapshot(t, ctx, snapshotSingleton, "librecovery", "librecovery.a", staticDir, staticVariant)
+ checkSnapshot(t, ctx, snapshotSingleton, "librecovery_available", "librecovery_available.a", staticDir, staticVariant)
+ jsonFiles = append(jsonFiles,
+ filepath.Join(staticDir, "libb.a.json"),
+ filepath.Join(staticDir, "librecovery.a.json"),
+ filepath.Join(staticDir, "librecovery_available.a.json"))
+
+ // For binary executables, all recovery:true and recovery_available modules are captured.
+ if archType == "arm64" {
+ binaryVariant := fmt.Sprintf("android_recovery_%s_%s", archType, archVariant)
+ binaryDir := filepath.Join(snapshotVariantPath, archDir, "binary")
+ checkSnapshot(t, ctx, snapshotSingleton, "recovery_bin", "recovery_bin", binaryDir, binaryVariant)
+ checkSnapshot(t, ctx, snapshotSingleton, "recovery_available_bin", "recovery_available_bin", binaryDir, binaryVariant)
+ jsonFiles = append(jsonFiles,
+ filepath.Join(binaryDir, "recovery_bin.json"),
+ filepath.Join(binaryDir, "recovery_available_bin.json"))
+ }
+
+ // For header libraries, all vendor:true and vendor_available modules are captured.
+ headerDir := filepath.Join(snapshotVariantPath, archDir, "header")
+ jsonFiles = append(jsonFiles, filepath.Join(headerDir, "librecovery_headers.json"))
+
+ // For object modules, all vendor:true and vendor_available modules are captured.
+ objectVariant := fmt.Sprintf("android_recovery_%s_%s", archType, archVariant)
+ objectDir := filepath.Join(snapshotVariantPath, archDir, "object")
+ checkSnapshot(t, ctx, snapshotSingleton, "obj", "obj.o", objectDir, objectVariant)
+ jsonFiles = append(jsonFiles, filepath.Join(objectDir, "obj.o.json"))
+ }
+
+ for _, jsonFile := range jsonFiles {
+ // verify all json files exist
+ if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil {
+ t.Errorf("%q expected but not found", jsonFile)
+ }
+ }
+}
+
func TestDoubleLoadableDepError(t *testing.T) {
// Check whether an error is emitted when a LLNDK depends on a non-double_loadable VNDK lib.
testCcError(t, "module \".*\" variant \".*\": link.* \".*\" which is not LL-NDK, VNDK-SP, .*double_loadable", `
@@ -3941,98 +4069,3 @@
}
}
-
-func TestInstallSharedLibs(t *testing.T) {
- bp := `
- cc_binary {
- name: "bin",
- host_supported: true,
- shared_libs: ["libshared"],
- runtime_libs: ["libruntime"],
- srcs: [":gen"],
- }
-
- cc_library_shared {
- name: "libshared",
- host_supported: true,
- shared_libs: ["libtransitive"],
- }
-
- cc_library_shared {
- name: "libtransitive",
- host_supported: true,
- }
-
- cc_library_shared {
- name: "libruntime",
- host_supported: true,
- }
-
- cc_binary_host {
- name: "tool",
- srcs: ["foo.cpp"],
- }
-
- genrule {
- name: "gen",
- tools: ["tool"],
- out: ["gen.cpp"],
- cmd: "$(location tool) $(out)",
- }
- `
-
- config := TestConfig(buildDir, android.Android, nil, bp, nil)
- ctx := testCcWithConfig(t, config)
-
- hostBin := ctx.ModuleForTests("bin", config.BuildOSTarget.String()).Description("install")
- hostShared := ctx.ModuleForTests("libshared", config.BuildOSTarget.String()+"_shared").Description("install")
- hostRuntime := ctx.ModuleForTests("libruntime", config.BuildOSTarget.String()+"_shared").Description("install")
- hostTransitive := ctx.ModuleForTests("libtransitive", config.BuildOSTarget.String()+"_shared").Description("install")
- hostTool := ctx.ModuleForTests("tool", config.BuildOSTarget.String()).Description("install")
-
- if g, w := hostBin.Implicits.Strings(), hostShared.Output.String(); !android.InList(w, g) {
- t.Errorf("expected host bin dependency %q, got %q", w, g)
- }
-
- if g, w := hostBin.Implicits.Strings(), hostTransitive.Output.String(); !android.InList(w, g) {
- t.Errorf("expected host bin dependency %q, got %q", w, g)
- }
-
- if g, w := hostShared.Implicits.Strings(), hostTransitive.Output.String(); !android.InList(w, g) {
- t.Errorf("expected host bin dependency %q, got %q", w, g)
- }
-
- if g, w := hostBin.Implicits.Strings(), hostRuntime.Output.String(); !android.InList(w, g) {
- t.Errorf("expected host bin dependency %q, got %q", w, g)
- }
-
- if g, w := hostBin.Implicits.Strings(), hostTool.Output.String(); android.InList(w, g) {
- t.Errorf("expected no host bin dependency %q, got %q", w, g)
- }
-
- deviceBin := ctx.ModuleForTests("bin", "android_arm64_armv8-a").Description("install")
- deviceShared := ctx.ModuleForTests("libshared", "android_arm64_armv8-a_shared").Description("install")
- deviceTransitive := ctx.ModuleForTests("libtransitive", "android_arm64_armv8-a_shared").Description("install")
- deviceRuntime := ctx.ModuleForTests("libruntime", "android_arm64_armv8-a_shared").Description("install")
-
- if g, w := deviceBin.OrderOnly.Strings(), deviceShared.Output.String(); !android.InList(w, g) {
- t.Errorf("expected device bin dependency %q, got %q", w, g)
- }
-
- if g, w := deviceBin.OrderOnly.Strings(), deviceTransitive.Output.String(); !android.InList(w, g) {
- t.Errorf("expected device bin dependency %q, got %q", w, g)
- }
-
- if g, w := deviceShared.OrderOnly.Strings(), deviceTransitive.Output.String(); !android.InList(w, g) {
- t.Errorf("expected device bin dependency %q, got %q", w, g)
- }
-
- if g, w := deviceBin.OrderOnly.Strings(), deviceRuntime.Output.String(); !android.InList(w, g) {
- t.Errorf("expected device bin dependency %q, got %q", w, g)
- }
-
- if g, w := deviceBin.OrderOnly.Strings(), hostTool.Output.String(); android.InList(w, g) {
- t.Errorf("expected no device bin dependency %q, got %q", w, g)
- }
-
-}
diff --git a/cc/config/vndk.go b/cc/config/vndk.go
index d18ae25..eb3d16f 100644
--- a/cc/config/vndk.go
+++ b/cc/config/vndk.go
@@ -21,6 +21,7 @@
"android.hardware.automotive.occupant_awareness-ndk_platform",
"android.hardware.light-ndk_platform",
"android.hardware.identity-ndk_platform",
+ "android.hardware.keymint-ndk_platform",
"android.hardware.nfc@1.2",
"android.hardware.power-ndk_platform",
"android.hardware.rebootescrow-ndk_platform",
diff --git a/cc/sanitize.go b/cc/sanitize.go
index b1326d9..eb61525 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -847,7 +847,7 @@
return true
}
- if p, ok := d.linker.(*vendorSnapshotLibraryDecorator); ok {
+ if p, ok := d.linker.(*snapshotLibraryDecorator); ok {
if Bool(p.properties.Sanitize_minimal_dep) {
c.sanitize.Properties.MinimalRuntimeDep = true
}
diff --git a/cc/snapshot_utils.go b/cc/snapshot_utils.go
index 05c06ac..a3d52e6 100644
--- a/cc/snapshot_utils.go
+++ b/cc/snapshot_utils.go
@@ -60,7 +60,8 @@
func isSnapshotAware(ctx android.ModuleContext, m *Module, apexInfo android.ApexInfo) bool {
if _, _, ok := isVndkSnapshotLibrary(ctx.DeviceConfig(), m, apexInfo); ok {
return ctx.Config().VndkSnapshotBuildArtifacts()
- } else if isVendorSnapshotModule(m, isVendorProprietaryPath(ctx.ModuleDir()), apexInfo) {
+ } else if isVendorSnapshotModule(m, isVendorProprietaryPath(ctx.ModuleDir()), apexInfo) ||
+ isRecoverySnapshotModule(m, isVendorProprietaryPath(ctx.ModuleDir()), apexInfo) {
return true
}
return false
diff --git a/cc/test.go b/cc/test.go
index 619dc4d..3772691 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -46,6 +46,9 @@
// a list of extra test configuration files that should be installed with the module.
Extra_test_configs []string `android:"path,arch_variant"`
+
+ // If the test is a hostside(no device required) unittest that shall be run during presubmit check.
+ Unit_test *bool
}
type TestBinaryProperties struct {
diff --git a/cc/testing.go b/cc/testing.go
index a3235e9..7161313 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -16,7 +16,6 @@
import (
"android/soong/android"
- "android/soong/genrule"
)
func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
@@ -25,7 +24,6 @@
RegisterBinaryBuildComponents(ctx)
RegisterLibraryBuildComponents(ctx)
RegisterLibraryHeadersBuildComponents(ctx)
- genrule.RegisterGenruleBuildComponents(ctx)
ctx.RegisterModuleType("toolchain_library", ToolchainLibraryFactory)
ctx.RegisterModuleType("llndk_library", LlndkLibraryFactory)
@@ -565,6 +563,7 @@
RegisterRequiredBuildComponentsForTest(ctx)
ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
ctx.RegisterSingletonType("vendor-snapshot", VendorSnapshotSingleton)
+ ctx.RegisterSingletonType("recovery-snapshot", RecoverySnapshotSingleton)
return ctx
}
diff --git a/cc/vendor_snapshot.go b/cc/vendor_snapshot.go
index 78bde38..6563f6e 100644
--- a/cc/vendor_snapshot.go
+++ b/cc/vendor_snapshot.go
@@ -25,6 +25,115 @@
"android/soong/android"
)
+// Defines the specifics of different images to which the snapshot process is
+// applicable, e.g., vendor, recovery, ramdisk.
+type image interface {
+ // Used to register callbacks with the build system.
+ init()
+
+ // Function that returns true if the module is included in this image.
+ // Using a function return instead of a value to prevent early
+ // evalution of a function that may be not be defined.
+ inImage(m *Module) func() bool
+
+ // Returns the value of the "available" property for a given module for
+ // and snapshot, e.g., "vendor_available", "recovery_available", etc.
+ // or nil if the property is not defined.
+ available(m *Module) *bool
+
+ // Returns true if a dir under source tree is an SoC-owned proprietary
+ // directory, such as device/, vendor/, etc.
+ //
+ // For a given snapshot (e.g., vendor, recovery, etc.) if
+ // isProprietaryPath(dir) returns true, then the module in dir will be
+ // built from sources.
+ isProprietaryPath(dir string) bool
+
+ // Whether to include VNDK in the snapshot for this image.
+ includeVndk() bool
+
+ // Whether a given module has been explicitly excluded from the
+ // snapshot, e.g., using the exclude_from_vendor_snapshot or
+ // exclude_from_recovery_snapshot properties.
+ excludeFromSnapshot(m *Module) bool
+}
+
+type vendorImage struct{}
+type recoveryImage struct{}
+
+func (vendorImage) init() {
+ android.RegisterSingletonType(
+ "vendor-snapshot", VendorSnapshotSingleton)
+ android.RegisterModuleType(
+ "vendor_snapshot_shared", VendorSnapshotSharedFactory)
+ android.RegisterModuleType(
+ "vendor_snapshot_static", VendorSnapshotStaticFactory)
+ android.RegisterModuleType(
+ "vendor_snapshot_header", VendorSnapshotHeaderFactory)
+ android.RegisterModuleType(
+ "vendor_snapshot_binary", VendorSnapshotBinaryFactory)
+ android.RegisterModuleType(
+ "vendor_snapshot_object", VendorSnapshotObjectFactory)
+}
+
+func (vendorImage) inImage(m *Module) func() bool {
+ return m.inVendor
+}
+
+func (vendorImage) available(m *Module) *bool {
+ return m.VendorProperties.Vendor_available
+}
+
+func (vendorImage) isProprietaryPath(dir string) bool {
+ return isVendorProprietaryPath(dir)
+}
+
+func (vendorImage) includeVndk() bool {
+ return true
+}
+
+func (vendorImage) excludeFromSnapshot(m *Module) bool {
+ return m.ExcludeFromVendorSnapshot()
+}
+
+func (recoveryImage) init() {
+ android.RegisterSingletonType(
+ "recovery-snapshot", RecoverySnapshotSingleton)
+ android.RegisterModuleType(
+ "recovery_snapshot_shared", RecoverySnapshotSharedFactory)
+ android.RegisterModuleType(
+ "recovery_snapshot_static", RecoverySnapshotStaticFactory)
+ android.RegisterModuleType(
+ "recovery_snapshot_header", RecoverySnapshotHeaderFactory)
+ android.RegisterModuleType(
+ "recovery_snapshot_binary", RecoverySnapshotBinaryFactory)
+ android.RegisterModuleType(
+ "recovery_snapshot_object", RecoverySnapshotObjectFactory)
+}
+
+func (recoveryImage) inImage(m *Module) func() bool {
+ return m.InRecovery
+}
+
+func (recoveryImage) available(m *Module) *bool {
+ return m.Properties.Recovery_available
+}
+
+func (recoveryImage) isProprietaryPath(dir string) bool {
+ return isRecoveryProprietaryPath(dir)
+}
+
+func (recoveryImage) includeVndk() bool {
+ return false
+}
+
+func (recoveryImage) excludeFromSnapshot(m *Module) bool {
+ return m.ExcludeFromRecoverySnapshot()
+}
+
+var vendorImageSingleton vendorImage
+var recoveryImageSingleton recoveryImage
+
const (
vendorSnapshotHeaderSuffix = ".vendor_header."
vendorSnapshotSharedSuffix = ".vendor_shared."
@@ -33,6 +142,14 @@
vendorSnapshotObjectSuffix = ".vendor_object."
)
+const (
+ recoverySnapshotHeaderSuffix = ".recovery_header."
+ recoverySnapshotSharedSuffix = ".recovery_shared."
+ recoverySnapshotStaticSuffix = ".recovery_static."
+ recoverySnapshotBinarySuffix = ".recovery_binary."
+ recoverySnapshotObjectSuffix = ".recovery_object."
+)
+
var (
vendorSnapshotsLock sync.Mutex
vendorSuffixModulesKey = android.NewOnceKey("vendorSuffixModules")
@@ -136,7 +253,7 @@
}
}
-type vendorSnapshotLibraryProperties struct {
+type snapshotLibraryProperties struct {
// Prebuilt file for each arch.
Src *string `android:"arch_variant"`
@@ -161,25 +278,25 @@
setSanitizerVariation(t sanitizerType, enabled bool)
}
-type vendorSnapshotLibraryDecorator struct {
+type snapshotLibraryDecorator struct {
vendorSnapshotModuleBase
*libraryDecorator
- properties vendorSnapshotLibraryProperties
+ properties snapshotLibraryProperties
sanitizerProperties struct {
CfiEnabled bool `blueprint:"mutated"`
// Library flags for cfi variant.
- Cfi vendorSnapshotLibraryProperties `android:"arch_variant"`
+ Cfi snapshotLibraryProperties `android:"arch_variant"`
}
androidMkVendorSuffix bool
}
-func (p *vendorSnapshotLibraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
+func (p *snapshotLibraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
p.libraryDecorator.libName = strings.TrimSuffix(ctx.ModuleName(), p.NameSuffix())
return p.libraryDecorator.linkerFlags(ctx, flags)
}
-func (p *vendorSnapshotLibraryDecorator) matchesWithDevice(config android.DeviceConfig) bool {
+func (p *snapshotLibraryDecorator) matchesWithDevice(config android.DeviceConfig) bool {
arches := config.Arches()
if len(arches) == 0 || arches[0].ArchType.String() != p.arch() {
return false
@@ -190,7 +307,7 @@
return true
}
-func (p *vendorSnapshotLibraryDecorator) link(ctx ModuleContext,
+func (p *snapshotLibraryDecorator) link(ctx ModuleContext,
flags Flags, deps PathDeps, objs Objects) android.Path {
m := ctx.Module().(*Module)
p.androidMkVendorSuffix = vendorSuffixModules(ctx.Config())[m.BaseModuleName()]
@@ -246,17 +363,17 @@
return in
}
-func (p *vendorSnapshotLibraryDecorator) install(ctx ModuleContext, file android.Path) {
+func (p *snapshotLibraryDecorator) install(ctx ModuleContext, file android.Path) {
if p.matchesWithDevice(ctx.DeviceConfig()) && (p.shared() || p.static()) {
p.baseInstaller.install(ctx, file)
}
}
-func (p *vendorSnapshotLibraryDecorator) nativeCoverage() bool {
+func (p *snapshotLibraryDecorator) nativeCoverage() bool {
return false
}
-func (p *vendorSnapshotLibraryDecorator) isSanitizerEnabled(t sanitizerType) bool {
+func (p *snapshotLibraryDecorator) isSanitizerEnabled(t sanitizerType) bool {
switch t {
case cfi:
return p.sanitizerProperties.Cfi.Src != nil
@@ -265,7 +382,7 @@
}
}
-func (p *vendorSnapshotLibraryDecorator) setSanitizerVariation(t sanitizerType, enabled bool) {
+func (p *snapshotLibraryDecorator) setSanitizerVariation(t sanitizerType, enabled bool) {
if !enabled {
return
}
@@ -277,14 +394,14 @@
}
}
-func vendorSnapshotLibrary(suffix string) (*Module, *vendorSnapshotLibraryDecorator) {
+func snapshotLibrary(suffix string) (*Module, *snapshotLibraryDecorator) {
module, library := NewLibrary(android.DeviceSupported)
module.stl = nil
module.sanitize = nil
library.disableStripping()
- prebuilt := &vendorSnapshotLibraryDecorator{
+ prebuilt := &snapshotLibraryDecorator{
libraryDecorator: library,
}
@@ -310,38 +427,56 @@
}
func VendorSnapshotSharedFactory() android.Module {
- module, prebuilt := vendorSnapshotLibrary(vendorSnapshotSharedSuffix)
+ module, prebuilt := snapshotLibrary(vendorSnapshotSharedSuffix)
+ prebuilt.libraryDecorator.BuildOnlyShared()
+ return module.Init()
+}
+
+func RecoverySnapshotSharedFactory() android.Module {
+ module, prebuilt := snapshotLibrary(recoverySnapshotSharedSuffix)
prebuilt.libraryDecorator.BuildOnlyShared()
return module.Init()
}
func VendorSnapshotStaticFactory() android.Module {
- module, prebuilt := vendorSnapshotLibrary(vendorSnapshotStaticSuffix)
+ module, prebuilt := snapshotLibrary(vendorSnapshotStaticSuffix)
+ prebuilt.libraryDecorator.BuildOnlyStatic()
+ return module.Init()
+}
+
+func RecoverySnapshotStaticFactory() android.Module {
+ module, prebuilt := snapshotLibrary(recoverySnapshotStaticSuffix)
prebuilt.libraryDecorator.BuildOnlyStatic()
return module.Init()
}
func VendorSnapshotHeaderFactory() android.Module {
- module, prebuilt := vendorSnapshotLibrary(vendorSnapshotHeaderSuffix)
+ module, prebuilt := snapshotLibrary(vendorSnapshotHeaderSuffix)
prebuilt.libraryDecorator.HeaderOnly()
return module.Init()
}
-var _ snapshotSanitizer = (*vendorSnapshotLibraryDecorator)(nil)
+func RecoverySnapshotHeaderFactory() android.Module {
+ module, prebuilt := snapshotLibrary(recoverySnapshotHeaderSuffix)
+ prebuilt.libraryDecorator.HeaderOnly()
+ return module.Init()
+}
-type vendorSnapshotBinaryProperties struct {
+var _ snapshotSanitizer = (*snapshotLibraryDecorator)(nil)
+
+type snapshotBinaryProperties struct {
// Prebuilt file for each arch.
Src *string `android:"arch_variant"`
}
-type vendorSnapshotBinaryDecorator struct {
+type snapshotBinaryDecorator struct {
vendorSnapshotModuleBase
*binaryDecorator
- properties vendorSnapshotBinaryProperties
+ properties snapshotBinaryProperties
androidMkVendorSuffix bool
}
-func (p *vendorSnapshotBinaryDecorator) matchesWithDevice(config android.DeviceConfig) bool {
+func (p *snapshotBinaryDecorator) matchesWithDevice(config android.DeviceConfig) bool {
if config.DeviceArch() != p.arch() {
return false
}
@@ -351,7 +486,7 @@
return true
}
-func (p *vendorSnapshotBinaryDecorator) link(ctx ModuleContext,
+func (p *snapshotBinaryDecorator) link(ctx ModuleContext,
flags Flags, deps PathDeps, objs Objects) android.Path {
if !p.matchesWithDevice(ctx.DeviceConfig()) {
return nil
@@ -382,11 +517,19 @@
return outputFile
}
-func (p *vendorSnapshotBinaryDecorator) nativeCoverage() bool {
+func (p *snapshotBinaryDecorator) nativeCoverage() bool {
return false
}
func VendorSnapshotBinaryFactory() android.Module {
+ return snapshotBinaryFactory(vendorSnapshotBinarySuffix)
+}
+
+func RecoverySnapshotBinaryFactory() android.Module {
+ return snapshotBinaryFactory(recoverySnapshotBinarySuffix)
+}
+
+func snapshotBinaryFactory(suffix string) android.Module {
module, binary := NewBinary(android.DeviceSupported)
binary.baseLinker.Properties.No_libcrt = BoolPtr(true)
binary.baseLinker.Properties.Nocrt = BoolPtr(true)
@@ -396,7 +539,7 @@
binary.baseLinker.Properties.System_shared_libs = []string{}
}
- prebuilt := &vendorSnapshotBinaryDecorator{
+ prebuilt := &snapshotBinaryDecorator{
binaryDecorator: binary,
}
@@ -405,7 +548,7 @@
module.stl = nil
module.linker = prebuilt
- prebuilt.init(module, vendorSnapshotBinarySuffix)
+ prebuilt.init(module, suffix)
module.AddProperties(&prebuilt.properties)
return module.Init()
}
@@ -415,14 +558,14 @@
Src *string `android:"arch_variant"`
}
-type vendorSnapshotObjectLinker struct {
+type snapshotObjectLinker struct {
vendorSnapshotModuleBase
objectLinker
properties vendorSnapshotObjectProperties
androidMkVendorSuffix bool
}
-func (p *vendorSnapshotObjectLinker) matchesWithDevice(config android.DeviceConfig) bool {
+func (p *snapshotObjectLinker) matchesWithDevice(config android.DeviceConfig) bool {
if config.DeviceArch() != p.arch() {
return false
}
@@ -432,7 +575,7 @@
return true
}
-func (p *vendorSnapshotObjectLinker) link(ctx ModuleContext,
+func (p *snapshotObjectLinker) link(ctx ModuleContext,
flags Flags, deps PathDeps, objs Objects) android.Path {
if !p.matchesWithDevice(ctx.DeviceConfig()) {
return nil
@@ -444,14 +587,14 @@
return android.PathForModuleSrc(ctx, *p.properties.Src)
}
-func (p *vendorSnapshotObjectLinker) nativeCoverage() bool {
+func (p *snapshotObjectLinker) nativeCoverage() bool {
return false
}
func VendorSnapshotObjectFactory() android.Module {
module := newObject()
- prebuilt := &vendorSnapshotObjectLinker{
+ prebuilt := &snapshotObjectLinker{
objectLinker: objectLinker{
baseLinker: NewBaseLinker(nil),
},
@@ -463,21 +606,68 @@
return module.Init()
}
+func RecoverySnapshotObjectFactory() android.Module {
+ module := newObject()
+
+ prebuilt := &snapshotObjectLinker{
+ objectLinker: objectLinker{
+ baseLinker: NewBaseLinker(nil),
+ },
+ }
+ module.linker = prebuilt
+
+ prebuilt.init(module, recoverySnapshotObjectSuffix)
+ module.AddProperties(&prebuilt.properties)
+ return module.Init()
+}
+
func init() {
- android.RegisterSingletonType("vendor-snapshot", VendorSnapshotSingleton)
- android.RegisterModuleType("vendor_snapshot_shared", VendorSnapshotSharedFactory)
- android.RegisterModuleType("vendor_snapshot_static", VendorSnapshotStaticFactory)
- android.RegisterModuleType("vendor_snapshot_header", VendorSnapshotHeaderFactory)
- android.RegisterModuleType("vendor_snapshot_binary", VendorSnapshotBinaryFactory)
- android.RegisterModuleType("vendor_snapshot_object", VendorSnapshotObjectFactory)
+ vendorImageSingleton.init()
+ recoveryImageSingleton.init()
+}
+
+var vendorSnapshotSingleton = snapshotSingleton{
+ "vendor",
+ "SOONG_VENDOR_SNAPSHOT_ZIP",
+ android.OptionalPath{},
+ true,
+ vendorImageSingleton,
+}
+
+var recoverySnapshotSingleton = snapshotSingleton{
+ "recovery",
+ "SOONG_RECOVERY_SNAPSHOT_ZIP",
+ android.OptionalPath{},
+ false,
+ recoveryImageSingleton,
}
func VendorSnapshotSingleton() android.Singleton {
- return &vendorSnapshotSingleton{}
+ return &vendorSnapshotSingleton
}
-type vendorSnapshotSingleton struct {
- vendorSnapshotZipFile android.OptionalPath
+func RecoverySnapshotSingleton() android.Singleton {
+ return &recoverySnapshotSingleton
+}
+
+type snapshotSingleton struct {
+ // Name, e.g., "vendor", "recovery", "ramdisk".
+ name string
+
+ // Make variable that points to the snapshot file, e.g.,
+ // "SOONG_RECOVERY_SNAPSHOT_ZIP".
+ makeVar string
+
+ // Path to the snapshot zip file.
+ snapshotZipFile android.OptionalPath
+
+ // Whether the image supports VNDK extension modules.
+ supportsVndkExt bool
+
+ // Implementation of the image interface specific to the image
+ // associated with this snapshot (e.g., specific to the vendor image,
+ // recovery image, etc.).
+ image image
}
var (
@@ -491,6 +681,17 @@
"hardware",
}
+ // Modules under following directories are ignored. They are OEM's and vendor's
+ // proprietary modules(device/, kernel/, vendor/, and hardware/).
+ // TODO(b/65377115): Clean up these with more maintainable way
+ recoveryProprietaryDirs = []string{
+ "bootable/recovery",
+ "device",
+ "hardware",
+ "kernel",
+ "vendor",
+ }
+
// Modules under following directories are included as they are in AOSP,
// although hardware/ and kernel/ are normally for vendor's own.
// TODO(b/65377115): Clean up these with more maintainable way
@@ -508,7 +709,17 @@
// Determine if a dir under source tree is an SoC-owned proprietary directory, such as
// device/, vendor/, etc.
func isVendorProprietaryPath(dir string) bool {
- for _, p := range vendorProprietaryDirs {
+ return isProprietaryPath(dir, vendorProprietaryDirs)
+}
+
+func isRecoveryProprietaryPath(dir string) bool {
+ return isProprietaryPath(dir, recoveryProprietaryDirs)
+}
+
+// Determine if a dir under source tree is an SoC-owned proprietary directory, such as
+// device/, vendor/, etc.
+func isProprietaryPath(dir string, proprietaryDirs []string) bool {
+ for _, p := range proprietaryDirs {
if strings.HasPrefix(dir, p) {
// filter out AOSP defined directories, e.g. hardware/interfaces/
aosp := false
@@ -556,6 +767,14 @@
// depend on newer VNDK) So they are captured as vendor snapshot To build older vendor
// image and newer system image altogether.
func isVendorSnapshotModule(m *Module, inVendorProprietaryPath bool, apexInfo android.ApexInfo) bool {
+ return isSnapshotModule(m, inVendorProprietaryPath, apexInfo, vendorImageSingleton)
+}
+
+func isRecoverySnapshotModule(m *Module, inRecoveryProprietaryPath bool, apexInfo android.ApexInfo) bool {
+ return isSnapshotModule(m, inRecoveryProprietaryPath, apexInfo, recoveryImageSingleton)
+}
+
+func isSnapshotModule(m *Module, inProprietaryPath bool, apexInfo android.ApexInfo, image image) bool {
if !m.Enabled() || m.Properties.HideFromMake {
return false
}
@@ -564,8 +783,9 @@
if m.IsSkipInstall() {
return false
}
- // skip proprietary modules, but include all VNDK (static)
- if inVendorProprietaryPath && !m.IsVndk() {
+ // skip proprietary modules, but (for the vendor snapshot only)
+ // include all VNDK (static)
+ if inProprietaryPath && (!image.includeVndk() || !m.IsVndk()) {
return false
}
// If the module would be included based on its path, check to see if
@@ -580,7 +800,7 @@
return false
}
// the module must be installed in /vendor
- if !apexInfo.IsForPlatform() || m.isSnapshotPrebuilt() || !m.inVendor() {
+ if !apexInfo.IsForPlatform() || m.isSnapshotPrebuilt() || !image.inImage(m)() {
return false
}
// skip kernel_headers which always depend on vendor
@@ -612,29 +832,31 @@
}
}
if l.static() {
- return m.outputFile.Valid() && proptools.BoolDefault(m.VendorProperties.Vendor_available, true)
+ return m.outputFile.Valid() && proptools.BoolDefault(image.available(m), true)
}
if l.shared() {
if !m.outputFile.Valid() {
return false
}
- if !m.IsVndk() {
- return true
+ if image.includeVndk() {
+ if !m.IsVndk() {
+ return true
+ }
+ return m.isVndkExt()
}
- return m.isVndkExt()
}
return true
}
// Binaries and Objects
if m.binary() || m.object() {
- return m.outputFile.Valid() && proptools.BoolDefault(m.VendorProperties.Vendor_available, true)
+ return m.outputFile.Valid() && proptools.BoolDefault(image.available(m), true)
}
return false
}
-func (c *vendorSnapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
+func (c *snapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
// BOARD_VNDK_VERSION must be set to 'current' in order to generate a vendor snapshot.
if ctx.DeviceConfig().VndkVersion() != "current" {
return
@@ -675,7 +897,7 @@
(header files of same directory structure with source tree)
*/
- snapshotDir := "vendor-snapshot"
+ snapshotDir := c.name + "-snapshot"
snapshotArchDir := filepath.Join(snapshotDir, ctx.DeviceConfig().DeviceArch())
includeDir := filepath.Join(snapshotArchDir, "include")
@@ -722,7 +944,7 @@
// Common properties among snapshots.
prop.ModuleName = ctx.ModuleName(m)
- if m.isVndkExt() {
+ if c.supportsVndkExt && m.isVndkExt() {
// vndk exts are installed to /vendor/lib(64)?/vndk(-sp)?
if m.isVndkSp() {
prop.RelativeInstallPath = "vndk-sp"
@@ -843,26 +1065,30 @@
}
moduleDir := ctx.ModuleDir(module)
- inVendorProprietaryPath := isVendorProprietaryPath(moduleDir)
+ inProprietaryPath := c.image.isProprietaryPath(moduleDir)
apexInfo := ctx.ModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo)
if m.ExcludeFromVendorSnapshot() {
- if inVendorProprietaryPath {
+ if inProprietaryPath {
// Error: exclude_from_vendor_snapshot applies
// to framework-path modules only.
ctx.Errorf("module %q in vendor proprietary path %q may not use \"exclude_from_vendor_snapshot: true\"", m.String(), moduleDir)
return
}
- if Bool(m.VendorProperties.Vendor_available) {
+ if Bool(c.image.available(m)) {
// Error: may not combine "vendor_available:
// true" with "exclude_from_vendor_snapshot:
// true".
- ctx.Errorf("module %q may not use both \"vendor_available: true\" and \"exclude_from_vendor_snapshot: true\"", m.String())
+ ctx.Errorf(
+ "module %q may not use both \""+
+ c.name+
+ "_available: true\" and \"exclude_from_vendor_snapshot: true\"",
+ m.String())
return
}
}
- if !isVendorSnapshotModule(m, inVendorProprietaryPath, apexInfo) {
+ if !isSnapshotModule(m, inProprietaryPath, apexInfo, c.image) {
return
}
@@ -894,11 +1120,17 @@
return snapshotOutputs[i].String() < snapshotOutputs[j].String()
})
- zipPath := android.PathForOutput(ctx, snapshotDir, "vendor-"+ctx.Config().DeviceName()+".zip")
+ zipPath := android.PathForOutput(
+ ctx,
+ snapshotDir,
+ c.name+"-"+ctx.Config().DeviceName()+".zip")
zipRule := android.NewRuleBuilder()
// filenames in rspfile from FlagWithRspFileInputList might be single-quoted. Remove it with tr
- snapshotOutputList := android.PathForOutput(ctx, snapshotDir, "vendor-"+ctx.Config().DeviceName()+"_list")
+ snapshotOutputList := android.PathForOutput(
+ ctx,
+ snapshotDir,
+ c.name+"-"+ctx.Config().DeviceName()+"_list")
zipRule.Command().
Text("tr").
FlagWithArg("-d ", "\\'").
@@ -913,13 +1145,15 @@
FlagWithArg("-C ", android.PathForOutput(ctx, snapshotDir).String()).
FlagWithInput("-l ", snapshotOutputList)
- zipRule.Build(pctx, ctx, zipPath.String(), "vendor snapshot "+zipPath.String())
+ zipRule.Build(pctx, ctx, zipPath.String(), c.name+" snapshot "+zipPath.String())
zipRule.DeleteTemporaryFiles()
- c.vendorSnapshotZipFile = android.OptionalPathForPath(zipPath)
+ c.snapshotZipFile = android.OptionalPathForPath(zipPath)
}
-func (c *vendorSnapshotSingleton) MakeVars(ctx android.MakeVarsContext) {
- ctx.Strict("SOONG_VENDOR_SNAPSHOT_ZIP", c.vendorSnapshotZipFile.String())
+func (c *snapshotSingleton) MakeVars(ctx android.MakeVarsContext) {
+ ctx.Strict(
+ c.makeVar,
+ c.snapshotZipFile.String())
}
type snapshotInterface interface {
@@ -927,9 +1161,9 @@
}
var _ snapshotInterface = (*vndkPrebuiltLibraryDecorator)(nil)
-var _ snapshotInterface = (*vendorSnapshotLibraryDecorator)(nil)
-var _ snapshotInterface = (*vendorSnapshotBinaryDecorator)(nil)
-var _ snapshotInterface = (*vendorSnapshotObjectLinker)(nil)
+var _ snapshotInterface = (*snapshotLibraryDecorator)(nil)
+var _ snapshotInterface = (*snapshotBinaryDecorator)(nil)
+var _ snapshotInterface = (*snapshotObjectLinker)(nil)
// gathers all snapshot modules for vendor, and disable unnecessary snapshots
// TODO(b/145966707): remove mutator and utilize android.Prebuilt to override source modules
@@ -970,9 +1204,9 @@
// header
snapshotMap = vendorSnapshotHeaderLibs(ctx.Config())
}
- } else if _, ok := module.linker.(*vendorSnapshotBinaryDecorator); ok {
+ } else if _, ok := module.linker.(*snapshotBinaryDecorator); ok {
snapshotMap = vendorSnapshotBinaries(ctx.Config())
- } else if _, ok := module.linker.(*vendorSnapshotObjectLinker); ok {
+ } else if _, ok := module.linker.(*snapshotObjectLinker); ok {
snapshotMap = vendorSnapshotObjects(ctx.Config())
} else {
return
diff --git a/dexpreopt/class_loader_context.go b/dexpreopt/class_loader_context.go
index 77d6ee9..b910a70 100644
--- a/dexpreopt/class_loader_context.go
+++ b/dexpreopt/class_loader_context.go
@@ -71,6 +71,10 @@
// Nested class loader subcontexts for dependencies.
Subcontexts []*ClassLoaderContext
+
+ // If the library is a shared library. This affects which elements of class loader context are
+ // added as <uses-library> tags by the manifest_fixer (dependencies of shared libraries aren't).
+ IsSharedLibrary bool
}
// ClassLoaderContextMap is a map from SDK version to a class loader context.
@@ -81,7 +85,7 @@
// Add class loader context for the given library to the map entry for the given SDK version.
func (clcMap ClassLoaderContextMap) addContext(ctx android.ModuleInstallPathContext, sdkVer int, lib string,
- hostPath, installPath android.Path, strict bool, nestedClcMap ClassLoaderContextMap) error {
+ shared bool, hostPath, installPath android.Path, strict bool, nestedClcMap ClassLoaderContextMap) error {
// If missing dependencies are allowed, the build shouldn't fail when a <uses-library> is
// not found. However, this is likely to result is disabling dexpreopt, as it won't be
@@ -128,46 +132,46 @@
}
clcMap[sdkVer] = append(clcMap[sdkVer], &ClassLoaderContext{
- Name: lib,
- Host: hostPath,
- Device: devicePath,
- Subcontexts: subcontexts,
+ Name: lib,
+ Host: hostPath,
+ Device: devicePath,
+ Subcontexts: subcontexts,
+ IsSharedLibrary: shared,
})
return nil
}
// Wrapper around addContext that reports errors.
func (clcMap ClassLoaderContextMap) addContextOrReportError(ctx android.ModuleInstallPathContext, sdkVer int, lib string,
- hostPath, installPath android.Path, strict bool, nestedClcMap ClassLoaderContextMap) {
+ shared bool, hostPath, installPath android.Path, strict bool, nestedClcMap ClassLoaderContextMap) {
- err := clcMap.addContext(ctx, sdkVer, lib, hostPath, installPath, strict, nestedClcMap)
+ err := clcMap.addContext(ctx, sdkVer, lib, shared, hostPath, installPath, strict, nestedClcMap)
if err != nil {
ctx.ModuleErrorf(err.Error())
- android.ReportPathErrorf(ctx, err.Error())
}
}
// Add class loader context. Fail on unknown build/install paths.
func (clcMap ClassLoaderContextMap) AddContext(ctx android.ModuleInstallPathContext, lib string,
- hostPath, installPath android.Path) {
+ shared bool, hostPath, installPath android.Path) {
- clcMap.addContextOrReportError(ctx, AnySdkVersion, lib, hostPath, installPath, true, nil)
+ clcMap.addContextOrReportError(ctx, AnySdkVersion, lib, shared, hostPath, installPath, true, nil)
}
// Add class loader context if the library exists. Don't fail on unknown build/install paths.
func (clcMap ClassLoaderContextMap) MaybeAddContext(ctx android.ModuleInstallPathContext, lib *string,
- hostPath, installPath android.Path) {
+ shared bool, hostPath, installPath android.Path) {
if lib != nil {
- clcMap.addContextOrReportError(ctx, AnySdkVersion, *lib, hostPath, installPath, false, nil)
+ clcMap.addContextOrReportError(ctx, AnySdkVersion, *lib, shared, hostPath, installPath, false, nil)
}
}
// Add class loader context for the given SDK version. Fail on unknown build/install paths.
func (clcMap ClassLoaderContextMap) AddContextForSdk(ctx android.ModuleInstallPathContext, sdkVer int,
- lib string, hostPath, installPath android.Path, nestedClcMap ClassLoaderContextMap) {
+ lib string, shared bool, hostPath, installPath android.Path, nestedClcMap ClassLoaderContextMap) {
- clcMap.addContextOrReportError(ctx, sdkVer, lib, hostPath, installPath, true, nestedClcMap)
+ clcMap.addContextOrReportError(ctx, sdkVer, lib, shared, hostPath, installPath, true, nestedClcMap)
}
// Merge the other class loader context map into this one, do not override existing entries.
@@ -204,7 +208,9 @@
}
}
-// List of libraries in the unconditional class loader context, excluding dependencies of shared libraries.
+// List of libraries in the unconditional class loader context, excluding dependencies of shared
+// libraries. These libraries should be in the <uses-library> tags in the manifest. Some of them may
+// be present in the original manifest, others are added by the manifest_fixer.
func (clcMap ClassLoaderContextMap) UsesLibs() (ulibs []string) {
if clcMap != nil {
// compatibility libraries (those in conditional context) are not added to <uses-library> tags
@@ -217,7 +223,12 @@
func usesLibsRec(clcs []*ClassLoaderContext) (ulibs []string) {
for _, clc := range clcs {
ulibs = append(ulibs, clc.Name)
- ulibs = append(ulibs, usesLibsRec(clc.Subcontexts)...)
+ // <uses-library> tags in the manifest should not include dependencies of shared libraries,
+ // because PackageManager already tracks all such dependencies and automatically adds their
+ // class loader contexts as subcontext of the shared library.
+ if !clc.IsSharedLibrary {
+ ulibs = append(ulibs, usesLibsRec(clc.Subcontexts)...)
+ }
}
return ulibs
}
diff --git a/dexpreopt/class_loader_context_test.go b/dexpreopt/class_loader_context_test.go
index e0a75bf..abfca27 100644
--- a/dexpreopt/class_loader_context_test.go
+++ b/dexpreopt/class_loader_context_test.go
@@ -25,6 +25,11 @@
"android/soong/android"
)
+const (
+ shared = true // dependencies are not added to uses libs
+ nonshared = false // dependencies are added to uses libs
+)
+
func TestCLC(t *testing.T) {
// Construct class loader context with the following structure:
// .
@@ -50,36 +55,36 @@
m := make(ClassLoaderContextMap)
- m.AddContext(ctx, "a", buildPath(ctx, "a"), installPath(ctx, "a"))
- m.AddContext(ctx, "b", buildPath(ctx, "b"), installPath(ctx, "b"))
+ m.AddContext(ctx, "a", nonshared, buildPath(ctx, "a"), installPath(ctx, "a"))
+ m.AddContext(ctx, "b", shared, buildPath(ctx, "b"), installPath(ctx, "b"))
// "Maybe" variant in the good case: add as usual.
c := "c"
- m.MaybeAddContext(ctx, &c, buildPath(ctx, "c"), installPath(ctx, "c"))
+ m.MaybeAddContext(ctx, &c, nonshared, buildPath(ctx, "c"), installPath(ctx, "c"))
// "Maybe" variant in the bad case: don't add library with unknown name, keep going.
- m.MaybeAddContext(ctx, nil, nil, nil)
+ m.MaybeAddContext(ctx, nil, nonshared, nil, nil)
// Add some libraries with nested subcontexts.
m1 := make(ClassLoaderContextMap)
- m1.AddContext(ctx, "a1", buildPath(ctx, "a1"), installPath(ctx, "a1"))
- m1.AddContext(ctx, "b1", buildPath(ctx, "b1"), installPath(ctx, "b1"))
+ m1.AddContext(ctx, "a1", nonshared, buildPath(ctx, "a1"), installPath(ctx, "a1"))
+ m1.AddContext(ctx, "b1", shared, buildPath(ctx, "b1"), installPath(ctx, "b1"))
m2 := make(ClassLoaderContextMap)
- m2.AddContext(ctx, "a2", buildPath(ctx, "a2"), installPath(ctx, "a2"))
- m2.AddContext(ctx, "b2", buildPath(ctx, "b2"), installPath(ctx, "b2"))
- m2.AddContextForSdk(ctx, AnySdkVersion, "c2", buildPath(ctx, "c2"), installPath(ctx, "c2"), m1)
+ m2.AddContext(ctx, "a2", nonshared, buildPath(ctx, "a2"), installPath(ctx, "a2"))
+ m2.AddContext(ctx, "b2", shared, buildPath(ctx, "b2"), installPath(ctx, "b2"))
+ m2.AddContextForSdk(ctx, AnySdkVersion, "c2", shared, buildPath(ctx, "c2"), installPath(ctx, "c2"), m1)
m3 := make(ClassLoaderContextMap)
- m3.AddContext(ctx, "a3", buildPath(ctx, "a3"), installPath(ctx, "a3"))
- m3.AddContext(ctx, "b3", buildPath(ctx, "b3"), installPath(ctx, "b3"))
+ m3.AddContext(ctx, "a3", nonshared, buildPath(ctx, "a3"), installPath(ctx, "a3"))
+ m3.AddContext(ctx, "b3", shared, buildPath(ctx, "b3"), installPath(ctx, "b3"))
- m.AddContextForSdk(ctx, AnySdkVersion, "d", buildPath(ctx, "d"), installPath(ctx, "d"), m2)
+ m.AddContextForSdk(ctx, AnySdkVersion, "d", nonshared, buildPath(ctx, "d"), installPath(ctx, "d"), m2)
// When the same library is both in conditional and unconditional context, it should be removed
// from conditional context.
- m.AddContextForSdk(ctx, 42, "f", buildPath(ctx, "f"), installPath(ctx, "f"), nil)
- m.AddContextForSdk(ctx, AnySdkVersion, "f", buildPath(ctx, "f"), installPath(ctx, "f"), nil)
+ m.AddContextForSdk(ctx, 42, "f", nonshared, buildPath(ctx, "f"), installPath(ctx, "f"), nil)
+ m.AddContextForSdk(ctx, AnySdkVersion, "f", nonshared, buildPath(ctx, "f"), installPath(ctx, "f"), nil)
// Merge map with implicit root library that is among toplevel contexts => does nothing.
m.AddContextMap(m1, "c")
@@ -88,12 +93,12 @@
m.AddContextMap(m3, "m_g")
// Compatibility libraries with unknown install paths get default paths.
- m.AddContextForSdk(ctx, 29, AndroidHidlManager, buildPath(ctx, AndroidHidlManager), nil, nil)
- m.AddContextForSdk(ctx, 29, AndroidHidlBase, buildPath(ctx, AndroidHidlBase), nil, nil)
+ m.AddContextForSdk(ctx, 29, AndroidHidlManager, nonshared, buildPath(ctx, AndroidHidlManager), nil, nil)
+ m.AddContextForSdk(ctx, 29, AndroidHidlBase, nonshared, buildPath(ctx, AndroidHidlBase), nil, nil)
// Add "android.test.mock" to conditional CLC, observe that is gets removed because it is only
// needed as a compatibility library if "android.test.runner" is in CLC as well.
- m.AddContextForSdk(ctx, 30, AndroidTestMock, buildPath(ctx, AndroidTestMock), nil, nil)
+ m.AddContextForSdk(ctx, 30, AndroidTestMock, nonshared, buildPath(ctx, AndroidTestMock), nil, nil)
valid, validationError := validateClassLoaderContext(m)
@@ -153,7 +158,7 @@
// Test for libraries that are added by the manifest_fixer.
t.Run("uses libs", func(t *testing.T) {
- wantUsesLibs := []string{"a", "b", "c", "d", "a2", "b2", "c2", "a1", "b1", "f", "a3", "b3"}
+ wantUsesLibs := []string{"a", "b", "c", "d", "a2", "b2", "c2", "f", "a3", "b3"}
if !reflect.DeepEqual(wantUsesLibs, haveUsesLibs) {
t.Errorf("\nwant uses libs: %s\nhave uses libs: %s", wantUsesLibs, haveUsesLibs)
}
@@ -164,7 +169,7 @@
func TestCLCUnknownBuildPath(t *testing.T) {
ctx := testContext()
m := make(ClassLoaderContextMap)
- err := m.addContext(ctx, AnySdkVersion, "a", nil, nil, true, nil)
+ err := m.addContext(ctx, AnySdkVersion, "a", nonshared, nil, nil, true, nil)
checkError(t, err, "unknown build path to <uses-library> \"a\"")
}
@@ -172,7 +177,7 @@
func TestCLCUnknownInstallPath(t *testing.T) {
ctx := testContext()
m := make(ClassLoaderContextMap)
- err := m.addContext(ctx, AnySdkVersion, "a", buildPath(ctx, "a"), nil, true, nil)
+ err := m.addContext(ctx, AnySdkVersion, "a", nonshared, buildPath(ctx, "a"), nil, true, nil)
checkError(t, err, "unknown install path to <uses-library> \"a\"")
}
@@ -181,7 +186,7 @@
m := make(ClassLoaderContextMap)
a := "a"
- m.MaybeAddContext(ctx, &a, nil, nil)
+ m.MaybeAddContext(ctx, &a, nonshared, nil, nil)
// The library should be added to <uses-library> tags by the manifest_fixer.
t.Run("maybe add", func(t *testing.T) {
@@ -203,9 +208,9 @@
func TestCLCNestedConditional(t *testing.T) {
ctx := testContext()
m1 := make(ClassLoaderContextMap)
- m1.AddContextForSdk(ctx, 42, "a", buildPath(ctx, "a"), installPath(ctx, "a"), nil)
+ m1.AddContextForSdk(ctx, 42, "a", nonshared, buildPath(ctx, "a"), installPath(ctx, "a"), nil)
m := make(ClassLoaderContextMap)
- err := m.addContext(ctx, AnySdkVersion, "b", buildPath(ctx, "b"), installPath(ctx, "b"), true, m1)
+ err := m.addContext(ctx, AnySdkVersion, "b", nonshared, buildPath(ctx, "b"), installPath(ctx, "b"), true, m1)
checkError(t, err, "nested class loader context shouldn't have conditional part")
}
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 3067846..53b9dbe 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -31,10 +31,10 @@
)
func init() {
- RegisterGenruleBuildComponents(android.InitRegistrationContext)
+ registerGenruleBuildComponents(android.InitRegistrationContext)
}
-func RegisterGenruleBuildComponents(ctx android.RegistrationContext) {
+func registerGenruleBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("genrule_defaults", defaultsFactory)
ctx.RegisterModuleType("gensrcs", GenSrcsFactory)
diff --git a/genrule/genrule_test.go b/genrule/genrule_test.go
index c3c0b97..c19078f 100644
--- a/genrule/genrule_test.go
+++ b/genrule/genrule_test.go
@@ -57,7 +57,7 @@
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
ctx.RegisterModuleType("tool", toolFactory)
- RegisterGenruleBuildComponents(ctx)
+ registerGenruleBuildComponents(ctx)
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
ctx.Register()
diff --git a/java/aar.go b/java/aar.go
index 7c3840b..051715d 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -259,16 +259,16 @@
})
func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext sdkContext,
- sdkLibraries dexpreopt.ClassLoaderContextMap, extraLinkFlags ...string) {
+ classLoaderContexts dexpreopt.ClassLoaderContextMap, extraLinkFlags ...string) {
transitiveStaticLibs, transitiveStaticLibManifests, staticRRODirs, assetPackages, libDeps, libFlags :=
- aaptLibs(ctx, sdkContext, sdkLibraries)
+ aaptLibs(ctx, sdkContext, classLoaderContexts)
// App manifest file
manifestFile := proptools.StringDefault(a.aaptProperties.Manifest, "AndroidManifest.xml")
manifestSrcPath := android.PathForModuleSrc(ctx, manifestFile)
- manifestPath := manifestFixer(ctx, manifestSrcPath, sdkContext, sdkLibraries,
+ manifestPath := manifestFixer(ctx, manifestSrcPath, sdkContext, classLoaderContexts,
a.isLibrary, a.useEmbeddedNativeLibs, a.usesNonSdkApis, a.useEmbeddedDex, a.hasNoCode,
a.LoggingParent)
@@ -389,15 +389,15 @@
}
// aaptLibs collects libraries from dependencies and sdk_version and converts them into paths
-func aaptLibs(ctx android.ModuleContext, sdkContext sdkContext, sdkLibraries dexpreopt.ClassLoaderContextMap) (
+func aaptLibs(ctx android.ModuleContext, sdkContext sdkContext, classLoaderContexts dexpreopt.ClassLoaderContextMap) (
transitiveStaticLibs, transitiveStaticLibManifests android.Paths, staticRRODirs []rroDir, assets, deps android.Paths, flags []string) {
var sharedLibs android.Paths
- if sdkLibraries == nil {
+ if classLoaderContexts == nil {
// Not all callers need to compute class loader context, those who don't just pass nil.
// Create a temporary class loader context here (it will be computed, but not used).
- sdkLibraries = make(dexpreopt.ClassLoaderContextMap)
+ classLoaderContexts = make(dexpreopt.ClassLoaderContextMap)
}
sdkDep := decodeSdkDep(ctx, sdkContext)
@@ -426,7 +426,7 @@
// (including the java_sdk_library) itself then append any implicit sdk library
// names to the list of sdk libraries to be added to the manifest.
if component, ok := module.(SdkLibraryComponentDependency); ok {
- sdkLibraries.MaybeAddContext(ctx, component.OptionalImplicitSdkLibrary(),
+ classLoaderContexts.MaybeAddContext(ctx, component.OptionalImplicitSdkLibrary(), true,
component.DexJarBuildPath(), component.DexJarInstallPath())
}
@@ -439,7 +439,7 @@
transitiveStaticLibs = append(transitiveStaticLibs, aarDep.ExportedStaticPackages()...)
transitiveStaticLibs = append(transitiveStaticLibs, exportPackage)
transitiveStaticLibManifests = append(transitiveStaticLibManifests, aarDep.ExportedManifests()...)
- sdkLibraries.AddContextMap(aarDep.ExportedSdkLibs(), depName)
+ classLoaderContexts.AddContextMap(aarDep.ClassLoaderContexts(), depName)
if aarDep.ExportedAssets().Valid() {
assets = append(assets, aarDep.ExportedAssets().Path())
}
@@ -461,7 +461,7 @@
// Add nested dependencies after processing the direct dependency: if it is a <uses-library>,
// nested context is added as its subcontext, and should not be re-added at the top-level.
if dep, ok := module.(Dependency); ok {
- sdkLibraries.AddContextMap(dep.ExportedSdkLibs(), depName)
+ classLoaderContexts.AddContextMap(dep.ClassLoaderContexts(), depName)
}
})
@@ -514,8 +514,8 @@
func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.aapt.isLibrary = true
- a.exportedSdkLibs = make(dexpreopt.ClassLoaderContextMap)
- a.aapt.buildActions(ctx, sdkContext(a), a.exportedSdkLibs)
+ a.classLoaderContexts = make(dexpreopt.ClassLoaderContextMap)
+ a.aapt.buildActions(ctx, sdkContext(a), a.classLoaderContexts)
a.hideApexVariantFromMake = !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform()
@@ -832,7 +832,7 @@
return nil
}
-func (a *AARImport) ExportedSdkLibs() dexpreopt.ClassLoaderContextMap {
+func (a *AARImport) ClassLoaderContexts() dexpreopt.ClassLoaderContextMap {
return nil
}
diff --git a/java/android_manifest.go b/java/android_manifest.go
index 6b39c35..c76bb2f 100644
--- a/java/android_manifest.go
+++ b/java/android_manifest.go
@@ -44,7 +44,7 @@
// Uses manifest_fixer.py to inject minSdkVersion, etc. into an AndroidManifest.xml
func manifestFixer(ctx android.ModuleContext, manifest android.Path, sdkContext sdkContext,
- sdkLibraries dexpreopt.ClassLoaderContextMap, isLibrary, useEmbeddedNativeLibs, usesNonSdkApis,
+ classLoaderContexts dexpreopt.ClassLoaderContextMap, isLibrary, useEmbeddedNativeLibs, usesNonSdkApis,
useEmbeddedDex, hasNoCode bool, loggingParent string) android.Path {
var args []string
@@ -71,7 +71,7 @@
args = append(args, "--use-embedded-dex")
}
- for _, usesLib := range sdkLibraries.UsesLibs() {
+ for _, usesLib := range classLoaderContexts.UsesLibs() {
if inList(usesLib, dexpreopt.OptionalCompatUsesLibs) {
args = append(args, "--optional-uses-library", usesLib)
} else {
diff --git a/java/androidmk.go b/java/androidmk.go
index c606245..386a97f 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -115,7 +115,7 @@
entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile)
}
- entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", library.exportedSdkLibs.UsesLibs()...)
+ entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", library.classLoaderContexts.UsesLibs()...)
if len(library.additionalCheckedModules) != 0 {
entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", library.additionalCheckedModules.Strings()...)
@@ -160,6 +160,9 @@
entries.SetString("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", "true")
}
entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", j.testProperties.Test_mainline_modules...)
+ if Bool(j.testProperties.Test_options.Unit_test) {
+ entries.SetBool("LOCAL_IS_UNIT_TEST", true)
+ }
})
return entriesList
diff --git a/java/app.go b/java/app.go
index 9ff413c..17de8b9 100755
--- a/java/app.go
+++ b/java/app.go
@@ -566,7 +566,7 @@
a.aapt.splitNames = a.appProperties.Package_splits
a.aapt.LoggingParent = String(a.overridableAppProperties.Logging_parent)
- a.aapt.buildActions(ctx, sdkContext(a), a.exportedSdkLibs, aaptLinkFlags...)
+ a.aapt.buildActions(ctx, sdkContext(a), a.classLoaderContexts, aaptLinkFlags...)
// apps manifests are handled by aapt, don't let Module see them
a.properties.Manifest = nil
@@ -608,7 +608,7 @@
}
a.dexpreopter.uncompressedDex = *a.dexProperties.Uncompress_dex
a.dexpreopter.enforceUsesLibs = a.usesLibrary.enforceUsesLibraries()
- a.dexpreopter.classLoaderContexts = a.exportedSdkLibs
+ a.dexpreopter.classLoaderContexts = a.classLoaderContexts
a.dexpreopter.manifestFile = a.mergedManifestFile
if ctx.ModuleName() != "framework-res" {
@@ -779,7 +779,7 @@
a.aapt.noticeFile = a.noticeOutputs.HtmlGzOutput
}
- a.exportedSdkLibs = a.usesLibrary.classLoaderContextForUsesLibDeps(ctx)
+ a.classLoaderContexts = a.usesLibrary.classLoaderContextForUsesLibDeps(ctx)
// Process all building blocks, from AAPT to certificates.
a.aaptBuildActions(ctx)
@@ -788,7 +788,7 @@
a.usesLibrary.freezeEnforceUsesLibraries()
// Add implicit SDK libraries to <uses-library> list.
- for _, usesLib := range a.exportedSdkLibs.UsesLibs() {
+ for _, usesLib := range a.classLoaderContexts.UsesLibs() {
a.usesLibrary.addLib(usesLib, inList(usesLib, dexpreopt.OptionalCompatUsesLibs))
}
@@ -1981,8 +1981,8 @@
if tag, ok := ctx.OtherModuleDependencyTag(m).(usesLibraryDependencyTag); ok {
dep := ctx.OtherModuleName(m)
if lib, ok := m.(Dependency); ok {
- clcMap.AddContextForSdk(ctx, tag.sdkVersion, dep,
- lib.DexJarBuildPath(), lib.DexJarInstallPath(), lib.ExportedSdkLibs())
+ clcMap.AddContextForSdk(ctx, tag.sdkVersion, dep, isSharedSdkLibrary(m),
+ lib.DexJarBuildPath(), lib.DexJarInstallPath(), lib.ClassLoaderContexts())
} else if ctx.Config().AllowMissingDependencies() {
ctx.AddMissingDependencies([]string{dep})
} else {
@@ -1995,6 +1995,11 @@
return clcMap
}
+func isSharedSdkLibrary(m android.Module) bool {
+ lib, ok := m.(SdkLibraryDependency)
+ return ok && lib.IsSharedLibrary()
+}
+
// enforceUsesLibraries returns true of <uses-library> tags should be checked against uses_libs and optional_uses_libs
// properties. Defaults to true if either of uses_libs or optional_uses_libs is specified. Will default to true
// unconditionally in the future.
diff --git a/java/device_host_converter.go b/java/device_host_converter.go
index d8b617e..cd395b1 100644
--- a/java/device_host_converter.go
+++ b/java/device_host_converter.go
@@ -163,7 +163,7 @@
return nil
}
-func (d *DeviceHostConverter) ExportedSdkLibs() dexpreopt.ClassLoaderContextMap {
+func (d *DeviceHostConverter) ClassLoaderContexts() dexpreopt.ClassLoaderContextMap {
return nil
}
diff --git a/java/java.go b/java/java.go
index d049685..a23c649 100644
--- a/java/java.go
+++ b/java/java.go
@@ -417,7 +417,7 @@
overrideManifest android.OptionalPath
// map of SDK version to class loader context
- exportedSdkLibs dexpreopt.ClassLoaderContextMap
+ classLoaderContexts dexpreopt.ClassLoaderContextMap
// list of plugins that this java module is exporting
exportedPluginJars android.Paths
@@ -509,7 +509,7 @@
ImplementationJars() android.Paths
ResourceJars() android.Paths
AidlIncludeDirs() android.Paths
- ExportedSdkLibs() dexpreopt.ClassLoaderContextMap
+ ClassLoaderContexts() dexpreopt.ClassLoaderContextMap
ExportedPlugins() (android.Paths, []string)
SrcJarArgs() ([]string, android.Paths)
BaseModuleName() string
@@ -547,14 +547,6 @@
name string
}
-// installDependencyTag is a dependency tag that is annotated to cause the installed files of the
-// dependency to be installed when the parent module is installed.
-type installDependencyTag struct {
- blueprint.BaseDependencyTag
- android.InstallAlwaysNeededDependencyTag
- name string
-}
-
type usesLibraryDependencyTag struct {
dependencyTag
sdkVersion int // SDK version in which the library appared as a standalone library.
@@ -588,8 +580,6 @@
instrumentationForTag = dependencyTag{name: "instrumentation_for"}
extraLintCheckTag = dependencyTag{name: "extra-lint-check"}
jniLibTag = dependencyTag{name: "jnilib"}
- jniInstallTag = installDependencyTag{name: "jni install"}
- binaryInstallTag = installDependencyTag{name: "binary install"}
usesLibTag = makeUsesLibraryDependencyTag(dexpreopt.AnySdkVersion)
usesLibCompat28Tag = makeUsesLibraryDependencyTag(28)
usesLibCompat29Tag = makeUsesLibraryDependencyTag(29)
@@ -1037,7 +1027,7 @@
case libTag:
deps.classpath = append(deps.classpath, dep.SdkHeaderJars(ctx, j.sdkVersion())...)
// names of sdk libs that are directly depended are exported
- j.exportedSdkLibs.MaybeAddContext(ctx, dep.OptionalImplicitSdkLibrary(),
+ j.classLoaderContexts.MaybeAddContext(ctx, dep.OptionalImplicitSdkLibrary(), true,
dep.DexJarBuildPath(), dep.DexJarInstallPath())
case staticLibTag:
ctx.ModuleErrorf("dependency on java_sdk_library %q can only be in libs", otherName)
@@ -1049,7 +1039,7 @@
case libTag, instrumentationForTag:
deps.classpath = append(deps.classpath, dep.HeaderJars()...)
// sdk lib names from dependencies are re-exported
- j.exportedSdkLibs.AddContextMap(dep.ExportedSdkLibs(), otherName)
+ j.classLoaderContexts.AddContextMap(dep.ClassLoaderContexts(), otherName)
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
pluginJars, pluginClasses := dep.ExportedPlugins()
addPlugins(&deps, pluginJars, pluginClasses...)
@@ -1061,7 +1051,7 @@
deps.staticHeaderJars = append(deps.staticHeaderJars, dep.HeaderJars()...)
deps.staticResourceJars = append(deps.staticResourceJars, dep.ResourceJars()...)
// sdk lib names from dependencies are re-exported
- j.exportedSdkLibs.AddContextMap(dep.ExportedSdkLibs(), otherName)
+ j.classLoaderContexts.AddContextMap(dep.ClassLoaderContexts(), otherName)
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
pluginJars, pluginClasses := dep.ExportedPlugins()
addPlugins(&deps, pluginJars, pluginClasses...)
@@ -1913,8 +1903,8 @@
return j.exportAidlIncludeDirs
}
-func (j *Module) ExportedSdkLibs() dexpreopt.ClassLoaderContextMap {
- return j.exportedSdkLibs
+func (j *Module) ClassLoaderContexts() dexpreopt.ClassLoaderContextMap {
+ return j.classLoaderContexts
}
func (j *Module) ExportedPlugins() (android.Paths, []string) {
@@ -2052,7 +2042,7 @@
j.dexProperties.Uncompress_dex = proptools.BoolPtr(shouldUncompressDex(ctx, &j.dexpreopter))
}
j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex
- j.exportedSdkLibs = make(dexpreopt.ClassLoaderContextMap)
+ j.classLoaderContexts = make(dexpreopt.ClassLoaderContextMap)
j.compile(ctx, nil)
// Collect the module directory for IDE info in java/jdeps.go.
@@ -2072,12 +2062,12 @@
// add the name of that java_sdk_library to the exported sdk libs to make sure
// that, if necessary, a <uses-library> element for that java_sdk_library is
// added to the Android manifest.
- j.exportedSdkLibs.MaybeAddContext(ctx, j.OptionalImplicitSdkLibrary(),
+ j.classLoaderContexts.MaybeAddContext(ctx, j.OptionalImplicitSdkLibrary(), true,
j.DexJarBuildPath(), j.DexJarInstallPath())
// A non-SDK library may provide a <uses-library> (the name may be different from the module name).
if lib := proptools.String(j.usesLibraryProperties.Provides_uses_lib); lib != "" {
- j.exportedSdkLibs.AddContext(ctx, lib, j.DexJarBuildPath(), j.DexJarInstallPath())
+ j.classLoaderContexts.AddContext(ctx, lib, true, j.DexJarBuildPath(), j.DexJarInstallPath())
}
j.distFiles = j.GenerateTaggedDistFiles(ctx)
@@ -2236,6 +2226,9 @@
type TestOptions struct {
// a list of extra test configuration files that should be installed with the module.
Extra_test_configs []string `android:"path,arch_variant"`
+
+ // If the test is a hostside(no device required) unittest that shall be run during presubmit check.
+ Unit_test *bool
}
type testProperties struct {
@@ -2560,12 +2553,9 @@
if ctx.Arch().ArchType == android.Common {
j.deps(ctx)
} else {
- // These dependencies ensure the host installation rules will install the jar file and
- // the jni libraries when the wrapper is installed.
- ctx.AddVariationDependencies(nil, jniInstallTag, j.binaryProperties.Jni_libs...)
- ctx.AddVariationDependencies(
- []blueprint.Variation{{Mutator: "arch", Variation: android.CommonArch.String()}},
- binaryInstallTag, ctx.ModuleName())
+ // This dependency ensures the host installation rules will install the jni libraries
+ // when the wrapper is installed.
+ ctx.AddVariationDependencies(nil, jniLibTag, j.binaryProperties.Jni_libs...)
}
}
@@ -2659,7 +2649,7 @@
dexJarFile android.Path
combinedClasspathFile android.Path
- exportedSdkLibs dexpreopt.ClassLoaderContextMap
+ classLoaderContexts dexpreopt.ClassLoaderContextMap
exportAidlIncludeDirs android.Paths
hideApexVariantFromMake bool
@@ -2734,7 +2724,7 @@
TransformJetifier(ctx, outputFile, inputFile)
}
j.combinedClasspathFile = outputFile
- j.exportedSdkLibs = make(dexpreopt.ClassLoaderContextMap)
+ j.classLoaderContexts = make(dexpreopt.ClassLoaderContextMap)
var flags javaBuilderFlags
@@ -2748,7 +2738,7 @@
case libTag, staticLibTag:
flags.classpath = append(flags.classpath, dep.HeaderJars()...)
// sdk lib names from dependencies are re-exported
- j.exportedSdkLibs.AddContextMap(dep.ExportedSdkLibs(), otherName)
+ j.classLoaderContexts.AddContextMap(dep.ClassLoaderContexts(), otherName)
case bootClasspathTag:
flags.bootClasspath = append(flags.bootClasspath, dep.HeaderJars()...)
}
@@ -2757,7 +2747,7 @@
case libTag:
flags.classpath = append(flags.classpath, dep.SdkHeaderJars(ctx, j.sdkVersion())...)
// names of sdk libs that are directly depended are exported
- j.exportedSdkLibs.AddContext(ctx, otherName,
+ j.classLoaderContexts.AddContext(ctx, otherName, dep.IsSharedLibrary(),
dep.DexJarBuildPath(), dep.DexJarInstallPath())
}
}
@@ -2773,7 +2763,7 @@
// add the name of that java_sdk_library to the exported sdk libs to make sure
// that, if necessary, a <uses-library> element for that java_sdk_library is
// added to the Android manifest.
- j.exportedSdkLibs.MaybeAddContext(ctx, j.OptionalImplicitSdkLibrary(),
+ j.classLoaderContexts.MaybeAddContext(ctx, j.OptionalImplicitSdkLibrary(), true,
outputFile, installFile)
j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.properties.Aidl.Export_include_dirs)
@@ -2856,8 +2846,8 @@
return j.exportAidlIncludeDirs
}
-func (j *Import) ExportedSdkLibs() dexpreopt.ClassLoaderContextMap {
- return j.exportedSdkLibs
+func (j *Import) ClassLoaderContexts() dexpreopt.ClassLoaderContextMap {
+ return j.classLoaderContexts
}
func (j *Import) ExportedPlugins() (android.Paths, []string) {
diff --git a/java/java_test.go b/java/java_test.go
index 7f51982..87d6ebb 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -29,6 +29,7 @@
"android/soong/android"
"android/soong/cc"
"android/soong/dexpreopt"
+ "android/soong/genrule"
"android/soong/python"
)
@@ -79,6 +80,7 @@
RegisterSystemModulesBuildComponents(ctx)
ctx.RegisterModuleType("java_plugin", PluginFactory)
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
+ ctx.RegisterModuleType("genrule", genrule.GenRuleFactory)
ctx.RegisterModuleType("python_binary_host", python.PythonBinaryHostFactory)
RegisterDocsBuildComponents(ctx)
RegisterStubsBuildComponents(ctx)
@@ -1591,7 +1593,7 @@
// test if baz has exported SDK lib names foo and bar to qux
qux := ctx.ModuleForTests("qux", "android_common")
if quxLib, ok := qux.Module().(*Library); ok {
- sdkLibs := quxLib.ExportedSdkLibs().UsesLibs()
+ sdkLibs := quxLib.ClassLoaderContexts().UsesLibs()
if w := []string{"foo", "bar", "fred", "quuz"}; !reflect.DeepEqual(w, sdkLibs) {
t.Errorf("qux should export %q but exports %q", w, sdkLibs)
}
diff --git a/java/robolectric.go b/java/robolectric.go
index 04fc117..62d1d99 100644
--- a/java/robolectric.go
+++ b/java/robolectric.go
@@ -389,8 +389,10 @@
}
runtimeFromSourceJar := android.OutputFileForModule(ctx, runtimeFromSourceModule, "")
+ // TODO(murj) Update this to ctx.Config().PlatformSdkCodename() once the platform
+ // classes like android.os.Build are updated to S.
runtimeName := fmt.Sprintf("android-all-%s-robolectric-r0.jar",
- ctx.Config().PlatformSdkCodename())
+ "R")
installedRuntime := ctx.InstallFile(androidAllDir, runtimeName, runtimeFromSourceJar)
r.runtimes = append(r.runtimes, installedRuntime)
}
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 21c03cd..13cd5f9 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -673,6 +673,11 @@
return c.namingScheme.apiModuleName(apiScope, c.moduleBase.BaseModuleName())
}
+// If the SDK library is a shared library.
+func (c *commonToSdkLibraryAndImport) IsSharedLibrary() bool {
+ return c.sharedLibrary()
+}
+
// The component names for different outputs of the java_sdk_library.
//
// They are similar to the names used for the child modules it creates
@@ -918,6 +923,9 @@
// jars for the stubs. The latter should only be needed when generating JavaDoc as otherwise
// they are identical to the corresponding header jars.
SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion sdkSpec) android.Paths
+
+ // If the SDK library is a shared library.
+ IsSharedLibrary() bool
}
type SdkLibrary struct {
diff --git a/python/androidmk.go b/python/androidmk.go
index 8ad5889..040b6be 100644
--- a/python/androidmk.go
+++ b/python/androidmk.go
@@ -80,6 +80,10 @@
fmt.Fprintln(w, "LOCAL_TEST_DATA :=",
strings.Join(android.AndroidMkDataPaths(p.data), " "))
}
+
+ if Bool(p.testProperties.Test_options.Unit_test) {
+ fmt.Fprintln(w, "LOCAL_IS_UNIT_TEST := true")
+ }
})
base.subAndroidMk(ret, p.binaryDecorator.pythonInstaller)
}
diff --git a/python/test.go b/python/test.go
index 434e71a..f9baa46 100644
--- a/python/test.go
+++ b/python/test.go
@@ -26,6 +26,12 @@
android.RegisterModuleType("python_test", PythonTestFactory)
}
+// Test option struct.
+type TestOptions struct {
+ // If the test is a hostside(no device required) unittest that shall be run during presubmit check.
+ Unit_test *bool
+}
+
type TestProperties struct {
// the name of the test configuration (for example "AndroidTest.xml") that should be
// installed with the module.
@@ -38,6 +44,9 @@
// list of files or filegroup modules that provide data that should be installed alongside
// the test
Data []string `android:"path,arch_variant"`
+
+ // Test options.
+ Test_options TestOptions
}
type testDecorator struct {
diff --git a/rust/androidmk.go b/rust/androidmk.go
index 29e4bd7..f98360a 100644
--- a/rust/androidmk.go
+++ b/rust/androidmk.go
@@ -116,6 +116,9 @@
if !BoolDefault(test.Properties.Auto_gen_config, true) {
fmt.Fprintln(w, "LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG := true")
}
+ if Bool(test.Properties.Test_options.Unit_test) {
+ fmt.Fprintln(w, "LOCAL_IS_UNIT_TEST := true")
+ }
})
// TODO(chh): add test data with androidMkWriteTestData(test.data, ctx, ret)
}
diff --git a/rust/builder.go b/rust/builder.go
index a09b1d1..6079e30 100644
--- a/rust/builder.go
+++ b/rust/builder.go
@@ -200,7 +200,9 @@
profileEmitArg := strings.TrimPrefix(cc.PwdPrefix(), "PWD=") + "/"
if outputFile.Ext() != "" {
- gcnoFile = android.PathForModuleOut(ctx, pathtools.ReplaceExtension(outputFile.Base(), "gcno"))
+ // rustc seems to split the output filename at the first '.' when determining the gcno filename
+ // so we need to do the same here.
+ gcnoFile = android.PathForModuleOut(ctx, strings.Split(outputFile.Base(), ".")[0]+".gcno")
rustcFlags = append(rustcFlags, "-Z profile-emit="+profileEmitArg+android.PathForModuleOut(
ctx, pathtools.ReplaceExtension(outputFile.Base(), "gcda")).String())
} else {
diff --git a/rust/coverage_test.go b/rust/coverage_test.go
index 90155ca..e7f873e 100644
--- a/rust/coverage_test.go
+++ b/rust/coverage_test.go
@@ -160,7 +160,7 @@
t.Fatalf("missing expected coverage files for rust 'fizz' binary: %#v", fizzZipInputs)
}
if !android.SuffixInList(libfooZipInputs, "android_arm64_armv8-a_rlib_dylib-std_cov/librlib.gcno") ||
- !android.SuffixInList(libfooZipInputs, "android_arm64_armv8-a_dylib_cov/libfoo.dylib.gcno") {
+ !android.SuffixInList(libfooZipInputs, "android_arm64_armv8-a_dylib_cov/libfoo.gcno") {
t.Fatalf("missing expected coverage files for rust 'fizz' binary: %#v", libfooZipInputs)
}
if !android.SuffixInList(buzzZipInputs, "android_arm64_armv8-a_cov/obj/foo.gcno") ||
diff --git a/rust/rust_test.go b/rust/rust_test.go
index 187f0b6..14bbd0b 100644
--- a/rust/rust_test.go
+++ b/rust/rust_test.go
@@ -286,12 +286,6 @@
srcs: ["src/any.h"],
out: ["src/any.rs"],
}
- rust_binary_host {
- name: "any_rust_binary",
- srcs: [
- "foo.rs",
- ],
- }
rust_bindgen {
name: "libbindings",
crate_name: "bindings",
diff --git a/rust/test.go b/rust/test.go
index bc7f53c..408e03a 100644
--- a/rust/test.go
+++ b/rust/test.go
@@ -19,6 +19,12 @@
"android/soong/tradefed"
)
+// Test option struct.
+type TestOptions struct {
+ // If the test is a hostside(no device required) unittest that shall be run during presubmit check.
+ Unit_test *bool
+}
+
type TestProperties struct {
// Disables the creation of a test-specific directory when used with
// relative_install_path. Useful if several tests need to be in the same
@@ -44,6 +50,9 @@
// if set, build with the standard Rust test harness. Defaults to true.
Test_harness *bool
+
+ // Test options.
+ Test_options TestOptions
}
// A test module is a binary module with extra --test compiler flag
diff --git a/rust/testing.go b/rust/testing.go
index 001f322..66877a9 100644
--- a/rust/testing.go
+++ b/rust/testing.go
@@ -17,6 +17,7 @@
import (
"android/soong/android"
"android/soong/cc"
+ "android/soong/genrule"
)
func GatherRequiredDepsForTest() string {
@@ -131,6 +132,7 @@
android.RegisterPrebuiltMutators(ctx)
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
cc.RegisterRequiredBuildComponentsForTest(ctx)
+ ctx.RegisterModuleType("genrule", genrule.GenRuleFactory)
ctx.RegisterModuleType("rust_binary", RustBinaryFactory)
ctx.RegisterModuleType("rust_binary_host", RustBinaryHostFactory)
ctx.RegisterModuleType("rust_bindgen", RustBindgenFactory)
diff --git a/scripts/check_boot_jars/check_boot_jars.py b/scripts/check_boot_jars/check_boot_jars.py
index 63fc9a9..c271211 100755
--- a/scripts/check_boot_jars/check_boot_jars.py
+++ b/scripts/check_boot_jars/check_boot_jars.py
@@ -10,6 +10,7 @@
import re
import subprocess
import sys
+import xml.etree.ElementTree
# The compiled allow list RE.
@@ -38,46 +39,40 @@
return False
return True
-# Pattern that matches the class descriptor in a "Class descriptor" line output
-# by dexdump and extracts the class name - with / instead of .
-CLASS_DESCRIPTOR_RE = re.compile("'L([^;]+);'")
-
def CheckDexJar(dexdump_path, allow_list_path, jar):
"""Check a dex jar file.
"""
- # Get the class descriptor lines in the dexdump output. This filters out lines
- # that do not contain class descriptors to reduce the size of the data read by
- # this script.
- p = subprocess.Popen(args='%s %s | grep "Class descriptor "' % (dexdump_path, jar),
+ # Use dexdump to generate the XML representation of the dex jar file.
+ p = subprocess.Popen(args='%s -l xml %s' % (dexdump_path, jar),
stdout=subprocess.PIPE, shell=True)
stdout, _ = p.communicate()
if p.returncode != 0:
return False
- # Split the output into lines
- lines = stdout.split('\n')
- classes = 0
- for line in lines:
- # The last line will be empty
- if line == '':
- continue
- # Try and find the descriptor on the line. Fail immediately if it cannot be found
- # as the dexdump output has probably changed.
- found = CLASS_DESCRIPTOR_RE.search(line)
- if not found:
- print >> sys.stderr, ('Could not find class descriptor in line `%s`' % line)
- return False
- # Extract the class name (using / instead of .) from the class descriptor line
- f = found.group(1)
- classes += 1
- package_name = os.path.dirname(f)
- package_name = package_name.replace('/', '.')
+
+ packages = 0
+ try:
+ # TODO(b/172063475) - improve performance
+ root = xml.etree.ElementTree.fromstring(stdout)
+ except xml.etree.ElementTree.ParseError as e:
+ print >> sys.stderr, 'Error processing jar %s - %s' % (jar, e)
+ print >> sys.stderr, stdout
+ return False
+ for package_elt in root.iterfind('package'):
+ packages += 1
+ package_name = package_elt.get('name')
if not package_name or not allow_list_re.match(package_name):
+ # Report the name of a class in the package as it is easier to navigate to
+ # the source of a concrete class than to a package which is often required
+ # to investigate this failure.
+ class_name = package_elt[0].get('name')
+ if package_name != "":
+ class_name = package_name + "." + class_name
print >> sys.stderr, ('Error: %s contains class file %s, whose package name "%s" is empty or'
' not in the allow list %s of packages allowed on the bootclasspath.'
- % (jar, f, package_name, allow_list_path))
+ % (jar, class_name, package_name, allow_list_path))
return False
- if classes == 0:
- print >> sys.stderr, ('Error: %s does not contain any class files.' % jar)
+ if packages == 0:
+ print >> sys.stderr, ('Error: %s does not contain any packages.' % jar)
return False
return True
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go
index 84e4f28..b1eebe9 100644
--- a/sdk/cc_sdk_test.go
+++ b/sdk/cc_sdk_test.go
@@ -109,6 +109,7 @@
name: "mysdk_sdkmember@current",
sdk_member_name: "sdkmember",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
host_supported: true,
installable: false,
stl: "none",
@@ -131,6 +132,7 @@
name: "sdkmember",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
host_supported: true,
stl: "none",
compile_multilib: "64",
@@ -353,6 +355,7 @@
name: "mysdk_crtobj@current",
sdk_member_name: "crtobj",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
stl: "none",
compile_multilib: "both",
sanitize: {
@@ -372,6 +375,7 @@
name: "crtobj",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
stl: "none",
compile_multilib: "both",
sanitize: {
@@ -480,6 +484,7 @@
name: "mysdk_mynativelib@current",
sdk_member_name: "mynativelib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
installable: false,
stl: "none",
compile_multilib: "both",
@@ -511,6 +516,7 @@
name: "mynativelib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
@@ -575,6 +581,7 @@
name: "mymodule_exports_mynativebinary@current",
sdk_member_name: "mynativebinary",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
installable: false,
compile_multilib: "both",
arch: {
@@ -591,6 +598,7 @@
name: "mynativebinary",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
compile_multilib: "both",
arch: {
arm64: {
@@ -654,6 +662,7 @@
name: "myexports_mynativebinary@current",
sdk_member_name: "mynativebinary",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
installable: false,
@@ -687,6 +696,7 @@
name: "mynativebinary",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
stl: "none",
@@ -802,6 +812,7 @@
name: "myexports_mynativebinary@current",
sdk_member_name: "mynativebinary",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
installable: false,
@@ -822,6 +833,7 @@
name: "mynativebinary",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
stl: "none",
@@ -841,6 +853,7 @@
name: "myexports_mynativelib@current",
sdk_member_name: "mynativelib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
installable: false,
@@ -861,6 +874,7 @@
name: "mynativelib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
stl: "none",
@@ -933,6 +947,7 @@
name: "mymodule_exports_linker@current",
sdk_member_name: "linker",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
installable: false,
@@ -959,6 +974,7 @@
name: "linker",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
stl: "none",
@@ -1167,6 +1183,7 @@
name: "mysdk_mynativelib@current",
sdk_member_name: "mynativelib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
installable: false,
stl: "none",
compile_multilib: "both",
@@ -1188,6 +1205,7 @@
name: "mynativelib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
stl: "none",
compile_multilib: "both",
shared_libs: [
@@ -1208,6 +1226,7 @@
name: "mysdk_myothernativelib@current",
sdk_member_name: "myothernativelib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
installable: false,
stl: "none",
compile_multilib: "both",
@@ -1226,6 +1245,7 @@
name: "myothernativelib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
stl: "none",
compile_multilib: "both",
system_shared_libs: ["libm"],
@@ -1243,6 +1263,7 @@
name: "mysdk_mysystemnativelib@current",
sdk_member_name: "mysystemnativelib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
installable: false,
stl: "none",
compile_multilib: "both",
@@ -1260,6 +1281,7 @@
name: "mysystemnativelib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
stl: "none",
compile_multilib: "both",
arch: {
@@ -1327,6 +1349,7 @@
name: "mysdk_mynativelib@current",
sdk_member_name: "mynativelib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
installable: false,
@@ -1355,6 +1378,7 @@
name: "mynativelib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
sdk_version: "minimum",
@@ -1449,6 +1473,7 @@
name: "mysdk_mynativelib@current",
sdk_member_name: "mynativelib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
installable: false,
@@ -1482,6 +1507,7 @@
name: "mynativelib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
stl: "none",
@@ -1572,6 +1598,7 @@
name: "myexports_mynativelib@current",
sdk_member_name: "mynativelib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
installable: false,
stl: "none",
compile_multilib: "both",
@@ -1592,6 +1619,7 @@
name: "mynativelib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
@@ -1660,6 +1688,7 @@
name: "myexports_mynativelib@current",
sdk_member_name: "mynativelib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
installable: false,
@@ -1687,6 +1716,7 @@
name: "mynativelib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
stl: "none",
@@ -1769,6 +1799,7 @@
name: "myexports_mynativelib@current",
sdk_member_name: "mynativelib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
installable: false,
recovery_available: true,
vendor_available: true,
@@ -1799,6 +1830,7 @@
name: "mynativelib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
recovery_available: true,
vendor_available: true,
stl: "none",
@@ -1877,6 +1909,7 @@
name: "myexports_mynativelib@current",
sdk_member_name: "mynativelib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
installable: false,
@@ -1899,6 +1932,7 @@
name: "mynativelib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
stl: "none",
@@ -1964,6 +1998,7 @@
name: "mysdk_mynativeheaders@current",
sdk_member_name: "mynativeheaders",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
@@ -1973,6 +2008,7 @@
name: "mynativeheaders",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/include"],
@@ -2016,6 +2052,7 @@
name: "mysdk_mynativeheaders@current",
sdk_member_name: "mynativeheaders",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
stl: "none",
@@ -2038,6 +2075,7 @@
name: "mynativeheaders",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
stl: "none",
@@ -2113,6 +2151,7 @@
name: "mysdk_mynativeheaders@current",
sdk_member_name: "mynativeheaders",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
host_supported: true,
stl: "none",
compile_multilib: "both",
@@ -2140,6 +2179,7 @@
name: "mynativeheaders",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
host_supported: true,
stl: "none",
compile_multilib: "both",
@@ -2220,6 +2260,7 @@
name: "mysdk_sslnil@current",
sdk_member_name: "sslnil",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
installable: false,
compile_multilib: "both",
arch: {
@@ -2236,6 +2277,7 @@
name: "sslnil",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
compile_multilib: "both",
arch: {
arm64: {
@@ -2251,6 +2293,7 @@
name: "mysdk_sslempty@current",
sdk_member_name: "sslempty",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
installable: false,
compile_multilib: "both",
system_shared_libs: [],
@@ -2268,6 +2311,7 @@
name: "sslempty",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
compile_multilib: "both",
system_shared_libs: [],
arch: {
@@ -2284,6 +2328,7 @@
name: "mysdk_sslnonempty@current",
sdk_member_name: "sslnonempty",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
installable: false,
compile_multilib: "both",
system_shared_libs: ["mysdk_sslnil@current"],
@@ -2301,6 +2346,7 @@
name: "sslnonempty",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
compile_multilib: "both",
system_shared_libs: ["sslnil"],
arch: {
@@ -2350,6 +2396,7 @@
name: "mysdk_sslvariants@current",
sdk_member_name: "sslvariants",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
host_supported: true,
installable: false,
compile_multilib: "both",
@@ -2381,6 +2428,7 @@
name: "sslvariants",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
host_supported: true,
compile_multilib: "both",
target: {
@@ -2456,6 +2504,7 @@
name: "mysdk_stubslib@current",
sdk_member_name: "stubslib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
installable: false,
compile_multilib: "both",
stubs: {
@@ -2479,6 +2528,7 @@
name: "stubslib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
compile_multilib: "both",
stubs: {
versions: [
@@ -2537,6 +2587,7 @@
name: "mysdk_stubslib@current",
sdk_member_name: "stubslib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
host_supported: true,
installable: false,
compile_multilib: "both",
@@ -2572,6 +2623,7 @@
name: "stubslib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
host_supported: true,
compile_multilib: "both",
stubs: {
@@ -2645,6 +2697,7 @@
name: "mysdk_mylib@current",
sdk_member_name: "mylib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
host_supported: true,
installable: false,
unique_host_soname: true,
@@ -2674,6 +2727,7 @@
name: "mylib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
host_supported: true,
unique_host_soname: true,
compile_multilib: "both",
@@ -2755,6 +2809,7 @@
name: "mysdk_mynativelib@current",
sdk_member_name: "mynativelib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
installable: false,
compile_multilib: "both",
export_include_dirs: ["include/include"],
@@ -2772,6 +2827,7 @@
name: "mynativelib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
compile_multilib: "both",
export_include_dirs: ["include/include"],
arch: {
diff --git a/sdk/exports_test.go b/sdk/exports_test.go
index aa1200f..1c59244 100644
--- a/sdk/exports_test.go
+++ b/sdk/exports_test.go
@@ -50,6 +50,7 @@
name: "myexports_myjavalib@current",
sdk_member_name: "myjavalib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
jars: ["java/myjavalib.jar"],
}
@@ -57,6 +58,7 @@
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
jars: ["java/myjavalib.jar"],
}
diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go
index 731e528..ec8ebb3 100644
--- a/sdk/java_sdk_test.go
+++ b/sdk/java_sdk_test.go
@@ -122,6 +122,7 @@
name: "mysdk_sdkmember@current",
sdk_member_name: "sdkmember",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
jars: ["java/sdkmember.jar"],
}
@@ -129,6 +130,7 @@
name: "sdkmember",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
jars: ["java/sdkmember.jar"],
}
@@ -247,6 +249,7 @@
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
jars: ["java/myjavalib.jar"],
}
@@ -254,6 +257,7 @@
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
jars: ["java/myjavalib.jar"],
}
@@ -302,6 +306,7 @@
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
jars: ["java/myjavalib.jar"],
@@ -311,6 +316,7 @@
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
jars: ["java/myjavalib.jar"],
@@ -357,6 +363,7 @@
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
host_supported: true,
target: {
android: {
@@ -372,6 +379,7 @@
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
host_supported: true,
target: {
android: {
@@ -426,6 +434,7 @@
name: "myexports_myjavalib@current",
sdk_member_name: "myjavalib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
jars: ["java/myjavalib.jar"],
}
@@ -433,6 +442,7 @@
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
jars: ["java/myjavalib.jar"],
}
@@ -481,6 +491,7 @@
name: "myexports_myjavalib@current",
sdk_member_name: "myjavalib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
jars: ["java/myjavalib.jar"],
@@ -490,6 +501,7 @@
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
jars: ["java/myjavalib.jar"],
@@ -535,6 +547,7 @@
name: "myexports_myjavatests@current",
sdk_member_name: "myjavatests",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
jars: ["java/myjavatests.jar"],
test_config: "java/myjavatests-AndroidTest.xml",
}
@@ -543,6 +556,7 @@
name: "myjavatests",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
jars: ["java/myjavatests.jar"],
test_config: "java/myjavatests-AndroidTest.xml",
}
@@ -588,6 +602,7 @@
name: "myexports_myjavatests@current",
sdk_member_name: "myjavatests",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
jars: ["java/myjavatests.jar"],
@@ -598,6 +613,7 @@
name: "myjavatests",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
jars: ["java/myjavatests.jar"],
@@ -655,6 +671,7 @@
name: "mysdk_exported-system-module@current",
sdk_member_name: "exported-system-module",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
jars: ["java/exported-system-module.jar"],
}
@@ -662,6 +679,7 @@
name: "exported-system-module",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
jars: ["java/exported-system-module.jar"],
}
@@ -669,6 +687,7 @@
name: "mysdk_system-module@current",
sdk_member_name: "system-module",
visibility: ["//visibility:private"],
+ apex_available: ["//apex_available:platform"],
jars: ["java/system-module.jar"],
}
@@ -676,6 +695,7 @@
name: "mysdk_system-module",
prefer: false,
visibility: ["//visibility:private"],
+ apex_available: ["//apex_available:platform"],
jars: ["java/system-module.jar"],
}
@@ -747,6 +767,7 @@
name: "mysdk_system-module@current",
sdk_member_name: "system-module",
visibility: ["//visibility:private"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
jars: ["java/system-module.jar"],
@@ -756,6 +777,7 @@
name: "mysdk_system-module",
prefer: false,
visibility: ["//visibility:private"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
jars: ["java/system-module.jar"],
@@ -836,6 +858,7 @@
name: "myexports_hostjavalib@current",
sdk_member_name: "hostjavalib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
jars: ["java/hostjavalib.jar"],
@@ -845,6 +868,7 @@
name: "hostjavalib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
device_supported: false,
host_supported: true,
jars: ["java/hostjavalib.jar"],
@@ -854,6 +878,7 @@
name: "myexports_androidjavalib@current",
sdk_member_name: "androidjavalib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
jars: ["java/androidjavalib.jar"],
}
@@ -861,6 +886,7 @@
name: "androidjavalib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
jars: ["java/androidjavalib.jar"],
}
@@ -868,6 +894,7 @@
name: "myexports_myjavalib@current",
sdk_member_name: "myjavalib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
host_supported: true,
target: {
android: {
@@ -883,6 +910,7 @@
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
host_supported: true,
target: {
android: {
@@ -1045,6 +1073,7 @@
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
shared_library: true,
public: {
jars: ["sdk_library/public/myjavalib-stubs.jar"],
@@ -1059,6 +1088,7 @@
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
shared_library: true,
public: {
jars: ["sdk_library/public/myjavalib-stubs.jar"],
@@ -1112,6 +1142,7 @@
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
shared_library: true,
public: {
jars: ["sdk_library/public/myjavalib-stubs.jar"],
@@ -1126,6 +1157,7 @@
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
shared_library: true,
public: {
jars: ["sdk_library/public/myjavalib-stubs.jar"],
@@ -1547,6 +1579,7 @@
name: "mysdk_myjavalib@current",
sdk_member_name: "myjavalib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
shared_library: true,
doctag_files: ["doctags/docs/known_doctags"],
public: {
@@ -1562,6 +1595,7 @@
name: "myjavalib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
shared_library: true,
doctag_files: ["doctags/docs/known_doctags"],
public: {
diff --git a/sdk/sdk_test.go b/sdk/sdk_test.go
index 2e6c62a..c4dc41b 100644
--- a/sdk/sdk_test.go
+++ b/sdk/sdk_test.go
@@ -181,6 +181,7 @@
"//package",
"//prebuilts/mysdk",
],
+ apex_available: ["//apex_available:platform"],
jars: ["java/myjavalib.jar"],
}
@@ -192,6 +193,7 @@
"//package",
"//prebuilts/mysdk",
],
+ apex_available: ["//apex_available:platform"],
jars: ["java/myjavalib.jar"],
}
@@ -199,6 +201,7 @@
name: "mysdk_mypublicjavalib@current",
sdk_member_name: "mypublicjavalib",
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
jars: ["java/mypublicjavalib.jar"],
}
@@ -206,6 +209,7 @@
name: "mypublicjavalib",
prefer: false,
visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
jars: ["java/mypublicjavalib.jar"],
}
@@ -217,6 +221,7 @@
"//package",
"//prebuilts/mysdk",
],
+ apex_available: ["//apex_available:platform"],
jars: ["java/mydefaultedjavalib.jar"],
}
@@ -228,6 +233,7 @@
"//package",
"//prebuilts/mysdk",
],
+ apex_available: ["//apex_available:platform"],
jars: ["java/mydefaultedjavalib.jar"],
}
@@ -238,6 +244,7 @@
"//package",
"//prebuilts/mysdk",
],
+ apex_available: ["//apex_available:platform"],
jars: ["java/myprivatejavalib.jar"],
}
@@ -248,6 +255,7 @@
"//package",
"//prebuilts/mysdk",
],
+ apex_available: ["//apex_available:platform"],
jars: ["java/myprivatejavalib.jar"],
}
diff --git a/sdk/update.go b/sdk/update.go
index 7bf5dea..ba63542 100644
--- a/sdk/update.go
+++ b/sdk/update.go
@@ -735,6 +735,24 @@
}
}
+ // Where available copy apex_available properties from the member.
+ if apexAware, ok := variant.(interface{ ApexAvailable() []string }); ok {
+ apexAvailable := apexAware.ApexAvailable()
+ if len(apexAvailable) == 0 {
+ // //apex_available:platform is the default.
+ apexAvailable = []string{android.AvailableToPlatform}
+ }
+
+ // Add in any baseline apex available settings.
+ apexAvailable = append(apexAvailable, apex.BaselineApexAvailable(member.Name())...)
+
+ // Remove duplicates and sort.
+ apexAvailable = android.FirstUniqueStrings(apexAvailable)
+ sort.Strings(apexAvailable)
+
+ m.AddProperty("apex_available", apexAvailable)
+ }
+
deviceSupported := false
hostSupported := false
@@ -749,22 +767,6 @@
addHostDeviceSupportedProperties(deviceSupported, hostSupported, m)
- // Where available copy apex_available properties from the member.
- if apexAware, ok := variant.(interface{ ApexAvailable() []string }); ok {
- apexAvailable := apexAware.ApexAvailable()
-
- // Add in any baseline apex available settings.
- apexAvailable = append(apexAvailable, apex.BaselineApexAvailable(member.Name())...)
-
- if len(apexAvailable) > 0 {
- // Remove duplicates and sort.
- apexAvailable = android.FirstUniqueStrings(apexAvailable)
- sort.Strings(apexAvailable)
-
- m.AddProperty("apex_available", apexAvailable)
- }
- }
-
// Disable installation in the versioned module of those modules that are ever installable.
if installable, ok := variant.(interface{ EverInstallable() bool }); ok {
if installable.EverInstallable() {
diff --git a/ui/build/bazel.go b/ui/build/bazel.go
index 7cc7caf..2d36f67 100644
--- a/ui/build/bazel.go
+++ b/ui/build/bazel.go
@@ -24,8 +24,8 @@
"android/soong/ui/metrics"
)
-// Main entry point to construct the Bazel build command line, environment variables
-// and post-processing steps (e.g. converge output directories)
+// Main entry point to construct the Bazel build command line, environment
+// variables and post-processing steps (e.g. converge output directories)
func runBazel(ctx Context, config Config) {
ctx.BeginTrace(metrics.RunBazel, "bazel")
defer ctx.EndTrace()
@@ -41,53 +41,86 @@
outputGroups = strings.Join(config.ninjaArgs, ",")
}
+ // Environment variables are the primary mechanism to pass information from
+ // soong_ui configuration or context to Bazel.
+ //
+ // Use *_NINJA variables to pass the root-relative path of the combined,
+ // kati-generated, soong-generated, and packaging Ninja files to Bazel.
+ // Bazel reads these from the lunch() repository rule.
config.environ.Set("COMBINED_NINJA", config.CombinedNinjaFile())
config.environ.Set("KATI_NINJA", config.KatiBuildNinjaFile())
config.environ.Set("PACKAGE_NINJA", config.KatiPackageNinjaFile())
config.environ.Set("SOONG_NINJA", config.SoongNinjaFile())
+ // `tools/bazel` is the default entry point for executing Bazel in the AOSP
+ // source tree.
bazelExecutable := filepath.Join("tools", "bazel")
cmd := Command(ctx, config, "bazel", bazelExecutable)
- if extra_startup_args, ok := cmd.Environment.Get("BAZEL_STARTUP_ARGS"); ok {
- cmd.Args = append(cmd.Args, strings.Fields(extra_startup_args)...)
+ // Append custom startup flags to the Bazel command. Startup flags affect
+ // the Bazel server itself, and any changes to these flags would incur a
+ // restart of the server, losing much of the in-memory incrementality.
+ if extraStartupArgs, ok := cmd.Environment.Get("BAZEL_STARTUP_ARGS"); ok {
+ cmd.Args = append(cmd.Args, strings.Fields(extraStartupArgs)...)
}
+ // Start constructing the `build` command.
actionName := "build"
cmd.Args = append(cmd.Args,
actionName,
+ // Use output_groups to select the set of outputs to produce from a
+ // ninja_build target.
"--output_groups="+outputGroups,
+ // Generate a performance profile
"--profile="+filepath.Join(shared.BazelMetricsFilename(config.OutDir(), actionName)),
"--slim_profile=true",
)
- if extra_build_args, ok := cmd.Environment.Get("BAZEL_BUILD_ARGS"); ok {
- cmd.Args = append(cmd.Args, strings.Fields(extra_build_args)...)
+ // Append custom build flags to the Bazel command. Changes to these flags
+ // may invalidate Bazel's analysis cache.
+ if extraBuildArgs, ok := cmd.Environment.Get("BAZEL_BUILD_ARGS"); ok {
+ cmd.Args = append(cmd.Args, strings.Fields(extraBuildArgs)...)
}
+ // Append the label of the default ninja_build target.
cmd.Args = append(cmd.Args,
"//:"+config.TargetProduct()+"-"+config.TargetBuildVariant(),
)
+ // Ensure that the PATH environment variable value used in the action
+ // environment is the restricted set computed from soong_ui, and not a
+ // user-provided one, for hermeticity reasons.
if pathEnvValue, ok := config.environ.Get("PATH"); ok {
cmd.Environment.Set("PATH", pathEnvValue)
cmd.Args = append(cmd.Args, "--action_env=PATH="+pathEnvValue)
}
+
cmd.Environment.Set("DIST_DIR", config.DistDir())
cmd.Environment.Set("SHELL", "/bin/bash")
+ // Print the full command line for debugging purposes.
ctx.Println(cmd.Cmd)
+
+ // Execute the command at the root of the directory.
cmd.Dir = filepath.Join(config.OutDir(), "..")
ctx.Status.Status("Starting Bazel..")
+
+ // Execute the build command.
cmd.RunAndStreamOrFatal()
+ // Post-processing steps start here. Once the Bazel build completes, the
+ // output files are still stored in the execution root, not in $OUT_DIR.
+ // Ensure that the $OUT_DIR contains the expected set of files by symlinking
+ // the files from the execution root's output direction into $OUT_DIR.
+
// Obtain the Bazel output directory for ninja_build.
infoCmd := Command(ctx, config, "bazel", bazelExecutable)
- if extra_startup_args, ok := infoCmd.Environment.Get("BAZEL_STARTUP_ARGS"); ok {
- infoCmd.Args = append(infoCmd.Args, strings.Fields(extra_startup_args)...)
+ if extraStartupArgs, ok := infoCmd.Environment.Get("BAZEL_STARTUP_ARGS"); ok {
+ infoCmd.Args = append(infoCmd.Args, strings.Fields(extraStartupArgs)...)
}
+ // Obtain the output directory path in the execution root.
infoCmd.Args = append(infoCmd.Args,
"info",
"output_path",