summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md26
-rw-r--r--android/bazel_handler.go18
-rw-r--r--apex/prebuilt.go5
-rw-r--r--cc/coverage.go6
-rw-r--r--cc/prebuilt.go31
-rw-r--r--cc/prebuilt_test.go24
-rw-r--r--cc/sanitize.go5
-rw-r--r--cc/strip.go4
-rw-r--r--cmd/pom2bp/pom2bp.go24
-rw-r--r--cmd/soong_build/main.go18
-rw-r--r--java/base.go54
-rw-r--r--java/droidstubs.go6
-rw-r--r--java/droidstubs_test.go17
-rw-r--r--java/java_test.go4
-rw-r--r--java/lint.go19
-rw-r--r--java/robolectric.go4
-rw-r--r--python/binary.go4
-rw-r--r--python/python.go3
-rw-r--r--rust/sanitize.go14
-rw-r--r--ui/build/soong.go1
20 files changed, 215 insertions, 72 deletions
diff --git a/README.md b/README.md
index 87d6948da..18cf7b2ad 100644
--- a/README.md
+++ b/README.md
@@ -1,13 +1,33 @@
# Soong
-Soong is the replacement for the old Android make-based build system. It
-replaces Android.mk files with Android.bp files, which are JSON-like simple
-declarative descriptions of modules to build.
+Soong is one of the build systems used in Android. There are altogether three:
+* The legacy Make-based build system that is controlled by files called
+ `Android.mk`.
+* Soong, which is controlled by files called `Android.bp`.
+* The upcoming Bazel-based build system that is controlled by files called
+ `BUILD.bazel`.
+
+`Android.bp` file are JSON-like declarative descriptions of "modules" to build;
+a "module" is the basic unit of building that Soong understands, similarly to
+how "target" is the basic unit of building for Bazel (and Make, although the
+two kinds of "targets" are very different)
See [Simple Build
Configuration](https://source.android.com/compatibility/tests/development/blueprints)
on source.android.com to read how Soong is configured for testing.
+### Contributing
+
+Code reviews are handled through the usual code review system of Android,
+available [here](https://android-review.googlesource.com/dashboard/self).
+
+For simple changes (fixing typos, obvious optimizations, etc.), sending a code
+review request is enough. For more substantial changes, file a bug in our
+[bug tracker](https://issuetracker.google.com/issues/new?component=381517) or
+or write us at android-building@googlegroups.com .
+
+For Googlers, see our [internal documentation](http://go/soong).
+
## Android.bp file format
By design, Android.bp files are very simple. There are no conditionals or
diff --git a/android/bazel_handler.go b/android/bazel_handler.go
index e81086d7d..308827c11 100644
--- a/android/bazel_handler.go
+++ b/android/bazel_handler.go
@@ -172,12 +172,13 @@ type bazelRunner interface {
}
type bazelPaths struct {
- homeDir string
- bazelPath string
- outputBase string
- workspaceDir string
- soongOutDir string
- metricsDir string
+ homeDir string
+ bazelPath string
+ outputBase string
+ workspaceDir string
+ soongOutDir string
+ metricsDir string
+ bazelDepsFile string
}
// A context object which tracks queued requests that need to be made to Bazel,
@@ -424,6 +425,11 @@ func bazelPathsFromConfig(c *config) (*bazelPaths, error) {
} else {
missingEnvVars = append(missingEnvVars, "BAZEL_METRICS_DIR")
}
+ if len(c.Getenv("BAZEL_DEPS_FILE")) > 1 {
+ p.bazelDepsFile = c.Getenv("BAZEL_DEPS_FILE")
+ } else {
+ missingEnvVars = append(missingEnvVars, "BAZEL_DEPS_FILE")
+ }
if len(missingEnvVars) > 0 {
return nil, errors.New(fmt.Sprintf("missing required env vars to use bazel: %s", missingEnvVars))
} else {
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index 0f57911c6..70308c802 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -500,6 +500,9 @@ type ApexFileProperties struct {
Arm64 struct {
Src *string `android:"path"`
}
+ Riscv64 struct {
+ Src *string `android:"path"`
+ }
X86 struct {
Src *string `android:"path"`
}
@@ -527,6 +530,8 @@ func (p *ApexFileProperties) prebuiltApexSelector(ctx android.BaseModuleContext,
src = String(p.Arch.Arm.Src)
case android.Arm64:
src = String(p.Arch.Arm64.Src)
+ case android.Riscv64:
+ src = String(p.Arch.Riscv64.Src)
case android.X86:
src = String(p.Arch.X86.Src)
case android.X86_64:
diff --git a/cc/coverage.go b/cc/coverage.go
index d0902eab8..a7356f879 100644
--- a/cc/coverage.go
+++ b/cc/coverage.go
@@ -108,6 +108,12 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags
if EnableContinuousCoverage(ctx) {
flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-mllvm", "-runtime-counter-relocation")
}
+
+ // http://b/248022906, http://b/247941801 enabling coverage and hwasan-globals
+ // instrumentation together causes duplicate-symbol errors for __llvm_profile_filename.
+ if c, ok := ctx.Module().(*Module); ok && c.sanitize.isSanitizerEnabled(Hwasan) {
+ flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-mllvm", "-hwasan-globals=0")
+ }
}
}
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index 68df87981..3756810bc 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -674,9 +674,15 @@ func PrebuiltBinaryFactory() android.Module {
return module.Init()
}
+type prebuiltBinaryBazelHandler struct {
+ module *Module
+ decorator *binaryDecorator
+}
+
func NewPrebuiltBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecorator) {
- module, binary := newBinary(hod, false)
+ module, binary := newBinary(hod, true)
module.compiler = nil
+ module.bazelHandler = &prebuiltBinaryBazelHandler{module, binary}
prebuilt := &prebuiltBinaryLinker{
binaryDecorator: binary,
@@ -690,6 +696,29 @@ func NewPrebuiltBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecor
return module, binary
}
+var _ BazelHandler = (*prebuiltBinaryBazelHandler)(nil)
+
+func (h *prebuiltBinaryBazelHandler) QueueBazelCall(ctx android.BaseModuleContext, label string) {
+ bazelCtx := ctx.Config().BazelContext
+ bazelCtx.QueueBazelRequest(label, cquery.GetOutputFiles, android.GetConfigKey(ctx))
+}
+
+func (h *prebuiltBinaryBazelHandler) ProcessBazelQueryResponse(ctx android.ModuleContext, label string) {
+ bazelCtx := ctx.Config().BazelContext
+ outputs, err := bazelCtx.GetOutputFiles(label, android.GetConfigKey(ctx))
+ if err != nil {
+ ctx.ModuleErrorf(err.Error())
+ return
+ }
+ if len(outputs) != 1 {
+ ctx.ModuleErrorf("Expected a single output for `%s`, but got:\n%v", label, outputs)
+ return
+ }
+ out := android.PathForBazelOut(ctx, outputs[0])
+ h.module.outputFile = android.OptionalPathForPath(out)
+ h.module.maybeUnhideFromMake()
+}
+
type bazelPrebuiltBinaryAttributes struct {
Src bazel.LabelAttribute
Strip stripAttributes
diff --git a/cc/prebuilt_test.go b/cc/prebuilt_test.go
index 53cf7818d..95fa99e43 100644
--- a/cc/prebuilt_test.go
+++ b/cc/prebuilt_test.go
@@ -683,3 +683,27 @@ cc_prebuilt_binary {
}`
testCcError(t, `Android.bp:4:6: module "bintest" variant "android_arm64_armv8-a": srcs: multiple prebuilt source files`, bp)
}
+
+func TestPrebuiltBinaryWithBazel(t *testing.T) {
+ const bp = `
+cc_prebuilt_binary {
+ name: "bintest",
+ srcs: ["bin"],
+ bazel_module: { label: "//bin/foo:foo" },
+}`
+ const outBaseDir = "outputbase"
+ const expectedOut = outBaseDir + "/execroot/__main__/bin"
+ config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
+ config.BazelContext = android.MockBazelContext{
+ OutputBaseDir: outBaseDir,
+ LabelToOutputFiles: map[string][]string{"//bin/foo:foo": []string{"bin"}},
+ }
+ ctx := testCcWithConfig(t, config)
+ bin := ctx.ModuleForTests("bintest", "android_arm64_armv8-a").Module().(*Module)
+ out := bin.OutputFile()
+ if !out.Valid() {
+ t.Error("Invalid output file")
+ return
+ }
+ android.AssertStringEquals(t, "output file", expectedOut, out.String())
+}
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 66dfef57b..0b47f0e6d 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -564,11 +564,6 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) {
s.Scudo = nil
}
- if Bool(s.Undefined) || Bool(s.All_undefined) || len(s.Misc_undefined) > 0 {
- // TODO(b/251249010): re-enable Hwaddress with UBSan once fixed.
- s.Hwaddress = nil
- }
-
if Bool(s.Hwaddress) {
s.Address = nil
s.Thread = nil
diff --git a/cc/strip.go b/cc/strip.go
index c60e13530..5c32d8b04 100644
--- a/cc/strip.go
+++ b/cc/strip.go
@@ -56,7 +56,9 @@ func (stripper *Stripper) NeedsStrip(actx android.ModuleContext) bool {
forceEnable := Bool(stripper.StripProperties.Strip.All) ||
Bool(stripper.StripProperties.Strip.Keep_symbols) ||
Bool(stripper.StripProperties.Strip.Keep_symbols_and_debug_frame)
- return !forceDisable && (forceEnable || defaultEnable)
+ // create_minidebuginfo doesn't work for riscv64 yet, disable stripping for now
+ riscv64 := actx.Arch().ArchType == android.Riscv64
+ return !forceDisable && (forceEnable || defaultEnable) && !riscv64
}
// Keep this consistent with //build/bazel/rules/stripped_shared_library.bzl.
diff --git a/cmd/pom2bp/pom2bp.go b/cmd/pom2bp/pom2bp.go
index 0e8ad05a9..ba0648d19 100644
--- a/cmd/pom2bp/pom2bp.go
+++ b/cmd/pom2bp/pom2bp.go
@@ -207,6 +207,10 @@ func (p Pom) IsJar() bool {
return p.Packaging == "jar"
}
+func (p Pom) IsApk() bool {
+ return p.Packaging == "apk"
+}
+
func (p Pom) IsHostModule() bool {
return hostModuleNames.IsHostModule(p.GroupId, p.ArtifactId)
}
@@ -244,6 +248,8 @@ func (p Pom) BazelTargetType() string {
func (p Pom) ImportModuleType() string {
if p.IsAar() {
return "android_library_import"
+ } else if p.IsApk() {
+ return "android_app_import"
} else if p.IsHostOnly() {
return "java_import_host"
} else {
@@ -254,6 +260,8 @@ func (p Pom) ImportModuleType() string {
func (p Pom) BazelImportTargetType() string {
if p.IsAar() {
return "aar_import"
+ } else if p.IsApk() {
+ return "apk_import"
} else {
return "java_import"
}
@@ -262,6 +270,8 @@ func (p Pom) BazelImportTargetType() string {
func (p Pom) ImportProperty() string {
if p.IsAar() {
return "aars"
+ } else if p.IsApk() {
+ return "apk"
} else {
return "jars"
}
@@ -270,6 +280,8 @@ func (p Pom) ImportProperty() string {
func (p Pom) BazelImportProperty() string {
if p.IsAar() {
return "aar"
+ } else if p.IsApk() {
+ return "apk"
} else {
return "jars"
}
@@ -493,8 +505,12 @@ func (p *Pom) ExtractMinSdkVersion() error {
var bpTemplate = template.Must(template.New("bp").Parse(`
{{.ImportModuleType}} {
name: "{{.BpName}}",
+ {{- if .IsApk}}
+ {{.ImportProperty}}: "{{.ArtifactFile}}",
+ {{- else}}
{{.ImportProperty}}: ["{{.ArtifactFile}}"],
sdk_version: "{{.SdkVersion}}",
+ {{- end}}
{{- if .Jetifier}}
jetifier: true,
{{- end}}
@@ -535,8 +551,14 @@ var bpTemplate = template.Must(template.New("bp").Parse(`
],
{{- end}}
{{- else if not .IsHostOnly}}
+ {{- if not .IsApk}}
min_sdk_version: "{{.DefaultMinSdkVersion}}",
{{- end}}
+ {{- end}}
+ {{- if .IsApk}}
+ presigned: true
+ {{- end}}
+
}
`))
@@ -995,7 +1017,7 @@ Usage: %s [--rewrite <regex>=<replace>] [--exclude <module>] [--extra-static-lib
for _, pom := range poms {
var err error
- if staticDeps {
+ if staticDeps && !pom.IsApk() {
err = depsTemplate.Execute(buf, pom)
} else {
err = template.Execute(buf, pom)
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index 9f00fc338..0ba25c884 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -167,10 +167,15 @@ func runMixedModeBuild(configuration android.Config, ctx *android.Context, extra
return configuration.BazelContext.InvokeBazel(configuration)
}
ctx.SetBeforePrepareBuildActionsHook(bazelHook)
-
ninjaDeps := bootstrap.RunBlueprint(cmdlineArgs, bootstrap.DoEverything, ctx.Context, configuration)
ninjaDeps = append(ninjaDeps, extraNinjaDeps...)
+ bazelPaths, err := readBazelPaths(configuration)
+ if err != nil {
+ panic("Bazel deps file not found: " + err.Error())
+ }
+ ninjaDeps = append(ninjaDeps, bazelPaths...)
+
globListFiles := writeBuildGlobsNinjaFile(ctx, configuration.SoongOutDir(), configuration)
ninjaDeps = append(ninjaDeps, globListFiles...)
@@ -699,3 +704,14 @@ func writeBp2BuildMetrics(codegenMetrics *bp2build.CodegenMetrics,
}
codegenMetrics.Write(metricsDir)
}
+
+func readBazelPaths(configuration android.Config) ([]string, error) {
+ depsPath := configuration.Getenv("BAZEL_DEPS_FILE")
+
+ data, err := os.ReadFile(depsPath)
+ if err != nil {
+ return nil, err
+ }
+ paths := strings.Split(strings.TrimSpace(string(data)), "\n")
+ return paths, nil
+}
diff --git a/java/base.go b/java/base.go
index bcb722603..ab5a7d9a2 100644
--- a/java/base.go
+++ b/java/base.go
@@ -447,9 +447,11 @@ type Module struct {
// installed file for hostdex copy
hostdexInstallFile android.InstallPath
- // list of .java files and srcjars that was passed to javac
- compiledJavaSrcs android.Paths
- compiledSrcJars android.Paths
+ // list of unique .java and .kt source files
+ uniqueSrcFiles android.Paths
+
+ // list of srcjars that was passed to javac
+ compiledSrcJars android.Paths
// manifest file to use instead of properties.Manifest
overrideManifest android.OptionalPath
@@ -1078,15 +1080,26 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
jarName := ctx.ModuleName() + ".jar"
- javaSrcFiles := srcFiles.FilterByExt(".java")
- var uniqueSrcFiles android.Paths
+ var uniqueJavaFiles android.Paths
set := make(map[string]bool)
- for _, v := range javaSrcFiles {
+ for _, v := range srcFiles.FilterByExt(".java") {
if _, found := set[v.String()]; !found {
set[v.String()] = true
- uniqueSrcFiles = append(uniqueSrcFiles, v)
+ uniqueJavaFiles = append(uniqueJavaFiles, v)
}
}
+ var uniqueKtFiles android.Paths
+ for _, v := range srcFiles.FilterByExt(".kt") {
+ if _, found := set[v.String()]; !found {
+ set[v.String()] = true
+ uniqueKtFiles = append(uniqueKtFiles, v)
+ }
+ }
+
+ var uniqueSrcFiles android.Paths
+ uniqueSrcFiles = append(uniqueSrcFiles, uniqueJavaFiles...)
+ uniqueSrcFiles = append(uniqueSrcFiles, uniqueKtFiles...)
+ j.uniqueSrcFiles = uniqueSrcFiles
// We don't currently run annotation processors in turbine, which means we can't use turbine
// generated header jars when an annotation processor that generates API is enabled. One
@@ -1094,7 +1107,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
// is used to run all of the annotation processors.
disableTurbine := deps.disableTurbine
- // Collect .java files for AIDEGen
+ // Collect .java and .kt files for AIDEGen
j.expandIDEInfoCompiledSrcs = append(j.expandIDEInfoCompiledSrcs, uniqueSrcFiles.Strings()...)
var kotlinJars android.Paths
@@ -1132,12 +1145,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
flags.kotlincFlags += "$kotlincFlags"
}
- var kotlinSrcFiles android.Paths
- kotlinSrcFiles = append(kotlinSrcFiles, uniqueSrcFiles...)
- kotlinSrcFiles = append(kotlinSrcFiles, srcFiles.FilterByExt(".kt")...)
-
- // Collect .kt files for AIDEGen
- j.expandIDEInfoCompiledSrcs = append(j.expandIDEInfoCompiledSrcs, srcFiles.FilterByExt(".kt").Strings()...)
+ // Collect common .kt files for AIDEGen
j.expandIDEInfoCompiledSrcs = append(j.expandIDEInfoCompiledSrcs, kotlinCommonSrcFiles.Strings()...)
flags.classpath = append(flags.classpath, deps.kotlinStdlib...)
@@ -1150,7 +1158,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
// Use kapt for annotation processing
kaptSrcJar := android.PathForModuleOut(ctx, "kapt", "kapt-sources.jar")
kaptResJar := android.PathForModuleOut(ctx, "kapt", "kapt-res.jar")
- kotlinKapt(ctx, kaptSrcJar, kaptResJar, kotlinSrcFiles, kotlinCommonSrcFiles, srcJars, flags)
+ kotlinKapt(ctx, kaptSrcJar, kaptResJar, uniqueSrcFiles, kotlinCommonSrcFiles, srcJars, flags)
srcJars = append(srcJars, kaptSrcJar)
kotlinJars = append(kotlinJars, kaptResJar)
// Disable annotation processing in javac, it's already been handled by kapt
@@ -1160,7 +1168,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
kotlinJar := android.PathForModuleOut(ctx, "kotlin", jarName)
kotlinHeaderJar := android.PathForModuleOut(ctx, "kotlin_headers", jarName)
- kotlinCompile(ctx, kotlinJar, kotlinHeaderJar, kotlinSrcFiles, kotlinCommonSrcFiles, srcJars, flags)
+ kotlinCompile(ctx, kotlinJar, kotlinHeaderJar, uniqueSrcFiles, kotlinCommonSrcFiles, srcJars, flags)
if ctx.Failed() {
return
}
@@ -1185,8 +1193,6 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
jars := append(android.Paths(nil), kotlinJars...)
- // Store the list of .java files that was passed to javac
- j.compiledJavaSrcs = uniqueSrcFiles
j.compiledSrcJars = srcJars
enableSharding := false
@@ -1201,12 +1207,12 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
// with sharding enabled. See: b/77284273.
}
headerJarFileWithoutDepsOrJarjar, j.headerJarFile =
- j.compileJavaHeader(ctx, uniqueSrcFiles, srcJars, deps, flags, jarName, kotlinHeaderJars)
+ j.compileJavaHeader(ctx, uniqueJavaFiles, srcJars, deps, flags, jarName, kotlinHeaderJars)
if ctx.Failed() {
return
}
}
- if len(uniqueSrcFiles) > 0 || len(srcJars) > 0 {
+ if len(uniqueJavaFiles) > 0 || len(srcJars) > 0 {
hasErrorproneableFiles := false
for _, ext := range j.sourceExtensions {
if ext != ".proto" && ext != ".aidl" {
@@ -1231,7 +1237,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
errorproneFlags := enableErrorproneFlags(flags)
errorprone := android.PathForModuleOut(ctx, "errorprone", jarName)
- transformJavaToClasses(ctx, errorprone, -1, uniqueSrcFiles, srcJars, errorproneFlags, nil,
+ transformJavaToClasses(ctx, errorprone, -1, uniqueJavaFiles, srcJars, errorproneFlags, nil,
"errorprone", "errorprone")
extraJarDeps = append(extraJarDeps, errorprone)
@@ -1243,8 +1249,8 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
}
shardSize := int(*(j.properties.Javac_shard_size))
var shardSrcs []android.Paths
- if len(uniqueSrcFiles) > 0 {
- shardSrcs = android.ShardPaths(uniqueSrcFiles, shardSize)
+ if len(uniqueJavaFiles) > 0 {
+ shardSrcs = android.ShardPaths(uniqueJavaFiles, shardSize)
for idx, shardSrc := range shardSrcs {
classes := j.compileJavaClasses(ctx, jarName, idx, shardSrc,
nil, flags, extraJarDeps)
@@ -1257,7 +1263,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
jars = append(jars, classes)
}
} else {
- classes := j.compileJavaClasses(ctx, jarName, -1, uniqueSrcFiles, srcJars, flags, extraJarDeps)
+ classes := j.compileJavaClasses(ctx, jarName, -1, uniqueJavaFiles, srcJars, flags, extraJarDeps)
jars = append(jars, classes)
}
if ctx.Failed() {
diff --git a/java/droidstubs.go b/java/droidstubs.go
index d9efb408f..5777b185c 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -28,7 +28,7 @@ import (
)
// The values allowed for Droidstubs' Api_levels_sdk_type
-var allowedApiLevelSdkTypes = []string{"public", "system", "module-lib"}
+var allowedApiLevelSdkTypes = []string{"public", "system", "module-lib", "system-server"}
func init() {
RegisterStubsBuildComponents(android.InitRegistrationContext)
@@ -134,7 +134,7 @@ type DroidstubsProperties struct {
// the dirs which Metalava extracts API levels annotations from.
Api_levels_annotations_dirs []string
- // the sdk kind which Metalava extracts API levels annotations from. Supports 'public', 'system' and 'module-lib' for now; defaults to public.
+ // the sdk kind which Metalava extracts API levels annotations from. Supports 'public', 'system', 'module-lib' and 'system-server'; defaults to public.
Api_levels_sdk_type *string
// the filename which Metalava extracts API levels annotations from. Defaults to android.jar.
@@ -445,6 +445,8 @@ func (d *Droidstubs) apiLevelsGenerationFlags(ctx android.ModuleContext, cmd *an
// for older releases. Similarly, module-lib falls back to system API.
var sdkDirs []string
switch proptools.StringDefault(d.properties.Api_levels_sdk_type, "public") {
+ case "system-server":
+ sdkDirs = []string{"system-server", "module-lib", "system", "public"}
case "module-lib":
sdkDirs = []string{"module-lib", "system", "public"}
case "system":
diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go
index 24436921c..25f8c8667 100644
--- a/java/droidstubs_test.go
+++ b/java/droidstubs_test.go
@@ -122,7 +122,7 @@ func getAndroidJarPatternsForDroidstubs(t *testing.T, sdkType string) []string {
"some-other-exported-dir",
],
api_levels_annotations_enabled: true,
- api_levels_sdk_type: "%s",
+ api_levels_sdk_type: "%s",
}
`, sdkType),
map[string][]byte{
@@ -169,6 +169,21 @@ func TestModuleLibDroidstubs(t *testing.T) {
}, patterns)
}
+func TestSystemServerDroidstubs(t *testing.T) {
+ patterns := getAndroidJarPatternsForDroidstubs(t, "system-server")
+
+ android.AssertArrayString(t, "order of patterns", []string{
+ "--android-jar-pattern somedir/%/system-server/android.jar",
+ "--android-jar-pattern someotherdir/%/system-server/android.jar",
+ "--android-jar-pattern somedir/%/module-lib/android.jar",
+ "--android-jar-pattern someotherdir/%/module-lib/android.jar",
+ "--android-jar-pattern somedir/%/system/android.jar",
+ "--android-jar-pattern someotherdir/%/system/android.jar",
+ "--android-jar-pattern somedir/%/public/android.jar",
+ "--android-jar-pattern someotherdir/%/public/android.jar",
+ }, patterns)
+}
+
func TestDroidstubsSandbox(t *testing.T) {
ctx, _ := testJavaWithFS(t, `
genrule {
diff --git a/java/java_test.go b/java/java_test.go
index 7f0cea718..d2373e349 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -588,8 +588,8 @@ func TestPrebuilts(t *testing.T) {
sdklibStubsJar := ctx.ModuleForTests("sdklib.stubs", "android_common").Rule("combineJar").Output
fooLibrary := fooModule.Module().(*Library)
- assertDeepEquals(t, "foo java sources incorrect",
- []string{"a.java"}, fooLibrary.compiledJavaSrcs.Strings())
+ assertDeepEquals(t, "foo unique sources incorrect",
+ []string{"a.java"}, fooLibrary.uniqueSrcFiles.Strings())
assertDeepEquals(t, "foo java source jars incorrect",
[]string{".intermediates/stubs-source/android_common/stubs-source-stubs.srcjar"},
diff --git a/java/lint.go b/java/lint.go
index 931820d74..fcd6d31ff 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -473,20 +473,23 @@ func (l *linter) lint(ctx android.ModuleContext) {
cmd.FlagWithOutput("--write-reference-baseline ", baseline)
- cmd.Text("|| (").Text("if [ -e").Input(text).Text("]; then cat").Input(text).Text("; fi; exit 7)")
-
- rule.Command().Text("rm -rf").Flag(lintPaths.cacheDir.String()).Flag(lintPaths.homeDir.String())
-
- // The HTML output contains a date, remove it to make the output deterministic.
- rule.Command().Text(`sed -i.tmp -e 's|Check performed at .*\(</nav>\)|\1|'`).Output(html)
+ cmd.Text("; EXITCODE=$?; ")
// The sources in the sandbox may have been modified by --apply-suggestions, zip them up and
- // export them out of the sandbox.
- rule.Command().BuiltTool("soong_zip").
+ // export them out of the sandbox. Do this before exiting so that the suggestions exit even after
+ // a fatal error.
+ cmd.BuiltTool("soong_zip").
FlagWithOutput("-o ", android.PathForModuleOut(ctx, "lint", "suggested-fixes.zip")).
FlagWithArg("-C ", cmd.PathForInput(android.PathForSource(ctx))).
FlagWithInput("-r ", srcsList)
+ cmd.Text("; if [ $EXITCODE != 0 ]; then if [ -e").Input(text).Text("]; then cat").Input(text).Text("; fi; exit $EXITCODE; fi")
+
+ rule.Command().Text("rm -rf").Flag(lintPaths.cacheDir.String()).Flag(lintPaths.homeDir.String())
+
+ // The HTML output contains a date, remove it to make the output deterministic.
+ rule.Command().Text(`sed -i.tmp -e 's|Check performed at .*\(</nav>\)|\1|'`).Output(html)
+
rule.Build("lint", "lint")
l.outputs = lintOutputs{
diff --git a/java/robolectric.go b/java/robolectric.go
index 7f2981fa8..b6116ec9d 100644
--- a/java/robolectric.go
+++ b/java/robolectric.go
@@ -188,9 +188,9 @@ func (r *robolectricTest) GenerateAndroidBuildActions(ctx android.ModuleContext)
// TODO: this could all be removed if tradefed was used as the test runner, it will find everything
// annotated as a test and run it.
- for _, src := range r.compiledJavaSrcs {
+ for _, src := range r.uniqueSrcFiles {
s := src.Rel()
- if !strings.HasSuffix(s, "Test.java") {
+ if !strings.HasSuffix(s, "Test.java") && !strings.HasSuffix(s, "Test.kt") {
continue
} else if strings.HasSuffix(s, "/BaseRobolectricTest.java") {
continue
diff --git a/python/binary.go b/python/binary.go
index 1c2b5552a..1f49a5476 100644
--- a/python/binary.go
+++ b/python/binary.go
@@ -192,8 +192,8 @@ func (binary *binaryDecorator) bootstrap(ctx android.ModuleContext, actualVersio
})
}
- addTopDirectoriesToPath := !proptools.BoolDefault(binary.binaryProperties.Dont_add_top_level_directories_to_path, false)
- dontAddEntrypointFolderToPath := proptools.BoolDefault(binary.binaryProperties.Dont_add_entrypoint_folder_to_path, false)
+ addTopDirectoriesToPath := !proptools.BoolDefault(binary.binaryProperties.Dont_add_top_level_directories_to_path, true)
+ dontAddEntrypointFolderToPath := proptools.BoolDefault(binary.binaryProperties.Dont_add_entrypoint_folder_to_path, true)
binFile := registerBuildActionForParFile(ctx, embeddedLauncher, launcherPath,
binary.getHostInterpreterName(ctx, actualVersion),
diff --git a/python/python.go b/python/python.go
index f6029c250..6f3a0ecf3 100644
--- a/python/python.go
+++ b/python/python.go
@@ -677,8 +677,7 @@ func (p *Module) createSrcsZip(ctx android.ModuleContext, pkgPath string) androi
protoFlags := android.GetProtoFlags(ctx, &p.protoProperties)
protoFlags.OutTypeFlag = "--python_out"
- // TODO(b/247578564): Change the default to true, and then eventually remove respect_pkg_path
- protosRespectPkgPath := proptools.BoolDefault(p.properties.Proto.Respect_pkg_path, false)
+ protosRespectPkgPath := proptools.BoolDefault(p.properties.Proto.Respect_pkg_path, true)
pkgPathForProtos := pkgPath
if pkgPathForProtos != "" && protosRespectPkgPath {
pkgPathStagingDir := android.PathForModuleGen(ctx, "protos_staged_for_pkg_path")
diff --git a/rust/sanitize.go b/rust/sanitize.go
index a3c5cb583..c68137ecd 100644
--- a/rust/sanitize.go
+++ b/rust/sanitize.go
@@ -189,16 +189,6 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) {
}
}
- // TODO:(b/178369775)
- // For now sanitizing is only supported on devices
- if ctx.Os() == android.Android && Bool(s.Fuzzer) {
- sanitize.Properties.SanitizerEnabled = true
- }
-
- if ctx.Os() == android.Android && Bool(s.Address) {
- sanitize.Properties.SanitizerEnabled = true
- }
-
// HWASan requires AArch64 hardware feature (top-byte-ignore).
if ctx.Arch().ArchType != android.Arm64 || !ctx.Os().Bionic() {
s.Hwaddress = nil
@@ -219,7 +209,9 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) {
s.Memtag_heap = nil
}
- if ctx.Os() == android.Android && (Bool(s.Hwaddress) || Bool(s.Address) || Bool(s.Memtag_heap)) {
+ // TODO:(b/178369775)
+ // For now sanitizing is only supported on devices
+ if ctx.Os() == android.Android && (Bool(s.Hwaddress) || Bool(s.Address) || Bool(s.Memtag_heap) || Bool(s.Fuzzer)) {
sanitize.Properties.SanitizerEnabled = true
}
}
diff --git a/ui/build/soong.go b/ui/build/soong.go
index e0d67cc84..28c6ec937 100644
--- a/ui/build/soong.go
+++ b/ui/build/soong.go
@@ -404,6 +404,7 @@ func runSoong(ctx Context, config Config) {
soongBuildEnv.Set("BAZEL_WORKSPACE", absPath(ctx, "."))
soongBuildEnv.Set("BAZEL_METRICS_DIR", config.BazelMetricsDir())
soongBuildEnv.Set("LOG_DIR", config.LogsDir())
+ soongBuildEnv.Set("BAZEL_DEPS_FILE", filepath.Join(os.Getenv("TOP"), config.OutDir(), "tools", "bazel.list"))
// For Soong bootstrapping tests
if os.Getenv("ALLOW_MISSING_DEPENDENCIES") == "true" {