Merge "Temporarily move APIs to blocked list."
diff --git a/Android.bp b/Android.bp
index 4d69877..e7a5de2 100644
--- a/Android.bp
+++ b/Android.bp
@@ -46,6 +46,7 @@
name: "libatomic",
defaults: ["linux_bionic_supported"],
vendor_available: true,
+ product_available: true,
ramdisk_available: true,
vendor_ramdisk_available: true,
recovery_available: true,
@@ -71,6 +72,7 @@
name: "libgcc",
defaults: ["linux_bionic_supported"],
vendor_available: true,
+ product_available: true,
recovery_available: true,
native_bridge_supported: true,
@@ -94,6 +96,7 @@
name: "libgcc_stripped",
defaults: ["linux_bionic_supported"],
vendor_available: true,
+ product_available: true,
ramdisk_available: true,
vendor_ramdisk_available: true,
recovery_available: true,
diff --git a/android/Android.bp b/android/Android.bp
index 2de0ca9..7bd1450 100644
--- a/android/Android.bp
+++ b/android/Android.bp
@@ -16,7 +16,6 @@
"api_levels.go",
"arch.go",
"bazel_handler.go",
- "bazel_overlay.go",
"config.go",
"csuite_config.go",
"defaults.go",
@@ -44,6 +43,7 @@
"prebuilt.go",
"prebuilt_build_tool.go",
"proto.go",
+ "queryview.go",
"register.go",
"rule_builder.go",
"sandbox.go",
diff --git a/android/bazel_overlay.go b/android/bazel_overlay.go
deleted file mode 100644
index a034282..0000000
--- a/android/bazel_overlay.go
+++ /dev/null
@@ -1,76 +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 (
- "fmt"
- "os"
- "strings"
-
- "github.com/google/blueprint"
-)
-
-// The Bazel Overlay singleton is responsible for generating the Ninja actions
-// for calling the soong_build primary builder in the main build.ninja file.
-func init() {
- RegisterSingletonType("bazel_overlay", BazelOverlaySingleton)
-}
-
-func BazelOverlaySingleton() Singleton {
- return &bazelOverlaySingleton{}
-}
-
-type bazelOverlaySingleton struct{}
-
-func (c *bazelOverlaySingleton) GenerateBuildActions(ctx SingletonContext) {
- // Create a build and rule statement, using the Bazel overlay's WORKSPACE
- // file as the output file marker.
- var deps Paths
- moduleListFilePath := pathForBuildToolDep(ctx, ctx.Config().moduleListFile)
- deps = append(deps, moduleListFilePath)
- deps = append(deps, pathForBuildToolDep(ctx, ctx.Config().ProductVariablesFileName))
-
- bazelOverlayDirectory := PathForOutput(ctx, "bazel_overlay")
- bazelOverlayWorkspaceFile := bazelOverlayDirectory.Join(ctx, "WORKSPACE")
- primaryBuilder := primaryBuilderPath(ctx)
- bazelOverlay := ctx.Rule(pctx, "bazelOverlay",
- blueprint.RuleParams{
- Command: fmt.Sprintf(
- "rm -rf ${outDir}/* && %s --bazel_overlay_dir ${outDir} %s && echo WORKSPACE: `cat %s` > ${outDir}/.overlay-depfile.d",
- primaryBuilder.String(),
- strings.Join(os.Args[1:], " "),
- moduleListFilePath.String(), // Use the contents of Android.bp.list as the depfile.
- ),
- CommandDeps: []string{primaryBuilder.String()},
- Description: fmt.Sprintf(
- "Creating the Bazel overlay workspace with %s at $outDir",
- primaryBuilder.Base()),
- Deps: blueprint.DepsGCC,
- Depfile: "${outDir}/.overlay-depfile.d",
- },
- "outDir")
-
- ctx.Build(pctx, BuildParams{
- Rule: bazelOverlay,
- Output: bazelOverlayWorkspaceFile,
- Inputs: deps,
- Args: map[string]string{
- "outDir": bazelOverlayDirectory.String(),
- },
- })
-
- // Add a phony target for building the bazel overlay
- ctx.Phony("bazel_overlay", bazelOverlayWorkspaceFile)
-}
diff --git a/android/env.go b/android/env.go
index c7c96d5..c2a09aa 100644
--- a/android/env.go
+++ b/android/env.go
@@ -41,7 +41,10 @@
// access originalEnv with dependencies. Store the value where soong_build can find it, it will manually
// ensure the dependencies are created.
soongDelveListen = os.Getenv("SOONG_DELVE")
- soongDelvePath, _ = exec.LookPath("dlv")
+ soongDelvePath = os.Getenv("SOONG_DELVE_PATH")
+ if soongDelvePath == "" {
+ soongDelvePath, _ = exec.LookPath("dlv")
+ }
originalEnv = make(map[string]string)
soongDelveEnv = []string{}
@@ -49,7 +52,7 @@
idx := strings.IndexRune(env, '=')
if idx != -1 {
originalEnv[env[:idx]] = env[idx+1:]
- if env[:idx] != "SOONG_DELVE" {
+ if env[:idx] != "SOONG_DELVE" && env[:idx] != "SOONG_DELVE_PATH" {
soongDelveEnv = append(soongDelveEnv, env)
}
}
diff --git a/android/queryview.go b/android/queryview.go
new file mode 100644
index 0000000..7e615b1
--- /dev/null
+++ b/android/queryview.go
@@ -0,0 +1,78 @@
+// 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 (
+ "fmt"
+ "os"
+ "strings"
+
+ "github.com/google/blueprint"
+)
+
+// The Bazel QueryView singleton is responsible for generating the Ninja actions
+// for calling the soong_build primary builder in the main build.ninja file.
+func init() {
+ RegisterSingletonType("bazel_queryview", BazelQueryViewSingleton)
+}
+
+func BazelQueryViewSingleton() Singleton {
+ return &bazelQueryViewSingleton{}
+}
+
+type bazelQueryViewSingleton struct{}
+
+func (c *bazelQueryViewSingleton) GenerateBuildActions(ctx SingletonContext) {
+ // Create a build and rule statement, using the Bazel QueryView's WORKSPACE
+ // file as the output file marker.
+ var deps Paths
+ moduleListFilePath := pathForBuildToolDep(ctx, ctx.Config().moduleListFile)
+ deps = append(deps, moduleListFilePath)
+ deps = append(deps, pathForBuildToolDep(ctx, ctx.Config().ProductVariablesFileName))
+
+ bazelQueryViewDirectory := PathForOutput(ctx, "queryview")
+ bazelQueryViewWorkspaceFile := bazelQueryViewDirectory.Join(ctx, "WORKSPACE")
+ primaryBuilder := primaryBuilderPath(ctx)
+ bazelQueryView := ctx.Rule(pctx, "bazelQueryView",
+ blueprint.RuleParams{
+ Command: fmt.Sprintf(
+ "rm -rf ${outDir}/* && "+
+ "%s --bazel_queryview_dir ${outDir} %s && "+
+ "echo WORKSPACE: `cat %s` > ${outDir}/.queryview-depfile.d",
+ primaryBuilder.String(),
+ strings.Join(os.Args[1:], " "),
+ moduleListFilePath.String(), // Use the contents of Android.bp.list as the depfile.
+ ),
+ CommandDeps: []string{primaryBuilder.String()},
+ Description: fmt.Sprintf(
+ "[EXPERIMENTAL] Creating the Bazel QueryView workspace with %s at $outDir",
+ primaryBuilder.Base()),
+ Deps: blueprint.DepsGCC,
+ Depfile: "${outDir}/.queryview-depfile.d",
+ },
+ "outDir")
+
+ ctx.Build(pctx, BuildParams{
+ Rule: bazelQueryView,
+ Output: bazelQueryViewWorkspaceFile,
+ Inputs: deps,
+ Args: map[string]string{
+ "outDir": bazelQueryViewDirectory.String(),
+ },
+ })
+
+ // Add a phony target for building the Bazel QueryView
+ ctx.Phony("queryview", bazelQueryViewWorkspaceFile)
+}
diff --git a/apex/allowed_deps.txt b/apex/allowed_deps.txt
index e5b91e5..5b8563d 100644
--- a/apex/allowed_deps.txt
+++ b/apex/allowed_deps.txt
@@ -172,6 +172,7 @@
framework-sdkextensions(minSdkVersion:30)
framework-sdkextensions(minSdkVersion:current)
framework-statsd(minSdkVersion:current)
+framework-tethering(minSdkVersion:30)
framework-tethering(minSdkVersion:current)
gemmlowp_headers(minSdkVersion:(no version))
GoogleCellBroadcastApp(minSdkVersion:29)
@@ -183,6 +184,7 @@
i18n.module.public.api.stubs(minSdkVersion:(no version))
iconloader(minSdkVersion:21)
ike-internals(minSdkVersion:current)
+InProcessTethering(minSdkVersion:30)
InProcessTethering(minSdkVersion:current)
ipmemorystore-aidl-interfaces-java(minSdkVersion:29)
ipmemorystore-aidl-interfaces-unstable-java(minSdkVersion:29)
@@ -235,6 +237,7 @@
libc_headers(minSdkVersion:apex_inherit)
libc_headers_arch(minSdkVersion:apex_inherit)
libcap(minSdkVersion:29)
+libclang_rt.hwasan-aarch64-android.llndk(minSdkVersion:(no version))
libcodec2(minSdkVersion:29)
libcodec2_headers(minSdkVersion:29)
libcodec2_hidl@1.0(minSdkVersion:29)
@@ -389,6 +392,7 @@
libstatssocket_headers(minSdkVersion:29)
libsystem_headers(minSdkVersion:apex_inherit)
libsysutils(minSdkVersion:apex_inherit)
+libtetherutilsjni(minSdkVersion:30)
libtetherutilsjni(minSdkVersion:current)
libtextclassifier(minSdkVersion:(no version))
libtextclassifier-java(minSdkVersion:current)
@@ -539,7 +543,9 @@
statsd-aidl-ndk_platform(minSdkVersion:(no version))
statsprotos(minSdkVersion:29)
tensorflow_headers(minSdkVersion:(no version))
+Tethering(minSdkVersion:30)
Tethering(minSdkVersion:current)
+TetheringApiCurrentLib(minSdkVersion:30)
TetheringApiCurrentLib(minSdkVersion:current)
TetheringGoogle(minSdkVersion:current)
textclassifier-statsd(minSdkVersion:current)
diff --git a/apex/apex_singleton.go b/apex/apex_singleton.go
index 803e0c5..ee9fc81 100644
--- a/apex/apex_singleton.go
+++ b/apex/apex_singleton.go
@@ -100,6 +100,8 @@
"new_allowed_deps": newAllowedDeps.String(),
},
})
+
+ ctx.Phony("apex-allowed-deps-check", s.allowedApexDepsInfoCheckResult)
}
func (s *apexDepsInfoSingleton) MakeVars(ctx android.MakeVarsContext) {
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 8b1f40d..09d9c44 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -2349,6 +2349,7 @@
enabled: true,
},
vendor_available: true,
+ product_available: true,
}
cc_library {
name: "libvendor",
@@ -3022,6 +3023,7 @@
name: "libvndk",
srcs: ["mylib.cpp"],
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -3034,6 +3036,7 @@
name: "libvndksp",
srcs: ["mylib.cpp"],
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
support_system_process: true,
@@ -3075,6 +3078,7 @@
name: "libvndk",
srcs: ["libvndk.so"],
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -3087,6 +3091,7 @@
name: "libvndk.arm",
srcs: ["libvndk.arm.so"],
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -3159,6 +3164,7 @@
name: "libvndk27",
version: "27",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -3178,6 +3184,7 @@
name: "libvndk27",
version: "27",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -3231,6 +3238,7 @@
name: "libvndk",
srcs: ["mylib.cpp"],
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -3242,6 +3250,7 @@
name: "libvndk",
version: "27",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -3301,6 +3310,7 @@
name: "libvndk",
srcs: ["mylib.cpp"],
vendor_available: true,
+ product_available: true,
native_bridge_supported: true,
host_supported: true,
vndk: {
@@ -3340,6 +3350,7 @@
name: "libvndk",
srcs: ["mylib.cpp"],
vendor_available: true,
+ product_available: true,
native_bridge_supported: true,
host_supported: true,
vndk: {
@@ -3371,6 +3382,7 @@
version: "27",
target_arch: "arm",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -3387,6 +3399,7 @@
target_arch: "arm",
binder32bit: true,
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -3434,6 +3447,7 @@
cc_library {
name: "libz",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
diff --git a/apex/vndk_test.go b/apex/vndk_test.go
index 60b6ed5..27d93ee 100644
--- a/apex/vndk_test.go
+++ b/apex/vndk_test.go
@@ -25,6 +25,7 @@
name: "libvndk",
srcs: ["mylib.cpp"],
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -37,6 +38,7 @@
name: "libvndksp",
srcs: ["mylib.cpp"],
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
support_system_process: true,
@@ -73,6 +75,7 @@
cc_library {
name: "libfoo",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
diff --git a/cc/cc.go b/cc/cc.go
index 3297e41..1f31872 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -314,26 +314,39 @@
type VendorProperties struct {
// whether this module should be allowed to be directly depended by other
// modules with `vendor: true`, `proprietary: true`, or `vendor_available:true`.
- // In addition, this module should be allowed to be directly depended by
- // product modules with `product_specific: true`.
- // If set to true, three variants will be built separately, one like
- // normal, another limited to the set of libraries and headers
- // that are exposed to /vendor modules, and the other to /product modules.
+ // If set to true, two variants will be built separately, one like
+ // normal, and the other limited to the set of libraries and headers
+ // that are exposed to /vendor modules.
//
- // The vendor and product variants may be used with a different (newer) /system,
+ // The vendor variant may be used with a different (newer) /system,
// so it shouldn't have any unversioned runtime dependencies, or
// make assumptions about the system that may not be true in the
// future.
//
- // If set to false, this module becomes inaccessible from /vendor or /product
- // modules.
+ // If set to false, this module becomes inaccessible from /vendor modules.
//
// Default value is true when vndk: {enabled: true} or vendor: true.
//
// Nothing happens if BOARD_VNDK_VERSION isn't set in the BoardConfig.mk
- // If PRODUCT_PRODUCT_VNDK_VERSION isn't set, product variant will not be used.
Vendor_available *bool
+ // whether this module should be allowed to be directly depended by other
+ // modules with `product_specific: true` or `product_available: true`.
+ // If set to true, an additional product variant will be built separately
+ // that is limited to the set of libraries and headers that are exposed to
+ // /product modules.
+ //
+ // The product variant may be used with a different (newer) /system,
+ // so it shouldn't have any unversioned runtime dependencies, or
+ // make assumptions about the system that may not be true in the
+ // future.
+ //
+ // It must be set to true by default for vndk: {enabled: true} modules.
+ //
+ // Nothing happens if BOARD_VNDK_VERSION isn't set in the BoardConfig.mk
+ // and PRODUCT_PRODUCT_VNDK_VERSION isn't set.
+ Product_available *bool
+
// whether this module is capable of being loaded with other instance
// (possibly an older version) of the same module in the same process.
// Currently, a shared library that is a member of VNDK (vndk: {enabled: true})
@@ -899,7 +912,7 @@
// "product" and "vendor" variant modules return true for this function.
// When BOARD_VNDK_VERSION is set, vendor variants of "vendor_available: true", "vendor: true",
// "soc_specific: true" and more vendor installed modules are included here.
-// When PRODUCT_PRODUCT_VNDK_VERSION is set, product variants of "vendor_available: true" or
+// When PRODUCT_PRODUCT_VNDK_VERSION is set, product variants of "product_available: true" or
// "product_specific: true" modules are included here.
func (c *Module) UseVndk() bool {
return c.Properties.VndkVersion != ""
@@ -1352,7 +1365,7 @@
_, llndk := c.linker.(*llndkStubDecorator)
_, llndkHeader := c.linker.(*llndkHeadersDecorator)
- if llndk || llndkHeader || (c.UseVndk() && c.HasVendorVariant()) {
+ if llndk || llndkHeader || (c.UseVndk() && c.HasNonSystemVariants()) {
// .vendor.{version} suffix is added for vendor variant or .product.{version} suffix is
// added for product variant only when we have vendor and product variants with core
// variant. The suffix is not added for vendor-only or product-only module.
@@ -1993,9 +2006,9 @@
// VNDK is cc.Module supported only for now.
if ccFrom, ok := from.(*Module); ok && from.UseVndk() {
- // Though vendor code is limited by the vendor mutator,
- // each vendor-available module needs to check
- // link-type for VNDK.
+ // Though allowed dependency is limited by the image mutator,
+ // each vendor and product module needs to check link-type
+ // for VNDK.
if ccTo, ok := to.(*Module); ok {
if ccFrom.vndkdep != nil {
ccFrom.vndkdep.vndkCheckLinkType(ctx, ccTo, tag)
@@ -2126,9 +2139,10 @@
return false
}
- // Even if target lib has no vendor variant, keep checking dependency graph
- // in case it depends on vendor_available but not double_loadable transtively.
- if !to.HasVendorVariant() {
+ // Even if target lib has no vendor variant, keep checking dependency
+ // graph in case it depends on vendor_available or product_available
+ // but not double_loadable transtively.
+ if !to.HasNonSystemVariants() {
return true
}
@@ -2771,6 +2785,7 @@
return "native:vndk_private"
}
if c.IsVndk() && !c.isVndkExt() {
+ // Product_available, if defined, must have the same value with Vendor_available.
if Bool(c.VendorProperties.Vendor_available) {
return "native:vndk"
}
@@ -3008,38 +3023,6 @@
return module
}
-func squashVendorSrcs(m *Module) {
- if lib, ok := m.compiler.(*libraryDecorator); ok {
- lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
- lib.baseCompiler.Properties.Target.Vendor.Srcs...)
-
- lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
- lib.baseCompiler.Properties.Target.Vendor.Exclude_srcs...)
-
- lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
- lib.baseCompiler.Properties.Target.Vendor.Exclude_generated_sources...)
- }
-}
-
-func squashRecoverySrcs(m *Module) {
- if lib, ok := m.compiler.(*libraryDecorator); ok {
- lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
- lib.baseCompiler.Properties.Target.Recovery.Srcs...)
-
- lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
- lib.baseCompiler.Properties.Target.Recovery.Exclude_srcs...)
-
- lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
- lib.baseCompiler.Properties.Target.Recovery.Exclude_generated_sources...)
- }
-}
-
-func squashVendorRamdiskSrcs(m *Module) {
- if lib, ok := m.compiler.(*libraryDecorator); ok {
- lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs, lib.baseCompiler.Properties.Target.Vendor_ramdisk.Exclude_srcs...)
- }
-}
-
func (c *Module) IsSdkVariant() bool {
return c.Properties.IsSdkVariant || c.AlwaysSdk()
}
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 3982c0c..b3bb282 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -326,6 +326,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -335,6 +336,7 @@
cc_library {
name: "libvndk_private",
vendor_available: false,
+ product_available: false,
vndk: {
enabled: true,
},
@@ -345,6 +347,7 @@
cc_library {
name: "libvndk_sp",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
support_system_process: true,
@@ -356,6 +359,7 @@
cc_library {
name: "libvndk_sp_private",
vendor_available: false,
+ product_available: false,
vndk: {
enabled: true,
support_system_process: true,
@@ -386,6 +390,7 @@
config := TestConfig(buildDir, android.Android, nil, bp, nil)
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
+ config.TestProductVariables.ProductVndkVersion = StringPtr("current")
config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
ctx := testCcWithConfig(t, config)
@@ -397,6 +402,11 @@
checkVndkModule(t, ctx, "libvndk_sp", "", true, "", vendorVariant)
checkVndkModule(t, ctx, "libvndk_sp_private", "", true, "", vendorVariant)
+ checkVndkModule(t, ctx, "libvndk", "", false, "", productVariant)
+ checkVndkModule(t, ctx, "libvndk_private", "", false, "", productVariant)
+ checkVndkModule(t, ctx, "libvndk_sp", "", true, "", productVariant)
+ checkVndkModule(t, ctx, "libvndk_sp_private", "", true, "", productVariant)
+
// Check VNDK snapshot output.
snapshotDir := "vndk-snapshot"
@@ -454,6 +464,7 @@
cc_library {
name: "libvndk_host_supported",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -463,6 +474,7 @@
cc_library {
name: "libvndk_host_supported_but_disabled_on_device",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -503,6 +515,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -512,6 +525,7 @@
cc_library {
name: "libvndk_sp",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
support_system_process: true,
@@ -522,6 +536,7 @@
cc_library {
name: "libvndk2",
vendor_available: false,
+ product_available: false,
vndk: {
enabled: true,
},
@@ -647,6 +662,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -665,12 +681,28 @@
})
}
+func TestVndkModuleError(t *testing.T) {
+ // Check the error message for vendor_available and product_available properties.
+ testCcError(t, "product_available: may not have different value than `vendor_available`", `
+ cc_library {
+ name: "libvndk",
+ vendor_available: true,
+ product_available: false,
+ vndk: {
+ enabled: true,
+ },
+ nocrt: true,
+ }
+ `)
+}
+
func TestVndkDepError(t *testing.T) {
// Check whether an error is emitted when a VNDK lib depends on a system lib.
testCcError(t, "dependency \".*\" of \".*\" missing variant", `
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -689,6 +721,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -708,6 +741,7 @@
cc_library {
name: "libvndk_sp",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
support_system_process: true,
@@ -727,6 +761,7 @@
cc_library {
name: "libvndk_sp",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
support_system_process: true,
@@ -747,6 +782,7 @@
cc_library {
name: "libvndk_sp",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
support_system_process: true,
@@ -758,6 +794,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -770,6 +807,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -789,6 +827,7 @@
cc_library {
name: "libvndkprivate",
vendor_available: false,
+ product_available: false,
vndk: {
enabled: true,
},
@@ -808,6 +847,7 @@
cc_library {
name: "libvndksp",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
support_system_process: true,
@@ -828,6 +868,7 @@
cc_library {
name: "libvndkspprivate",
vendor_available: false,
+ product_available: false,
vndk: {
enabled: true,
support_system_process: true,
@@ -861,6 +902,7 @@
cc_library {
name: "libdoubleloadable",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -883,6 +925,7 @@
cc_library {
name: "libvndksp",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
support_system_process: true,
@@ -909,6 +952,7 @@
cc_library {
name: "libdoubleloadable",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -919,6 +963,7 @@
cc_library {
name: "libnondoubleloadable",
vendor_available: false,
+ product_available: false,
vndk: {
enabled: true,
},
@@ -957,6 +1002,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -1090,6 +1136,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -1124,6 +1171,7 @@
version: "BOARD",
target_arch: "arm64",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -1566,6 +1614,7 @@
cc_library {
name: "libnondoubleloadable",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -1619,6 +1668,7 @@
cc_library {
name: "libnondoubleloadable",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -1630,6 +1680,7 @@
cc_library {
name: "libdoubleloadable",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -1640,6 +1691,7 @@
cc_library {
name: "libnondoubleloadable",
vendor_available: false,
+ product_available: false,
vndk: {
enabled: true,
},
@@ -1678,6 +1730,7 @@
name: "libvndksp",
shared_libs: ["libanothervndksp"],
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
support_system_process: true,
@@ -1707,6 +1760,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -1715,6 +1769,7 @@
cc_library {
name: "libvndk2",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -1722,6 +1777,9 @@
vendor: {
suffix: "-suffix",
},
+ product: {
+ suffix: "-suffix",
+ },
},
nocrt: true,
}
@@ -1789,6 +1847,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -1819,6 +1878,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -1849,6 +1909,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -1869,6 +1930,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -1889,6 +1951,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -1909,6 +1972,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -1919,6 +1983,7 @@
name: "libvndk_ext_product",
product_specific: true,
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
extends: "libvndk",
@@ -1934,6 +1999,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -1956,6 +2022,7 @@
cc_library {
name: "libvndk_sp",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
support_system_process: true,
@@ -1982,6 +2049,7 @@
cc_library {
name: "libvndk",
vendor_available: false,
+ product_available: false,
vndk: {
enabled: true,
},
@@ -2003,6 +2071,7 @@
cc_library {
name: "libvndk",
vendor_available: false,
+ product_available: false,
vndk: {
enabled: true,
},
@@ -2027,6 +2096,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -2046,6 +2116,7 @@
cc_library {
name: "libvndk_sp",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
support_system_process: true,
@@ -2079,6 +2150,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -2108,6 +2180,7 @@
cc_library {
name: "libvndk_sp",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
support_system_process: true,
@@ -2140,6 +2213,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -2160,6 +2234,7 @@
cc_library {
name: "libvndk_sp",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
support_system_process: true,
@@ -2207,6 +2282,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -2216,6 +2292,7 @@
cc_library {
name: "libvndk_sp",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
support_system_process: true,
@@ -2242,6 +2319,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -2261,6 +2339,7 @@
cc_library {
name: "libvndk_sp",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
support_system_process: true,
@@ -2289,6 +2368,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -2308,6 +2388,7 @@
cc_library {
name: "libvndk2",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -2320,6 +2401,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -2339,6 +2421,7 @@
cc_library {
name: "libvndk2",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -2355,6 +2438,7 @@
cc_library {
name: "libvndk_sp",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
support_system_process: true,
@@ -2376,6 +2460,7 @@
cc_library {
name: "libvndk_sp_2",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
support_system_process: true,
@@ -2389,6 +2474,7 @@
cc_library {
name: "libvndk_sp",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -2408,6 +2494,7 @@
cc_library {
name: "libvndk_sp2",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -2434,6 +2521,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -2442,6 +2530,7 @@
cc_library {
name: "libvndk_sp",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
support_system_process: true,
@@ -2454,6 +2543,11 @@
nocrt: true,
}
cc_library {
+ name: "libpa",
+ product_available: true,
+ nocrt: true,
+ }
+ cc_library {
name: "libproduct_va",
product_specific: true,
vendor_available: true,
@@ -2466,7 +2560,7 @@
"libllndk",
"libvndk",
"libvndk_sp",
- "libva",
+ "libpa",
"libproduct_va",
],
nocrt: true,
@@ -2538,6 +2632,7 @@
cc_library {
name: "libvndk_private",
vendor_available: false,
+ product_available: false,
vndk: {
enabled: true,
},
@@ -2581,6 +2676,7 @@
cc_library {
name: "libvndk",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
@@ -2588,6 +2684,7 @@
cc_library {
name: "libvndksp",
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
support_system_process: true,
@@ -2596,6 +2693,7 @@
cc_library {
name: "libvndkprivate",
vendor_available: false,
+ product_available: false,
vndk: {
enabled: true,
},
@@ -2618,6 +2716,7 @@
target_arch: "arm",
binder32bit: true,
vendor_available: true,
+ product_available: true,
vndk: {
enabled: true,
},
diff --git a/cc/compiler.go b/cc/compiler.go
index e2a33d7..3c86d20 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -143,21 +143,21 @@
} `android:"arch_variant"`
Target struct {
- Vendor struct {
- // list of source files that should only be used in the
- // vendor variant of the C/C++ module.
+ Vendor, Product struct {
+ // list of source files that should only be used in vendor or
+ // product variant of the C/C++ module.
Srcs []string `android:"path"`
- // list of source files that should not be used to
- // build the vendor variant of the C/C++ module.
+ // list of source files that should not be used to build vendor
+ // or product variant of the C/C++ module.
Exclude_srcs []string `android:"path"`
- // List of additional cflags that should be used to build the vendor
- // variant of the C/C++ module.
+ // List of additional cflags that should be used to build vendor
+ // or product variant of the C/C++ module.
Cflags []string
- // list of generated sources that should not be used to
- // build the vendor variant of the C/C++ module.
+ // list of generated sources that should not be used to build
+ // vendor or product variant of the C/C++ module.
Exclude_generated_sources []string
}
Recovery struct {
@@ -298,6 +298,7 @@
CheckBadCompilerFlags(ctx, "conlyflags", compiler.Properties.Conlyflags)
CheckBadCompilerFlags(ctx, "asflags", compiler.Properties.Asflags)
CheckBadCompilerFlags(ctx, "vendor.cflags", compiler.Properties.Target.Vendor.Cflags)
+ CheckBadCompilerFlags(ctx, "product.cflags", compiler.Properties.Target.Product.Cflags)
CheckBadCompilerFlags(ctx, "recovery.cflags", compiler.Properties.Target.Recovery.Cflags)
CheckBadCompilerFlags(ctx, "vendor_ramdisk.cflags", compiler.Properties.Target.Vendor_ramdisk.Cflags)
@@ -473,7 +474,12 @@
flags.Local.ConlyFlags = append([]string{"-std=" + cStd}, flags.Local.ConlyFlags...)
flags.Local.CppFlags = append([]string{"-std=" + cppStd}, flags.Local.CppFlags...)
- if ctx.useVndk() {
+ if ctx.inVendor() {
+ flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Target.Vendor.Cflags)...)
+ }
+
+ if ctx.inProduct() {
+ // TODO(b/150902910): must use 'compiler.Properties.Target.Product.Cflags'
flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Target.Vendor.Cflags)...)
}
diff --git a/cc/config/arm64_linux_host.go b/cc/config/arm64_linux_host.go
index 74642c2..59c52d1 100644
--- a/cc/config/arm64_linux_host.go
+++ b/cc/config/arm64_linux_host.go
@@ -29,6 +29,10 @@
// which stands for "Android device target". Keeping PIC on is required because
// many modules we have (e.g. Bionic) assume PIC.
"-fpic",
+
+ // This is normally in ClangExtraTargetCflags, but that's for device and we need
+ // the same for host
+ "-nostdlibinc",
))
linuxCrossLdflags = ClangFilterUnknownCflags([]string{
diff --git a/cc/genrule.go b/cc/genrule.go
index a5a58d2..3668e2b 100644
--- a/cc/genrule.go
+++ b/cc/genrule.go
@@ -25,6 +25,7 @@
type GenruleExtraProperties struct {
Vendor_available *bool
+ Product_available *bool
Ramdisk_available *bool
Vendor_ramdisk_available *bool
Recovery_available *bool
@@ -62,7 +63,7 @@
return false
}
- return Bool(g.Vendor_available) || !(ctx.SocSpecific() || ctx.DeviceSpecific())
+ return Bool(g.Vendor_available) || Bool(g.Product_available) || !(ctx.SocSpecific() || ctx.DeviceSpecific())
}
func (g *GenruleExtraProperties) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
@@ -100,7 +101,8 @@
return variants
}
- if Bool(g.Vendor_available) || ctx.ProductSpecific() {
+ // TODO(b/150902910): vendor_available will not create product variant. Remove Bool(g.Vendor_available)
+ if Bool(g.Vendor_available) || Bool(g.Product_available) || ctx.ProductSpecific() {
variants = append(variants, ProductVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion())
if vndkVersion := ctx.DeviceConfig().ProductVndkVersion(); vndkVersion != "current" {
variants = append(variants, ProductVariationPrefix+vndkVersion)
diff --git a/cc/image.go b/cc/image.go
index 7b9425f..3d6769e 100644
--- a/cc/image.go
+++ b/cc/image.go
@@ -65,8 +65,9 @@
)
func (ctx *moduleContext) ProductSpecific() bool {
+ //TODO(b/150902910): Replace HasNonSystemVariants() with HasProductVariant()
return ctx.ModuleContext.ProductSpecific() ||
- (ctx.mod.HasVendorVariant() && ctx.mod.inProduct())
+ (ctx.mod.HasNonSystemVariants() && ctx.mod.inProduct())
}
func (ctx *moduleContext) SocSpecific() bool {
@@ -94,12 +95,21 @@
return ctx.mod.InRecovery()
}
-// Returns true only when this module is configured to have core, product and vendor
-// variants.
+// Returns true when this module is configured to have core and vendor variants.
func (c *Module) HasVendorVariant() bool {
return c.IsVndk() || Bool(c.VendorProperties.Vendor_available)
}
+// Returns true when this module is configured to have core and product variants.
+func (c *Module) HasProductVariant() bool {
+ return c.IsVndk() || Bool(c.VendorProperties.Product_available)
+}
+
+// Returns true when this module is configured to have core and either product or vendor variants.
+func (c *Module) HasNonSystemVariants() bool {
+ return c.IsVndk() || Bool(c.VendorProperties.Vendor_available) || Bool(c.VendorProperties.Product_available)
+}
+
// Returns true if the module is "product" variant. Usually these modules are installed in /product
func (c *Module) inProduct() bool {
return c.Properties.ImageVariationPrefix == ProductVariationPrefix
@@ -139,9 +149,30 @@
vendorSpecific := mctx.SocSpecific() || mctx.DeviceSpecific()
productSpecific := mctx.ProductSpecific()
- if m.VendorProperties.Vendor_available != nil && vendorSpecific {
- mctx.PropertyErrorf("vendor_available",
- "doesn't make sense at the same time as `vendor: true`, `proprietary: true`, or `device_specific:true`")
+ if m.VendorProperties.Vendor_available != nil {
+ if vendorSpecific {
+ mctx.PropertyErrorf("vendor_available",
+ "doesn't make sense at the same time as `vendor: true`, `proprietary: true`, or `device_specific:true`")
+ }
+ // If defined, make sure vendor_available and product_available has the
+ // same value since `false` for these properties means the module is
+ // for system only but provides the variant.
+ if m.VendorProperties.Product_available != nil {
+ if Bool(m.VendorProperties.Vendor_available) != Bool(m.VendorProperties.Product_available) {
+ mctx.PropertyErrorf("product_available", "may not have different value than `vendor_available`")
+ }
+ }
+ }
+
+ if m.VendorProperties.Product_available != nil {
+ if productSpecific {
+ mctx.PropertyErrorf("product_available",
+ "doesn't make sense at the same time as `product_specific: true`")
+ }
+ if vendorSpecific {
+ mctx.PropertyErrorf("product_available",
+ "cannot provide product variant from a vendor module. Please use `product_specific: true` with `vendor_available: true`")
+ }
}
if vndkdep := m.vndkdep; vndkdep != nil {
@@ -153,6 +184,9 @@
} else if m.VendorProperties.Vendor_available != nil {
mctx.PropertyErrorf("vendor_available",
"must not set at the same time as `vndk: {extends: \"...\"}`")
+ } else if m.VendorProperties.Product_available != nil {
+ mctx.PropertyErrorf("product_available",
+ "must not set at the same time as `vndk: {extends: \"...\"}`")
}
} else {
if vndkdep.isVndkExt() {
@@ -231,21 +265,25 @@
} else {
mctx.ModuleErrorf("version is unknown for snapshot prebuilt")
}
- } else if m.HasVendorVariant() && !m.isVndkExt() {
- // This will be available in /system, /vendor and /product
- // or a /system directory that is available to vendor and product.
+ } else if m.HasNonSystemVariants() && !m.isVndkExt() {
+ // This will be available to /system unless it is product_specific
+ // which will be handled later.
coreVariantNeeded = true
// We assume that modules under proprietary paths are compatible for
// BOARD_VNDK_VERSION. The other modules are regarded as AOSP, or
// PLATFORM_VNDK_VERSION.
- if isVendorProprietaryModule(mctx) {
- vendorVariants = append(vendorVariants, boardVndkVersion)
- } else {
- vendorVariants = append(vendorVariants, platformVndkVersion)
+ if m.HasVendorVariant() {
+ if isVendorProprietaryModule(mctx) {
+ vendorVariants = append(vendorVariants, boardVndkVersion)
+ } else {
+ vendorVariants = append(vendorVariants, platformVndkVersion)
+ }
}
// vendor_available modules are also available to /product.
+ // TODO(b/150902910): product variant will be created only if
+ // m.HasProductVariant() is true.
productVariants = append(productVariants, platformVndkVersion)
// VNDK is always PLATFORM_VNDK_VERSION
if !m.IsVndk() {
@@ -351,6 +389,51 @@
return c.Properties.ExtraVariants
}
+func squashVendorSrcs(m *Module) {
+ if lib, ok := m.compiler.(*libraryDecorator); ok {
+ lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
+ lib.baseCompiler.Properties.Target.Vendor.Srcs...)
+
+ lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
+ lib.baseCompiler.Properties.Target.Vendor.Exclude_srcs...)
+
+ lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
+ lib.baseCompiler.Properties.Target.Vendor.Exclude_generated_sources...)
+ }
+}
+
+func squashProductSrcs(m *Module) {
+ if lib, ok := m.compiler.(*libraryDecorator); ok {
+ lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
+ lib.baseCompiler.Properties.Target.Product.Srcs...)
+
+ lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
+ lib.baseCompiler.Properties.Target.Product.Exclude_srcs...)
+
+ lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
+ lib.baseCompiler.Properties.Target.Product.Exclude_generated_sources...)
+ }
+}
+
+func squashRecoverySrcs(m *Module) {
+ if lib, ok := m.compiler.(*libraryDecorator); ok {
+ lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
+ lib.baseCompiler.Properties.Target.Recovery.Srcs...)
+
+ lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
+ lib.baseCompiler.Properties.Target.Recovery.Exclude_srcs...)
+
+ lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
+ lib.baseCompiler.Properties.Target.Recovery.Exclude_generated_sources...)
+ }
+}
+
+func squashVendorRamdiskSrcs(m *Module) {
+ if lib, ok := m.compiler.(*libraryDecorator); ok {
+ lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs, lib.baseCompiler.Properties.Target.Vendor_ramdisk.Exclude_srcs...)
+ }
+}
+
func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
m := module.(*Module)
if variant == android.RamdiskVariation {
@@ -376,6 +459,7 @@
} else if strings.HasPrefix(variant, ProductVariationPrefix) {
m.Properties.ImageVariationPrefix = ProductVariationPrefix
m.Properties.VndkVersion = strings.TrimPrefix(variant, ProductVariationPrefix)
+ // TODO (b/150902910): This will be replaced with squashProductSrcs(m).
squashVendorSrcs(m)
}
}
diff --git a/cc/library.go b/cc/library.go
index d946629..eeddd90 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -72,7 +72,7 @@
Suffix *string `android:"arch_variant"`
Target struct {
- Vendor struct {
+ Vendor, Product struct {
// set suffix of the name of the output
Suffix *string `android:"arch_variant"`
}
@@ -172,11 +172,11 @@
Export_system_include_dirs []string `android:"arch_variant"`
Target struct {
- Vendor struct {
+ Vendor, Product struct {
// list of exported include directories, like
- // export_include_dirs, that will be applied to the
- // vendor variant of this library. This will overwrite
- // any other declarations.
+ // export_include_dirs, that will be applied to
+ // vendor or product variant of this library.
+ // This will overwrite any other declarations.
Override_export_include_dirs []string
}
}
@@ -253,6 +253,7 @@
}
func (f *flagExporter) exportedIncludes(ctx ModuleContext) android.Paths {
+ // TODO(b/150902910): product variant must use Target.Product
if ctx.useVndk() && f.Properties.Target.Vendor.Override_export_include_dirs != nil {
return android.PathsForModuleSrc(ctx, f.Properties.Target.Vendor.Override_export_include_dirs)
} else {
@@ -716,6 +717,7 @@
suffix := ""
if useVndk {
+ // TODO(b/150902910): product variant must use Target.Product
suffix = String(library.Properties.Target.Vendor.Suffix)
}
if suffix == "" {
@@ -812,6 +814,7 @@
deps.ReexportSharedLibHeaders = append(deps.ReexportSharedLibHeaders, library.SharedProperties.Shared.Export_shared_lib_headers...)
deps.ReexportStaticLibHeaders = append(deps.ReexportStaticLibHeaders, library.SharedProperties.Shared.Export_static_lib_headers...)
}
+ // TODO(b/150902910): product variant must use Target.Product
if ctx.useVndk() {
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, library.baseLinker.Properties.Target.Vendor.Exclude_static_libs)
deps.SharedLibs = removeListFromList(deps.SharedLibs, library.baseLinker.Properties.Target.Vendor.Exclude_shared_libs)
diff --git a/cc/library_sdk_member.go b/cc/library_sdk_member.go
index 106b2eb..3f2cf49 100644
--- a/cc/library_sdk_member.go
+++ b/cc/library_sdk_member.go
@@ -130,6 +130,10 @@
pbm.AddProperty("vendor_available", true)
}
+ if proptools.Bool(ccModule.VendorProperties.Product_available) {
+ pbm.AddProperty("product_available", true)
+ }
+
sdkVersion := ccModule.SdkVersion()
if sdkVersion != "" {
pbm.AddProperty("sdk_version", sdkVersion)
diff --git a/cc/linker.go b/cc/linker.go
index 7f13e28..cbf8898 100644
--- a/cc/linker.go
+++ b/cc/linker.go
@@ -96,32 +96,32 @@
Runtime_libs []string `android:"arch_variant"`
Target struct {
- Vendor struct {
- // list of shared libs that only should be used to build the vendor
- // variant of the C/C++ module.
+ Vendor, Product struct {
+ // list of shared libs that only should be used to build vendor or
+ // product variant of the C/C++ module.
Shared_libs []string
- // list of static libs that only should be used to build the vendor
- // variant of the C/C++ module.
+ // list of static libs that only should be used to build vendor or
+ // product variant of the C/C++ module.
Static_libs []string
- // list of shared libs that should not be used to build the vendor variant
- // of the C/C++ module.
+ // list of shared libs that should not be used to build vendor or
+ // product variant of the C/C++ module.
Exclude_shared_libs []string
- // list of static libs that should not be used to build the vendor variant
- // of the C/C++ module.
+ // list of static libs that should not be used to build vendor or
+ // product variant of the C/C++ module.
Exclude_static_libs []string
- // list of header libs that should not be used to build the vendor variant
- // of the C/C++ module.
+ // list of header libs that should not be used to build vendor or
+ // product variant of the C/C++ module.
Exclude_header_libs []string
- // list of runtime libs that should not be installed along with the vendor
- // variant of the C/C++ module.
+ // list of runtime libs that should not be installed along with
+ // vendor or variant of the C/C++ module.
Exclude_runtime_libs []string
- // version script for this vendor variant
+ // version script for vendor or product variant
Version_script *string `android:"arch_variant"`
}
Recovery struct {
@@ -243,6 +243,7 @@
deps.WholeStaticLibs = append(deps.WholeStaticLibs, "libbuildversion")
}
+ // TODO(b/150902910): product variant must use Target.Product
if ctx.useVndk() {
deps.SharedLibs = append(deps.SharedLibs, linker.Properties.Target.Vendor.Shared_libs...)
deps.SharedLibs = removeListFromList(deps.SharedLibs, linker.Properties.Target.Vendor.Exclude_shared_libs)
@@ -479,6 +480,7 @@
versionScript := ctx.ExpandOptionalSource(
linker.Properties.Version_script, "version_script")
+ // TODO(b/150902910): product variant must use Target.Product
if ctx.useVndk() && linker.Properties.Target.Vendor.Version_script != nil {
versionScript = ctx.ExpandOptionalSource(
linker.Properties.Target.Vendor.Version_script,
diff --git a/cc/llndk_library.go b/cc/llndk_library.go
index 3b1d2f4..212720b 100644
--- a/cc/llndk_library.go
+++ b/cc/llndk_library.go
@@ -55,9 +55,11 @@
// Whether the system library uses symbol versions.
Unversioned *bool
- // whether this module can be directly depended upon by libs that are installed to /vendor.
- // When set to false, this module can only be depended on by VNDK libraries, not vendor
- // libraries. This effectively hides this module from vendors. Default value is true.
+ // whether this module can be directly depended upon by libs that are installed
+ // to /vendor and /product.
+ // When set to false, this module can only be depended on by VNDK libraries, not
+ // vendor nor product libraries. This effectively hides this module from
+ // non-system modules. Default value is true.
Vendor_available *bool
// list of llndk headers to re-export include directories from.
diff --git a/cc/testing.go b/cc/testing.go
index 019a186..388a9ce 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -40,6 +40,7 @@
name: "libatomic",
defaults: ["linux_bionic_supported"],
vendor_available: true,
+ product_available: true,
recovery_available: true,
native_bridge_supported: true,
src: "",
@@ -48,6 +49,7 @@
toolchain_library {
name: "libcompiler_rt-extras",
vendor_available: true,
+ product_available: true,
recovery_available: true,
src: "",
}
@@ -55,6 +57,7 @@
toolchain_library {
name: "libclang_rt.builtins-arm-android",
vendor_available: true,
+ product_available: true,
recovery_available: true,
native_bridge_supported: true,
src: "",
@@ -63,6 +66,7 @@
toolchain_library {
name: "libclang_rt.builtins-aarch64-android",
vendor_available: true,
+ product_available: true,
recovery_available: true,
native_bridge_supported: true,
src: "",
@@ -72,6 +76,7 @@
name: "libclang_rt.hwasan-aarch64-android",
nocrt: true,
vendor_available: true,
+ product_available: true,
recovery_available: true,
system_shared_libs: [],
stl: "none",
@@ -85,6 +90,7 @@
toolchain_library {
name: "libclang_rt.builtins-i686-android",
vendor_available: true,
+ product_available: true,
recovery_available: true,
native_bridge_supported: true,
src: "",
@@ -94,6 +100,7 @@
name: "libclang_rt.builtins-x86_64-android",
defaults: ["linux_bionic_supported"],
vendor_available: true,
+ product_available: true,
recovery_available: true,
native_bridge_supported: true,
src: "",
@@ -102,6 +109,7 @@
toolchain_library {
name: "libclang_rt.fuzzer-arm-android",
vendor_available: true,
+ product_available: true,
recovery_available: true,
src: "",
}
@@ -109,6 +117,7 @@
toolchain_library {
name: "libclang_rt.fuzzer-aarch64-android",
vendor_available: true,
+ product_available: true,
recovery_available: true,
src: "",
}
@@ -116,6 +125,7 @@
toolchain_library {
name: "libclang_rt.fuzzer-i686-android",
vendor_available: true,
+ product_available: true,
recovery_available: true,
src: "",
}
@@ -124,6 +134,7 @@
name: "libclang_rt.fuzzer-x86_64-android",
defaults: ["linux_bionic_supported"],
vendor_available: true,
+ product_available: true,
recovery_available: true,
src: "",
}
@@ -131,6 +142,7 @@
toolchain_library {
name: "libclang_rt.fuzzer-x86_64",
vendor_available: true,
+ product_available: true,
recovery_available: true,
src: "",
}
@@ -139,6 +151,7 @@
cc_prebuilt_library_shared {
name: "libclang_rt.ubsan_standalone-aarch64-android",
vendor_available: true,
+ product_available: true,
recovery_available: true,
system_shared_libs: [],
srcs: [""],
@@ -148,6 +161,7 @@
name: "libgcc",
defaults: ["linux_bionic_supported"],
vendor_available: true,
+ product_available: true,
recovery_available: true,
src: "",
}
@@ -156,6 +170,7 @@
name: "libgcc_stripped",
defaults: ["linux_bionic_supported"],
vendor_available: true,
+ product_available: true,
recovery_available: true,
sdk_version: "current",
src: "",
@@ -173,7 +188,7 @@
versions: ["27", "28", "29"],
},
llndk_stubs: "libc.llndk",
-}
+ }
llndk_library {
name: "libc.llndk",
symbol_file: "",
@@ -206,6 +221,7 @@
cc_library {
name: "libprofile-extras",
vendor_available: true,
+ product_available: true,
recovery_available: true,
native_coverage: false,
system_shared_libs: [],
@@ -215,6 +231,7 @@
cc_library {
name: "libprofile-clang-extras",
vendor_available: true,
+ product_available: true,
recovery_available: true,
native_coverage: false,
system_shared_libs: [],
@@ -224,6 +241,7 @@
cc_library {
name: "libprofile-extras_ndk",
vendor_available: true,
+ product_available: true,
native_coverage: false,
system_shared_libs: [],
stl: "none",
@@ -233,6 +251,7 @@
cc_library {
name: "libprofile-clang-extras_ndk",
vendor_available: true,
+ product_available: true,
native_coverage: false,
system_shared_libs: [],
stl: "none",
@@ -283,6 +302,7 @@
system_shared_libs: [],
stl: "none",
vendor_available: true,
+ product_available: true,
recovery_available: true,
host_supported: true,
min_sdk_version: "29",
@@ -298,6 +318,7 @@
system_shared_libs: [],
stl: "none",
vendor_available: true,
+ product_available: true,
recovery_available: true,
host_supported: true,
min_sdk_version: "29",
@@ -318,6 +339,7 @@
stl: "none",
host_supported: false,
vendor_available: true,
+ product_available: true,
recovery_available: true,
min_sdk_version: "29",
apex_available: [
@@ -332,6 +354,7 @@
system_shared_libs: [],
stl: "none",
vendor_available: true,
+ product_available: true,
recovery_available: true,
}
@@ -340,6 +363,7 @@
defaults: ["linux_bionic_supported"],
recovery_available: true,
vendor_available: true,
+ product_available: true,
native_bridge_supported: true,
stl: "none",
min_sdk_version: "16",
diff --git a/cc/vndk.go b/cc/vndk.go
index b2614c5..2cac03c 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -62,8 +62,8 @@
// declared as a VNDK or VNDK-SP module. The vendor variant
// will be installed in /system instead of /vendor partition.
//
- // `vendor_available` must be explicitly set to either true or
- // false together with `vndk: {enabled: true}`.
+ // `vendor_available` and `product_available` must be explicitly
+ // set to either true or false together with `vndk: {enabled: true}`.
Enabled *bool
// declared as a VNDK-SP module, which is a subset of VNDK.
@@ -129,13 +129,16 @@
return "native:vendor:vndkspext"
}
+// VNDK link type check from a module with UseVndk() == true.
func (vndk *vndkdep) vndkCheckLinkType(ctx android.BaseModuleContext, to *Module, tag blueprint.DependencyTag) {
if to.linker == nil {
return
}
if !vndk.isVndk() {
- // Non-VNDK modules (those installed to /vendor, /product, or /system/product) can't depend
- // on modules marked with vendor_available: false.
+ // Non-VNDK modules those installed to /vendor or /system/vendor
+ // can't depend on modules marked with vendor_available: false;
+ // or those installed to /product or /system/product can't depend
+ // on modules marked with product_available: false.
violation := false
if lib, ok := to.linker.(*llndkStubDecorator); ok && !Bool(lib.Properties.Vendor_available) {
violation = true
@@ -174,6 +177,7 @@
to.Name())
return
}
+ // TODO(b/150902910): vndk-ext for product must check product_available.
if !Bool(to.VendorProperties.Vendor_available) {
ctx.ModuleErrorf(
"`extends` refers module %q which does not have `vendor_available: true`",
@@ -338,6 +342,8 @@
} else {
vndkCoreLibraries(mctx.Config())[name] = filename
}
+ // As `vendor_available` and `product_available` has the same value for VNDK modules,
+ // we don't need to check both values.
if !Bool(m.VendorProperties.Vendor_available) {
vndkPrivateLibraries(mctx.Config())[name] = filename
}
diff --git a/cc/vndk_prebuilt.go b/cc/vndk_prebuilt.go
index dddd5ac..c0320eb 100644
--- a/cc/vndk_prebuilt.go
+++ b/cc/vndk_prebuilt.go
@@ -34,6 +34,7 @@
// version: "27",
// target_arch: "arm64",
// vendor_available: true,
+// product_available: true,
// vndk: {
// enabled: true,
// },
@@ -52,7 +53,7 @@
// VNDK snapshot version.
Version *string
- // Target arch name of the snapshot (e.g. 'arm64' for variant 'aosp_arm64_ab')
+ // Target arch name of the snapshot (e.g. 'arm64' for variant 'aosp_arm64')
Target_arch *string
// If the prebuilt snapshot lib is built with 32 bit binder, this must be set to true.
@@ -251,6 +252,7 @@
// version: "27",
// target_arch: "arm64",
// vendor_available: true,
+// product_available: true,
// vndk: {
// enabled: true,
// },
diff --git a/cmd/soong_build/Android.bp b/cmd/soong_build/Android.bp
index 4ebbe68..680c00a 100644
--- a/cmd/soong_build/Android.bp
+++ b/cmd/soong_build/Android.bp
@@ -26,10 +26,10 @@
srcs: [
"main.go",
"writedocs.go",
- "bazel_overlay.go",
+ "queryview.go",
],
testSrcs: [
- "bazel_overlay_test.go",
+ "queryview_test.go",
],
primaryBuilder: true,
}
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index 7ae1c37..9d7dddd 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -26,13 +26,13 @@
)
var (
- docFile string
- bazelOverlayDir string
+ docFile string
+ bazelQueryViewDir string
)
func init() {
flag.StringVar(&docFile, "soong_docs", "", "build documentation file to output")
- flag.StringVar(&bazelOverlayDir, "bazel_overlay_dir", "", "path to the bazel overlay directory")
+ flag.StringVar(&bazelQueryViewDir, "bazel_queryview_dir", "", "path to the bazel queryview directory")
}
func newNameResolver(config android.Config) *android.NameResolver {
@@ -113,8 +113,8 @@
ctx = newContext(srcDir, configuration)
bootstrap.Main(ctx.Context, configuration, extraNinjaDeps...)
}
- if bazelOverlayDir != "" {
- if err := createBazelOverlay(ctx, bazelOverlayDir); err != nil {
+ if bazelQueryViewDir != "" {
+ if err := createBazelQueryView(ctx, bazelQueryViewDir); err != nil {
fmt.Fprintf(os.Stderr, "%s", err)
os.Exit(1)
}
@@ -140,7 +140,7 @@
}
func shouldPrepareBuildActions() bool {
- // If we're writing soong_docs or bazel_overlay, don't write build.ninja or
+ // If we're writing soong_docs or queryview, don't write build.ninja or
// collect metrics.
- return docFile == "" && bazelOverlayDir == ""
+ return docFile == "" && bazelQueryViewDir == ""
}
diff --git a/cmd/soong_build/bazel_overlay.go b/cmd/soong_build/queryview.go
similarity index 94%
rename from cmd/soong_build/bazel_overlay.go
rename to cmd/soong_build/queryview.go
index cdc5775..27856b5 100644
--- a/cmd/soong_build/bazel_overlay.go
+++ b/cmd/soong_build/queryview.go
@@ -31,7 +31,7 @@
const (
// The default `load` preamble for every generated BUILD file.
soongModuleLoad = `package(default_visibility = ["//visibility:public"])
-load("//build/bazel/overlay_rules:soong_module.bzl", "soong_module")
+load("//build/bazel/queryview_rules:soong_module.bzl", "soong_module")
`
@@ -62,7 +62,7 @@
soongModuleBzl = `
%s
-load("//build/bazel/overlay_rules:providers.bzl", "SoongModuleInfo")
+load("//build/bazel/queryview_rules:providers.bzl", "SoongModuleInfo")
def _generic_soong_module_impl(ctx):
return [
@@ -370,7 +370,7 @@
// Canonicalize and normalize module property types to Bazel attribute types
starlarkAttrType := prop.Type
- if starlarkAttrType == "list of strings" {
+ if starlarkAttrType == "list of string" {
starlarkAttrType = "string_list"
} else if starlarkAttrType == "int64" {
starlarkAttrType = "int"
@@ -396,7 +396,7 @@
ruleShims := map[string]RuleShim{}
for _, pkg := range packages {
- content := "load(\"//build/bazel/overlay_rules:providers.bzl\", \"SoongModuleInfo\")\n"
+ content := "load(\"//build/bazel/queryview_rules:providers.bzl\", \"SoongModuleInfo\")\n"
bzlFileName := strings.ReplaceAll(pkg.Path, "android/soong/", "")
bzlFileName = strings.ReplaceAll(bzlFileName, ".", "_")
@@ -441,10 +441,10 @@
return ruleShims, nil
}
-func createBazelOverlay(ctx *android.Context, bazelOverlayDir string) error {
+func createBazelQueryView(ctx *android.Context, bazelQueryViewDir string) error {
blueprintCtx := ctx.Context
blueprintCtx.VisitAllModules(func(module blueprint.Module) {
- buildFile, err := buildFileForModule(blueprintCtx, module)
+ buildFile, err := buildFileForModule(blueprintCtx, module, bazelQueryViewDir)
if err != nil {
panic(err)
}
@@ -455,12 +455,12 @@
var err error
// Write top level files: WORKSPACE and BUILD. These files are empty.
- if err = writeReadOnlyFile(bazelOverlayDir, "WORKSPACE", ""); err != nil {
+ if err = writeReadOnlyFile(bazelQueryViewDir, "WORKSPACE", ""); err != nil {
return err
}
// Used to denote that the top level directory is a package.
- if err = writeReadOnlyFile(bazelOverlayDir, "BUILD", ""); err != nil {
+ if err = writeReadOnlyFile(bazelQueryViewDir, "BUILD", ""); err != nil {
return err
}
@@ -474,7 +474,7 @@
}
// Write .bzl Starlark files into the bazel_rules top level directory (provider and rule definitions)
- bazelRulesDir := bazelOverlayDir + "/build/bazel/overlay_rules"
+ bazelRulesDir := bazelQueryViewDir + "/build/bazel/queryview_rules"
if err = writeReadOnlyFile(bazelRulesDir, "BUILD", ""); err != nil {
return err
}
@@ -497,7 +497,7 @@
var loadStmts string
var moduleRuleMap string
for bzlFileName, ruleShim := range bzlLoads {
- loadStmt := "load(\"//build/bazel/overlay_rules:"
+ loadStmt := "load(\"//build/bazel/queryview_rules:"
loadStmt += bzlFileName
loadStmt += ".bzl\""
for _, rule := range ruleShim.rules {
@@ -563,9 +563,10 @@
attributes)
}
-func buildFileForModule(ctx *blueprint.Context, module blueprint.Module) (*os.File, error) {
+func buildFileForModule(
+ ctx *blueprint.Context, module blueprint.Module, bazelQueryViewDir string) (*os.File, error) {
// Create nested directories for the BUILD file
- dirPath := filepath.Join(bazelOverlayDir, packagePath(ctx, module))
+ dirPath := filepath.Join(bazelQueryViewDir, packagePath(ctx, module))
createDirectoryIfNonexistent(dirPath)
// Open the file for appending, and create it if it doesn't exist
f, err := os.OpenFile(
@@ -594,7 +595,7 @@
}
}
-// The overlay directory should be read-only, sufficient for bazel query. The files
+// The QueryView directory should be read-only, sufficient for bazel query. The files
// are not intended to be edited by end users.
func writeReadOnlyFile(dir string, baseName string, content string) error {
createDirectoryIfNonexistent(dir)
diff --git a/cmd/soong_build/bazel_overlay_test.go b/cmd/soong_build/queryview_test.go
similarity index 96%
rename from cmd/soong_build/bazel_overlay_test.go
rename to cmd/soong_build/queryview_test.go
index de060bb..675b532 100644
--- a/cmd/soong_build/bazel_overlay_test.go
+++ b/cmd/soong_build/queryview_test.go
@@ -28,7 +28,7 @@
func setUp() {
var err error
- buildDir, err = ioutil.TempDir("", "bazel_overlay_test")
+ buildDir, err = ioutil.TempDir("", "bazel_queryview_test")
if err != nil {
panic(err)
}
@@ -63,7 +63,7 @@
return module
}
-func TestGenerateBazelOverlayFromBlueprint(t *testing.T) {
+func TestGenerateBazelQueryViewFromBlueprint(t *testing.T) {
testCases := []struct {
bp string
expectedBazelTarget string
@@ -277,7 +277,7 @@
},
bpdoc.Property{
Name: "string_list_prop",
- Type: "list of strings",
+ Type: "list of string",
},
bpdoc.Property{
Name: "nested_prop",
@@ -362,7 +362,7 @@
}
}
- expectedBzl := `load("//build/bazel/overlay_rules:providers.bzl", "SoongModuleInfo")
+ expectedBzl := `load("//build/bazel/queryview_rules:providers.bzl", "SoongModuleInfo")
def _foo_binary_impl(ctx):
return [SoongModuleInfo()]
@@ -440,7 +440,7 @@
}
actualSoongModuleBzl := generateSoongModuleBzl(ruleShims)
- expectedLoad := "load(\"//build/bazel/overlay_rules:foo.bzl\", \"foo_binary\", \"foo_library\", \"foo_test_\")"
+ expectedLoad := "load(\"//build/bazel/queryview_rules:foo.bzl\", \"foo_binary\", \"foo_library\", \"foo_test_\")"
expectedRuleMap := `soong_module_rule_map = {
"foo_binary": foo_binary,
"foo_library": foo_library,
diff --git a/java/droiddoc.go b/java/droiddoc.go
index 1e09d64..c7a27c2 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -19,7 +19,6 @@
"path/filepath"
"strings"
- "github.com/google/blueprint"
"github.com/google/blueprint/proptools"
"android/soong/android"
@@ -30,16 +29,6 @@
func init() {
RegisterDocsBuildComponents(android.InitRegistrationContext)
RegisterStubsBuildComponents(android.InitRegistrationContext)
-
- // Register sdk member type.
- android.RegisterSdkMemberType(&droidStubsSdkMemberType{
- SdkMemberTypeBase: android.SdkMemberTypeBase{
- PropertyName: "stubs_sources",
- // stubs_sources can be used with sdk to provide the source stubs for APIs provided by
- // the APEX.
- SupportsSdk: true,
- },
- })
}
func RegisterDocsBuildComponents(ctx android.RegistrationContext) {
@@ -1829,47 +1818,3 @@
InitDroiddocModule(module, android.HostAndDeviceSupported)
return module
}
-
-type droidStubsSdkMemberType struct {
- android.SdkMemberTypeBase
-}
-
-func (mt *droidStubsSdkMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) {
- mctx.AddVariationDependencies(nil, dependencyTag, names...)
-}
-
-func (mt *droidStubsSdkMemberType) IsInstance(module android.Module) bool {
- _, ok := module.(*Droidstubs)
- return ok
-}
-
-func (mt *droidStubsSdkMemberType) AddPrebuiltModule(ctx android.SdkMemberContext, member android.SdkMember) android.BpModule {
- return ctx.SnapshotBuilder().AddPrebuiltModule(member, "prebuilt_stubs_sources")
-}
-
-func (mt *droidStubsSdkMemberType) CreateVariantPropertiesStruct() android.SdkMemberProperties {
- return &droidStubsInfoProperties{}
-}
-
-type droidStubsInfoProperties struct {
- android.SdkMemberPropertiesBase
-
- StubsSrcJar android.Path
-}
-
-func (p *droidStubsInfoProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) {
- droidstubs := variant.(*Droidstubs)
- p.StubsSrcJar = droidstubs.stubsSrcJar
-}
-
-func (p *droidStubsInfoProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
- if p.StubsSrcJar != nil {
- builder := ctx.SnapshotBuilder()
-
- snapshotRelativeDir := filepath.Join("java", ctx.Name()+"_stubs_sources")
-
- builder.UnzipToSnapshot(p.StubsSrcJar, snapshotRelativeDir)
-
- propertySet.AddProperty("srcs", []string{snapshotRelativeDir})
- }
-}
diff --git a/java/hiddenapi_singleton.go b/java/hiddenapi_singleton.go
index debdb7c..1f80e77 100644
--- a/java/hiddenapi_singleton.go
+++ b/java/hiddenapi_singleton.go
@@ -211,15 +211,6 @@
rule.Build(pctx, ctx, "hiddenAPIStubFlagsFile", "hiddenapi stub flags")
}
-func moduleForGreyListRemovedApis(ctx android.SingletonContext, module android.Module) bool {
- switch ctx.ModuleName(module) {
- case "api-stubs-docs", "system-api-stubs-docs", "android.car-stubs-docs", "android.car-system-stubs-docs":
- return true
- default:
- return false
- }
-}
-
// flagsRule creates a rule to build hiddenapi-flags.csv out of flags.csv files generated for boot image modules and
// the unsupported API.
func flagsRule(ctx android.SingletonContext) android.Path {
diff --git a/java/sdk_library.go b/java/sdk_library.go
index d6ef4e9..21c03cd 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -2292,10 +2292,11 @@
scopeSet.AddProperty("jars", jars)
// Merge the stubs source jar into the snapshot zip so that when it is unpacked
- // the source files are also unpacked.
+ // the source files are also unpacked. Use a glob so that if the directory is missing
+ // (because there are no stubs sources for this scope) it will not fail.
snapshotRelativeDir := filepath.Join(scopeDir, ctx.Name()+"_stub_sources")
ctx.SnapshotBuilder().UnzipToSnapshot(properties.StubsSrcJar, snapshotRelativeDir)
- scopeSet.AddProperty("stub_srcs", []string{snapshotRelativeDir})
+ scopeSet.AddProperty("stub_srcs", []string{snapshotRelativeDir + "/**/*.java"})
if properties.CurrentApiFile != nil {
currentApiSnapshotPath := filepath.Join(scopeDir, ctx.Name()+".txt")
diff --git a/linkerconfig/proto/linker_config.proto b/linkerconfig/proto/linker_config.proto
index 91a5968..fec66c8 100644
--- a/linkerconfig/proto/linker_config.proto
+++ b/linkerconfig/proto/linker_config.proto
@@ -28,4 +28,10 @@
// Force APEX namespace visible
bool visible = 2;
+
+ // Providing libs from the module
+ repeated string provideLibs = 3;
+
+ // Required libs from the module
+ repeated string requireLibs = 4;
}
diff --git a/python/python.go b/python/python.go
index 479c729..945e264 100644
--- a/python/python.go
+++ b/python/python.go
@@ -101,6 +101,13 @@
// this property name is hidden from users' perspectives, and soong will populate it during
// runtime.
Actual_version string `blueprint:"mutated"`
+
+ // true, if the module is required to be built with actual_version.
+ Enabled *bool `blueprint:"mutated"`
+
+ // true, if the binary is required to be built with embedded launcher.
+ // TODO(nanzhang): Remove this flag when embedded Python3 is supported later.
+ Embedded_launcher *bool `blueprint:"mutated"`
}
type pathMapping struct {
@@ -228,15 +235,18 @@
return func(mctx android.BottomUpMutatorContext) {
if base, ok := mctx.Module().(*Module); ok {
versionNames := []string{}
+ versionProps := []VersionProperties{}
// PY3 is first so that we alias the PY3 variant rather than PY2 if both
// are available
if !(base.properties.Version.Py3.Enabled != nil &&
*(base.properties.Version.Py3.Enabled) == false) {
versionNames = append(versionNames, pyVersion3)
+ versionProps = append(versionProps, base.properties.Version.Py3)
}
if base.properties.Version.Py2.Enabled != nil &&
*(base.properties.Version.Py2.Enabled) == true {
versionNames = append(versionNames, pyVersion2)
+ versionProps = append(versionProps, base.properties.Version.Py2)
}
modules := mctx.CreateVariations(versionNames...)
if len(versionNames) > 0 {
@@ -245,6 +255,11 @@
for i, v := range versionNames {
// set the actual version for Python module.
modules[i].(*Module).properties.Actual_version = v
+ // append versioned properties for the Python module
+ err := proptools.AppendMatchingProperties([]interface{}{&modules[i].(*Module).properties}, &versionProps[i], nil)
+ if err != nil {
+ panic(err)
+ }
}
}
}
@@ -270,15 +285,8 @@
}
}
-func (p *Module) isEmbeddedLauncherEnabled(actual_version string) bool {
- switch actual_version {
- case pyVersion2:
- return Bool(p.properties.Version.Py2.Embedded_launcher)
- case pyVersion3:
- return Bool(p.properties.Version.Py3.Embedded_launcher)
- }
-
- return false
+func (p *Module) isEmbeddedLauncherEnabled() bool {
+ return Bool(p.properties.Embedded_launcher)
}
func hasSrcExt(srcs []string, ext string) bool {
@@ -292,18 +300,7 @@
}
func (p *Module) hasSrcExt(ctx android.BottomUpMutatorContext, ext string) bool {
- if hasSrcExt(p.properties.Srcs, protoExt) {
- return true
- }
- switch p.properties.Actual_version {
- case pyVersion2:
- return hasSrcExt(p.properties.Version.Py2.Srcs, protoExt)
- case pyVersion3:
- return hasSrcExt(p.properties.Version.Py3.Srcs, protoExt)
- default:
- panic(fmt.Errorf("unknown Python Actual_version: %q for module: %q.",
- p.properties.Actual_version, ctx.ModuleName()))
- }
+ return hasSrcExt(p.properties.Srcs, protoExt)
}
func (p *Module) DepsMutator(ctx android.BottomUpMutatorContext) {
@@ -312,13 +309,12 @@
if p.hasSrcExt(ctx, protoExt) && p.Name() != "libprotobuf-python" {
ctx.AddVariationDependencies(nil, pythonLibTag, "libprotobuf-python")
}
+ ctx.AddVariationDependencies(nil, pythonLibTag, android.LastUniqueStrings(p.properties.Libs)...)
+
switch p.properties.Actual_version {
case pyVersion2:
- ctx.AddVariationDependencies(nil, pythonLibTag,
- uniqueLibs(ctx, p.properties.Libs, "version.py2.libs",
- p.properties.Version.Py2.Libs)...)
- if p.bootstrapper != nil && p.isEmbeddedLauncherEnabled(pyVersion2) {
+ if p.bootstrapper != nil && p.isEmbeddedLauncherEnabled() {
ctx.AddVariationDependencies(nil, pythonLibTag, "py2-stdlib")
launcherModule := "py2-launcher"
@@ -340,11 +336,8 @@
}
case pyVersion3:
- ctx.AddVariationDependencies(nil, pythonLibTag,
- uniqueLibs(ctx, p.properties.Libs, "version.py3.libs",
- p.properties.Version.Py3.Libs)...)
- if p.bootstrapper != nil && p.isEmbeddedLauncherEnabled(pyVersion3) {
+ if p.bootstrapper != nil && p.isEmbeddedLauncherEnabled() {
ctx.AddVariationDependencies(nil, pythonLibTag, "py3-stdlib")
launcherModule := "py3-launcher"
@@ -375,34 +368,6 @@
}
}
-// check "libs" duplicates from current module dependencies.
-func uniqueLibs(ctx android.BottomUpMutatorContext,
- commonLibs []string, versionProp string, versionLibs []string) []string {
- set := make(map[string]string)
- ret := []string{}
-
- // deps from "libs" property.
- for _, l := range commonLibs {
- if _, found := set[l]; found {
- ctx.PropertyErrorf("libs", "%q has duplicates within libs.", l)
- } else {
- set[l] = "libs"
- ret = append(ret, l)
- }
- }
- // deps from "version.pyX.libs" property.
- for _, l := range versionLibs {
- if _, found := set[l]; found {
- ctx.PropertyErrorf(versionProp, "%q has duplicates within %q.", set[l])
- } else {
- set[l] = versionProp
- ret = append(ret, l)
- }
- }
-
- return ret
-}
-
func (p *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
p.GeneratePythonBuildActions(ctx)
@@ -410,11 +375,7 @@
if p.bootstrapper != nil {
p.walkTransitiveDeps(ctx)
embeddedLauncher := false
- if p.properties.Actual_version == pyVersion2 {
- embeddedLauncher = p.isEmbeddedLauncherEnabled(pyVersion2)
- } else {
- embeddedLauncher = p.isEmbeddedLauncherEnabled(pyVersion3)
- }
+ embeddedLauncher = p.isEmbeddedLauncherEnabled()
p.installSource = p.bootstrapper.bootstrap(ctx, p.properties.Actual_version,
embeddedLauncher, p.srcsPathMappings, p.srcsZip, p.depsSrcsZips)
}
@@ -439,17 +400,6 @@
// expand python files from "srcs" property.
srcs := p.properties.Srcs
exclude_srcs := p.properties.Exclude_srcs
- switch p.properties.Actual_version {
- case pyVersion2:
- srcs = append(srcs, p.properties.Version.Py2.Srcs...)
- exclude_srcs = append(exclude_srcs, p.properties.Version.Py2.Exclude_srcs...)
- case pyVersion3:
- srcs = append(srcs, p.properties.Version.Py3.Srcs...)
- exclude_srcs = append(exclude_srcs, p.properties.Version.Py3.Exclude_srcs...)
- default:
- panic(fmt.Errorf("unknown Python Actual_version: %q for module: %q.",
- p.properties.Actual_version, ctx.ModuleName()))
- }
expandedSrcs := android.PathsForModuleSrcExcludes(ctx, srcs, exclude_srcs)
requiresSrcs := true
if p.bootstrapper != nil && !p.bootstrapper.autorun() {
diff --git a/python/python_test.go b/python/python_test.go
index 23db24e..10b565a 100644
--- a/python/python_test.go
+++ b/python/python_test.go
@@ -395,10 +395,11 @@
if !reflect.DeepEqual(actualPyRunfiles, expectedPyRunfiles) {
testErrs = append(testErrs, errors.New(fmt.Sprintf(
- `binary "%s" variant "%s" has unexpected pyRunfiles: %q!`,
+ `binary "%s" variant "%s" has unexpected pyRunfiles: %q! (expected: %q)`,
base.Name(),
base.properties.Actual_version,
- actualPyRunfiles)))
+ actualPyRunfiles,
+ expectedPyRunfiles)))
}
if base.srcsZip.String() != strings.Replace(expectedSrcsZip, "@prefix@", buildDir, 1) {
diff --git a/rust/bindgen.go b/rust/bindgen.go
index 3db2d65..7cc0fc8 100644
--- a/rust/bindgen.go
+++ b/rust/bindgen.go
@@ -29,10 +29,10 @@
defaultBindgenFlags = []string{""}
// bindgen should specify its own Clang revision so updating Clang isn't potentially blocked on bindgen failures.
- bindgenClangVersion = "clang-r383902c"
+ bindgenClangVersion = "clang-r399163b"
//TODO(b/160803703) Use a prebuilt bindgen instead of the built bindgen.
- _ = pctx.SourcePathVariable("bindgenCmd", "out/host/${config.HostPrebuiltTag}/bin/bindgen")
+ _ = pctx.HostBinToolVariable("bindgenCmd", "bindgen")
_ = pctx.SourcePathVariable("bindgenClang",
"${cc_config.ClangBase}/${config.HostPrebuiltTag}/"+bindgenClangVersion+"/bin/clang")
_ = pctx.SourcePathVariable("bindgenLibClang",
diff --git a/rust/builder.go b/rust/builder.go
index 654b1e6..3e082dc 100644
--- a/rust/builder.go
+++ b/rust/builder.go
@@ -22,6 +22,7 @@
"android/soong/android"
"android/soong/cc"
+ "android/soong/rust/config"
)
var (
@@ -138,6 +139,13 @@
crate_name := ctx.RustModule().CrateName()
targetTriple := ctx.toolchain().RustTriple()
+ // libstd requires a specific environment variable to be set. This is
+ // not officially documented and may be removed in the future. See
+ // https://github.com/rust-lang/rust/blob/master/library/std/src/env.rs#L866.
+ if crate_name == "std" {
+ envVars = append(envVars, "STD_ENV_ARCH="+config.StdEnvArch[ctx.RustModule().Arch().ArchType])
+ }
+
inputs = append(inputs, main)
// Collect rustc flags
diff --git a/rust/config/global.go b/rust/config/global.go
index 71c4240..6e268a0 100644
--- a/rust/config/global.go
+++ b/rust/config/global.go
@@ -24,7 +24,7 @@
var pctx = android.NewPackageContext("android/soong/rust/config")
var (
- RustDefaultVersion = "1.46.0"
+ RustDefaultVersion = "1.47.0"
RustDefaultBase = "prebuilts/rust/"
DefaultEdition = "2018"
Stdlibs = []string{
@@ -32,6 +32,15 @@
"libtest",
}
+ // Mapping between Soong internal arch types and std::env constants.
+ // Required as Rust uses aarch64 when Soong uses arm64.
+ StdEnvArch = map[android.ArchType]string{
+ android.Arm: "arm",
+ android.Arm64: "aarch64",
+ android.X86: "x86",
+ android.X86_64: "x86_64",
+ }
+
GlobalRustFlags = []string{
"--remap-path-prefix $$(pwd)=",
"-C codegen-units=1",
diff --git a/rust/protobuf.go b/rust/protobuf.go
index ebb1c3c..ca40154 100644
--- a/rust/protobuf.go
+++ b/rust/protobuf.go
@@ -22,9 +22,18 @@
defaultProtobufFlags = []string{""}
)
+type PluginType int
+
+const (
+ Protobuf PluginType = iota
+ Grpc
+)
+
func init() {
android.RegisterModuleType("rust_protobuf", RustProtobufFactory)
android.RegisterModuleType("rust_protobuf_host", RustProtobufHostFactory)
+ android.RegisterModuleType("rust_grpcio", RustGrpcioFactory)
+ android.RegisterModuleType("rust_grpcio_host", RustGrpcioHostFactory)
}
var _ SourceProvider = (*protobufDecorator)(nil)
@@ -41,26 +50,28 @@
*BaseSourceProvider
Properties ProtobufProperties
+ plugin PluginType
}
func (proto *protobufDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) android.Path {
var protoFlags android.ProtoFlags
- pluginPath := ctx.Config().HostToolPath(ctx, "protoc-gen-rust")
+ var pluginPaths android.Paths
protoFlags.OutTypeFlag = "--rust_out"
+ outDir := android.PathForModuleOut(ctx)
- protoFlags.Flags = append(protoFlags.Flags, " --plugin="+pluginPath.String())
+ pluginPaths, protoFlags = proto.setupPlugin(ctx, protoFlags, outDir)
+
protoFlags.Flags = append(protoFlags.Flags, defaultProtobufFlags...)
protoFlags.Flags = append(protoFlags.Flags, proto.Properties.Proto_flags...)
- protoFlags.Deps = append(protoFlags.Deps, pluginPath)
+ protoFlags.Deps = append(protoFlags.Deps, pluginPaths...)
protoFile := android.OptionalPathForModuleSrc(ctx, proto.Properties.Proto)
if !protoFile.Valid() {
ctx.PropertyErrorf("proto", "invalid path to proto file")
}
- outDir := android.PathForModuleOut(ctx)
stem := proto.BaseSourceProvider.getStem(ctx)
// rust protobuf-codegen output <stem>.rs
stemFile := android.PathForModuleOut(ctx, stem+".rs")
@@ -79,6 +90,27 @@
return modFile
}
+func (proto *protobufDecorator) setupPlugin(ctx ModuleContext, protoFlags android.ProtoFlags, outDir android.ModuleOutPath) (android.Paths, android.ProtoFlags) {
+ pluginPaths := []android.Path{}
+
+ if proto.plugin == Protobuf {
+ pluginPath := ctx.Config().HostToolPath(ctx, "protoc-gen-rust")
+ pluginPaths = append(pluginPaths, pluginPath)
+ protoFlags.Flags = append(protoFlags.Flags, "--plugin="+pluginPath.String())
+ } else if proto.plugin == Grpc {
+ grpcPath := ctx.Config().HostToolPath(ctx, "grpc_rust_plugin")
+ protobufPath := ctx.Config().HostToolPath(ctx, "protoc-gen-rust")
+ pluginPaths = append(pluginPaths, grpcPath, protobufPath)
+ protoFlags.Flags = append(protoFlags.Flags, "--grpc_out="+outDir.String())
+ protoFlags.Flags = append(protoFlags.Flags, "--plugin=protoc-gen-grpc="+grpcPath.String())
+ protoFlags.Flags = append(protoFlags.Flags, "--plugin=protoc-gen-rust="+protobufPath.String())
+ } else {
+ ctx.ModuleErrorf("Unknown protobuf plugin type requested")
+ }
+
+ return pluginPaths, protoFlags
+}
+
func (proto *protobufDecorator) SourceProviderProps() []interface{} {
return append(proto.BaseSourceProvider.SourceProviderProps(), &proto.Properties)
}
@@ -104,10 +136,34 @@
return module.Init()
}
+func RustGrpcioFactory() android.Module {
+ module, _ := NewRustGrpcio(android.HostAndDeviceSupported)
+ return module.Init()
+}
+
+// A host-only variant of rust_protobuf. Refer to rust_protobuf for more details.
+func RustGrpcioHostFactory() android.Module {
+ module, _ := NewRustGrpcio(android.HostSupported)
+ return module.Init()
+}
+
func NewRustProtobuf(hod android.HostOrDeviceSupported) (*Module, *protobufDecorator) {
protobuf := &protobufDecorator{
BaseSourceProvider: NewSourceProvider(),
Properties: ProtobufProperties{},
+ plugin: Protobuf,
+ }
+
+ module := NewSourceProviderModule(hod, protobuf, false)
+
+ return module, protobuf
+}
+
+func NewRustGrpcio(hod android.HostOrDeviceSupported) (*Module, *protobufDecorator) {
+ protobuf := &protobufDecorator{
+ BaseSourceProvider: NewSourceProvider(),
+ Properties: ProtobufProperties{},
+ plugin: Grpc,
}
module := NewSourceProviderModule(hod, protobuf, false)
diff --git a/rust/protobuf_test.go b/rust/protobuf_test.go
index bd11a5a..7c39071 100644
--- a/rust/protobuf_test.go
+++ b/rust/protobuf_test.go
@@ -15,8 +15,10 @@
package rust
import (
- "android/soong/android"
+ "strings"
"testing"
+
+ "android/soong/android"
)
func TestRustProtobuf(t *testing.T) {
@@ -28,12 +30,41 @@
source_stem: "buf",
}
`)
- // Check that there's a rule to generate the expected output
- _ = ctx.ModuleForTests("librust_proto", "android_arm64_armv8-a_source").Output("buf.rs")
-
// Check that libprotobuf is added as a dependency.
librust_proto := ctx.ModuleForTests("librust_proto", "android_arm64_armv8-a_dylib").Module().(*Module)
if !android.InList("libprotobuf", librust_proto.Properties.AndroidMkDylibs) {
t.Errorf("libprotobuf dependency missing for rust_protobuf (dependency missing from AndroidMkDylibs)")
}
+
+ // Make sure the correct plugin is being used.
+ librust_proto_out := ctx.ModuleForTests("librust_proto", "android_arm64_armv8-a_source").Output("buf.rs")
+ cmd := librust_proto_out.RuleParams.Command
+ if w := "protoc-gen-rust"; !strings.Contains(cmd, w) {
+ t.Errorf("expected %q in %q", w, cmd)
+ }
+
+}
+
+func TestRustGrpcio(t *testing.T) {
+ ctx := testRust(t, `
+ rust_grpcio {
+ name: "librust_grpcio",
+ proto: "buf.proto",
+ crate_name: "rust_grpcio",
+ source_stem: "buf",
+ }
+ `)
+
+ // Check that libprotobuf is added as a dependency.
+ librust_grpcio_module := ctx.ModuleForTests("librust_grpcio", "android_arm64_armv8-a_dylib").Module().(*Module)
+ if !android.InList("libprotobuf", librust_grpcio_module.Properties.AndroidMkDylibs) {
+ t.Errorf("libprotobuf dependency missing for rust_grpcio (dependency missing from AndroidMkDylibs)")
+ }
+
+ // Make sure the correct plugin is being used.
+ librust_grpcio_out := ctx.ModuleForTests("librust_grpcio", "android_arm64_armv8-a_source").Output("buf.rs")
+ cmd := librust_grpcio_out.RuleParams.Command
+ if w := "protoc-gen-grpc"; !strings.Contains(cmd, w) {
+ t.Errorf("expected %q in %q", w, cmd)
+ }
}
diff --git a/rust/testing.go b/rust/testing.go
index 42b0da1..4a1894c 100644
--- a/rust/testing.go
+++ b/rust/testing.go
@@ -132,6 +132,8 @@
ctx.RegisterModuleType("rust_ffi_host", RustFFIHostFactory)
ctx.RegisterModuleType("rust_ffi_host_shared", RustFFISharedHostFactory)
ctx.RegisterModuleType("rust_ffi_host_static", RustFFIStaticHostFactory)
+ ctx.RegisterModuleType("rust_grpcio", RustGrpcioFactory)
+ ctx.RegisterModuleType("rust_grpcio_host", RustGrpcioHostFactory)
ctx.RegisterModuleType("rust_proc_macro", ProcMacroFactory)
ctx.RegisterModuleType("rust_protobuf", RustProtobufFactory)
ctx.RegisterModuleType("rust_protobuf_host", RustProtobufHostFactory)
diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go
index d6828c9..731e528 100644
--- a/sdk/java_sdk_test.go
+++ b/sdk/java_sdk_test.go
@@ -619,148 +619,6 @@
)
}
-func testSdkWithDroidstubs(t *testing.T, bp string) *testSdkResult {
- t.Helper()
-
- fs := map[string][]byte{
- "foo/bar/Foo.java": nil,
- "stubs-sources/foo/bar/Foo.java": nil,
- }
- return testSdkWithFs(t, bp, fs)
-}
-
-// Note: This test does not verify that a droidstubs can be referenced, either
-// directly or indirectly from an APEX as droidstubs can never be a part of an
-// apex.
-func TestBasicSdkWithDroidstubs(t *testing.T) {
- testSdkWithDroidstubs(t, `
- sdk {
- name: "mysdk",
- stubs_sources: ["mystub"],
- }
- sdk_snapshot {
- name: "mysdk@10",
- stubs_sources: ["mystub_mysdk@10"],
- }
- prebuilt_stubs_sources {
- name: "mystub_mysdk@10",
- sdk_member_name: "mystub",
- srcs: ["stubs-sources/foo/bar/Foo.java"],
- }
- droidstubs {
- name: "mystub",
- srcs: ["foo/bar/Foo.java"],
- sdk_version: "none",
- system_modules: "none",
- }
- java_library {
- name: "myjavalib",
- srcs: [":mystub"],
- sdk_version: "none",
- system_modules: "none",
- }
- `)
-}
-
-func TestSnapshotWithDroidstubs(t *testing.T) {
- result := testSdkWithDroidstubs(t, `
- module_exports {
- name: "myexports",
- stubs_sources: ["myjavaapistubs"],
- }
-
- droidstubs {
- name: "myjavaapistubs",
- srcs: ["foo/bar/Foo.java"],
- system_modules: "none",
- sdk_version: "none",
- }
- `)
-
- result.CheckSnapshot("myexports", "",
- checkAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-prebuilt_stubs_sources {
- name: "myexports_myjavaapistubs@current",
- sdk_member_name: "myjavaapistubs",
- visibility: ["//visibility:public"],
- srcs: ["java/myjavaapistubs_stubs_sources"],
-}
-
-prebuilt_stubs_sources {
- name: "myjavaapistubs",
- prefer: false,
- visibility: ["//visibility:public"],
- srcs: ["java/myjavaapistubs_stubs_sources"],
-}
-
-module_exports_snapshot {
- name: "myexports@current",
- visibility: ["//visibility:public"],
- stubs_sources: ["myexports_myjavaapistubs@current"],
-}
-
-`),
- checkAllCopyRules(""),
- checkMergeZips(".intermediates/myexports/common_os/tmp/java/myjavaapistubs_stubs_sources.zip"),
- )
-}
-
-func TestHostSnapshotWithDroidstubs(t *testing.T) {
- result := testSdkWithDroidstubs(t, `
- module_exports {
- name: "myexports",
- device_supported: false,
- host_supported: true,
- stubs_sources: ["myjavaapistubs"],
- }
-
- droidstubs {
- name: "myjavaapistubs",
- device_supported: false,
- host_supported: true,
- srcs: ["foo/bar/Foo.java"],
- system_modules: "none",
- sdk_version: "none",
- }
- `)
-
- result.CheckSnapshot("myexports", "",
- checkAndroidBpContents(`
-// This is auto-generated. DO NOT EDIT.
-
-prebuilt_stubs_sources {
- name: "myexports_myjavaapistubs@current",
- sdk_member_name: "myjavaapistubs",
- visibility: ["//visibility:public"],
- device_supported: false,
- host_supported: true,
- srcs: ["java/myjavaapistubs_stubs_sources"],
-}
-
-prebuilt_stubs_sources {
- name: "myjavaapistubs",
- prefer: false,
- visibility: ["//visibility:public"],
- device_supported: false,
- host_supported: true,
- srcs: ["java/myjavaapistubs_stubs_sources"],
-}
-
-module_exports_snapshot {
- name: "myexports@current",
- visibility: ["//visibility:public"],
- device_supported: false,
- host_supported: true,
- stubs_sources: ["myexports_myjavaapistubs@current"],
-}
-`),
- checkAllCopyRules(""),
- checkMergeZips(".intermediates/myexports/common_os/tmp/java/myjavaapistubs_stubs_sources.zip"),
- )
-}
-
func TestSnapshotWithJavaSystemModules(t *testing.T) {
result := testSdkWithJava(t, `
sdk {
@@ -1090,21 +948,21 @@
shared_library: false,
public: {
jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/public/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/public/myjavalib.txt",
removed_api: "sdk_library/public/myjavalib-removed.txt",
sdk_version: "current",
},
system: {
jars: ["sdk_library/system/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/system/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/system/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/system/myjavalib.txt",
removed_api: "sdk_library/system/myjavalib-removed.txt",
sdk_version: "system_current",
},
test: {
jars: ["sdk_library/test/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/test/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/test/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/test/myjavalib.txt",
removed_api: "sdk_library/test/myjavalib-removed.txt",
sdk_version: "test_current",
@@ -1119,21 +977,21 @@
shared_library: false,
public: {
jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/public/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/public/myjavalib.txt",
removed_api: "sdk_library/public/myjavalib-removed.txt",
sdk_version: "current",
},
system: {
jars: ["sdk_library/system/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/system/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/system/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/system/myjavalib.txt",
removed_api: "sdk_library/system/myjavalib-removed.txt",
sdk_version: "system_current",
},
test: {
jars: ["sdk_library/test/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/test/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/test/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/test/myjavalib.txt",
removed_api: "sdk_library/test/myjavalib-removed.txt",
sdk_version: "test_current",
@@ -1190,7 +1048,7 @@
shared_library: true,
public: {
jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/public/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/public/myjavalib.txt",
removed_api: "sdk_library/public/myjavalib-removed.txt",
sdk_version: "none",
@@ -1204,7 +1062,7 @@
shared_library: true,
public: {
jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/public/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/public/myjavalib.txt",
removed_api: "sdk_library/public/myjavalib-removed.txt",
sdk_version: "none",
@@ -1257,7 +1115,7 @@
shared_library: true,
public: {
jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/public/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/public/myjavalib.txt",
removed_api: "sdk_library/public/myjavalib-removed.txt",
sdk_version: "module_current",
@@ -1271,7 +1129,7 @@
shared_library: true,
public: {
jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/public/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/public/myjavalib.txt",
removed_api: "sdk_library/public/myjavalib-removed.txt",
sdk_version: "module_current",
@@ -1328,14 +1186,14 @@
shared_library: true,
public: {
jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/public/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/public/myjavalib.txt",
removed_api: "sdk_library/public/myjavalib-removed.txt",
sdk_version: "current",
},
system: {
jars: ["sdk_library/system/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/system/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/system/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/system/myjavalib.txt",
removed_api: "sdk_library/system/myjavalib-removed.txt",
sdk_version: "system_current",
@@ -1350,14 +1208,14 @@
shared_library: true,
public: {
jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/public/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/public/myjavalib.txt",
removed_api: "sdk_library/public/myjavalib-removed.txt",
sdk_version: "current",
},
system: {
jars: ["sdk_library/system/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/system/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/system/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/system/myjavalib.txt",
removed_api: "sdk_library/system/myjavalib-removed.txt",
sdk_version: "system_current",
@@ -1421,21 +1279,21 @@
shared_library: true,
public: {
jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/public/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/public/myjavalib.txt",
removed_api: "sdk_library/public/myjavalib-removed.txt",
sdk_version: "current",
},
system: {
jars: ["sdk_library/system/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/system/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/system/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/system/myjavalib.txt",
removed_api: "sdk_library/system/myjavalib-removed.txt",
sdk_version: "system_current",
},
module_lib: {
jars: ["sdk_library/module-lib/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/module-lib/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/module-lib/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/module-lib/myjavalib.txt",
removed_api: "sdk_library/module-lib/myjavalib-removed.txt",
sdk_version: "module_current",
@@ -1450,21 +1308,21 @@
shared_library: true,
public: {
jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/public/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/public/myjavalib.txt",
removed_api: "sdk_library/public/myjavalib-removed.txt",
sdk_version: "current",
},
system: {
jars: ["sdk_library/system/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/system/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/system/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/system/myjavalib.txt",
removed_api: "sdk_library/system/myjavalib-removed.txt",
sdk_version: "system_current",
},
module_lib: {
jars: ["sdk_library/module-lib/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/module-lib/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/module-lib/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/module-lib/myjavalib.txt",
removed_api: "sdk_library/module-lib/myjavalib-removed.txt",
sdk_version: "module_current",
@@ -1529,14 +1387,14 @@
shared_library: true,
public: {
jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/public/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/public/myjavalib.txt",
removed_api: "sdk_library/public/myjavalib-removed.txt",
sdk_version: "current",
},
system_server: {
jars: ["sdk_library/system-server/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/system-server/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/system-server/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/system-server/myjavalib.txt",
removed_api: "sdk_library/system-server/myjavalib-removed.txt",
sdk_version: "system_server_current",
@@ -1551,14 +1409,14 @@
shared_library: true,
public: {
jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/public/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/public/myjavalib.txt",
removed_api: "sdk_library/public/myjavalib-removed.txt",
sdk_version: "current",
},
system_server: {
jars: ["sdk_library/system-server/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/system-server/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/system-server/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/system-server/myjavalib.txt",
removed_api: "sdk_library/system-server/myjavalib-removed.txt",
sdk_version: "system_server_current",
@@ -1618,7 +1476,7 @@
shared_library: true,
public: {
jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/public/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/public/myjavalib.txt",
removed_api: "sdk_library/public/myjavalib-removed.txt",
sdk_version: "current",
@@ -1634,7 +1492,7 @@
shared_library: true,
public: {
jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/public/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/public/myjavalib.txt",
removed_api: "sdk_library/public/myjavalib-removed.txt",
sdk_version: "current",
@@ -1693,7 +1551,7 @@
doctag_files: ["doctags/docs/known_doctags"],
public: {
jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/public/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/public/myjavalib.txt",
removed_api: "sdk_library/public/myjavalib-removed.txt",
sdk_version: "current",
@@ -1708,7 +1566,7 @@
doctag_files: ["doctags/docs/known_doctags"],
public: {
jars: ["sdk_library/public/myjavalib-stubs.jar"],
- stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
+ stub_srcs: ["sdk_library/public/myjavalib_stub_sources/**/*.java"],
current_api: "sdk_library/public/myjavalib.txt",
removed_api: "sdk_library/public/myjavalib-removed.txt",
sdk_version: "current",
diff --git a/sysprop/sysprop_library.go b/sysprop/sysprop_library.go
index edb8b30..1740ba8 100644
--- a/sysprop/sysprop_library.go
+++ b/sysprop/sysprop_library.go
@@ -143,6 +143,9 @@
// Make this module available when building for vendor
Vendor_available *bool
+ // Make this module available when building for product
+ Product_available *bool
+
// list of .sysprop files which defines the properties.
Srcs []string `android:"path"`
@@ -353,6 +356,7 @@
Recovery *bool
Recovery_available *bool
Vendor_available *bool
+ Product_available *bool
Host_supported *bool
Apex_available []string
Min_sdk_version *string
@@ -449,6 +453,7 @@
ccProps.Target.Host.Static_libs = []string{"libbase", "liblog"}
ccProps.Recovery_available = m.properties.Recovery_available
ccProps.Vendor_available = m.properties.Vendor_available
+ ccProps.Product_available = m.properties.Product_available
ccProps.Host_supported = m.properties.Host_supported
ccProps.Apex_available = m.ApexProperties.Apex_available
ccProps.Min_sdk_version = m.properties.Cpp.Min_sdk_version
diff --git a/ui/build/bazel.go b/ui/build/bazel.go
index c5702c0..ca9ad43 100644
--- a/ui/build/bazel.go
+++ b/ui/build/bazel.go
@@ -15,12 +15,16 @@
package build
import (
+ "io/ioutil"
+ "os"
"path/filepath"
"strings"
)
func runBazel(ctx Context, config Config) {
// "droid" is the default ninja target.
+ // TODO(b/160568333): stop hardcoding 'droid' to support building any
+ // Ninja target.
outputGroups := "droid"
if len(config.ninjaArgs) > 0 {
// At this stage, the residue slice of args passed to ninja
@@ -30,19 +34,24 @@
}
bazelExecutable := filepath.Join("tools", "bazel")
- args := []string{
- "build",
- "--verbose_failures",
- "--show_progress_rate_limit=0.05",
- "--color=yes",
- "--curses=yes",
- "--show_timestamps",
- "--announce_rc",
- "--output_groups=" + outputGroups,
- "//:" + config.TargetProduct() + "-" + config.TargetBuildVariant(),
+ 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)...)
}
- cmd := Command(ctx, config, "bazel", bazelExecutable, args...)
+ cmd.Args = append(cmd.Args,
+ "build",
+ "--output_groups="+outputGroups,
+ )
+
+ if extra_build_args, ok := cmd.Environment.Get("BAZEL_BUILD_ARGS"); ok {
+ cmd.Args = append(cmd.Args, strings.Fields(extra_build_args)...)
+ }
+
+ cmd.Args = append(cmd.Args,
+ "//:"+config.TargetProduct()+"-"+config.TargetBuildVariant(),
+ )
cmd.Environment.Set("DIST_DIR", config.DistDir())
cmd.Environment.Set("SHELL", "/bin/bash")
@@ -51,4 +60,61 @@
cmd.Dir = filepath.Join(config.OutDir(), "..")
ctx.Status.Status("Starting Bazel..")
cmd.RunAndStreamOrFatal()
+
+ // 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)...)
+ }
+
+ infoCmd.Args = append(infoCmd.Args,
+ "info",
+ "output_path",
+ )
+
+ infoCmd.Environment.Set("DIST_DIR", config.DistDir())
+ infoCmd.Environment.Set("SHELL", "/bin/bash")
+ infoCmd.Dir = filepath.Join(config.OutDir(), "..")
+ ctx.Status.Status("Getting Bazel Info..")
+ outputBasePath := string(infoCmd.OutputOrFatal())
+ // TODO: Don't hardcode out/ as the bazel output directory. This is
+ // currently hardcoded as ninja_build.output_root.
+ bazelNinjaBuildOutputRoot := filepath.Join(outputBasePath, "..", "out")
+
+ symlinkOutdir(ctx, config, bazelNinjaBuildOutputRoot, ".")
+}
+
+// For all files F recursively under rootPath/relativePath, creates symlinks
+// such that OutDir/F resolves to rootPath/F via symlinks.
+func symlinkOutdir(ctx Context, config Config, rootPath string, relativePath string) {
+ destDir := filepath.Join(rootPath, relativePath)
+ os.MkdirAll(destDir, 0755)
+ files, err := ioutil.ReadDir(destDir)
+ if err != nil {
+ ctx.Fatal(err)
+ }
+ for _, f := range files {
+ destPath := filepath.Join(destDir, f.Name())
+ srcPath := filepath.Join(config.OutDir(), relativePath, f.Name())
+ if statResult, err := os.Stat(srcPath); err == nil {
+ if statResult.Mode().IsDir() && f.IsDir() {
+ // Directory under OutDir already exists, so recurse on its contents.
+ symlinkOutdir(ctx, config, rootPath, filepath.Join(relativePath, f.Name()))
+ } else if !statResult.Mode().IsDir() && !f.IsDir() {
+ // File exists both in source and destination, and it's not a directory
+ // in either location. Do nothing.
+ // This can arise for files which are generated under OutDir outside of
+ // soong_build, such as .bootstrap files.
+ } else {
+ // File is a directory in one location but not the other. Raise an error.
+ ctx.Fatalf("Could not link %s to %s due to conflict", srcPath, destPath)
+ }
+ } else if os.IsNotExist(err) {
+ // Create symlink srcPath -> fullDestPath.
+ os.Symlink(destPath, srcPath)
+ } else {
+ ctx.Fatalf("Unable to stat %s: %s", srcPath, err)
+ }
+ }
}
diff --git a/ui/build/exec.go b/ui/build/exec.go
index 053bbae..8f92269 100644
--- a/ui/build/exec.go
+++ b/ui/build/exec.go
@@ -66,8 +66,11 @@
}
func (c *Cmd) report() {
- if c.Cmd.ProcessState != nil {
- rusage := c.Cmd.ProcessState.SysUsage().(*syscall.Rusage)
+ if state := c.Cmd.ProcessState; state != nil {
+ if c.ctx.Metrics != nil {
+ c.ctx.Metrics.EventTracer.AddProcResInfo(c.name, state)
+ }
+ rusage := state.SysUsage().(*syscall.Rusage)
c.ctx.Verbosef("%q finished with exit code %d (%s real, %s user, %s system, %dMB maxrss)",
c.name, c.Cmd.ProcessState.ExitCode(),
time.Since(c.started).Round(time.Millisecond),
diff --git a/ui/metrics/event.go b/ui/metrics/event.go
index 5a62847..6becfd1 100644
--- a/ui/metrics/event.go
+++ b/ui/metrics/event.go
@@ -15,6 +15,8 @@
package metrics
import (
+ "os"
+ "syscall"
"time"
"android/soong/ui/metrics/metrics_proto"
@@ -31,11 +33,15 @@
// the time that the event started to occur.
start time.Time
+
+ // The list of process resource information that was executed
+ procResInfo []*soong_metrics_proto.ProcessResourceInfo
}
type EventTracer interface {
Begin(name, desc string, thread tracer.Thread)
End(thread tracer.Thread) soong_metrics_proto.PerfInfo
+ AddProcResInfo(string, *os.ProcessState)
}
type eventTracerImpl struct {
@@ -48,6 +54,34 @@
return time.Now()
}
+// AddProcResInfo adds information on an executed process such as max resident set memory
+// and the number of voluntary context switches.
+func (t *eventTracerImpl) AddProcResInfo(name string, state *os.ProcessState) {
+ if len(t.activeEvents) < 1 {
+ return
+ }
+
+ rusage := state.SysUsage().(*syscall.Rusage)
+ // The implementation of the metrics system is a stacked based system. The steps of the
+ // build system in the UI layer is sequential so the Begin function is invoked when a
+ // function (or scoped code) is invoked. That is translated to a new event which is added
+ // at the end of the activeEvents array. When the invoking function is completed, End is
+ // invoked which is a pop operation from activeEvents.
+ curEvent := &t.activeEvents[len(t.activeEvents)-1]
+ curEvent.procResInfo = append(curEvent.procResInfo, &soong_metrics_proto.ProcessResourceInfo{
+ Name: proto.String(name),
+ UserTimeMicros: proto.Uint64(uint64(rusage.Utime.Usec)),
+ SystemTimeMicros: proto.Uint64(uint64(rusage.Stime.Usec)),
+ MinorPageFaults: proto.Uint64(uint64(rusage.Minflt)),
+ MajorPageFaults: proto.Uint64(uint64(rusage.Majflt)),
+ // ru_inblock and ru_oublock are measured in blocks of 512 bytes.
+ IoInputKb: proto.Uint64(uint64(rusage.Inblock / 2)),
+ IoOutputKb: proto.Uint64(uint64(rusage.Oublock / 2)),
+ VoluntaryContextSwitches: proto.Uint64(uint64(rusage.Nvcsw)),
+ InvoluntaryContextSwitches: proto.Uint64(uint64(rusage.Nivcsw)),
+ })
+}
+
func (t *eventTracerImpl) Begin(name, desc string, _ tracer.Thread) {
t.activeEvents = append(t.activeEvents, event{name: name, desc: desc, start: _now()})
}
@@ -61,9 +95,10 @@
realTime := uint64(_now().Sub(lastEvent.start).Nanoseconds())
return soong_metrics_proto.PerfInfo{
- Desc: proto.String(lastEvent.desc),
- Name: proto.String(lastEvent.name),
- StartTime: proto.Uint64(uint64(lastEvent.start.UnixNano())),
- RealTime: proto.Uint64(realTime),
+ Desc: proto.String(lastEvent.desc),
+ Name: proto.String(lastEvent.name),
+ StartTime: proto.Uint64(uint64(lastEvent.start.UnixNano())),
+ RealTime: proto.Uint64(realTime),
+ ProcessesResourceInfo: lastEvent.procResInfo,
}
}