Merge "Support env based compiler flags."
diff --git a/android/bazel_handler.go b/android/bazel_handler.go
index d132d43..e9c97d0 100644
--- a/android/bazel_handler.go
+++ b/android/bazel_handler.go
@@ -1204,7 +1204,7 @@
}
}
osName := key.configKey.osType.Name
- if len(osName) == 0 || osName == "common_os" || osName == "linux_glibc" {
+ if len(osName) == 0 || osName == "common_os" || osName == "linux_glibc" || osName == "linux_musl" {
// Use host OS, which is currently hardcoded to be linux.
osName = "linux"
}
diff --git a/android/config.go b/android/config.go
index 9c1a484..4ebb00f 100644
--- a/android/config.go
+++ b/android/config.go
@@ -595,10 +595,6 @@
fmt.Fprintln(os.Stderr, "unsupported env var GLOBAL_THINLTO for Bazel: falling back to non-mixed build")
return false
}
- if c.IsEnvTrue("CLANG_COVERAGE") {
- fmt.Fprintln(os.Stderr, "unsupported env var CLANG_COVERAGE for Bazel: falling back to non-mixed build")
- return false
- }
if len(c.productVariables.SanitizeHost) > 0 {
fmt.Fprintln(os.Stderr, "unsupported product var SanitizeHost for Bazel: falling back to non-mixed build")
return false
diff --git a/android/soong_config_modules.go b/android/soong_config_modules.go
index c0f4523..c1e92b8 100644
--- a/android/soong_config_modules.go
+++ b/android/soong_config_modules.go
@@ -382,15 +382,15 @@
defer r.Close()
mtDef, errs := soongconfig.Parse(r, from)
- if ctx.Config().BuildMode == Bp2build {
- ctx.Config().Bp2buildSoongConfigDefinitions.AddVars(*mtDef)
- }
-
if len(errs) > 0 {
reportErrors(ctx, from, errs...)
return (map[string]blueprint.ModuleFactory)(nil)
}
+ if ctx.Config().BuildMode == Bp2build {
+ ctx.Config().Bp2buildSoongConfigDefinitions.AddVars(*mtDef)
+ }
+
globalModuleTypes := ctx.moduleFactories()
factories := make(map[string]blueprint.ModuleFactory)
diff --git a/bazel/configurability.go b/bazel/configurability.go
index 3f4cc73..2b8753b 100644
--- a/bazel/configurability.go
+++ b/bazel/configurability.go
@@ -157,7 +157,7 @@
platformOsMap = map[string]string{
OsAndroid: "//build/bazel/platforms/os:android",
osDarwin: "//build/bazel/platforms/os:darwin",
- osLinux: "//build/bazel/platforms/os:linux",
+ osLinux: "//build/bazel/platforms/os:linux_glibc",
osLinuxMusl: "//build/bazel/platforms/os:linux_musl",
osLinuxBionic: "//build/bazel/platforms/os:linux_bionic",
osWindows: "//build/bazel/platforms/os:windows",
@@ -204,7 +204,7 @@
AndroidAndInApex: "//build/bazel/rules/apex:android-in_apex",
AndroidAndNonApex: "//build/bazel/rules/apex:android-non_apex",
osDarwin: "//build/bazel/platforms/os:darwin",
- osLinux: "//build/bazel/platforms/os:linux",
+ osLinux: "//build/bazel/platforms/os:linux_glibc",
osLinuxMusl: "//build/bazel/platforms/os:linux_musl",
osLinuxBionic: "//build/bazel/platforms/os:linux_bionic",
osWindows: "//build/bazel/platforms/os:windows",
diff --git a/bp2build/build_conversion_test.go b/bp2build/build_conversion_test.go
index c40c45a..8433f52 100644
--- a/bp2build/build_conversion_test.go
+++ b/bp2build/build_conversion_test.go
@@ -426,13 +426,6 @@
"darwin.txt",
"not_windows.txt",
],
- "//build/bazel/platforms/os:linux": [
- "host.txt",
- "linux.txt",
- "glibc.txt",
- "linux_glibc.txt",
- "not_windows.txt",
- ],
"//build/bazel/platforms/os:linux_bionic": [
"host.txt",
"linux.txt",
@@ -440,6 +433,13 @@
"linux_bionic.txt",
"not_windows.txt",
],
+ "//build/bazel/platforms/os:linux_glibc": [
+ "host.txt",
+ "linux.txt",
+ "glibc.txt",
+ "linux_glibc.txt",
+ "not_windows.txt",
+ ],
"//build/bazel/platforms/os:linux_musl": [
"host.txt",
"linux.txt",
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 728225a..cfd1a8c 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -149,8 +149,8 @@
"android.cpp",
],
"//build/bazel/platforms/os:darwin": ["darwin.cpp"],
- "//build/bazel/platforms/os:linux": ["linux.cpp"],
"//build/bazel/platforms/os:linux_bionic": ["bionic.cpp"],
+ "//build/bazel/platforms/os:linux_glibc": ["linux.cpp"],
"//conditions:default": [],
})`,
"sdk_version": `"current"`,
@@ -1409,7 +1409,6 @@
"linkopts": true,
"strip": true,
"inject_bssl_hash": true,
- "has_stubs": true,
"stubs_symbol_file": true,
"use_version_lib": true,
}
@@ -1928,14 +1927,14 @@
"android.cpp",
],
"//build/bazel/platforms/os:darwin": ["darwin.cpp"],
- "//build/bazel/platforms/os:linux": [
- "linux.cpp",
- "linux_glibc.cpp",
- ],
"//build/bazel/platforms/os:linux_bionic": [
"linux.cpp",
"bionic.cpp",
],
+ "//build/bazel/platforms/os:linux_glibc": [
+ "linux.cpp",
+ "linux_glibc.cpp",
+ ],
"//build/bazel/platforms/os:linux_musl": [
"linux.cpp",
"linux_musl.cpp",
@@ -2712,7 +2711,6 @@
func TestCcLibraryStubs(t *testing.T) {
expectedBazelTargets := makeCcLibraryTargets("a", AttrNameToString{
- "has_stubs": `True`,
"stubs_symbol_file": `"a.map.txt"`,
})
expectedBazelTargets = append(expectedBazelTargets, makeCcStubSuiteTargets("a", AttrNameToString{
@@ -3012,15 +3010,15 @@
ExpectedBazelTargets: makeCcLibraryTargets("foolib", AttrNameToString{
"implementation_dynamic_deps": `select({
"//build/bazel/platforms/os:darwin": [":bazlib"],
- "//build/bazel/platforms/os:linux": [":bazlib"],
"//build/bazel/platforms/os:linux_bionic": [":bazlib"],
+ "//build/bazel/platforms/os:linux_glibc": [":bazlib"],
"//build/bazel/platforms/os:linux_musl": [":bazlib"],
"//build/bazel/platforms/os:windows": [":bazlib"],
"//conditions:default": [],
}) + select({
"//build/bazel/platforms/os:darwin": [":quxlib"],
- "//build/bazel/platforms/os:linux": [":quxlib"],
"//build/bazel/platforms/os:linux_bionic": [":quxlib"],
+ "//build/bazel/platforms/os:linux_glibc": [":quxlib"],
"//build/bazel/platforms/os:linux_musl": [":quxlib"],
"//build/bazel/platforms/os:windows": [":quxlib"],
"//build/bazel/rules/apex:android-in_apex": [
diff --git a/bp2build/cc_library_headers_conversion_test.go b/bp2build/cc_library_headers_conversion_test.go
index 686c9d5..32500a0 100644
--- a/bp2build/cc_library_headers_conversion_test.go
+++ b/bp2build/cc_library_headers_conversion_test.go
@@ -250,8 +250,8 @@
"deps": `[":base-lib"] + select({
"//build/bazel/platforms/os:android": [":android-lib"],
"//build/bazel/platforms/os:darwin": [":darwin-lib"],
- "//build/bazel/platforms/os:linux": [":linux-lib"],
"//build/bazel/platforms/os:linux_bionic": [":linux_bionic-lib"],
+ "//build/bazel/platforms/os:linux_glibc": [":linux-lib"],
"//build/bazel/platforms/os:windows": [":windows-lib"],
"//conditions:default": [],
})`,
@@ -343,7 +343,7 @@
"export_system_includes": `select({
"//build/bazel/platforms/os:android": ["android_include_dir"],
"//build/bazel/platforms/os:darwin": ["darwin_include_dir"],
- "//build/bazel/platforms/os:linux": ["linux_include_dir"],
+ "//build/bazel/platforms/os:linux_glibc": ["linux_include_dir"],
"//conditions:default": [],
}) + select({
"//build/bazel/platforms/arch:arm": ["arm_include_dir"],
diff --git a/bp2build/cc_library_shared_conversion_test.go b/bp2build/cc_library_shared_conversion_test.go
index 7e1d111..14b6f0d 100644
--- a/bp2build/cc_library_shared_conversion_test.go
+++ b/bp2build/cc_library_shared_conversion_test.go
@@ -543,7 +543,6 @@
]`,
}),
MakeBazelTarget("cc_library_shared", "a", AttrNameToString{
- "has_stubs": `True`,
"stubs_symbol_file": `"a.map.txt"`,
}),
},
diff --git a/bp2build/cc_test_conversion_test.go b/bp2build/cc_test_conversion_test.go
index b20f6ff..20adddb 100644
--- a/bp2build/cc_test_conversion_test.go
+++ b/bp2build/cc_test_conversion_test.go
@@ -97,8 +97,8 @@
]`,
"deps": `select({
"//build/bazel/platforms/os:darwin": [":hostlib"],
- "//build/bazel/platforms/os:linux": [":hostlib"],
"//build/bazel/platforms/os:linux_bionic": [":hostlib"],
+ "//build/bazel/platforms/os:linux_glibc": [":hostlib"],
"//build/bazel/platforms/os:linux_musl": [":hostlib"],
"//build/bazel/platforms/os:windows": [":hostlib"],
"//conditions:default": [],
@@ -115,8 +115,8 @@
"linux.cpp",
"android.cpp",
],
- "//build/bazel/platforms/os:linux": ["linux.cpp"],
"//build/bazel/platforms/os:linux_bionic": ["linux.cpp"],
+ "//build/bazel/platforms/os:linux_glibc": ["linux.cpp"],
"//build/bazel/platforms/os:linux_musl": ["linux.cpp"],
"//conditions:default": [],
})`,
diff --git a/bp2build/java_import_conversion_test.go b/bp2build/java_import_conversion_test.go
index ac7dfff..a5c01cb 100644
--- a/bp2build/java_import_conversion_test.go
+++ b/bp2build/java_import_conversion_test.go
@@ -81,7 +81,7 @@
MakeBazelTarget("java_import", "example_import", AttrNameToString{
"jars": `select({
"//build/bazel/platforms/os:android": ["android.jar"],
- "//build/bazel/platforms/os:linux": ["linux.jar"],
+ "//build/bazel/platforms/os:linux_glibc": ["linux.jar"],
"//conditions:default": [],
})`,
}),
diff --git a/bp2build/soong_config_module_type_conversion_test.go b/bp2build/soong_config_module_type_conversion_test.go
index a94b2b9..7029b93 100644
--- a/bp2build/soong_config_module_type_conversion_test.go
+++ b/bp2build/soong_config_module_type_conversion_test.go
@@ -17,6 +17,7 @@
import (
"android/soong/android"
"android/soong/cc"
+ "fmt"
"testing"
)
@@ -36,6 +37,29 @@
ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
}
+func TestErrorInBpFileDoesNotPanic(t *testing.T) {
+ bp := `
+soong_config_module_type {
+ name: "library_linking_strategy_cc_defaults",
+ module_type: "cc_defaults",
+ config_namespace: "ANDROID",
+ variables: ["library_linking_strategy"],
+ properties: [
+ "shared_libs",
+ "static_libs",
+ ],
+}
+`
+
+ runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
+ Description: "soong config variables - generates selects for library_linking_strategy",
+ ModuleTypeUnderTest: "cc_binary",
+ ModuleTypeUnderTestFactory: cc.BinaryFactory,
+ Blueprint: bp,
+ ExpectedErr: fmt.Errorf(`unknown variable "library_linking_strategy" in module type "library_linking_strategy_cc_defaults`),
+ })
+}
+
func TestSoongConfigModuleType(t *testing.T) {
bp := `
soong_config_module_type {
diff --git a/cc/library.go b/cc/library.go
index 8afc2fe..5760071 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -424,8 +424,6 @@
}
if compilerAttrs.stubsSymbolFile != nil && len(compilerAttrs.stubsVersions.Value) > 0 {
- hasStubs := true
- sharedTargetAttrs.Has_stubs.SetValue(&hasStubs)
sharedTargetAttrs.Stubs_symbol_file = compilerAttrs.stubsSymbolFile
}
@@ -2939,8 +2937,6 @@
Fdo_profile: compilerAttrs.fdoProfile,
}
if compilerAttrs.stubsSymbolFile != nil && len(compilerAttrs.stubsVersions.Value) > 0 {
- hasStubs := true
- sharedLibAttrs.Has_stubs.SetValue(&hasStubs)
sharedLibAttrs.Stubs_symbol_file = compilerAttrs.stubsSymbolFile
}
attrs = sharedLibAttrs
@@ -3026,7 +3022,6 @@
Features bazel.StringListAttribute
- Has_stubs bazel.BoolAttribute
Stubs_symbol_file *string
Inject_bssl_hash bazel.BoolAttribute
diff --git a/cc/sanitize.go b/cc/sanitize.go
index eba709b..8e2d161 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -630,15 +630,8 @@
// Also disable CFI for VNDK variants of components
if ctx.isVndk() && ctx.useVndk() {
- if ctx.static() {
- // Cfi variant for static vndk should be captured as vendor snapshot,
- // so don't strictly disable Cfi.
- s.Cfi = nil
- s.Diag.Cfi = nil
- } else {
- s.Cfi = nil
- s.Diag.Cfi = nil
- }
+ s.Cfi = nil
+ s.Diag.Cfi = nil
}
// HWASan ramdisk (which is built from recovery) goes over some bootloader limit.
@@ -1067,6 +1060,11 @@
// as vendor snapshot. Such modules must create both cfi and non-cfi variants,
// except for ones which explicitly disable cfi.
func needsCfiForVendorSnapshot(mctx android.BaseModuleContext) bool {
+ if inList("hwaddress", mctx.Config().SanitizeDevice()) {
+ // cfi will not be built if SANITIZE_TARGET=hwaddress is set
+ return false
+ }
+
if snapshot.IsVendorProprietaryModule(mctx) {
return false
}
@@ -1163,10 +1161,12 @@
//TODO: When Rust modules have vendor support, enable this path for PlatformSanitizeable
// Check if it's a snapshot module supporting sanitizer
- if ss, ok := c.linker.(snapshotSanitizer); ok && ss.isSanitizerAvailable(s.sanitizer) {
- return []string{"", s.sanitizer.variationName()}
- } else {
- return []string{""}
+ if ss, ok := c.linker.(snapshotSanitizer); ok {
+ if ss.isSanitizerAvailable(s.sanitizer) {
+ return []string{"", s.sanitizer.variationName()}
+ } else {
+ return []string{""}
+ }
}
}
diff --git a/cc/snapshot_prebuilt.go b/cc/snapshot_prebuilt.go
index 570300b..32878ca 100644
--- a/cc/snapshot_prebuilt.go
+++ b/cc/snapshot_prebuilt.go
@@ -801,6 +801,10 @@
prebuilt.Init(module, VendorSnapshotImageSingleton, snapshotObjectSuffix)
module.AddProperties(&prebuilt.properties)
+
+ // vendor_snapshot_object module does not provide sanitizer variants
+ module.sanitize.Properties.Sanitize.Never = BoolPtr(true)
+
return module.Init()
}
diff --git a/cc/vendor_snapshot.go b/cc/vendor_snapshot.go
index 2dcf26e..9b12bfa 100644
--- a/cc/vendor_snapshot.go
+++ b/cc/vendor_snapshot.go
@@ -93,17 +93,18 @@
// Libraries
if sanitizable, ok := m.(PlatformSanitizeable); ok && sanitizable.IsSnapshotLibrary() {
if sanitizable.SanitizePropDefined() {
- // scs and hwasan export both sanitized and unsanitized variants for static and header
- // Always use unsanitized variants of them.
- for _, t := range []SanitizerType{scs, Hwasan} {
- if !sanitizable.Shared() && sanitizable.IsSanitizerEnabled(t) {
- return false
- }
+ // scs exports both sanitized and unsanitized variants for static and header
+ // Always use unsanitized variant of it.
+ if !sanitizable.Shared() && sanitizable.IsSanitizerEnabled(scs) {
+ return false
}
- // cfi also exports both variants. But for static, we capture both.
+ // cfi and hwasan also export both variants. But for static, we capture both.
// This is because cfi static libraries can't be linked from non-cfi modules,
- // and vice versa. This isn't the case for scs and hwasan sanitizers.
- if !sanitizable.Static() && !sanitizable.Shared() && sanitizable.IsSanitizerEnabled(cfi) {
+ // and vice versa.
+ // hwasan is captured as well to support hwasan build.
+ if !sanitizable.Static() &&
+ !sanitizable.Shared() &&
+ (sanitizable.IsSanitizerEnabled(cfi) || sanitizable.IsSanitizerEnabled(Hwasan)) {
return false
}
}
@@ -303,14 +304,22 @@
libPath := m.OutputFile().Path()
stem = libPath.Base()
if sanitizable, ok := m.(PlatformSanitizeable); ok {
- if (sanitizable.Static() || sanitizable.Rlib()) && sanitizable.SanitizePropDefined() && sanitizable.IsSanitizerEnabled(cfi) {
- // both cfi and non-cfi variant for static libraries can exist.
- // attach .cfi to distinguish between cfi and non-cfi.
- // e.g. libbase.a -> libbase.cfi.a
- ext := filepath.Ext(stem)
- stem = strings.TrimSuffix(stem, ext) + ".cfi" + ext
- prop.Sanitize = "cfi"
- prop.ModuleName += ".cfi"
+ if (sanitizable.Static() || sanitizable.Rlib()) && sanitizable.SanitizePropDefined() {
+ if sanitizable.IsSanitizerEnabled(cfi) {
+ // both cfi and non-cfi variant for static libraries can exist.
+ // attach .cfi to distinguish between cfi and non-cfi.
+ // e.g. libbase.a -> libbase.cfi.a
+ ext := filepath.Ext(stem)
+ stem = strings.TrimSuffix(stem, ext) + ".cfi" + ext
+ prop.Sanitize = "cfi"
+ prop.ModuleName += ".cfi"
+ } else if sanitizable.IsSanitizerEnabled(Hwasan) {
+ // Same for the hwasan
+ ext := filepath.Ext(stem)
+ stem = strings.TrimSuffix(stem, ext) + ".hwasan" + ext
+ prop.Sanitize = "hwasan"
+ prop.ModuleName += ".hwasan"
+ }
}
}
snapshotLibOut := filepath.Join(snapshotArchDir, targetArch, libType, stem)
diff --git a/cc/vendor_snapshot_test.go b/cc/vendor_snapshot_test.go
index 79405e9..619500e 100644
--- a/cc/vendor_snapshot_test.go
+++ b/cc/vendor_snapshot_test.go
@@ -1050,6 +1050,12 @@
"libsnapshot",
"note_memtag_heap_sync",
],
+ objects: [
+ "snapshot_object",
+ ],
+ vndk_libs: [
+ "libclang_rt.hwasan",
+ ],
},
},
}
@@ -1084,6 +1090,35 @@
},
}
+ vndk_prebuilt_shared {
+ name: "libclang_rt.hwasan",
+ version: "28",
+ target_arch: "arm64",
+ vendor_available: true,
+ product_available: true,
+ vndk: {
+ enabled: true,
+ },
+ arch: {
+ arm64: {
+ srcs: ["libclang_rt.hwasan.so"],
+ },
+ },
+ }
+
+ vendor_snapshot_object {
+ name: "snapshot_object",
+ vendor: true,
+ target_arch: "arm64",
+ version: "28",
+ arch: {
+ arm64: {
+ src: "snapshot_object.o",
+ },
+ },
+ stl: "none",
+ }
+
cc_test {
name: "vstest",
gtest: false,
@@ -1100,15 +1135,18 @@
mockFS := map[string][]byte{
"vendor/Android.bp": []byte(bp),
"vendor/libc++demangle.a": nil,
+ "vendor/libclang_rt.hwasan.so": nil,
"vendor/libsnapshot.a": nil,
"vendor/libsnapshot.cfi.a": nil,
"vendor/libsnapshot.hwasan.a": nil,
"vendor/note_memtag_heap_sync.a": nil,
+ "vendor/snapshot_object.o": nil,
}
config := TestConfig(t.TempDir(), android.Android, nil, "", mockFS)
config.TestProductVariables.DeviceVndkVersion = StringPtr("28")
config.TestProductVariables.Platform_vndk_version = StringPtr("29")
+ config.TestProductVariables.SanitizeDevice = []string{"hwaddress"}
ctx := testCcWithConfig(t, config)
// Check non-cfi, cfi and hwasan variant.
@@ -1130,6 +1168,11 @@
if !staticHwasanCfiModule.HiddenFromMake() || !staticHwasanCfiModule.PreventInstall() {
t.Errorf("Hwasan and Cfi cannot enabled at the same time.")
}
+
+ snapshotObjModule := ctx.ModuleForTests("snapshot_object.vendor_object.28.arm64", "android_vendor.28_arm64_armv8-a").Module()
+ snapshotObjMkEntries := android.AndroidMkEntriesForTest(t, ctx, snapshotObjModule)
+ // snapshot object must not add ".hwasan" suffix
+ assertString(t, snapshotObjMkEntries[0].EntryMap["LOCAL_MODULE"][0], "snapshot_object")
}
func TestVendorSnapshotExclude(t *testing.T) {
diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go
index baad58e..b0660df 100644
--- a/etc/prebuilt_etc.go
+++ b/etc/prebuilt_etc.go
@@ -54,6 +54,7 @@
func RegisterPrebuiltEtcBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
ctx.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory)
+ ctx.RegisterModuleType("prebuilt_etc_cacerts", PrebuiltEtcCaCertsFactory)
ctx.RegisterModuleType("prebuilt_root", PrebuiltRootFactory)
ctx.RegisterModuleType("prebuilt_root_host", PrebuiltRootHostFactory)
ctx.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
@@ -455,6 +456,17 @@
return module
}
+// prebuilt_etc_host is for a host prebuilt artifact that is installed in
+// <partition>/etc/<sub_dir> directory.
+func PrebuiltEtcCaCertsFactory() android.Module {
+ module := &PrebuiltEtc{}
+ InitPrebuiltEtcModule(module, "cacerts")
+ // This module is device-only
+ android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
+ android.InitBazelModule(module)
+ return module
+}
+
// prebuilt_root is for a prebuilt artifact that is installed in
// <partition>/ directory. Can't have any sub directories.
func PrebuiltRootFactory() android.Module {
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index 1365d4a..e123f24 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -72,6 +72,9 @@
// Hash and signing algorithm for avbtool. Default is SHA256_RSA4096.
Avb_algorithm *string
+ // Hash and signing algorithm for avbtool. Default is SHA256_RSA4096.
+ Avb_hash_algorithm *string
+
// Name of the partition stored in vbmeta desc. Defaults to the name of this module.
Partition_name *string
@@ -333,7 +336,11 @@
addStr("avb_algorithm", algorithm)
key := android.PathForModuleSrc(ctx, proptools.String(f.properties.Avb_private_key))
addPath("avb_key_path", key)
- addStr("avb_add_hashtree_footer_args", "--do_not_generate_fec")
+ avb_add_hashtree_footer_args := "--do_not_generate_fec"
+ if hashAlgorithm := proptools.String(f.properties.Avb_hash_algorithm); hashAlgorithm != "" {
+ avb_add_hashtree_footer_args += " --hash_algorithm " + hashAlgorithm
+ }
+ addStr("avb_add_hashtree_footer_args", avb_add_hashtree_footer_args)
partitionName := proptools.StringDefault(f.properties.Partition_name, f.Name())
addStr("partition_name", partitionName)
addStr("avb_salt", f.salt())
diff --git a/ui/metrics/bazel_metrics_proto/bazel_metrics.pb.go b/ui/metrics/bazel_metrics_proto/bazel_metrics.pb.go
new file mode 100644
index 0000000..760b592
--- /dev/null
+++ b/ui/metrics/bazel_metrics_proto/bazel_metrics.pb.go
@@ -0,0 +1,267 @@
+// Copyright 2022 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.
+
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// protoc-gen-go v1.28.0
+// protoc v3.21.7
+// source: bazel_metrics.proto
+
+package bazel_metrics_proto
+
+import (
+ protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+ protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+ reflect "reflect"
+ sync "sync"
+)
+
+const (
+ // Verify that this generated code is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
+ // Verify that runtime/protoimpl is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
+)
+
+type BazelMetrics struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ PhaseTimings []*PhaseTiming `protobuf:"bytes,1,rep,name=phase_timings,json=phaseTimings,proto3" json:"phase_timings,omitempty"`
+ Total *int64 `protobuf:"varint,2,opt,name=total,proto3,oneof" json:"total,omitempty"`
+}
+
+func (x *BazelMetrics) Reset() {
+ *x = BazelMetrics{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_bazel_metrics_proto_msgTypes[0]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *BazelMetrics) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*BazelMetrics) ProtoMessage() {}
+
+func (x *BazelMetrics) ProtoReflect() protoreflect.Message {
+ mi := &file_bazel_metrics_proto_msgTypes[0]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use BazelMetrics.ProtoReflect.Descriptor instead.
+func (*BazelMetrics) Descriptor() ([]byte, []int) {
+ return file_bazel_metrics_proto_rawDescGZIP(), []int{0}
+}
+
+func (x *BazelMetrics) GetPhaseTimings() []*PhaseTiming {
+ if x != nil {
+ return x.PhaseTimings
+ }
+ return nil
+}
+
+func (x *BazelMetrics) GetTotal() int64 {
+ if x != nil && x.Total != nil {
+ return *x.Total
+ }
+ return 0
+}
+
+type PhaseTiming struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ // E.g. "execution", "analysis", "launch"
+ PhaseName *string `protobuf:"bytes,1,opt,name=phase_name,json=phaseName,proto3,oneof" json:"phase_name,omitempty"`
+ DurationNanos *int64 `protobuf:"varint,2,opt,name=duration_nanos,json=durationNanos,proto3,oneof" json:"duration_nanos,omitempty"`
+ // What percentage of the build time this phase took
+ PercentageMillis *int32 `protobuf:"varint,3,opt,name=percentage_millis,json=percentageMillis,proto3,oneof" json:"percentage_millis,omitempty"`
+}
+
+func (x *PhaseTiming) Reset() {
+ *x = PhaseTiming{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_bazel_metrics_proto_msgTypes[1]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *PhaseTiming) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*PhaseTiming) ProtoMessage() {}
+
+func (x *PhaseTiming) ProtoReflect() protoreflect.Message {
+ mi := &file_bazel_metrics_proto_msgTypes[1]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use PhaseTiming.ProtoReflect.Descriptor instead.
+func (*PhaseTiming) Descriptor() ([]byte, []int) {
+ return file_bazel_metrics_proto_rawDescGZIP(), []int{1}
+}
+
+func (x *PhaseTiming) GetPhaseName() string {
+ if x != nil && x.PhaseName != nil {
+ return *x.PhaseName
+ }
+ return ""
+}
+
+func (x *PhaseTiming) GetDurationNanos() int64 {
+ if x != nil && x.DurationNanos != nil {
+ return *x.DurationNanos
+ }
+ return 0
+}
+
+func (x *PhaseTiming) GetPercentageMillis() int32 {
+ if x != nil && x.PercentageMillis != nil {
+ return *x.PercentageMillis
+ }
+ return 0
+}
+
+var File_bazel_metrics_proto protoreflect.FileDescriptor
+
+var file_bazel_metrics_proto_rawDesc = []byte{
+ 0x0a, 0x13, 0x62, 0x61, 0x7a, 0x65, 0x6c, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e,
+ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x19, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x5f, 0x62, 0x75, 0x69,
+ 0x6c, 0x64, 0x5f, 0x62, 0x61, 0x7a, 0x65, 0x6c, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73,
+ 0x22, 0x80, 0x01, 0x0a, 0x0c, 0x42, 0x61, 0x7a, 0x65, 0x6c, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63,
+ 0x73, 0x12, 0x4b, 0x0a, 0x0d, 0x70, 0x68, 0x61, 0x73, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x69, 0x6e,
+ 0x67, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x73, 0x6f, 0x6f, 0x6e, 0x67,
+ 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x62, 0x61, 0x7a, 0x65, 0x6c, 0x5f, 0x6d, 0x65, 0x74,
+ 0x72, 0x69, 0x63, 0x73, 0x2e, 0x50, 0x68, 0x61, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x69, 0x6e, 0x67,
+ 0x52, 0x0c, 0x70, 0x68, 0x61, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x19,
+ 0x0a, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x48, 0x00, 0x52,
+ 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x88, 0x01, 0x01, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x74, 0x6f,
+ 0x74, 0x61, 0x6c, 0x22, 0xc7, 0x01, 0x0a, 0x0b, 0x50, 0x68, 0x61, 0x73, 0x65, 0x54, 0x69, 0x6d,
+ 0x69, 0x6e, 0x67, 0x12, 0x22, 0x0a, 0x0a, 0x70, 0x68, 0x61, 0x73, 0x65, 0x5f, 0x6e, 0x61, 0x6d,
+ 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x09, 0x70, 0x68, 0x61, 0x73, 0x65,
+ 0x4e, 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x12, 0x2a, 0x0a, 0x0e, 0x64, 0x75, 0x72, 0x61, 0x74,
+ 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6e, 0x6f, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x48,
+ 0x01, 0x52, 0x0d, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x61, 0x6e, 0x6f, 0x73,
+ 0x88, 0x01, 0x01, 0x12, 0x30, 0x0a, 0x11, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67,
+ 0x65, 0x5f, 0x6d, 0x69, 0x6c, 0x6c, 0x69, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x48, 0x02,
+ 0x52, 0x10, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x4d, 0x69, 0x6c, 0x6c,
+ 0x69, 0x73, 0x88, 0x01, 0x01, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x70, 0x68, 0x61, 0x73, 0x65, 0x5f,
+ 0x6e, 0x61, 0x6d, 0x65, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f,
+ 0x6e, 0x5f, 0x6e, 0x61, 0x6e, 0x6f, 0x73, 0x42, 0x14, 0x0a, 0x12, 0x5f, 0x70, 0x65, 0x72, 0x63,
+ 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x5f, 0x6d, 0x69, 0x6c, 0x6c, 0x69, 0x73, 0x42, 0x2e, 0x5a,
+ 0x2c, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x75,
+ 0x69, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2f, 0x62, 0x61, 0x7a, 0x65, 0x6c, 0x5f,
+ 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70,
+ 0x72, 0x6f, 0x74, 0x6f, 0x33,
+}
+
+var (
+ file_bazel_metrics_proto_rawDescOnce sync.Once
+ file_bazel_metrics_proto_rawDescData = file_bazel_metrics_proto_rawDesc
+)
+
+func file_bazel_metrics_proto_rawDescGZIP() []byte {
+ file_bazel_metrics_proto_rawDescOnce.Do(func() {
+ file_bazel_metrics_proto_rawDescData = protoimpl.X.CompressGZIP(file_bazel_metrics_proto_rawDescData)
+ })
+ return file_bazel_metrics_proto_rawDescData
+}
+
+var file_bazel_metrics_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
+var file_bazel_metrics_proto_goTypes = []interface{}{
+ (*BazelMetrics)(nil), // 0: soong_build_bazel_metrics.BazelMetrics
+ (*PhaseTiming)(nil), // 1: soong_build_bazel_metrics.PhaseTiming
+}
+var file_bazel_metrics_proto_depIdxs = []int32{
+ 1, // 0: soong_build_bazel_metrics.BazelMetrics.phase_timings:type_name -> soong_build_bazel_metrics.PhaseTiming
+ 1, // [1:1] is the sub-list for method output_type
+ 1, // [1:1] is the sub-list for method input_type
+ 1, // [1:1] is the sub-list for extension type_name
+ 1, // [1:1] is the sub-list for extension extendee
+ 0, // [0:1] is the sub-list for field type_name
+}
+
+func init() { file_bazel_metrics_proto_init() }
+func file_bazel_metrics_proto_init() {
+ if File_bazel_metrics_proto != nil {
+ return
+ }
+ if !protoimpl.UnsafeEnabled {
+ file_bazel_metrics_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*BazelMetrics); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_bazel_metrics_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*PhaseTiming); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ }
+ file_bazel_metrics_proto_msgTypes[0].OneofWrappers = []interface{}{}
+ file_bazel_metrics_proto_msgTypes[1].OneofWrappers = []interface{}{}
+ type x struct{}
+ out := protoimpl.TypeBuilder{
+ File: protoimpl.DescBuilder{
+ GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+ RawDescriptor: file_bazel_metrics_proto_rawDesc,
+ NumEnums: 0,
+ NumMessages: 2,
+ NumExtensions: 0,
+ NumServices: 0,
+ },
+ GoTypes: file_bazel_metrics_proto_goTypes,
+ DependencyIndexes: file_bazel_metrics_proto_depIdxs,
+ MessageInfos: file_bazel_metrics_proto_msgTypes,
+ }.Build()
+ File_bazel_metrics_proto = out.File
+ file_bazel_metrics_proto_rawDesc = nil
+ file_bazel_metrics_proto_goTypes = nil
+ file_bazel_metrics_proto_depIdxs = nil
+}
diff --git a/ui/metrics/bazel_metrics_proto/bazel_metrics.proto b/ui/metrics/bazel_metrics_proto/bazel_metrics.proto
new file mode 100644
index 0000000..e78a6b9
--- /dev/null
+++ b/ui/metrics/bazel_metrics_proto/bazel_metrics.proto
@@ -0,0 +1,31 @@
+// Copyright 2022 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.
+
+syntax = "proto3";
+
+package soong_build_bazel_metrics;
+option go_package = "android/soong/ui/metrics/bazel_metrics_proto";
+
+message BazelMetrics {
+ repeated PhaseTiming phase_timings = 1;
+ optional int64 total = 2;
+}
+
+message PhaseTiming {
+ // E.g. "execution", "analysis", "launch"
+ optional string phase_name = 1;
+ optional int64 duration_nanos = 2;
+ // What percentage of the build time this phase took
+ optional int32 percentage_millis = 3;
+}
diff --git a/ui/metrics/bazel_metrics_proto/regen.sh b/ui/metrics/bazel_metrics_proto/regen.sh
new file mode 100755
index 0000000..2cf2bf6
--- /dev/null
+++ b/ui/metrics/bazel_metrics_proto/regen.sh
@@ -0,0 +1,29 @@
+#!/bin/bash -e
+
+# Copyright 2022 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.
+
+# Generates the golang source file of bp2build_metrics.proto protobuf file.
+
+function die() { echo "ERROR: $1" >&2; exit 1; }
+
+readonly error_msg="Maybe you need to run 'lunch aosp_arm-eng && m aprotoc blueprint_tools'?"
+
+if ! hash aprotoc &>/dev/null; then
+ die "could not find aprotoc. ${error_msg}"
+fi
+
+if ! aprotoc --go_out=paths=source_relative:. bazel_metrics.proto; then
+ die "build failed. ${error_msg}"
+fi