summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/rule_builder.go22
-rw-r--r--apex/apex.go9
-rw-r--r--apex/apex_test.go55
-rw-r--r--apex/builder.go4
-rw-r--r--java/androidmk_test.go33
-rwxr-xr-xjava/app.go2
-rw-r--r--java/droiddoc.go87
-rw-r--r--java/sdk_library.go14
-rw-r--r--rust/library.go4
-rw-r--r--rust/library_test.go20
10 files changed, 195 insertions, 55 deletions
diff --git a/android/rule_builder.go b/android/rule_builder.go
index 6226548ba..afb5f4e4a 100644
--- a/android/rule_builder.go
+++ b/android/rule_builder.go
@@ -172,7 +172,7 @@ func (r *RuleBuilder) Inputs() Paths {
inputs := make(map[string]Path)
for _, c := range r.commands {
- for _, input := range c.inputs {
+ for _, input := range append(c.inputs, c.implicits...) {
inputStr := input.String()
if _, isOutput := outputs[inputStr]; !isOutput {
if _, isDepFile := depFiles[inputStr]; !isDepFile {
@@ -480,6 +480,7 @@ func (r *RuleBuilder) Build(pctx PackageContext, ctx BuilderContext, name string
type RuleBuilderCommand struct {
buf strings.Builder
inputs Paths
+ implicits Paths
orderOnlys Paths
outputs WritablePaths
depFiles WritablePaths
@@ -503,6 +504,16 @@ func (c *RuleBuilderCommand) addInput(path Path) string {
return path.String()
}
+func (c *RuleBuilderCommand) addImplicit(path Path) string {
+ if c.sbox {
+ if rel, isRel, _ := maybeRelErr(c.sboxOutDir.String(), path.String()); isRel {
+ return "__SBOX_OUT_DIR__/" + rel
+ }
+ }
+ c.implicits = append(c.implicits, path)
+ return path.String()
+}
+
func (c *RuleBuilderCommand) addOrderOnly(path Path) {
c.orderOnlys = append(c.orderOnlys, path)
}
@@ -623,7 +634,7 @@ func (c *RuleBuilderCommand) Inputs(paths Paths) *RuleBuilderCommand {
// Implicit adds the specified input path to the dependencies returned by RuleBuilder.Inputs without modifying the
// command line.
func (c *RuleBuilderCommand) Implicit(path Path) *RuleBuilderCommand {
- c.addInput(path)
+ c.addImplicit(path)
return c
}
@@ -631,11 +642,16 @@ func (c *RuleBuilderCommand) Implicit(path Path) *RuleBuilderCommand {
// command line.
func (c *RuleBuilderCommand) Implicits(paths Paths) *RuleBuilderCommand {
for _, path := range paths {
- c.addInput(path)
+ c.addImplicit(path)
}
return c
}
+// GetImplicits returns the command's implicit inputs.
+func (c *RuleBuilderCommand) GetImplicits() Paths {
+ return c.implicits
+}
+
// OrderOnly adds the specified input path to the dependencies returned by RuleBuilder.OrderOnlys
// without modifying the command line.
func (c *RuleBuilderCommand) OrderOnly(path Path) *RuleBuilderCommand {
diff --git a/apex/apex.go b/apex/apex.go
index 840dd4983..e308d488f 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -985,9 +985,6 @@ type apexBundleProperties struct {
// List of providing APEXes' names so that this APEX can depend on provided shared libraries.
Uses []string
- // A txt file containing list of files that are allowed to be included in this APEX.
- Allowed_files *string
-
// package format of this apex variant; could be non-flattened, flattened, or zip.
// imageApex, zipApex or flattened
ApexType apexPackaging `blueprint:"mutated"`
@@ -1063,6 +1060,9 @@ type overridableProperties struct {
// Apex Container Package Name.
// Override value for attribute package:name in AndroidManifest.xml
Package_name string
+
+ // A txt file containing list of files that are allowed to be included in this APEX.
+ Allowed_files *string `android:"path"`
}
type apexPackaging int
@@ -1454,6 +1454,9 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
}
func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) {
+ if a.overridableProperties.Allowed_files != nil {
+ android.ExtractSourceDeps(ctx, a.overridableProperties.Allowed_files)
+ }
ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
androidAppTag, a.overridableProperties.Apps...)
ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
diff --git a/apex/apex_test.go b/apex/apex_test.go
index a7a776561..3d5886ea9 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -5396,6 +5396,61 @@ func TestApexKeysTxt(t *testing.T) {
ensureNotContains(t, content, "myapex.apex")
}
+func TestAllowedFiles(t *testing.T) {
+ ctx, _ := testApex(t, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ apps: ["app"],
+ allowed_files: "allowed.txt",
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+
+ android_app {
+ name: "app",
+ srcs: ["foo/bar/MyClass.java"],
+ package_name: "foo",
+ sdk_version: "none",
+ system_modules: "none",
+ apex_available: [ "myapex" ],
+ }
+ `, withFiles(map[string][]byte{
+ "sub/Android.bp": []byte(`
+ override_apex {
+ name: "override_myapex",
+ base: "myapex",
+ apps: ["override_app"],
+ allowed_files: ":allowed",
+ }
+ // Overridable "path" property should be referenced indirectly
+ filegroup {
+ name: "allowed",
+ srcs: ["allowed.txt"],
+ }
+ override_android_app {
+ name: "override_app",
+ base: "app",
+ package_name: "bar",
+ }
+ `),
+ }))
+
+ rule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("diffApexContentRule")
+ if expected, actual := "allowed.txt", rule.Args["allowed_files_file"]; expected != actual {
+ t.Errorf("allowed_files_file: expected %q but got %q", expected, actual)
+ }
+
+ rule2 := ctx.ModuleForTests("myapex", "android_common_override_myapex_myapex_image").Rule("diffApexContentRule")
+ if expected, actual := "sub/allowed.txt", rule2.Args["allowed_files_file"]; expected != actual {
+ t.Errorf("allowed_files_file: expected %q but got %q", expected, actual)
+ }
+}
+
func TestMain(m *testing.M) {
run := func() int {
setUp()
diff --git a/apex/builder.go b/apex/builder.go
index 53c119391..af43417aa 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -391,7 +391,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
emitCommands = append(emitCommands, "sort -o "+imageContentFile.String()+" "+imageContentFile.String())
implicitInputs = append(implicitInputs, a.manifestPbOut)
- if a.properties.Allowed_files != nil {
+ if a.overridableProperties.Allowed_files != nil {
ctx.Build(pctx, android.BuildParams{
Rule: emitApexContentRule,
Implicits: implicitInputs,
@@ -402,7 +402,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
},
})
implicitInputs = append(implicitInputs, imageContentFile)
- allowedFilesFile := android.PathForModuleSrc(ctx, proptools.String(a.properties.Allowed_files))
+ allowedFilesFile := android.PathForModuleSrc(ctx, proptools.String(a.overridableProperties.Allowed_files))
phonyOutput := android.PathForModuleOut(ctx, a.Name()+"-diff-phony-output")
ctx.Build(pctx, android.BuildParams{
diff --git a/java/androidmk_test.go b/java/androidmk_test.go
index 7daa6244f..d471fb7d5 100644
--- a/java/androidmk_test.go
+++ b/java/androidmk_test.go
@@ -169,3 +169,36 @@ func TestDistWithTag(t *testing.T) {
t.Errorf("did not expect explicit DistFile, got %v", without_tag_entries[0].DistFile)
}
}
+
+func TestJavaSdkLibrary_RequireXmlPermissionFile(t *testing.T) {
+ ctx, config := testJava(t, `
+ java_sdk_library {
+ name: "foo-shared_library",
+ srcs: ["a.java"],
+ }
+ java_sdk_library {
+ name: "foo-no_shared_library",
+ srcs: ["a.java"],
+ shared_library: false,
+ }
+ `)
+
+ // Verify the existence of internal modules
+ ctx.ModuleForTests("foo-shared_library.xml", "android_common")
+
+ testCases := []struct {
+ moduleName string
+ expected []string
+ }{
+ {"foo-shared_library", []string{"foo-shared_library.xml"}},
+ {"foo-no_shared_library", nil},
+ }
+ for _, tc := range testCases {
+ mod := ctx.ModuleForTests(tc.moduleName, "android_common").Module()
+ entries := android.AndroidMkEntriesForTest(t, config, "", mod)[0]
+ actual := entries.EntryMap["LOCAL_REQUIRED_MODULES"]
+ if !reflect.DeepEqual(tc.expected, actual) {
+ t.Errorf("Unexpected required modules - expected: %q, actual: %q", tc.expected, actual)
+ }
+ }
+}
diff --git a/java/app.go b/java/app.go
index 1d2c58227..c568516eb 100755
--- a/java/app.go
+++ b/java/app.go
@@ -151,7 +151,7 @@ func (as *AndroidAppSet) GenerateAndroidBuildActions(ctx android.ModuleContext)
"allow-prereleased": strconv.FormatBool(proptools.Bool(as.properties.Prerelease)),
"screen-densities": screenDensities,
"sdk-version": ctx.Config().PlatformSdkVersion(),
- "stem": ctx.ModuleName(),
+ "stem": as.BaseModuleName(),
},
})
}
diff --git a/java/droiddoc.go b/java/droiddoc.go
index 5cb70e4cd..a0b7edfea 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -121,6 +121,10 @@ type JavadocProperties struct {
// names of the output files used in args that will be generated
Out []string
+
+ // If set, metalava is sandboxed to only read files explicitly specified on the command
+ // line. Defaults to false.
+ Sandbox *bool
}
type ApiToCheck struct {
@@ -1415,7 +1419,7 @@ func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *a
}
func (d *Droidstubs) apiToXmlFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
- if Bool(d.properties.Jdiff_enabled) && !ctx.Config().IsPdkBuild() {
+ if Bool(d.properties.Jdiff_enabled) && !ctx.Config().IsPdkBuild() && d.apiFile != nil {
if d.apiFile.String() == "" {
ctx.ModuleErrorf("API signature file has to be specified in Metalava when jdiff is enabled.")
}
@@ -1435,41 +1439,25 @@ func (d *Droidstubs) apiToXmlFlags(ctx android.ModuleContext, cmd *android.RuleB
}
func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersion javaVersion, srcs android.Paths,
- srcJarList android.Path, bootclasspath, classpath classpath, sourcepaths android.Paths, implicits android.Paths) *android.RuleBuilderCommand {
+ srcJarList android.Path, bootclasspath, classpath classpath, sourcepaths android.Paths, implicitsRsp android.WritablePath, sandbox bool) *android.RuleBuilderCommand {
// Metalava uses lots of memory, restrict the number of metalava jobs that can run in parallel.
rule.HighMem()
cmd := rule.Command()
-
- var implicitsRsp android.WritablePath
- if len(implicits) > 0 {
- implicitsRsp = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"implicits.rsp")
- impRule := android.NewRuleBuilder()
- impCmd := impRule.Command()
- // A dummy action that copies the ninja generated rsp file to a new location. This allows us to
- // add a large number of inputs to a file without exceeding bash command length limits (which
- // would happen if we use the WriteFile rule). The cp is needed because RuleBuilder sets the
- // rsp file to be ${output}.rsp.
- impCmd.Text("cp").FlagWithRspFileInputList("", implicits).Output(implicitsRsp)
- impRule.Build(pctx, ctx, "implicitsGen", "implicits generation")
- cmd.Implicits(implicits)
- cmd.Implicit(implicitsRsp)
- }
if ctx.Config().IsEnvTrue("RBE_METALAVA") {
rule.Remoteable(android.RemoteRuleSupports{RBE: true})
- execStrategy := remoteexec.LocalExecStrategy
- if v := ctx.Config().Getenv("RBE_METALAVA_EXEC_STRATEGY"); v != "" {
- execStrategy = v
- }
- pool := "metalava"
- if v := ctx.Config().Getenv("RBE_METALAVA_POOL"); v != "" {
- pool = v
+ pool := ctx.Config().GetenvWithDefault("RBE_METALAVA_POOL", "metalava")
+ execStrategy := ctx.Config().GetenvWithDefault("RBE_METALAVA_EXEC_STRATEGY", remoteexec.LocalExecStrategy)
+ labels := map[string]string{"type": "compile", "lang": "java", "compiler": "metalava"}
+ if !sandbox {
+ execStrategy = remoteexec.LocalExecStrategy
+ labels["shallow"] = "true"
}
inputs := []string{android.PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "framework", "metalava.jar").String()}
if v := ctx.Config().Getenv("RBE_METALAVA_INPUTS"); v != "" {
inputs = append(inputs, strings.Split(v, ",")...)
}
cmd.Text((&remoteexec.REParams{
- Labels: map[string]string{"type": "compile", "lang": "java", "compiler": "metalava", "shallow": "true"},
+ Labels: labels,
ExecStrategy: execStrategy,
Inputs: inputs,
RSPFile: implicitsRsp.String(),
@@ -1483,8 +1471,17 @@ func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersi
FlagWithArg("-encoding ", "UTF-8").
FlagWithArg("-source ", javaVersion.String()).
FlagWithRspFileInputList("@", srcs).
- FlagWithInput("@", srcJarList).
- FlagWithOutput("--strict-input-files:warn ", android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"violations.txt"))
+ FlagWithInput("@", srcJarList)
+
+ if javaHome := ctx.Config().Getenv("ANDROID_JAVA_HOME"); javaHome != "" {
+ cmd.Implicit(android.PathForSource(ctx, javaHome))
+ }
+
+ if sandbox {
+ cmd.FlagWithOutput("--strict-input-files ", android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"violations.txt"))
+ } else {
+ cmd.FlagWithOutput("--strict-input-files:warn ", android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"violations.txt"))
+ }
if implicitsRsp != nil {
cmd.FlagWithArg("--strict-input-files-exempt ", "@"+implicitsRsp.String())
@@ -1534,8 +1531,12 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
srcJarList := zipSyncCmd(ctx, rule, srcJarDir, d.Javadoc.srcJars)
+ implicitsRsp := android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"implicits.rsp")
+
cmd := metalavaCmd(ctx, rule, javaVersion, d.Javadoc.srcFiles, srcJarList,
- deps.bootClasspath, deps.classpath, d.Javadoc.sourcepaths, d.Javadoc.implicits)
+ deps.bootClasspath, deps.classpath, d.Javadoc.sourcepaths, implicitsRsp,
+ Bool(d.Javadoc.properties.Sandbox))
+ cmd.Implicits(d.Javadoc.implicits)
d.stubsFlags(ctx, cmd, stubsDir)
@@ -1654,6 +1655,16 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
cmd.FlagWithArg("--error-message:compatibility:released ", msg)
}
+ impRule := android.NewRuleBuilder()
+ impCmd := impRule.Command()
+ // A dummy action that copies the ninja generated rsp file to a new location. This allows us to
+ // add a large number of inputs to a file without exceeding bash command length limits (which
+ // would happen if we use the WriteFile rule). The cp is needed because RuleBuilder sets the
+ // rsp file to be ${output}.rsp.
+ impCmd.Text("cp").FlagWithRspFileInputList("", cmd.GetImplicits()).Output(implicitsRsp)
+ impRule.Build(pctx, ctx, "implicitsGen", "implicits generation")
+ cmd.Implicit(implicitsRsp)
+
if generateStubs {
rule.Command().
BuiltTool(ctx, "soong_zip").
@@ -1836,13 +1847,19 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Flag("-XDignore.symbol.file").
FlagWithArg("-doclet ", "jdiff.JDiff").
FlagWithInput("-docletpath ", jdiff).
- Flag("-quiet").
- FlagWithArg("-newapi ", strings.TrimSuffix(d.apiXmlFile.Base(), d.apiXmlFile.Ext())).
- FlagWithArg("-newapidir ", filepath.Dir(d.apiXmlFile.String())).
- Implicit(d.apiXmlFile).
- FlagWithArg("-oldapi ", strings.TrimSuffix(d.lastReleasedApiXmlFile.Base(), d.lastReleasedApiXmlFile.Ext())).
- FlagWithArg("-oldapidir ", filepath.Dir(d.lastReleasedApiXmlFile.String())).
- Implicit(d.lastReleasedApiXmlFile)
+ Flag("-quiet")
+
+ if d.apiXmlFile != nil {
+ cmd.FlagWithArg("-newapi ", strings.TrimSuffix(d.apiXmlFile.Base(), d.apiXmlFile.Ext())).
+ FlagWithArg("-newapidir ", filepath.Dir(d.apiXmlFile.String())).
+ Implicit(d.apiXmlFile)
+ }
+
+ if d.lastReleasedApiXmlFile != nil {
+ cmd.FlagWithArg("-oldapi ", strings.TrimSuffix(d.lastReleasedApiXmlFile.Base(), d.lastReleasedApiXmlFile.Ext())).
+ FlagWithArg("-oldapidir ", filepath.Dir(d.lastReleasedApiXmlFile.String())).
+ Implicit(d.lastReleasedApiXmlFile)
+ }
rule.Command().
BuiltTool(ctx, "soong_zip").
diff --git a/java/sdk_library.go b/java/sdk_library.go
index cc51e3abe..676557e64 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -1042,8 +1042,10 @@ func (module *SdkLibrary) AndroidMkEntries() []android.AndroidMkEntries {
return nil
}
entriesList := module.Library.AndroidMkEntries()
- entries := &entriesList[0]
- entries.Required = append(entries.Required, module.xmlPermissionsModuleName())
+ if module.sharedLibrary() {
+ entries := &entriesList[0]
+ entries.Required = append(entries.Required, module.xmlPermissionsModuleName())
+ }
return entriesList
}
@@ -2191,8 +2193,12 @@ func (s *sdkLibrarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMembe
properties.Jars = jars
properties.SdkVersion = sdk.sdkVersionForStubsLibrary(ctx.SdkModuleContext(), apiScope)
properties.StubsSrcJar = paths.stubsSrcJar.Path()
- properties.CurrentApiFile = paths.currentApiFilePath.Path()
- properties.RemovedApiFile = paths.removedApiFilePath.Path()
+ if paths.currentApiFilePath.Valid() {
+ properties.CurrentApiFile = paths.currentApiFilePath.Path()
+ }
+ if paths.removedApiFilePath.Valid() {
+ properties.RemovedApiFile = paths.removedApiFilePath.Path()
+ }
s.Scopes[apiScope] = properties
}
}
diff --git a/rust/library.go b/rust/library.go
index 704c77b40..3c948ea09 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -305,8 +305,8 @@ func (library *libraryDecorator) compilerProps() []interface{} {
func (library *libraryDecorator) compilerDeps(ctx DepsContext, deps Deps) Deps {
- // TODO(b/144861059) Remove if C libraries support dylib linkage in the future.
- if !ctx.Host() && (library.static() || library.shared()) {
+ // TODO(b/155498724) Remove if C static libraries no longer require libstd as an rlib dependency.
+ if !ctx.Host() && library.static() {
library.setNoStdlibs()
for _, stdlib := range config.Stdlibs {
deps.Rlibs = append(deps.Rlibs, stdlib+".static")
diff --git a/rust/library_test.go b/rust/library_test.go
index 37dd5414c..9d2f6c00a 100644
--- a/rust/library_test.go
+++ b/rust/library_test.go
@@ -17,6 +17,8 @@ package rust
import (
"strings"
"testing"
+
+ "android/soong/android"
)
// Test that variants are being generated correctly, and that crate-types are correct.
@@ -115,16 +117,24 @@ func TestValidateLibraryStem(t *testing.T) {
}
-func TestSharedLibraryFlags(t *testing.T) {
+func TestSharedLibrary(t *testing.T) {
ctx := testRust(t, `
- rust_library_host {
+ rust_library {
name: "libfoo",
srcs: ["foo.rs"],
crate_name: "foo",
}`)
- libfooShared := ctx.ModuleForTests("libfoo", "linux_glibc_x86_64_shared").Output("libfoo.so")
- if !strings.Contains(libfooShared.Args["linkFlags"], "-Wl,-soname=libfoo.so") {
- t.Errorf("missing expected -Wl,-soname linker flag for libfoo shared lib, linkFlags: %#v", libfooShared.Args["linkFlags"])
+ libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_shared")
+
+ libfooOutput := libfoo.Output("libfoo.so")
+ if !strings.Contains(libfooOutput.Args["linkFlags"], "-Wl,-soname=libfoo.so") {
+ t.Errorf("missing expected -Wl,-soname linker flag for libfoo shared lib, linkFlags: %#v",
+ libfooOutput.Args["linkFlags"])
+ }
+
+ if !android.InList("libstd", libfoo.Module().(*Module).Properties.AndroidMkDylibs) {
+ t.Errorf("Non-static libstd dylib expected to be a dependency of Rust shared libraries. Dylib deps are: %#v",
+ libfoo.Module().(*Module).Properties.AndroidMkDylibs)
}
}