Merge "Increase javac heap to 4096M"
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index e703d33..e4760b5 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -119,7 +119,10 @@
"external/icu": Bp2BuildDefaultTrueRecursively,
"external/icu/android_icu4j": Bp2BuildDefaultFalse, // java rules incomplete
"external/icu/icu4j": Bp2BuildDefaultFalse, // java rules incomplete
+ "external/jacoco": Bp2BuildDefaultTrueRecursively,
"external/jarjar": Bp2BuildDefaultTrueRecursively,
+ "external/javassist": Bp2BuildDefaultTrueRecursively,
+ "external/javaparser": Bp2BuildDefaultTrueRecursively,
"external/javapoet": Bp2BuildDefaultTrueRecursively,
"external/jemalloc_new": Bp2BuildDefaultTrueRecursively,
"external/jsoncpp": Bp2BuildDefaultTrueRecursively,
@@ -154,6 +157,7 @@
"external/zopfli": Bp2BuildDefaultTrueRecursively,
"external/zstd": Bp2BuildDefaultTrueRecursively,
+ "frameworks/av": Bp2BuildDefaultTrue,
"frameworks/av/media/codecs": Bp2BuildDefaultTrueRecursively,
"frameworks/av/media/liberror": Bp2BuildDefaultTrueRecursively,
"frameworks/av/services/minijail": Bp2BuildDefaultTrueRecursively,
@@ -177,6 +181,7 @@
"hardware/interfaces/configstore/1.0": Bp2BuildDefaultTrue,
"hardware/interfaces/configstore/1.1": Bp2BuildDefaultTrue,
"hardware/interfaces/configstore/utils": Bp2BuildDefaultTrue,
+ "hardware/interfaces/graphics/allocator/aidl": Bp2BuildDefaultTrue,
"hardware/interfaces/graphics/allocator/2.0": Bp2BuildDefaultTrue,
"hardware/interfaces/graphics/allocator/3.0": Bp2BuildDefaultTrue,
"hardware/interfaces/graphics/allocator/4.0": Bp2BuildDefaultTrue,
@@ -218,6 +223,7 @@
"packages/modules/adb/proto": Bp2BuildDefaultTrueRecursively,
"packages/modules/adb/tls": Bp2BuildDefaultTrueRecursively,
"packages/providers/MediaProvider/tools/dialogs": Bp2BuildDefaultFalse, // TODO(b/242834374)
+ "packages/modules/NeuralNetworks/driver/cache": Bp2BuildDefaultTrueRecursively,
"packages/screensavers/Basic": Bp2BuildDefaultTrue,
"packages/services/Car/tests/SampleRearViewCamera": Bp2BuildDefaultFalse, // TODO(b/242834321)
@@ -277,6 +283,7 @@
"system/timezone/apex": Bp2BuildDefaultTrueRecursively,
"system/timezone/output_data": Bp2BuildDefaultTrueRecursively,
"system/tools/sysprop": Bp2BuildDefaultTrue,
+ "system/tools/aidl/build/tests_bp2build": Bp2BuildDefaultTrue,
"system/unwinding/libunwindstack": Bp2BuildDefaultTrueRecursively,
"tools/apksig": Bp2BuildDefaultTrue,
@@ -298,10 +305,12 @@
// external/bazelbuild-rules_android/... is needed by mixed builds, otherwise mixed builds analysis fails
// e.g. ERROR: Analysis of target '@soong_injection//mixed_builds:buildroot' failed
"external/bazelbuild-rules_android":/* recursive = */ true,
+ "external/bazelbuild-kotlin-rules":/* recursive = */ true,
"external/bazel-skylib":/* recursive = */ true,
"external/guava":/* recursive = */ true,
"external/jsr305":/* recursive = */ true,
"external/protobuf":/* recursive = */ false,
+ "frameworks/base/tools/codegen":/* recursive = */ true,
"frameworks/ex/common":/* recursive = */ true,
"packages/apps/Music":/* recursive = */ true,
@@ -324,6 +333,7 @@
"code_coverage.policy",
"code_coverage.policy.other",
"codec2_soft_exports",
+ "codecs_g711dec",
"com.android.media.swcodec-androidManifest",
"com.android.media.swcodec-ld.config.txt",
"com.android.media.swcodec-mediaswcodec.rc",
@@ -335,6 +345,7 @@
"flatbuffer_headers",
"gemmlowp_headers",
"gl_headers",
+ "libaidlcommonsupport",
"libandroid_runtime_lazy",
"libandroid_runtime_vm_headers",
"libaudioclient_aidl_conversion_util",
@@ -343,6 +354,7 @@
"libbinder_aidl",
"libbinder_headers",
"libbinder_headers_platform_shared",
+ "libbinderthreadstateutils",
"libbluetooth-types-header",
"libbufferhub_headers",
"libcodec2",
@@ -352,6 +364,10 @@
"libdvr_headers",
"libgsm",
"libgui_bufferqueue_sources",
+ "libgrallocusage",
+ "libgralloctypes",
+ "libnativewindow",
+ "libgraphicsenv",
"libhardware",
"libhardware_headers",
"libincfs_headers",
@@ -365,15 +381,28 @@
"libandroidio",
"libandroidio_srcs",
"libserviceutils",
+ "libstagefright_amrnbenc",
+ "libstagefright_amrnbdec",
+ "libstagefright_amrwbdec",
+ "libstagefright_amrwbenc",
+ "libstagefright_amrnb_common",
"libstagefright_enc_common",
+ "libstagefright_flacdec",
+ "libstagefright_foundation",
"libstagefright_foundation_headers",
"libstagefright_headers",
+ "libstagefright_m4vh263dec",
+ "libstagefright_m4vh263enc",
+ "libstagefright_mp3dec",
+ "libstagefright_mp3dec_headers",
"libsurfaceflinger_headers",
"libsync",
"libtextclassifier_hash_headers",
"libtextclassifier_hash_static",
"libtflite_kernel_utils",
"libtinyxml2",
+ "libgui_aidl",
+ "libui",
"libui-types",
"libui_headers",
"libvorbisidec",
@@ -381,11 +410,24 @@
"media_plugin_headers",
"mediaswcodec.policy",
"mediaswcodec.xml",
+ "neuralnetworks_types",
+ "neuralnetworks_utils_hal_aidl",
+ "neuralnetworks_utils_hal_common",
+ "neuralnetworks_utils_hal_1_0",
+ "neuralnetworks_utils_hal_1_1",
+ "neuralnetworks_utils_hal_1_2",
+ "neuralnetworks_utils_hal_1_3",
+ "libneuralnetworks_common",
"philox_random",
"philox_random_headers",
"server_configurable_flags",
"tensorflow_headers",
+ "libgui_headers",
+ "libstagefright_bufferpool@2.0",
+ "libstagefright_bufferpool@2.0.1",
+ "libSurfaceFlingerProp",
+
// fastboot
"bootimg_headers",
"fastboot",
@@ -445,6 +487,9 @@
"ILogcatManagerService_aidl",
"libincremental_aidl-cpp",
"incremental_aidl",
+
+ //frameworks/native/cmds/cmd
+ "libcmd",
}
Bp2buildModuleTypeAlwaysConvertList = []string{
@@ -524,7 +569,6 @@
// unconverted deps
"CarHTMLViewer", // depends on unconverted modules android.car-stubs, car-ui-lib
- "abb", // depends on unconverted modules: libcmd, libbinder
"adb", // depends on unconverted modules: AdbWinApi, libandroidfw, libopenscreen-discovery, libopenscreen-platform-impl, libusb, bin2c_fastdeployagent, AdbWinUsbApi
"android_icu4j_srcgen", // depends on unconverted modules: currysrc
"android_icu4j_srcgen_binary", // depends on unconverted modules: android_icu4j_srcgen, currysrc
@@ -537,6 +581,7 @@
"generated_android_icu4j_resources", // depends on unconverted modules: android_icu4j_srcgen_binary, soong_zip
"generated_android_icu4j_test_resources", // depends on unconverted modules: android_icu4j_srcgen_binary, soong_zip
"host-libprotobuf-java-nano", // b/220869005, depends on libprotobuf-java-nano
+ "jacoco-stubs", // b/245767077, depends on droidstubs
"libapexutil", // depends on unconverted modules: apex-info-list-tinyxml
"libart", // depends on unconverted modules: apex-info-list-tinyxml, libtinyxml2, libnativeloader-headers, heapprofd_client_api, art_operator_srcs, libcpu_features, libodrstatslog, libelffile, art_cmdlineparser_headers, cpp-define-generator-definitions, libdexfile, libnativebridge, libnativeloader, libsigchain, libartbase, libprofile, cpp-define-generator-asm-support
"libart-runtime-gtest", // depends on unconverted modules: libgtest_isolated, libart-compiler, libdexfile, libprofile, libartbase, libartbase-art-gtest
@@ -605,10 +650,6 @@
"Mp3DecoderTest", // depends on unconverted modules: libsndfile, libaudioutils
"Mpeg4H263DecoderTest", // depends on unconverted modules: libstagefright_foundation
"Mpeg4H263EncoderTest",
- "adb_crypto_test",
- "adb_pairing_auth_test",
- "adb_pairing_connection_test",
- "adb_tls_connection_test",
"avcdec",
"avcenc",
"bionic-benchmarks-tests",
@@ -704,7 +745,6 @@
"yuvconstants",
"yuvconvert",
"zipalign_tests",
- // "zlib_tests",
// cc_test_library
"clang_diagnostic_tests",
diff --git a/android/gen_notice.go b/android/gen_notice.go
index e2b839f..2eb6bec 100644
--- a/android/gen_notice.go
+++ b/android/gen_notice.go
@@ -179,7 +179,7 @@
// The visibility property needs to be checked and parsed by the visibility module.
setPrimaryVisibilityProperty(module, "visibility", &module.properties.Visibility)
- initAndroidModuleBase(module)
+ InitAndroidArchModule(module, DeviceSupported, MultilibCommon)
InitDefaultableModule(module)
return module
diff --git a/android/gen_notice_test.go b/android/gen_notice_test.go
index 4ad2ecf..b45ce4f 100644
--- a/android/gen_notice_test.go
+++ b/android/gen_notice_test.go
@@ -12,19 +12,6 @@
expectedErrors []string
}{
{
- name: "gen_notice must not accept licenses property",
- fs: map[string][]byte{
- "top/Android.bp": []byte(`
- gen_notice {
- name: "top_license",
- licenses: ["other_license"],
- }`),
- },
- expectedErrors: []string{
- `unrecognized property "licenses"`,
- },
- },
- {
name: "bad gen_notice",
fs: map[string][]byte{
"top/Android.bp": []byte(`
diff --git a/android/testing.go b/android/testing.go
index 3708501..7b74c89 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -1037,7 +1037,7 @@
}
}
if !found {
- t.Errorf("missing the expected error %q (checked %d error(s))", pattern, len(errs))
+ t.Errorf("could not match the expected error regex %q (checked %d error(s))", pattern, len(errs))
for i, err := range errs {
t.Errorf("errs[%d] = %q", i, err)
}
diff --git a/android/variable.go b/android/variable.go
index 7a080fe..b156051 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -592,6 +592,9 @@
// "acme__board__soc_a", "acme__board__soc_b", and
// "acme__board__conditions_default"
FullConfig string
+
+ // keeps track of whether this product variable is nested under an arch variant
+ OuterAxis bazel.ConfigurationAxis
}
func (p *ProductConfigProperty) AlwaysEmit() bool {
@@ -600,11 +603,11 @@
func (p *ProductConfigProperty) ConfigurationAxis() bazel.ConfigurationAxis {
if p.Namespace == "" {
- return bazel.ProductVariableConfigurationAxis(p.FullConfig)
+ return bazel.ProductVariableConfigurationAxis(p.FullConfig, p.OuterAxis)
} else {
// Soong config variables can be uniquely identified by the namespace
// (e.g. acme, android) and the product variable name (e.g. board, size)
- return bazel.ProductVariableConfigurationAxis(p.Namespace + "__" + p.Name)
+ return bazel.ProductVariableConfigurationAxis(p.Namespace+"__"+p.Name, bazel.NoConfigAxis)
}
}
@@ -663,9 +666,11 @@
moduleBase.variableProperties,
"",
"",
- &productConfigProperties)
+ &productConfigProperties,
+ bazel.ConfigurationAxis{},
+ )
- for _, configToProps := range moduleBase.GetArchVariantProperties(ctx, moduleBase.variableProperties) {
+ for axis, configToProps := range moduleBase.GetArchVariantProperties(ctx, moduleBase.variableProperties) {
for config, props := range configToProps {
// GetArchVariantProperties is creating an instance of the requested type
// and productVariablesValues expects an interface, so no need to cast
@@ -674,7 +679,8 @@
props,
"",
config,
- &productConfigProperties)
+ &productConfigProperties,
+ axis)
}
}
}
@@ -687,7 +693,8 @@
namespacedVariableProp,
namespace,
"",
- &productConfigProperties)
+ &productConfigProperties,
+ bazel.NoConfigAxis)
}
}
}
@@ -803,6 +810,7 @@
p.Name,
p.FullConfig,
zeroValue,
+ bazel.NoConfigAxis,
)
}
}
@@ -810,7 +818,7 @@
}
func (p *ProductConfigProperties) AddProductConfigProperty(
- propertyName, namespace, productVariableName, config string, property interface{}) {
+ propertyName, namespace, productVariableName, config string, property interface{}, outerAxis bazel.ConfigurationAxis) {
if (*p)[propertyName] == nil {
(*p)[propertyName] = make(map[ProductConfigProperty]interface{})
}
@@ -819,6 +827,7 @@
Namespace: namespace, // e.g. acme, android
Name: productVariableName, // e.g. size, feature1, feature2, FEATURE3, board
FullConfig: config, // e.g. size, feature1-x86, size__conditions_default
+ OuterAxis: outerAxis,
}
if existing, ok := (*p)[propertyName][productConfigProp]; ok && namespace != "" {
@@ -869,7 +878,7 @@
return v, true
}
-func (productConfigProperties *ProductConfigProperties) AddProductConfigProperties(namespace, suffix string, variableValues reflect.Value) {
+func (productConfigProperties *ProductConfigProperties) AddProductConfigProperties(namespace, suffix string, variableValues reflect.Value, outerAxis bazel.ConfigurationAxis) {
// variableValues can either be a product_variables or
// soong_config_variables struct.
//
@@ -974,7 +983,8 @@
namespace, // e.g. acme, android
productVariableName, // e.g. size, feature1, FEATURE2, board
config,
- field.Field(k).Interface(), // e.g. ["-DDEFAULT"], ["foo", "bar"]
+ field.Field(k).Interface(), // e.g. ["-DDEFAULT"], ["foo", "bar"],
+ outerAxis,
)
}
} else if property.Kind() != reflect.Interface {
@@ -988,6 +998,7 @@
productVariableName,
config,
property.Interface(),
+ outerAxis,
)
}
}
@@ -998,14 +1009,14 @@
// product_variables and soong_config_variables to structs that can be generated
// as select statements.
func productVariableValues(
- fieldName string, variableProps interface{}, namespace, suffix string, productConfigProperties *ProductConfigProperties) {
+ fieldName string, variableProps interface{}, namespace, suffix string, productConfigProperties *ProductConfigProperties, outerAxis bazel.ConfigurationAxis) {
if suffix != "" {
suffix = "-" + suffix
}
// variableValues represent the product_variables or soong_config_variables struct.
variableValues := reflect.ValueOf(variableProps).Elem().FieldByName(fieldName)
- productConfigProperties.AddProductConfigProperties(namespace, suffix, variableValues)
+ productConfigProperties.AddProductConfigProperties(namespace, suffix, variableValues, outerAxis)
}
func VariableMutator(mctx BottomUpMutatorContext) {
diff --git a/apex/apex_test.go b/apex/apex_test.go
index d6803f6..1805291 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -8843,19 +8843,7 @@
android.FixtureWithRootAndroidBp(bp),
dexpreopt.FixtureSetApexBootJars("myapex:mybootclasspathlib"),
dexpreopt.FixtureSetApexSystemServerJars("myapex:mysystemserverclasspathlib"),
- android.FixtureMergeEnv(map[string]string{
- "EMMA_INSTRUMENT": "true",
- }),
- // need to mock jacocoagent here to satisfy dependency added for
- // instrumented libraries at build time
- android.FixtureAddFile("jacocoagent/Android.bp", []byte(`
- java_library {
- name: "jacocoagent",
- srcs: ["Test.java"],
- system_modules: "none",
- sdk_version: "none",
- }
- `)),
+ java.PrepareForTestWithJacocoInstrumentation,
).RunTest(t)
// Make sure jacoco ran on both mylib and mybootclasspathlib
diff --git a/bazel/configurability.go b/bazel/configurability.go
index e1cdd4a..7ff202b 100644
--- a/bazel/configurability.go
+++ b/bazel/configurability.go
@@ -295,10 +295,11 @@
)
// ProductVariableConfigurationAxis returns an axis for the given product variable
-func ProductVariableConfigurationAxis(variable string) ConfigurationAxis {
+func ProductVariableConfigurationAxis(variable string, outerAxis ConfigurationAxis) ConfigurationAxis {
return ConfigurationAxis{
configurationType: productVariables,
subType: variable,
+ outerAxisType: outerAxis.configurationType,
}
}
@@ -309,6 +310,8 @@
// some configuration types (e.g. productVariables) have multiple independent axes, subType helps
// distinguish between them without needing to list all 17 product variables.
subType string
+ // used to keep track of which product variables are arch variant
+ outerAxisType configurationType
}
func (ca *ConfigurationAxis) less(other ConfigurationAxis) bool {
diff --git a/bazel/properties.go b/bazel/properties.go
index d82fa64..11f6247 100644
--- a/bazel/properties.go
+++ b/bazel/properties.go
@@ -309,7 +309,19 @@
_, containsProductVariables := axisTypes[productVariables]
if containsProductVariables {
if containsOs || containsArch || containsOsArch {
- return fmt.Errorf("label attribute could not be collapsed as it has two or more unrelated axes")
+ if containsArch {
+ allProductVariablesAreArchVariant := true
+ for k := range la.ConfigurableValues {
+ if k.configurationType == productVariables && k.outerAxisType != arch {
+ allProductVariablesAreArchVariant = false
+ }
+ }
+ if !allProductVariablesAreArchVariant {
+ return fmt.Errorf("label attribute could not be collapsed as it has two or more unrelated axes")
+ }
+ } else {
+ return fmt.Errorf("label attribute could not be collapsed as it has two or more unrelated axes")
+ }
}
}
if (containsOs && containsArch) || (containsOsArch && (containsOs || containsArch)) {
diff --git a/bazel/properties_test.go b/bazel/properties_test.go
index dc4d5b0..8729381 100644
--- a/bazel/properties_test.go
+++ b/bazel/properties_test.go
@@ -247,13 +247,13 @@
OsArchConfigurationAxis: labelListSelectValues{
"linux_x86": makeLabelList([]string{"linux_x86_include"}, []string{}),
},
- ProductVariableConfigurationAxis("product_with_defaults"): labelListSelectValues{
+ ProductVariableConfigurationAxis("product_with_defaults", NoConfigAxis): labelListSelectValues{
"a": makeLabelList([]string{}, []string{"not_in_value"}),
"b": makeLabelList([]string{"b_val"}, []string{}),
"c": makeLabelList([]string{"c_val"}, []string{}),
ConditionsDefaultConfigKey: makeLabelList([]string{"c_val", "default", "default2"}, []string{}),
},
- ProductVariableConfigurationAxis("product_only_with_excludes"): labelListSelectValues{
+ ProductVariableConfigurationAxis("product_only_with_excludes", NoConfigAxis): labelListSelectValues{
"a": makeLabelList([]string{}, []string{"not_in_value"}),
},
},
@@ -281,7 +281,7 @@
"linux_x86": makeLabels("linux_x86_include"),
ConditionsDefaultConfigKey: nilLabels,
},
- ProductVariableConfigurationAxis("product_with_defaults"): {
+ ProductVariableConfigurationAxis("product_with_defaults", NoConfigAxis): {
"a": nilLabels,
"b": makeLabels("b_val"),
"c": makeLabels("c_val"),
@@ -674,7 +674,7 @@
OsArchConfigurationAxis: stringListSelectValues{
"linux_x86": {"linux_x86_include"},
},
- ProductVariableConfigurationAxis("a"): stringListSelectValues{
+ ProductVariableConfigurationAxis("a", NoConfigAxis): stringListSelectValues{
"a": []string{"not_in_value"},
},
},
@@ -699,7 +699,7 @@
"linux": []string{"linux_include"},
},
OsArchConfigurationAxis: stringListSelectValues{},
- ProductVariableConfigurationAxis("a"): stringListSelectValues{
+ ProductVariableConfigurationAxis("a", NoConfigAxis): stringListSelectValues{
"a": []string{"not_in_value"},
},
}
diff --git a/bp2build/build_conversion.go b/bp2build/build_conversion.go
index cf46533..ca8185e 100644
--- a/bp2build/build_conversion.go
+++ b/bp2build/build_conversion.go
@@ -289,7 +289,9 @@
return
}
}
- targets = generateBazelTargets(bpCtx, aModule)
+ var targetErrs []error
+ targets, targetErrs = generateBazelTargets(bpCtx, aModule)
+ errs = append(errs, targetErrs...)
for _, t := range targets {
// A module can potentially generate more than 1 Bazel
// target, each of a different rule class.
@@ -306,7 +308,10 @@
// be mapped cleanly to a bazel label.
return
}
- t := generateSoongModuleTarget(bpCtx, m)
+ t, err := generateSoongModuleTarget(bpCtx, m)
+ if err != nil {
+ errs = append(errs, err)
+ }
targets = append(targets, t)
default:
errs = append(errs, fmt.Errorf("Unknown code-generation mode: %s", ctx.Mode()))
@@ -347,12 +352,18 @@
}, errs
}
-func generateBazelTargets(ctx bpToBuildContext, m android.Module) []BazelTarget {
+func generateBazelTargets(ctx bpToBuildContext, m android.Module) ([]BazelTarget, []error) {
var targets []BazelTarget
+ var errs []error
for _, m := range m.Bp2buildTargets() {
- targets = append(targets, generateBazelTarget(ctx, m))
+ target, err := generateBazelTarget(ctx, m)
+ if err != nil {
+ errs = append(errs, err)
+ return targets, errs
+ }
+ targets = append(targets, target)
}
- return targets
+ return targets, errs
}
type bp2buildModule interface {
@@ -363,13 +374,16 @@
BazelAttributes() []interface{}
}
-func generateBazelTarget(ctx bpToBuildContext, m bp2buildModule) BazelTarget {
+func generateBazelTarget(ctx bpToBuildContext, m bp2buildModule) (BazelTarget, error) {
ruleClass := m.BazelRuleClass()
bzlLoadLocation := m.BazelRuleLoadLocation()
// extract the bazel attributes from the module.
attrs := m.BazelAttributes()
- props := extractModuleProperties(attrs, true)
+ props, err := extractModuleProperties(attrs, true)
+ if err != nil {
+ return BazelTarget{}, err
+ }
// name is handled in a special manner
delete(props.Attrs, "name")
@@ -389,13 +403,13 @@
targetName,
attributes,
),
- }
+ }, nil
}
// Convert a module and its deps and props into a Bazel macro/rule
// representation in the BUILD file.
-func generateSoongModuleTarget(ctx bpToBuildContext, m blueprint.Module) BazelTarget {
- props := getBuildProperties(ctx, m)
+func generateSoongModuleTarget(ctx bpToBuildContext, m blueprint.Module) (BazelTarget, error) {
+ props, err := getBuildProperties(ctx, m)
// TODO(b/163018919): DirectDeps can have duplicate (module, variant)
// items, if the modules are added using different DependencyTag. Figure
@@ -429,21 +443,21 @@
ctx.ModuleSubDir(m),
depLabelList,
attributes),
- }
+ }, err
}
-func getBuildProperties(ctx bpToBuildContext, m blueprint.Module) BazelAttributes {
+func getBuildProperties(ctx bpToBuildContext, m blueprint.Module) (BazelAttributes, error) {
// TODO: this omits properties for blueprint modules (blueprint_go_binary,
// bootstrap_go_binary, bootstrap_go_package), which will have to be handled separately.
if aModule, ok := m.(android.Module); ok {
return extractModuleProperties(aModule.GetProperties(), false)
}
- return BazelAttributes{}
+ return BazelAttributes{}, nil
}
// Generically extract module properties and types into a map, keyed by the module property name.
-func extractModuleProperties(props []interface{}, checkForDuplicateProperties bool) BazelAttributes {
+func extractModuleProperties(props []interface{}, checkForDuplicateProperties bool) (BazelAttributes, error) {
ret := map[string]string{}
// Iterate over this android.Module's property structs.
@@ -456,24 +470,29 @@
// manipulate internal props, if needed.
if isStructPtr(propertiesValue.Type()) {
structValue := propertiesValue.Elem()
- for k, v := range extractStructProperties(structValue, 0) {
+ ok, err := extractStructProperties(structValue, 0)
+ if err != nil {
+ return BazelAttributes{}, err
+ }
+ for k, v := range ok {
if existing, exists := ret[k]; checkForDuplicateProperties && exists {
- panic(fmt.Errorf(
+ return BazelAttributes{}, fmt.Errorf(
"%s (%v) is present in properties whereas it should be consolidated into a commonAttributes",
- k, existing))
+ k, existing)
}
ret[k] = v
}
} else {
- panic(fmt.Errorf(
- "properties must be a pointer to a struct, got %T",
- propertiesValue.Interface()))
+ return BazelAttributes{},
+ fmt.Errorf(
+ "properties must be a pointer to a struct, got %T",
+ propertiesValue.Interface())
}
}
return BazelAttributes{
Attrs: ret,
- }
+ }, nil
}
func isStructPtr(t reflect.Type) bool {
@@ -531,7 +550,12 @@
}
// Sort and print the struct props by the key.
- structProps := extractStructProperties(propertyValue, indent)
+ structProps, err := extractStructProperties(propertyValue, indent)
+
+ if err != nil {
+ return "", err
+ }
+
if len(structProps) == 0 {
return "", nil
}
@@ -550,11 +574,13 @@
// which each property value correctly pretty-printed and indented at the right nest level,
// since property structs can be nested. In Starlark, nested structs are represented as nested
// dicts: https://docs.bazel.build/skylark/lib/dict.html
-func extractStructProperties(structValue reflect.Value, indent int) map[string]string {
+func extractStructProperties(structValue reflect.Value, indent int) (map[string]string, error) {
if structValue.Kind() != reflect.Struct {
- panic(fmt.Errorf("Expected a reflect.Struct type, but got %s", structValue.Kind()))
+ return map[string]string{}, fmt.Errorf("Expected a reflect.Struct type, but got %s", structValue.Kind())
}
+ var err error
+
ret := map[string]string{}
structType := structValue.Type()
for i := 0; i < structValue.NumField(); i++ {
@@ -575,7 +601,10 @@
fieldValue = fieldValue.Elem()
}
if fieldValue.Type().Kind() == reflect.Struct {
- propsToMerge := extractStructProperties(fieldValue, indent)
+ propsToMerge, err := extractStructProperties(fieldValue, indent)
+ if err != nil {
+ return map[string]string{}, err
+ }
for prop, value := range propsToMerge {
ret[prop] = value
}
@@ -584,20 +613,20 @@
}
propertyName := proptools.PropertyNameForField(field.Name)
- prettyPrintedValue, err := prettyPrint(fieldValue, indent+1, false)
+ var prettyPrintedValue string
+ prettyPrintedValue, err = prettyPrint(fieldValue, indent+1, false)
if err != nil {
- panic(
- fmt.Errorf(
- "Error while parsing property: %q. %s",
- propertyName,
- err))
+ return map[string]string{}, fmt.Errorf(
+ "Error while parsing property: %q. %s",
+ propertyName,
+ err)
}
if prettyPrintedValue != "" {
ret[propertyName] = prettyPrintedValue
}
}
- return ret
+ return ret, nil
}
func isZero(value reflect.Value) bool {
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index a21a566..880ae75 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -2789,12 +2789,13 @@
]`,
}),
MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
- "whole_archive_deps": `[":foo_cc_aidl_library"]`,
- "local_includes": `["."]`,
+ "implementation_whole_archive_deps": `[":foo_cc_aidl_library"]`,
+ "local_includes": `["."]`,
}),
+ // TODO(b/239311679) Add implementation_whole_archive_deps to cc_library_shared
+ // for bp2build to be fully correct. This fallback is affecting proto as well.
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
- "whole_archive_deps": `[":foo_cc_aidl_library"]`,
- "local_includes": `["."]`,
+ "local_includes": `["."]`,
}),
},
})
@@ -2808,23 +2809,58 @@
Filesystem: map[string]string{
"path/to/A/Android.bp": `
filegroup {
- name: "A_aidl",
- srcs: ["aidl/A.aidl"],
- path: "aidl",
+ name: "A_aidl",
+ srcs: ["aidl/A.aidl"],
+ path: "aidl",
}`,
},
Blueprint: `
cc_library {
- name: "foo",
- srcs: [
- ":A_aidl",
- ],
+ name: "foo",
+ srcs: [
+ ":A_aidl",
+ ],
}`,
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_aidl_library", "foo_cc_aidl_library", AttrNameToString{
"deps": `["//path/to/A:A_aidl"]`,
}),
MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
+ "implementation_whole_archive_deps": `[":foo_cc_aidl_library"]`,
+ "local_includes": `["."]`,
+ }),
+ // TODO(b/239311679) Add implementation_whole_archive_deps to cc_library_shared
+ // for bp2build to be fully correct. This fallback is affecting proto as well.
+ MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
+ "local_includes": `["."]`,
+ }),
+ },
+ })
+}
+
+func TestCcLibraryWithExportAidlHeaders(t *testing.T) {
+ runCcLibraryTestCase(t, Bp2buildTestCase{
+ Description: "cc_library with export aidl headers",
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Blueprint: `
+cc_library {
+ name: "foo",
+ srcs: [
+ "Foo.aidl",
+ ],
+ aidl: {
+ export_aidl_headers: true,
+ }
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("aidl_library", "foo_aidl_library", AttrNameToString{
+ "srcs": `["Foo.aidl"]`,
+ }),
+ MakeBazelTarget("cc_aidl_library", "foo_cc_aidl_library", AttrNameToString{
+ "deps": `[":foo_aidl_library"]`,
+ }),
+ MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
"whole_archive_deps": `[":foo_cc_aidl_library"]`,
"local_includes": `["."]`,
}),
diff --git a/bp2build/cc_library_static_conversion_test.go b/bp2build/cc_library_static_conversion_test.go
index 0637ba2..316fa3e 100644
--- a/bp2build/cc_library_static_conversion_test.go
+++ b/bp2build/cc_library_static_conversion_test.go
@@ -1392,6 +1392,16 @@
Description: "cc_library_static system_shared_lib empty for linux_bionic variant",
Blueprint: soongCcLibraryStaticPreamble +
simpleModuleDoNotConvertBp2build("cc_library", "libc") + `
+
+cc_library {
+ name: "libm",
+ stubs: {
+ symbol_file: "libm.map.txt",
+ versions: ["current"],
+ },
+ bazel_module: { bp2build_available: false },
+}
+
cc_library_static {
name: "used_in_bionic_oses",
target: {
@@ -1414,7 +1424,20 @@
cc_library_static {
name: "keep_for_empty_system_shared_libs",
shared_libs: ["libc"],
- system_shared_libs: [],
+ system_shared_libs: [],
+ include_build_directory: false,
+}
+
+cc_library_static {
+ name: "used_with_stubs",
+ shared_libs: ["libm"],
+ include_build_directory: false,
+}
+
+cc_library_static {
+ name: "keep_with_stubs",
+ shared_libs: ["libm"],
+ system_shared_libs: [],
include_build_directory: false,
}
`,
@@ -1424,7 +1447,15 @@
"implementation_dynamic_deps": `[":libc"]`,
"system_dynamic_deps": `[]`,
}),
+ MakeBazelTarget("cc_library_static", "keep_with_stubs", AttrNameToString{
+ "implementation_dynamic_deps": `select({
+ "//build/bazel/rules/apex:android-in_apex": [":libm_stub_libs_current"],
+ "//conditions:default": [":libm"],
+ })`,
+ "system_dynamic_deps": `[]`,
+ }),
MakeBazelTarget("cc_library_static", "used_in_bionic_oses", AttrNameToString{}),
+ MakeBazelTarget("cc_library_static", "used_with_stubs", AttrNameToString{}),
},
})
}
diff --git a/bp2build/prebuilt_etc_conversion_test.go b/bp2build/prebuilt_etc_conversion_test.go
index b1e70dc..aa0a5b7 100644
--- a/bp2build/prebuilt_etc_conversion_test.go
+++ b/bp2build/prebuilt_etc_conversion_test.go
@@ -15,10 +15,11 @@
package bp2build
import (
+ "fmt"
+ "testing"
+
"android/soong/android"
"android/soong/etc"
-
- "testing"
)
func runPrebuiltEtcTestCase(t *testing.T, tc Bp2buildTestCase) {
@@ -128,6 +129,32 @@
"dir": `"etc/tz"`,
})}})
}
+func TestPrebuiltEtcProductVariables(t *testing.T) {
+ runPrebuiltEtcTestCase(t, Bp2buildTestCase{
+ Description: "prebuilt etc - product variables",
+ Filesystem: map[string]string{},
+ Blueprint: `
+prebuilt_etc {
+ name: "apex_tz_version",
+ src: "version/tz_version",
+ filename: "tz_version",
+ product_variables: {
+ native_coverage: {
+ src: "src1",
+ },
+ },
+}
+`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("prebuilt_file", "apex_tz_version", AttrNameToString{
+ "filename": `"tz_version"`,
+ "src": `select({
+ "//build/bazel/product_variables:native_coverage": "src1",
+ "//conditions:default": "version/tz_version",
+ })`,
+ "dir": `"etc"`,
+ })}})
+}
func runPrebuiltUsrShareTestCase(t *testing.T, tc Bp2buildTestCase) {
t.Helper()
@@ -265,3 +292,57 @@
"dir": `"etc"`,
})}})
}
+
+func TestPrebuiltEtcProductVariableArchSrcs(t *testing.T) {
+ runPrebuiltEtcTestCase(t, Bp2buildTestCase{
+ Description: "prebuilt etc- SRcs from arch variant product variables",
+ Filesystem: map[string]string{},
+ Blueprint: `
+prebuilt_etc {
+ name: "foo",
+ filename: "fooFilename",
+ arch: {
+ arm: {
+ src: "armSrc",
+ product_variables: {
+ native_coverage: {
+ src: "nativeCoverageArmSrc",
+ },
+ },
+ },
+ },
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("prebuilt_file", "foo", AttrNameToString{
+ "filename": `"fooFilename"`,
+ "dir": `"etc"`,
+ "src": `select({
+ "//build/bazel/platforms/arch:arm": "armSrc",
+ "//build/bazel/product_variables:native_coverage-arm": "nativeCoverageArmSrc",
+ "//conditions:default": None,
+ })`,
+ })}})
+}
+
+func TestPrebuiltEtcProductVariableError(t *testing.T) {
+ runPrebuiltEtcTestCase(t, Bp2buildTestCase{
+ Description: "",
+ Filesystem: map[string]string{},
+ Blueprint: `
+prebuilt_etc {
+ name: "foo",
+ filename: "fooFilename",
+ arch: {
+ arm: {
+ src: "armSrc",
+ },
+ },
+ product_variables: {
+ native_coverage: {
+ src: "nativeCoverageArmSrc",
+ },
+ },
+}`,
+ ExpectedErr: fmt.Errorf("label attribute could not be collapsed"),
+ })
+}
diff --git a/bp2build/testing.go b/bp2build/testing.go
index a0d512f..ac1268c 100644
--- a/bp2build/testing.go
+++ b/bp2build/testing.go
@@ -384,6 +384,9 @@
func generateBazelTargetsForDir(codegenCtx *CodegenContext, dir string) (BazelTargets, []error) {
// TODO: Set generateFilegroups to true and/or remove the generateFilegroups argument completely
res, err := GenerateBazelTargets(codegenCtx, false)
+ if err != nil {
+ return BazelTargets{}, err
+ }
return res.buildFileToTargets[dir], err
}
diff --git a/cc/bp2build.go b/cc/bp2build.go
index c1a3bef..e001d24 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -36,6 +36,8 @@
cppSrcPartition = "cpp"
protoSrcPartition = "proto"
aidlSrcPartition = "aidl"
+
+ stubsSuffix = "_stub_libs_current"
)
// staticOrSharedAttributes are the Bazel-ified versions of StaticOrSharedProperties --
@@ -723,15 +725,23 @@
(&compilerAttrs.srcs).Add(bp2BuildYasm(ctx, module, compilerAttrs))
protoDep := bp2buildProto(ctx, module, compilerAttrs.protoSrcs)
- aidlDep := bp2buildCcAidlLibrary(ctx, module, compilerAttrs.aidlSrcs)
// bp2buildProto will only set wholeStaticLib or implementationWholeStaticLib, but we don't know
// which. This will add the newly generated proto library to the appropriate attribute and nothing
// to the other
(&linkerAttrs).wholeArchiveDeps.Add(protoDep.wholeStaticLib)
(&linkerAttrs).implementationWholeArchiveDeps.Add(protoDep.implementationWholeStaticLib)
- // TODO(b/243023967) Add aidlDep to implementationWholeArchiveDeps if aidl.export_aidl_headers is true
- (&linkerAttrs).wholeArchiveDeps.Add(aidlDep)
+
+ aidlDep := bp2buildCcAidlLibrary(ctx, module, compilerAttrs.aidlSrcs)
+ if aidlDep != nil {
+ if lib, ok := module.linker.(*libraryDecorator); ok {
+ if proptools.Bool(lib.Properties.Aidl.Export_aidl_headers) {
+ (&linkerAttrs).wholeArchiveDeps.Add(aidlDep)
+ } else {
+ (&linkerAttrs).implementationWholeArchiveDeps.Add(aidlDep)
+ }
+ }
+ }
convertedLSrcs := bp2BuildLex(ctx, module.Name(), compilerAttrs)
(&compilerAttrs).srcs.Add(&convertedLSrcs.srcName)
@@ -927,7 +937,7 @@
stubLibLabels := []bazel.Label{}
for _, l := range depsWithStubs {
- l.Label = l.Label + "_stub_libs_current"
+ l.Label = l.Label + stubsSuffix
stubLibLabels = append(stubLibLabels, l)
}
inApexSelectValue := la.implementationDynamicDeps.SelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndInApex)
@@ -1088,12 +1098,20 @@
if la.systemDynamicDeps.IsNil() && len(la.usedSystemDynamicDepAsDynamicDep) > 0 {
toRemove := bazelLabelForSharedDeps(ctx, android.SortedStringKeys(la.usedSystemDynamicDepAsDynamicDep))
la.dynamicDeps.Exclude(bazel.NoConfigAxis, "", toRemove)
- la.implementationDynamicDeps.Exclude(bazel.NoConfigAxis, "", toRemove)
- la.implementationDynamicDeps.Exclude(bazel.NoConfigAxis, "", toRemove)
la.dynamicDeps.Exclude(bazel.OsConfigurationAxis, "android", toRemove)
la.dynamicDeps.Exclude(bazel.OsConfigurationAxis, "linux_bionic", toRemove)
+ la.implementationDynamicDeps.Exclude(bazel.NoConfigAxis, "", toRemove)
la.implementationDynamicDeps.Exclude(bazel.OsConfigurationAxis, "android", toRemove)
la.implementationDynamicDeps.Exclude(bazel.OsConfigurationAxis, "linux_bionic", toRemove)
+
+ la.implementationDynamicDeps.Exclude(bazel.OsAndInApexAxis, bazel.ConditionsDefaultConfigKey, toRemove)
+ la.implementationDynamicDeps.Exclude(bazel.OsAndInApexAxis, bazel.AndroidAndNonApex, toRemove)
+ stubsToRemove := make([]bazel.Label, 0, len(la.usedSystemDynamicDepAsDynamicDep))
+ for _, lib := range toRemove.Includes {
+ lib.Label += stubsSuffix
+ stubsToRemove = append(stubsToRemove, lib)
+ }
+ la.implementationDynamicDeps.Exclude(bazel.OsAndInApexAxis, bazel.AndroidAndInApex, bazel.MakeLabelList(stubsToRemove))
}
la.deps.ResolveExcludes()
diff --git a/cc/config/global.go b/cc/config/global.go
index 357ea44..f920471 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -290,7 +290,12 @@
"-Wno-deprecated-non-prototype",
}
- llvmNextExtraCommonGlobalCflags = []string{}
+ llvmNextExtraCommonGlobalCflags = []string{
+ // New warnings to be fixed after clang-r468909
+ "-Wno-error=array-parameter", // http://b/241941550
+ "-Wno-error=deprecated-builtins", // http://b/241601211
+ "-Wno-error=deprecated", // in external/googletest/googletest
+ }
IllegalFlags = []string{
"-w",
diff --git a/cc/sanitize.go b/cc/sanitize.go
index edff059..436b149 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -714,8 +714,13 @@
if Bool(sanitize.Properties.Sanitize.Memtag_stack) {
flags.Local.CFlags = append(flags.Local.CFlags, memtagStackCommonFlags...)
+ // TODO(fmayer): remove -Wno-error once https://reviews.llvm.org/D127917 is in Android toolchain.
+ flags.Local.CFlags = append(flags.Local.CFlags, "-Wno-error=frame-larger-than")
flags.Local.AsFlags = append(flags.Local.AsFlags, memtagStackCommonFlags...)
flags.Local.LdFlags = append(flags.Local.LdFlags, memtagStackCommonFlags...)
+ // This works around LLD complaining about the stack frame size.
+ // TODO(fmayer): remove once https://reviews.llvm.org/D127917 is in Android toolchain.
+ flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--no-fatal-warnings")
}
if (Bool(sanitize.Properties.Sanitize.Memtag_heap) || Bool(sanitize.Properties.Sanitize.Memtag_stack)) && ctx.binary() {
diff --git a/docs/perf.md b/docs/perf.md
index 86a27b4..694dcf1 100644
--- a/docs/perf.md
+++ b/docs/perf.md
@@ -221,6 +221,18 @@
various .ninja files. The files are (mostly) human-readable, but a (slow) web
interface can be used by running `NINJA_ARGS="-t browse <target>" m`.
+There is also `SOONG_UI_NINJA_ARGS`, which passes ninja arguments to soong ui's
+ninja invocations, e.g. to emit $OUT_DIR/soong/build.ninja, $OUT_DIR/soong/module-graph.json, etc.
+
+```bash
+$ m nothing
+$ touch Android.bp
+$ SOONG_UI_NINJA_ARGS="-d explain" m nothing
+...
+ninja explain: restat of output out/soong/build.ninja older than most recent input Android.bp
+...
+```
+
#### Builds take a long time
If the long part in the trace view of a build is a relatively solid block, then
diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go
index b2361ce..7520f58 100644
--- a/etc/prebuilt_etc.go
+++ b/etc/prebuilt_etc.go
@@ -31,6 +31,7 @@
"encoding/json"
"fmt"
"path/filepath"
+ "reflect"
"strings"
"github.com/google/blueprint/proptools"
@@ -692,6 +693,22 @@
src.SetSelectValue(axis, config, label)
}
}
+
+ for propName, productConfigProps := range android.ProductVariableProperties(ctx) {
+ for configProp, propVal := range productConfigProps {
+ if propName == "Src" {
+ props, ok := propVal.(*string)
+ if !ok {
+ ctx.PropertyErrorf(" Expected Property to have type string, but was %s\n", reflect.TypeOf(propVal).String())
+ continue
+ }
+ if props != nil {
+ label := android.BazelLabelForModuleSrcSingle(ctx, *props)
+ src.SetSelectValue(configProp.ConfigurationAxis(), configProp.SelectKey(), label)
+ }
+ }
+ }
+ }
}
var filename string
diff --git a/java/base.go b/java/base.go
index 53f0f52..23b4d46 100644
--- a/java/base.go
+++ b/java/base.go
@@ -650,6 +650,10 @@
return false
}
+func (j *Module) setInstrument(value bool) {
+ j.properties.Instrument = value
+}
+
func (j *Module) SdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
return android.SdkSpecFrom(ctx, String(j.deviceProperties.Sdk_version))
}
@@ -789,9 +793,6 @@
} else if j.shouldInstrumentStatic(ctx) {
ctx.AddVariationDependencies(nil, staticLibTag, "jacocoagent")
}
- if j.shouldInstrument(ctx) {
- ctx.AddVariationDependencies(nil, libTag, "jacocoagent")
- }
if j.useCompose() {
ctx.AddVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), kotlinPluginTag,
@@ -862,7 +863,9 @@
// add flags for dirs containing AIDL srcs that haven't been specified yet
flags = append(flags, genAidlIncludeFlags(ctx, aidlSrcs, includeDirs))
- if Bool(j.deviceProperties.Aidl.Generate_traces) {
+ sdkVersion := (j.SdkVersion(ctx)).Kind
+ defaultTrace := ((sdkVersion == android.SdkSystemServer) || (sdkVersion == android.SdkCore) || (sdkVersion == android.SdkCorePlatform))
+ if proptools.BoolDefault(j.deviceProperties.Aidl.Generate_traces, defaultTrace) {
flags = append(flags, "-t")
}
@@ -1435,10 +1438,6 @@
j.headerJarFile = j.implementationJarFile
}
- if j.shouldInstrumentInApex(ctx) {
- j.properties.Instrument = true
- }
-
// enforce syntax check to jacoco filters for any build (http://b/183622051)
specs := j.jacocoModuleToZipCommand(ctx)
if ctx.Failed() {
diff --git a/java/bootclasspath_fragment_test.go b/java/bootclasspath_fragment_test.go
index 2bfb255..c63df59 100644
--- a/java/bootclasspath_fragment_test.go
+++ b/java/bootclasspath_fragment_test.go
@@ -96,23 +96,6 @@
}
func TestBootclasspathFragment_Coverage(t *testing.T) {
- prepareForTestWithFrameworkCoverage := android.GroupFixturePreparers(
- android.FixtureMergeEnv(map[string]string{
- "EMMA_INSTRUMENT": "true",
- "EMMA_INSTRUMENT_FRAMEWORK": "true",
- }),
- // need to mock jacocoagent here to satisfy dependency added for
- // instrumented libraries at build time
- android.FixtureAddFile("jacocoagent/Android.bp", []byte(`
- java_library {
- name: "jacocoagent",
- srcs: ["Test.java"],
- system_modules: "none",
- sdk_version: "none",
- }
- `)),
- )
-
prepareWithBp := android.FixtureWithRootAndroidBp(`
bootclasspath_fragment {
name: "myfragment",
@@ -191,7 +174,7 @@
t.Run("with coverage", func(t *testing.T) {
result := android.GroupFixturePreparers(
- prepareForTestWithFrameworkCoverage,
+ prepareForTestWithFrameworkJacocoInstrumentation,
preparer,
).RunTest(t)
checkContents(t, result, "mybootlib", "coveragelib")
diff --git a/java/jacoco.go b/java/jacoco.go
index e11c2ce..f8012b8 100644
--- a/java/jacoco.go
+++ b/java/jacoco.go
@@ -47,6 +47,34 @@
"strippedJar", "stripSpec", "tmpDir", "tmpJar")
)
+func jacocoDepsMutator(ctx android.BottomUpMutatorContext) {
+ type instrumentable interface {
+ shouldInstrument(ctx android.BaseModuleContext) bool
+ shouldInstrumentInApex(ctx android.BaseModuleContext) bool
+ setInstrument(value bool)
+ }
+
+ j, ok := ctx.Module().(instrumentable)
+ if !ctx.Module().Enabled() || !ok {
+ return
+ }
+
+ if j.shouldInstrumentInApex(ctx) {
+ j.setInstrument(true)
+ }
+
+ if j.shouldInstrument(ctx) && ctx.ModuleName() != "jacocoagent" {
+ // We can use AddFarVariationDependencies here because, since this dep
+ // is added as libs only (i.e. a compiletime CLASSPATH entry only),
+ // the first variant of jacocoagent is sufficient to prevent
+ // compile time errors.
+ // At this stage in the build, AddVariationDependencies is not always
+ // able to procure a variant of jacocoagent that matches the calling
+ // module.
+ ctx.AddFarVariationDependencies(ctx.Module().Target().Variations(), libTag, "jacocoagent")
+ }
+}
+
// Instruments a jar using the Jacoco command line interface. Uses stripSpec to extract a subset
// of the classes in inputJar into strippedJar, instruments strippedJar into tmpJar, and then
// combines the classes in tmpJar with inputJar (preferring the instrumented classes in tmpJar)
diff --git a/java/java.go b/java/java.go
index 0251b57..d04e52a 100644
--- a/java/java.go
+++ b/java/java.go
@@ -66,6 +66,8 @@
// to support the checks in dexpreoptDisabled().
ctx.FinalDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("dexpreopt_tool_deps", dexpreoptToolDepsMutator).Parallel()
+ // needs access to ApexInfoProvider which is available after variant creation
+ ctx.BottomUp("jacoco_deps", jacocoDepsMutator).Parallel()
})
ctx.RegisterSingletonType("logtags", LogtagsSingleton)
diff --git a/java/testing.go b/java/testing.go
index 511cc5d..1f41191 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -59,11 +59,9 @@
}.AddToFixture(),
)
-// Test fixture preparer that will define all default java modules except the
-// fake_tool_binary for dex2oatd.
-var PrepareForTestWithJavaDefaultModulesWithoutFakeDex2oatd = android.GroupFixturePreparers(
- // Make sure that all the module types used in the defaults are registered.
- PrepareForTestWithJavaBuildComponents,
+var prepareForTestWithFrameworkDeps = android.GroupFixturePreparers(
+ // The java default module definitions.
+ android.FixtureAddTextFile(defaultJavaDir+"/Android.bp", gatherRequiredDepsForTest()),
// Additional files needed when test disallows non-existent source.
android.MockFS{
// Needed for framework-res
@@ -77,8 +75,14 @@
"build/make/core/proguard.flags": nil,
"build/make/core/proguard_basic_keeps.flags": nil,
}.AddToFixture(),
- // The java default module definitions.
- android.FixtureAddTextFile(defaultJavaDir+"/Android.bp", gatherRequiredDepsForTest()),
+)
+
+// Test fixture preparer that will define all default java modules except the
+// fake_tool_binary for dex2oatd.
+var PrepareForTestWithJavaDefaultModulesWithoutFakeDex2oatd = android.GroupFixturePreparers(
+ // Make sure that all the module types used in the defaults are registered.
+ PrepareForTestWithJavaBuildComponents,
+ prepareForTestWithFrameworkDeps,
// Add dexpreopt compat libs (android.test.base, etc.) and a fake dex2oatd module.
dexpreopt.PrepareForTestWithDexpreoptCompatLibs,
)
@@ -141,6 +145,30 @@
"30": {},
})
+var prepareForTestWithFrameworkJacocoInstrumentation = android.GroupFixturePreparers(
+ android.FixtureMergeEnv(map[string]string{
+ "EMMA_INSTRUMENT_FRAMEWORK": "true",
+ }),
+ PrepareForTestWithJacocoInstrumentation,
+)
+
+// PrepareForTestWithJacocoInstrumentation creates a mock jacocoagent library that can be
+// depended on as part of the build process for instrumented Java modules.
+var PrepareForTestWithJacocoInstrumentation = android.GroupFixturePreparers(
+ android.FixtureMergeEnv(map[string]string{
+ "EMMA_INSTRUMENT": "true",
+ }),
+ android.FixtureAddFile("jacocoagent/Test.java", nil),
+ android.FixtureAddFile("jacocoagent/Android.bp", []byte(`
+ java_library {
+ name: "jacocoagent",
+ host_supported: true,
+ srcs: ["Test.java"],
+ sdk_version: "current",
+ }
+ `)),
+)
+
// FixtureWithPrebuiltApis creates a preparer that will define prebuilt api modules for the
// specified releases and modules.
//
diff --git a/python/scripts/stub_template_host.txt b/python/scripts/stub_template_host.txt
index 138404b..23897b3 100644
--- a/python/scripts/stub_template_host.txt
+++ b/python/scripts/stub_template_host.txt
@@ -81,7 +81,9 @@
os.environ.update(new_env)
sys.stdout.flush()
- retCode = subprocess.call(args)
+ # close_fds=False so that you can run binaries with files provided on the command line:
+ # my_python_app --file <(echo foo)
+ retCode = subprocess.call(args, close_fds=False)
sys.exit(retCode)
except:
raise
diff --git a/tests/lib.sh b/tests/lib.sh
index 6210e77..7248ade 100644
--- a/tests/lib.sh
+++ b/tests/lib.sh
@@ -123,6 +123,7 @@
symlink_directory prebuilts/jdk
symlink_directory external/bazel-skylib
symlink_directory external/bazelbuild-rules_android
+ symlink_directory external/bazelbuild-kotlin-rules
symlink_file WORKSPACE
symlink_file BUILD