Merge "Allowlist libSurfaceFlingerProp which depends on cc_sysprop_library_static"
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index 7e0fbd2..e4760b5 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -223,6 +223,7 @@
"packages/modules/adb/proto": Bp2BuildDefaultTrueRecursively,
"packages/modules/adb/tls": Bp2BuildDefaultTrueRecursively,
"packages/providers/MediaProvider/tools/dialogs": Bp2BuildDefaultFalse, // TODO(b/242834374)
+ "packages/modules/NeuralNetworks/driver/cache": Bp2BuildDefaultTrueRecursively,
"packages/screensavers/Basic": Bp2BuildDefaultTrue,
"packages/services/Car/tests/SampleRearViewCamera": Bp2BuildDefaultFalse, // TODO(b/242834321)
@@ -410,6 +411,7 @@
"mediaswcodec.policy",
"mediaswcodec.xml",
"neuralnetworks_types",
+ "neuralnetworks_utils_hal_aidl",
"neuralnetworks_utils_hal_common",
"neuralnetworks_utils_hal_1_0",
"neuralnetworks_utils_hal_1_1",
diff --git a/bp2build/cc_library_static_conversion_test.go b/bp2build/cc_library_static_conversion_test.go
index 0637ba2..316fa3e 100644
--- a/bp2build/cc_library_static_conversion_test.go
+++ b/bp2build/cc_library_static_conversion_test.go
@@ -1392,6 +1392,16 @@
Description: "cc_library_static system_shared_lib empty for linux_bionic variant",
Blueprint: soongCcLibraryStaticPreamble +
simpleModuleDoNotConvertBp2build("cc_library", "libc") + `
+
+cc_library {
+ name: "libm",
+ stubs: {
+ symbol_file: "libm.map.txt",
+ versions: ["current"],
+ },
+ bazel_module: { bp2build_available: false },
+}
+
cc_library_static {
name: "used_in_bionic_oses",
target: {
@@ -1414,7 +1424,20 @@
cc_library_static {
name: "keep_for_empty_system_shared_libs",
shared_libs: ["libc"],
- system_shared_libs: [],
+ system_shared_libs: [],
+ include_build_directory: false,
+}
+
+cc_library_static {
+ name: "used_with_stubs",
+ shared_libs: ["libm"],
+ include_build_directory: false,
+}
+
+cc_library_static {
+ name: "keep_with_stubs",
+ shared_libs: ["libm"],
+ system_shared_libs: [],
include_build_directory: false,
}
`,
@@ -1424,7 +1447,15 @@
"implementation_dynamic_deps": `[":libc"]`,
"system_dynamic_deps": `[]`,
}),
+ MakeBazelTarget("cc_library_static", "keep_with_stubs", AttrNameToString{
+ "implementation_dynamic_deps": `select({
+ "//build/bazel/rules/apex:android-in_apex": [":libm_stub_libs_current"],
+ "//conditions:default": [":libm"],
+ })`,
+ "system_dynamic_deps": `[]`,
+ }),
MakeBazelTarget("cc_library_static", "used_in_bionic_oses", AttrNameToString{}),
+ MakeBazelTarget("cc_library_static", "used_with_stubs", AttrNameToString{}),
},
})
}
diff --git a/cc/Android.bp b/cc/Android.bp
index 1ead99b..2963c77 100644
--- a/cc/Android.bp
+++ b/cc/Android.bp
@@ -45,6 +45,7 @@
"snapshot_utils.go",
"stl.go",
"strip.go",
+ "sysprop.go",
"tidy.go",
"util.go",
"vendor_snapshot.go",
diff --git a/cc/bp2build.go b/cc/bp2build.go
index a2e0a31..e001d24 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -36,6 +36,8 @@
cppSrcPartition = "cpp"
protoSrcPartition = "proto"
aidlSrcPartition = "aidl"
+
+ stubsSuffix = "_stub_libs_current"
)
// staticOrSharedAttributes are the Bazel-ified versions of StaticOrSharedProperties --
@@ -935,7 +937,7 @@
stubLibLabels := []bazel.Label{}
for _, l := range depsWithStubs {
- l.Label = l.Label + "_stub_libs_current"
+ l.Label = l.Label + stubsSuffix
stubLibLabels = append(stubLibLabels, l)
}
inApexSelectValue := la.implementationDynamicDeps.SelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndInApex)
@@ -1096,12 +1098,20 @@
if la.systemDynamicDeps.IsNil() && len(la.usedSystemDynamicDepAsDynamicDep) > 0 {
toRemove := bazelLabelForSharedDeps(ctx, android.SortedStringKeys(la.usedSystemDynamicDepAsDynamicDep))
la.dynamicDeps.Exclude(bazel.NoConfigAxis, "", toRemove)
- la.implementationDynamicDeps.Exclude(bazel.NoConfigAxis, "", toRemove)
- la.implementationDynamicDeps.Exclude(bazel.NoConfigAxis, "", toRemove)
la.dynamicDeps.Exclude(bazel.OsConfigurationAxis, "android", toRemove)
la.dynamicDeps.Exclude(bazel.OsConfigurationAxis, "linux_bionic", toRemove)
+ la.implementationDynamicDeps.Exclude(bazel.NoConfigAxis, "", toRemove)
la.implementationDynamicDeps.Exclude(bazel.OsConfigurationAxis, "android", toRemove)
la.implementationDynamicDeps.Exclude(bazel.OsConfigurationAxis, "linux_bionic", toRemove)
+
+ la.implementationDynamicDeps.Exclude(bazel.OsAndInApexAxis, bazel.ConditionsDefaultConfigKey, toRemove)
+ la.implementationDynamicDeps.Exclude(bazel.OsAndInApexAxis, bazel.AndroidAndNonApex, toRemove)
+ stubsToRemove := make([]bazel.Label, 0, len(la.usedSystemDynamicDepAsDynamicDep))
+ for _, lib := range toRemove.Includes {
+ lib.Label += stubsSuffix
+ stubsToRemove = append(stubsToRemove, lib)
+ }
+ la.implementationDynamicDeps.Exclude(bazel.OsAndInApexAxis, bazel.AndroidAndInApex, bazel.MakeLabelList(stubsToRemove))
}
la.deps.ResolveExcludes()
diff --git a/cc/cc.go b/cc/cc.go
index d42ab6d..3129160 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -51,6 +51,7 @@
ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel()
ctx.BottomUp("version", versionMutator).Parallel()
ctx.BottomUp("begin", BeginMutator).Parallel()
+ ctx.BottomUp("sysprop_cc", SyspropMutator).Parallel()
})
ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
@@ -2391,8 +2392,18 @@
}
}
+ // sysprop_library has to support both C++ and Java. So sysprop_library internally creates one
+ // C++ implementation library and one Java implementation library. When a module links against
+ // sysprop_library, the C++ implementation library has to be linked. syspropImplLibraries is a
+ // map from sysprop_library to implementation library; it will be used in whole_static_libs,
+ // static_libs, and shared_libs.
+ syspropImplLibraries := syspropImplLibraries(actx.Config())
+
for _, lib := range deps.WholeStaticLibs {
depTag := libraryDependencyTag{Kind: staticLibraryDependency, wholeStatic: true, reexportFlags: true}
+ if impl, ok := syspropImplLibraries[lib]; ok {
+ lib = impl
+ }
lib = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs)
@@ -2410,6 +2421,10 @@
depTag.excludeInApex = true
}
+ if impl, ok := syspropImplLibraries[lib]; ok {
+ lib = impl
+ }
+
lib = GetReplaceModuleName(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs)
actx.AddVariationDependencies([]blueprint.Variation{
@@ -2439,6 +2454,10 @@
depTag.excludeInApex = true
}
+ if impl, ok := syspropImplLibraries[lib]; ok {
+ lib = impl
+ }
+
name, version := StubsLibNameAndVersion(lib)
sharedLibNames = append(sharedLibNames, name)
diff --git a/cc/sysprop.go b/cc/sysprop.go
new file mode 100644
index 0000000..f578b50
--- /dev/null
+++ b/cc/sysprop.go
@@ -0,0 +1,69 @@
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package cc
+
+// This file contains a map to redirect dependencies towards sysprop_library.
+// As sysprop_library has to support both Java and C++, sysprop_library internally
+// generates cc_library and java_library. For example, the following sysprop_library
+//
+// sysprop_library {
+// name: "foo",
+// }
+//
+// will internally generate with prefix "lib"
+//
+// cc_library {
+// name: "libfoo",
+// }
+//
+// When a cc module links against "foo", build system will redirect the
+// dependency to "libfoo". To do that, SyspropMutator gathers all sysprop_library,
+// records their cc implementation library names to a map. The map will be used in
+// cc.Module.DepsMutator.
+
+import (
+ "sync"
+
+ "android/soong/android"
+)
+
+type syspropLibraryInterface interface {
+ BaseModuleName() string
+ CcImplementationModuleName() string
+}
+
+var (
+ syspropImplLibrariesKey = android.NewOnceKey("syspropImplLibirares")
+ syspropImplLibrariesLock sync.Mutex
+)
+
+func syspropImplLibraries(config android.Config) map[string]string {
+ return config.Once(syspropImplLibrariesKey, func() interface{} {
+ return make(map[string]string)
+ }).(map[string]string)
+}
+
+// gather list of sysprop libraries
+func SyspropMutator(mctx android.BottomUpMutatorContext) {
+ if m, ok := mctx.Module().(syspropLibraryInterface); ok {
+ syspropImplLibraries := syspropImplLibraries(mctx.Config())
+ syspropImplLibrariesLock.Lock()
+ defer syspropImplLibrariesLock.Unlock()
+
+ // BaseModuleName is the name of sysprop_library
+ // CcImplementationModuleName is the name of cc_library generated by sysprop_library
+ syspropImplLibraries[m.BaseModuleName()] = m.CcImplementationModuleName()
+ }
+}
diff --git a/sysprop/sysprop_library.go b/sysprop/sysprop_library.go
index 578dc2b..0785f89 100644
--- a/sysprop/sysprop_library.go
+++ b/sysprop/sysprop_library.go
@@ -365,10 +365,7 @@
// sysprop_library creates schematized APIs from sysprop description files (.sysprop).
// Both Java and C++ modules can link against sysprop_library, and API stability check
// against latest APIs (see build/soong/scripts/freeze-sysprop-api-files.sh)
-// is performed. Note that the generated C++ module has its name prefixed with
-// `lib`, and it is this module that should be depended on from other C++
-// modules; i.e., if the sysprop_library module is named `foo`, C++ modules
-// should depend on `libfoo`.
+// is performed.
func syspropLibraryFactory() android.Module {
m := &syspropLibrary{}
diff --git a/sysprop/sysprop_test.go b/sysprop/sysprop_test.go
index 80b86e0..88ef615 100644
--- a/sysprop/sysprop_test.go
+++ b/sysprop/sysprop_test.go
@@ -209,32 +209,32 @@
cc_library {
name: "cc-client-platform",
srcs: ["d.cpp"],
- static_libs: ["libsysprop-platform"],
+ static_libs: ["sysprop-platform"],
}
cc_library_static {
name: "cc-client-platform-static",
srcs: ["d.cpp"],
- whole_static_libs: ["libsysprop-platform"],
+ whole_static_libs: ["sysprop-platform"],
}
cc_library {
name: "cc-client-product",
srcs: ["d.cpp"],
product_specific: true,
- static_libs: ["libsysprop-platform-on-product", "libsysprop-vendor-on-product"],
+ static_libs: ["sysprop-platform-on-product", "sysprop-vendor-on-product"],
}
cc_library {
name: "cc-client-vendor",
srcs: ["d.cpp"],
soc_specific: true,
- static_libs: ["libsysprop-platform", "libsysprop-vendor"],
+ static_libs: ["sysprop-platform", "sysprop-vendor"],
}
cc_binary_host {
name: "hostbin",
- static_libs: ["libsysprop-platform"],
+ static_libs: ["sysprop-platform"],
}
`)