Merge "Correct genrule path references"
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index e4dc602..c169e22 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -477,6 +477,7 @@
"code_coverage.policy",
"code_coverage.policy.other",
"codec2_soft_exports",
+ "compatibility_matrix_schema",
"flatbuffer_headers",
"framework-connectivity-protos",
"gemmlowp_headers",
@@ -781,6 +782,7 @@
"java_import_host",
"java_sdk_library",
"sysprop_library",
+ "xsd_config",
}
// Add the names of modules that bp2build should never convert, if it is
@@ -897,8 +899,6 @@
"static_crasher", // depends on unconverted modules: libdebuggerd_handler
"test_fips", // depends on unconverted modules: adb
"timezone-host", // depends on unconverted modules: art.module.api.annotations
- "truth-host-prebuilt", // depends on unconverted modules: truth-prebuilt
- "truth-prebuilt", // depends on unconverted modules: asm-7.0, guava
// '//bionic/libc:libc_bp2build_cc_library_static' is duplicated in the 'deps' attribute of rule
"toybox-static",
diff --git a/android/config.go b/android/config.go
index bed57e3..0e119a3 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1710,10 +1710,6 @@
return c.productVariables.ProductPrivateSepolicyDirs
}
-func (c *config) MissingUsesLibraries() []string {
- return c.productVariables.MissingUsesLibraries
-}
-
func (c *config) TargetMultitreeUpdateMeta() bool {
return c.productVariables.MultitreeUpdateMeta
}
@@ -1929,6 +1925,10 @@
return InList(name, c.config.productVariables.BuildBrokenInputDirModules)
}
+func (c *config) BuildWarningBadOptionalUsesLibsAllowlist() []string {
+ return c.productVariables.BuildWarningBadOptionalUsesLibsAllowlist
+}
+
func (c *deviceConfig) GenruleSandboxing() bool {
return Bool(c.config.productVariables.GenruleSandboxing)
}
@@ -1941,10 +1941,6 @@
return c.productVariables.SelinuxIgnoreNeverallows
}
-func (c *deviceConfig) SepolicySplit() bool {
- return c.config.productVariables.SepolicySplit
-}
-
func (c *deviceConfig) SepolicyFreezeTestExtraDirs() []string {
return c.config.productVariables.SepolicyFreezeTestExtraDirs
}
diff --git a/android/module.go b/android/module.go
index 98084f3..ba32710 100644
--- a/android/module.go
+++ b/android/module.go
@@ -4014,3 +4014,53 @@
WriteFileRule(ctx, outFile, string(j))
ctx.Phony("soong_config_trace", outFile)
}
+
+// Interface implemented by xsd_config which has 1:many mappings in bp2build workspace
+// This interface exists because we want to
+// 1. Determine the name of the additional targets generated by the primary soong module
+// 2. Enable distinguishing an xsd_config module from other Soong modules using type assertion
+type XsdConfigBp2buildTargets interface {
+ CppBp2buildTargetName() string
+ JavaBp2buildTargetName() string
+}
+
+// PartitionXsdSrcs partitions srcs into xsd_config modules and others
+// Since xsd_config are soong modules, we cannot use file extension for partitioning
+func PartitionXsdSrcs(ctx BazelConversionPathContext, srcs []string) ([]string, []string) {
+ //isXsd returns true if src is a soong module of type xsd_config
+ isXsd := func(src string) bool {
+ mod, exists := ctx.ModuleFromName(src)
+ if !exists {
+ return false
+ }
+ _, _isXsd := mod.(XsdConfigBp2buildTargets)
+ return _isXsd
+ }
+ nonXsd := []string{}
+ xsd := []string{}
+
+ for _, src := range srcs {
+ if isXsd(src) {
+ xsd = append(xsd, src)
+ } else {
+ nonXsd = append(nonXsd, src)
+ }
+ }
+
+ return nonXsd, xsd
+}
+
+// Replaces //a/b/my_xsd_config with //a/b/my_xsd_config-{cpp|java}
+// The new target name is provided by the `targetName` callback function
+func XsdConfigBp2buildTarget(ctx BazelConversionPathContext, mod blueprint.Module, targetName func(xsd XsdConfigBp2buildTargets) string) string {
+ xsd, isXsd := mod.(XsdConfigBp2buildTargets)
+ if !isXsd {
+ ctx.ModuleErrorf("xsdConfigJavaTarget called on %v, which is not an xsd_config", mod)
+ }
+ ret := BazelModuleLabel(ctx, mod)
+ // Remove the base module name
+ ret = strings.TrimSuffix(ret, mod.Name())
+ // Append the language specific target name
+ ret += targetName(xsd)
+ return ret
+}
diff --git a/android/variable.go b/android/variable.go
index 77888e5..60a6503 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -420,8 +420,6 @@
TargetFSConfigGen []string `json:",omitempty"`
- MissingUsesLibraries []string `json:",omitempty"`
-
EnforceProductPartitionInterface *bool `json:",omitempty"`
EnforceInterPartitionJavaSdkLibrary *bool `json:",omitempty"`
@@ -451,14 +449,14 @@
BuildBrokenVendorPropertyNamespace bool `json:",omitempty"`
BuildBrokenInputDirModules []string `json:",omitempty"`
+ BuildWarningBadOptionalUsesLibsAllowlist []string `json:",omitempty"`
+
BuildDebugfsRestrictionsEnabled bool `json:",omitempty"`
RequiresInsecureExecmemForSwiftshader bool `json:",omitempty"`
SelinuxIgnoreNeverallows bool `json:",omitempty"`
- SepolicySplit bool `json:",omitempty"`
-
SepolicyFreezeTestExtraDirs []string `json:",omitempty"`
SepolicyFreezeTestExtraPrebuiltDirs []string `json:",omitempty"`
diff --git a/bp2build/cc_binary_conversion_test.go b/bp2build/cc_binary_conversion_test.go
index 8a83cc0..610a9ca 100644
--- a/bp2build/cc_binary_conversion_test.go
+++ b/bp2build/cc_binary_conversion_test.go
@@ -1036,3 +1036,73 @@
},
})
}
+
+func TestCcBinaryWithCfi(t *testing.T) {
+ runCcBinaryTestCase(t, ccBinaryBp2buildTestCase{
+ description: "cc_binary has correct features when cfi is enabled",
+ blueprint: `
+{rule_name} {
+ name: "foo",
+ sanitize: {
+ cfi: true,
+ },
+}`,
+ targets: []testBazelTarget{
+ {"cc_binary", "foo", AttrNameToString{
+ "features": `["android_cfi"]`,
+ "local_includes": `["."]`,
+ }},
+ },
+ })
+}
+
+func TestCcBinaryWithCfiOsSpecific(t *testing.T) {
+ runCcBinaryTestCase(t, ccBinaryBp2buildTestCase{
+ description: "cc_binary has correct features when cfi is enabled for specific variants",
+ blueprint: `
+{rule_name} {
+ name: "foo",
+ target: {
+ android: {
+ sanitize: {
+ cfi: true,
+ },
+ },
+ },
+}`,
+ targets: []testBazelTarget{
+ {"cc_binary", "foo", AttrNameToString{
+ "features": `select({
+ "//build/bazel/platforms/os:android": ["android_cfi"],
+ "//conditions:default": [],
+ })`,
+ "local_includes": `["."]`,
+ }},
+ },
+ })
+}
+
+func TestCcBinaryWithCfiAndCfiAssemblySupport(t *testing.T) {
+ runCcBinaryTestCase(t, ccBinaryBp2buildTestCase{
+ description: "cc_binary has correct features when cfi is enabled with cfi assembly support",
+ blueprint: `
+{rule_name} {
+ name: "foo",
+ sanitize: {
+ cfi: true,
+ config: {
+ cfi_assembly_support: true,
+ },
+ },
+}`,
+ targets: []testBazelTarget{
+ {"cc_binary", "foo", AttrNameToString{
+ "features": `[
+ "android_cfi",
+ "android_cfi_assembly_support",
+ ]`,
+ "local_includes": `["."]`,
+ }},
+ },
+ })
+}
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 3dd9373..c2dba67 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -4718,3 +4718,97 @@
},
})
}
+
+func TestCcLibraryWithCfi(t *testing.T) {
+ runCcLibraryTestCase(t, Bp2buildTestCase{
+ Description: "cc_library has correct features when cfi is enabled",
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Blueprint: `
+cc_library {
+ name: "foo",
+ sanitize: {
+ cfi: true,
+ },
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
+ "features": `["android_cfi"]`,
+ "local_includes": `["."]`,
+ }),
+ MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
+ "features": `["android_cfi"]`,
+ "local_includes": `["."]`,
+ }),
+ },
+ })
+}
+
+func TestCcLibraryWithCfiOsSpecific(t *testing.T) {
+ runCcLibraryTestCase(t, Bp2buildTestCase{
+ Description: "cc_library has correct features when cfi is enabled for specific variants",
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Blueprint: `
+cc_library {
+ name: "foo",
+ target: {
+ android: {
+ sanitize: {
+ cfi: true,
+ },
+ },
+ },
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
+ "features": `select({
+ "//build/bazel/platforms/os:android": ["android_cfi"],
+ "//conditions:default": [],
+ })`,
+ "local_includes": `["."]`,
+ }),
+ MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
+ "features": `select({
+ "//build/bazel/platforms/os:android": ["android_cfi"],
+ "//conditions:default": [],
+ })`,
+ "local_includes": `["."]`,
+ }),
+ },
+ })
+}
+
+func TestCcLibraryWithCfiAndCfiAssemblySupport(t *testing.T) {
+ runCcLibraryTestCase(t, Bp2buildTestCase{
+ Description: "cc_library has correct features when cfi is enabled with cfi_assembly_support",
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Blueprint: `
+cc_library {
+ name: "foo",
+ sanitize: {
+ cfi: true,
+ config: {
+ cfi_assembly_support: true,
+ },
+ },
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
+ "features": `[
+ "android_cfi",
+ "android_cfi_assembly_support",
+ ]`,
+ "local_includes": `["."]`,
+ }),
+ MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
+ "features": `[
+ "android_cfi",
+ "android_cfi_assembly_support",
+ ]`,
+ "local_includes": `["."]`,
+ }),
+ },
+ })
+}
diff --git a/bp2build/cc_library_shared_conversion_test.go b/bp2build/cc_library_shared_conversion_test.go
index 6c9f9a1..7f0ba44 100644
--- a/bp2build/cc_library_shared_conversion_test.go
+++ b/bp2build/cc_library_shared_conversion_test.go
@@ -1445,3 +1445,73 @@
},
})
}
+
+func TestCcLibrarySharedWithCfi(t *testing.T) {
+ runCcLibrarySharedTestCase(t, Bp2buildTestCase{
+ Description: "cc_library_shared has correct features when cfi is enabled for specific variants",
+ Blueprint: `
+cc_library_shared {
+ name: "foo",
+ sanitize: {
+ cfi: true,
+ },
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
+ "features": `["android_cfi"]`,
+ "local_includes": `["."]`,
+ }),
+ },
+ })
+}
+
+func TestCcLibrarySharedWithCfiOsSpecific(t *testing.T) {
+ runCcLibrarySharedTestCase(t, Bp2buildTestCase{
+ Description: "cc_library_shared has correct features when cfi is enabled",
+ Blueprint: `
+cc_library_shared {
+ name: "foo",
+ target: {
+ android: {
+ sanitize: {
+ cfi: true,
+ },
+ },
+ },
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
+ "features": `select({
+ "//build/bazel/platforms/os:android": ["android_cfi"],
+ "//conditions:default": [],
+ })`,
+ "local_includes": `["."]`,
+ }),
+ },
+ })
+}
+
+func TestCcLibrarySharedWithCfiAndCfiAssemblySupport(t *testing.T) {
+ runCcLibrarySharedTestCase(t, Bp2buildTestCase{
+ Description: "cc_library_shared has correct features when cfi is enabled with cfi assembly support",
+ Blueprint: `
+cc_library_static {
+ name: "foo",
+ sanitize: {
+ cfi: true,
+ config: {
+ cfi_assembly_support: true,
+ },
+ },
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
+ "features": `[
+ "android_cfi",
+ "android_cfi_assembly_support",
+ ]`,
+ "local_includes": `["."]`,
+ }),
+ },
+ })
+}
diff --git a/bp2build/cc_library_static_conversion_test.go b/bp2build/cc_library_static_conversion_test.go
index 2705aaf..f537871 100644
--- a/bp2build/cc_library_static_conversion_test.go
+++ b/bp2build/cc_library_static_conversion_test.go
@@ -2075,3 +2075,73 @@
},
})
}
+
+func TestCcLibraryStaticWithCfi(t *testing.T) {
+ runCcLibraryStaticTestCase(t, Bp2buildTestCase{
+ Description: "cc_library_static has correct features when cfi is enabled",
+ Blueprint: `
+cc_library_static {
+ name: "foo",
+ sanitize: {
+ cfi: true,
+ },
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
+ "features": `["android_cfi"]`,
+ "local_includes": `["."]`,
+ }),
+ },
+ })
+}
+
+func TestCcLibraryStaticWithCfiOsSpecific(t *testing.T) {
+ runCcLibraryStaticTestCase(t, Bp2buildTestCase{
+ Description: "cc_library_static has correct features when cfi is enabled for specific variants",
+ Blueprint: `
+cc_library_static {
+ name: "foo",
+ target: {
+ android: {
+ sanitize: {
+ cfi: true,
+ },
+ },
+ },
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
+ "features": `select({
+ "//build/bazel/platforms/os:android": ["android_cfi"],
+ "//conditions:default": [],
+ })`,
+ "local_includes": `["."]`,
+ }),
+ },
+ })
+}
+
+func TestCcLibraryStaticWithCfiAndCfiAssemblySupport(t *testing.T) {
+ runCcLibraryStaticTestCase(t, Bp2buildTestCase{
+ Description: "cc_library_static has correct features when cfi is enabled with cfi_assembly_support",
+ Blueprint: `
+cc_library_static {
+ name: "foo",
+ sanitize: {
+ cfi: true,
+ config: {
+ cfi_assembly_support: true,
+ },
+ },
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
+ "features": `[
+ "android_cfi",
+ "android_cfi_assembly_support",
+ ]`,
+ "local_includes": `["."]`,
+ }),
+ },
+ })
+}
diff --git a/cc/bp2build.go b/cc/bp2build.go
index 259ba39..34cc574 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -591,7 +591,8 @@
anySrcs := false
// Add srcs-like dependencies such as generated files.
// First create a LabelList containing these dependencies, then merge the values with srcs.
- generatedSrcsLabelList := android.BazelLabelForModuleDepsExcludes(ctx, props.Generated_sources, props.Exclude_generated_sources)
+ genSrcs, _ := android.PartitionXsdSrcs(ctx, props.Generated_sources)
+ generatedSrcsLabelList := android.BazelLabelForModuleDepsExcludes(ctx, genSrcs, props.Exclude_generated_sources)
if len(props.Generated_sources) > 0 || len(props.Exclude_generated_sources) > 0 {
anySrcs = true
}
@@ -716,6 +717,14 @@
return ret
}
+// Replaces //a/b/my_xsd_config with //a/b/my_xsd_config-cpp
+func xsdConfigCppTarget(ctx android.BazelConversionPathContext, mod blueprint.Module) string {
+ callback := func(xsd android.XsdConfigBp2buildTargets) string {
+ return xsd.CppBp2buildTargetName()
+ }
+ return android.XsdConfigBp2buildTarget(ctx, mod, callback)
+}
+
// bp2BuildParseBaseProps returns all compiler, linker, library attributes of a cc module..
func bp2BuildParseBaseProps(ctx android.Bp2buildMutatorContext, module *Module) baseAttributes {
archVariantCompilerProps := module.GetArchVariantProperties(ctx, &BaseCompilerProperties{})
@@ -754,7 +763,14 @@
for cfg := range configs {
var allHdrs []string
if baseCompilerProps, ok := archVariantCompilerProps[axis][cfg].(*BaseCompilerProperties); ok {
- allHdrs = baseCompilerProps.Generated_headers
+ ah, allHdrsXsd := android.PartitionXsdSrcs(ctx, baseCompilerProps.Generated_headers)
+ allHdrs = ah
+ // in the synthetic bp2build workspace, xsd sources are compiled to a static library
+ xsdCppConfigLibraryLabels := android.BazelLabelForModuleDepsWithFn(ctx, allHdrsXsd, xsdConfigCppTarget)
+ iwad := linkerAttrs.implementationWholeArchiveDeps.SelectValue(axis, cfg)
+ (&iwad).Append(xsdCppConfigLibraryLabels)
+ linkerAttrs.implementationWholeArchiveDeps.SetSelectValue(axis, cfg, bazel.FirstUniqueBazelLabelList(iwad))
+
if baseCompilerProps.Lex != nil {
compilerAttrs.lexopts.SetSelectValue(axis, cfg, baseCompilerProps.Lex.Flags)
}
@@ -1757,6 +1773,12 @@
for _, sanitizer := range sanitizerProps.Sanitize.Misc_undefined {
features = append(features, "ubsan_"+sanitizer)
}
+ if proptools.Bool(sanitizerProps.Sanitize.Cfi) {
+ features = append(features, "android_cfi")
+ if proptools.Bool(sanitizerProps.Sanitize.Config.Cfi_assembly_support) {
+ features = append(features, "android_cfi_assembly_support")
+ }
+ }
sanitizerFeatures.SetSelectValue(axis, config, features)
}
})
diff --git a/cc/config/tidy.go b/cc/config/tidy.go
index d55a13d..efa4549 100644
--- a/cc/config/tidy.go
+++ b/cc/config/tidy.go
@@ -42,6 +42,8 @@
"-bugprone-unchecked-optional-access",
// http://b/265438407
"-misc-use-anonymous-namespace",
+ // http://b/285005947
+ "-performance-avoid-endl",
}
// Some clang-tidy checks are included in some tidy_checks_as_errors lists,
@@ -56,6 +58,14 @@
"-bugprone-signed-char-misuse",
// http://b/241819232
"-misc-const-correctness",
+ // http://b/285356805
+ "-bugprone-unsafe-functions",
+ "-cert-msc24-c",
+ "-cert-msc33-c",
+ // http://b/285356799
+ "-modernize-type-traits",
+ // http://b/285361108
+ "-readability-avoid-unconditional-preprocessor-if",
}
extraArgFlags = []string{
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 6e732b6..a5691ee 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -64,13 +64,14 @@
cfiBlocklistPath = "external/compiler-rt/lib/cfi"
cfiBlocklistFilename = "cfi_blocklist.txt"
+ cfiEnableFlag = "-fsanitize=cfi"
cfiCrossDsoFlag = "-fsanitize-cfi-cross-dso"
cfiCflags = []string{"-flto", cfiCrossDsoFlag,
"-fsanitize-ignorelist=" + cfiBlocklistPath + "/" + cfiBlocklistFilename}
// -flto and -fvisibility are required by clang when -fsanitize=cfi is
// used, but have no effect on assembly files
cfiAsflags = []string{"-flto", "-fvisibility=default"}
- cfiLdflags = []string{"-flto", cfiCrossDsoFlag, "-fsanitize=cfi",
+ cfiLdflags = []string{"-flto", cfiCrossDsoFlag, cfiEnableFlag,
"-Wl,-plugin-opt,O1"}
cfiExportsMapPath = "build/soong/cc/config"
cfiExportsMapFilename = "cfi_exports.map"
@@ -395,8 +396,8 @@
// Leave out "-flto" from the slices exported to bazel, as we will use the
// dedicated LTO feature for this. For C Flags and Linker Flags, also leave
- // out the cross DSO flag which will be added separately by transitions.
- exportedVars.ExportStringList("CfiCFlags", cfiCflags[2:])
+ // out the cross DSO flag which will be added separately under the correct conditions.
+ exportedVars.ExportStringList("CfiCFlags", append(cfiCflags[2:], cfiEnableFlag))
exportedVars.ExportStringList("CfiLdFlags", cfiLdflags[2:])
exportedVars.ExportStringList("CfiAsFlags", cfiAsflags[1:])
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index d589925..2e6b6d4 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -16,6 +16,7 @@
import (
"bytes"
+ "errors"
"flag"
"fmt"
"os"
@@ -135,12 +136,24 @@
writeDepFile(cmdlineArgs.OutFile, ctx.EventHandler, ninjaDeps)
- if ctx.Config().IsEnvTrue("SOONG_GENERATES_NINJA_HINT") {
+ if needToWriteNinjaHint(ctx) {
writeNinjaHint(ctx)
}
return cmdlineArgs.OutFile
}
+func needToWriteNinjaHint(ctx *android.Context) bool {
+ switch ctx.Config().GetenvWithDefault("SOONG_GENERATES_NINJA_HINT", "") {
+ case "always":
+ return true
+ case "depend":
+ if _, err := os.Stat(filepath.Join(ctx.Config().OutDir(), ".ninja_log")); errors.Is(err, os.ErrNotExist) {
+ return true
+ }
+ }
+ return false
+}
+
// Run the code-generation phase to convert BazelTargetModules to BUILD files.
func runQueryView(queryviewDir, queryviewMarker string, ctx *android.Context) {
ctx.EventHandler.Begin("queryview")
@@ -460,7 +473,7 @@
// The actual output (build.ninja) was written in the RunBlueprint() call
// above
writeDepFile(cmdlineArgs.OutFile, ctx.EventHandler, ninjaDeps)
- if ctx.Config().IsEnvTrue("SOONG_GENERATES_NINJA_HINT") {
+ if needToWriteNinjaHint(ctx) {
writeNinjaHint(ctx)
}
return cmdlineArgs.OutFile
diff --git a/fuzz/fuzz_common.go b/fuzz/fuzz_common.go
index 2a1b404..b470304 100644
--- a/fuzz/fuzz_common.go
+++ b/fuzz/fuzz_common.go
@@ -170,6 +170,27 @@
return false
}
+type UsePlatformLibs string
+
+const (
+ unknown_use_platform_libs UsePlatformLibs = "unknown_use_platform_libs"
+ // Use the native libraries on the device, typically in /system directory
+ use_platform_libs = "use_platform_libs"
+ // Do not use any native libraries (ART will not be initialized)
+ use_none = "use_none"
+)
+
+func (use_platform_libs UsePlatformLibs) isValidUsePlatformLibs() bool {
+ switch use_platform_libs {
+ case "",
+ unknown_use_platform_libs,
+ use_platform_libs,
+ use_none:
+ return true
+ }
+ return false
+}
+
type UserData string
const (
@@ -284,6 +305,10 @@
if !config.Automatically_route_to.isValidAutomaticallyRouteTo() {
panic(fmt.Errorf("Invalid automatically_route_to in fuzz config in %s", moduleName))
}
+
+ if !config.Use_platform_libs.isValidUsePlatformLibs() {
+ panic(fmt.Errorf("Invalid use_platform_libs in fuzz config in %s", moduleName))
+ }
}
return true
}
@@ -341,6 +366,8 @@
Target_modules []string `json:"target_modules,omitempty"`
// Specifies a bug assignee to replace default ISE assignment
Triage_assignee string `json:"triage_assignee,omitempty"`
+ // Specifies libs used to initialize ART (java only, 'use_none' for no initialization)
+ Use_platform_libs UsePlatformLibs `json:"use_platform_libs,omitempty"`
}
type FuzzFrameworks struct {
diff --git a/java/app.go b/java/app.go
index d99c184..3e4c8cf 100755
--- a/java/app.go
+++ b/java/app.go
@@ -18,6 +18,7 @@
// related module types, including their override variants.
import (
+ "fmt"
"path/filepath"
"strings"
@@ -1391,10 +1392,15 @@
}
}
-// presentOptionalUsesLibs returns optional_uses_libs after filtering out MissingUsesLibraries, which don't exist in the
-// build.
+// presentOptionalUsesLibs returns optional_uses_libs after filtering out libraries that don't exist in the source tree.
func (u *usesLibrary) presentOptionalUsesLibs(ctx android.BaseModuleContext) []string {
- optionalUsesLibs, _ := android.FilterList(u.usesLibraryProperties.Optional_uses_libs, ctx.Config().MissingUsesLibraries())
+ optionalUsesLibs := android.FilterListPred(u.usesLibraryProperties.Optional_uses_libs, func(s string) bool {
+ exists := ctx.OtherModuleExists(s)
+ if !exists && !android.InList(ctx.ModuleName(), ctx.Config().BuildWarningBadOptionalUsesLibsAllowlist()) {
+ fmt.Printf("Warning: Module '%s' depends on non-existing optional_uses_libs '%s'\n", ctx.ModuleName(), s)
+ }
+ return exists
+ })
return optionalUsesLibs
}
diff --git a/java/app_test.go b/java/app_test.go
index 68e9d11..cf7d174 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -2645,7 +2645,7 @@
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("runtime-library", "foo", "quuz", "qux", "bar", "fred"),
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.MissingUsesLibraries = []string{"baz"}
+ variables.BuildWarningBadOptionalUsesLibsAllowlist = []string{"app", "prebuilt"}
}),
).RunTestWithBp(t, bp)
diff --git a/java/fuzz.go b/java/fuzz.go
index 5dfaacf..b3c2fd4 100644
--- a/java/fuzz.go
+++ b/java/fuzz.go
@@ -30,8 +30,12 @@
const (
hostString = "host"
targetString = "target"
+ deviceString = "device"
)
+// Any shared libs for these deps will also be packaged
+var artDeps = []string{"libdl_android"}
+
func init() {
RegisterJavaFuzzBuildComponents(android.InitRegistrationContext)
}
@@ -78,7 +82,18 @@
}
func (j *JavaFuzzTest) DepsMutator(ctx android.BottomUpMutatorContext) {
+ if j.Os().Class.String() == deviceString {
+ j.testProperties.Jni_libs = append(j.testProperties.Jni_libs, artDeps...)
+ }
+
if len(j.testProperties.Jni_libs) > 0 {
+ if j.fuzzPackagedModule.FuzzProperties.Fuzz_config == nil {
+ config := &fuzz.FuzzConfig{}
+ j.fuzzPackagedModule.FuzzProperties.Fuzz_config = config
+ }
+ // this will be used by the ingestion pipeline to determine the version
+ // of jazzer to add to the fuzzer package
+ j.fuzzPackagedModule.FuzzProperties.Fuzz_config.IsJni = proptools.BoolPtr(true)
for _, target := range ctx.MultiTargets() {
sharedLibVariations := append(target.Variations(), blueprint.Variation{Mutator: "link", Variation: "shared"})
ctx.AddFarVariationDependencies(sharedLibVariations, jniLibTag, j.testProperties.Jni_libs...)
diff --git a/java/java.go b/java/java.go
index 4f7b401..a8793fe 100644
--- a/java/java.go
+++ b/java/java.go
@@ -2813,6 +2813,14 @@
hasKotlin bool
}
+// Replaces //a/b/my_xsd_config with //a/b/my_xsd_config-java
+func xsdConfigJavaTarget(ctx android.BazelConversionPathContext, mod blueprint.Module) string {
+ callback := func(xsd android.XsdConfigBp2buildTargets) string {
+ return xsd.JavaBp2buildTargetName()
+ }
+ return android.XsdConfigBp2buildTarget(ctx, mod, callback)
+}
+
// convertLibraryAttrsBp2Build returns a javaCommonAttributes struct with
// converted attributes shared across java_* modules and a bp2BuildJavaInfo struct
// which has other non-attribute information needed for bp2build conversion
@@ -2827,8 +2835,15 @@
for axis, configToProps := range archVariantProps {
for config, _props := range configToProps {
if archProps, ok := _props.(*CommonProperties); ok {
- archSrcs := android.BazelLabelForModuleSrcExcludes(ctx, archProps.Srcs, archProps.Exclude_srcs)
+ srcsNonXsd, srcsXsd := android.PartitionXsdSrcs(ctx, archProps.Srcs)
+ excludeSrcsNonXsd, _ := android.PartitionXsdSrcs(ctx, archProps.Exclude_srcs)
+ archSrcs := android.BazelLabelForModuleSrcExcludes(ctx, srcsNonXsd, excludeSrcsNonXsd)
srcs.SetSelectValue(axis, config, archSrcs)
+
+ // Add to static deps
+ xsdJavaConfigLibraryLabels := android.BazelLabelForModuleDepsWithFn(ctx, srcsXsd, xsdConfigJavaTarget)
+ staticDeps.Append(xsdJavaConfigLibraryLabels)
+
}
}
}
diff --git a/tests/apex_comparison_tests.sh b/tests/apex_comparison_tests.sh
index e350323..8893060 100755
--- a/tests/apex_comparison_tests.sh
+++ b/tests/apex_comparison_tests.sh
@@ -29,7 +29,7 @@
# Test Setup
############
-OUTPUT_DIR="$(mktemp -d tmp.XXXXXX)"
+OUTPUT_DIR="$(mktemp -d $(pwd)/tmp.XXXXXX)"
SOONG_OUTPUT_DIR="$OUTPUT_DIR/soong"
BAZEL_OUTPUT_DIR="$OUTPUT_DIR/bazel"
@@ -45,6 +45,12 @@
call_bazel clean
rm -rf "${OUTPUT_DIR}"
}
+
+function deapexer() {
+ DEBUGFS_PATH="$(realpath $(call_bazel cquery --config=bp2build --config=linux_x86_64 --config=ci --output=files //external/e2fsprogs/debugfs))"
+ call_bazel run --config=bp2build //system/apex/tools:deapexer -- --debugfs_path=$DEBUGFS_PATH $@
+}
+
trap cleanup EXIT
###########
@@ -72,10 +78,7 @@
BAZEL_MINIMAL="$(realpath $(call_bazel cquery --config=bp2build --config=android --config=ci --output=files //build/bazel/examples/apex/minimal:build.bazel.examples.apex.minimal))"
# # Build debugfs separately, as it's not a dep of apexer, but needs to be an explicit arg.
-call_bazel build --config=bp2build --config=linux_x86_64 //external/e2fsprogs/debugfs //system/apex/tools:deapexer
-DEBUGFS_PATH="$(realpath $(call_bazel cquery --config=bp2build --config=linux_x86_64 --config=ci --output=files //external/e2fsprogs/debugfs))"
-DEAPEXER="bazel-bin/system/apex/tools/deapexer"
-DEAPEXER="$DEAPEXER --debugfs_path=$DEBUGFS_PATH"
+call_bazel build --config=bp2build --config=linux_x86_64 //external/e2fsprogs/debugfs
#######
# Tests
@@ -91,8 +94,8 @@
local SOONG_LIST="$OUTPUT_DIR/soong.list"
local BAZEL_LIST="$OUTPUT_DIR/bazel.list"
- $DEAPEXER list "$SOONG_APEX" > "$SOONG_LIST"
- $DEAPEXER list "$BAZEL_APEX" > "$BAZEL_LIST"
+ deapexer list "$SOONG_APEX" > "$SOONG_LIST"
+ deapexer list "$BAZEL_APEX" > "$BAZEL_LIST"
if cmp -s "$SOONG_LIST" "$BAZEL_LIST"
then
diff --git a/ui/build/cleanbuild.go b/ui/build/cleanbuild.go
index ee53327..41cb5ab 100644
--- a/ui/build/cleanbuild.go
+++ b/ui/build/cleanbuild.go
@@ -135,6 +135,7 @@
productOut("obj/NOTICE_FILES"),
productOut("obj/PACKAGING"),
productOut("ramdisk"),
+ productOut("ramdisk_16k"),
productOut("debug_ramdisk"),
productOut("vendor_ramdisk"),
productOut("vendor_debug_ramdisk"),
diff --git a/ui/build/config.go b/ui/build/config.go
index 711774a..697cc66 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -16,6 +16,7 @@
import (
"encoding/json"
+ "errors"
"fmt"
"io/ioutil"
"math/rand"
@@ -136,6 +137,9 @@
EXTERNAL_FILE
// ninja uses a prioritized module list from Soong
HINT_FROM_SOONG
+ // If ninja log exists, use NINJA_LOG, if not, use HINT_FROM_SOONG instead.
+ // We can assume it is an incremental build if ninja log exists.
+ DEFAULT
)
const srcDirFileCheck = "build/soong/root.bp"
@@ -233,7 +237,7 @@
ret := &configImpl{
environ: OsEnvironment(),
sandboxConfig: &SandboxConfig{},
- ninjaWeightListSource: NINJA_LOG,
+ ninjaWeightListSource: DEFAULT,
}
// Default matching ninja
@@ -244,8 +248,21 @@
ret.parseArgs(ctx, args)
if ret.ninjaWeightListSource == HINT_FROM_SOONG {
- ret.environ.Set("SOONG_GENERATES_NINJA_HINT", "true")
+ ret.environ.Set("SOONG_GENERATES_NINJA_HINT", "always")
+ } else if ret.ninjaWeightListSource == DEFAULT {
+ defaultNinjaWeightListSource := NINJA_LOG
+ if _, err := os.Stat(filepath.Join(ret.OutDir(), ninjaLogFileName)); errors.Is(err, os.ErrNotExist) {
+ ctx.Verboseln("$OUT/.ninja_log doesn't exist, use HINT_FROM_SOONG instead")
+ defaultNinjaWeightListSource = HINT_FROM_SOONG
+ } else {
+ ctx.Verboseln("$OUT/.ninja_log exist, use NINJA_LOG")
+ }
+ ret.ninjaWeightListSource = defaultNinjaWeightListSource
+ // soong_build generates ninja hint depending on ninja log existence.
+ // Set it "depend" to avoid soong re-run due to env variable change.
+ ret.environ.Set("SOONG_GENERATES_NINJA_HINT", "depend")
}
+
// Make sure OUT_DIR is set appropriately
if outDir, ok := ret.environ.Get("OUT_DIR"); ok {
ret.environ.Set("OUT_DIR", filepath.Clean(outDir))
diff --git a/ui/build/paths/config.go b/ui/build/paths/config.go
index b3092ea..b3e871f 100644
--- a/ui/build/paths/config.go
+++ b/ui/build/paths/config.go
@@ -86,27 +86,29 @@
// This list specifies whether a particular binary from $PATH is allowed to be
// run during the build. For more documentation, see path_interposer.go .
var Configuration = map[string]PathConfig{
- "bash": Allowed,
- "dd": Allowed,
- "diff": Allowed,
- "dlv": Allowed,
- "expr": Allowed,
- "fuser": Allowed,
- "getopt": Allowed,
- "git": Allowed,
- "hexdump": Allowed,
- "jar": Allowed,
- "java": Allowed,
- "javap": Allowed,
- "lsof": Allowed,
- "openssl": Allowed,
- "pstree": Allowed,
- "rsync": Allowed,
- "sh": Allowed,
- "stubby": Allowed,
- "tr": Allowed,
- "unzip": Allowed,
- "zip": Allowed,
+ "bash": Allowed,
+ "dd": Allowed,
+ "diff": Allowed,
+ "dlv": Allowed,
+ "expr": Allowed,
+ "fuser": Allowed,
+ "gcert": Allowed,
+ "getopt": Allowed,
+ "git": Allowed,
+ "hexdump": Allowed,
+ "jar": Allowed,
+ "java": Allowed,
+ "javap": Allowed,
+ "lsof": Allowed,
+ "openssl": Allowed,
+ "prodcertstatus": Allowed,
+ "pstree": Allowed,
+ "rsync": Allowed,
+ "sh": Allowed,
+ "stubby": Allowed,
+ "tr": Allowed,
+ "unzip": Allowed,
+ "zip": Allowed,
// Host toolchain is removed. In-tree toolchain should be used instead.
// GCC also can't find cc1 with this implementation.
diff --git a/ui/metrics/BUILD.bazel b/ui/metrics/BUILD.bazel
index 2dc1ab6..ca39c59 100644
--- a/ui/metrics/BUILD.bazel
+++ b/ui/metrics/BUILD.bazel
@@ -23,6 +23,7 @@
proto_library(
name = "metrics-proto",
srcs = [
+ "bazel_metrics_proto/bazel_metrics.proto",
"bp2build_metrics_proto/bp2build_metrics.proto",
"metrics_proto/metrics.proto",
],