Merge changes I866850b3,I9022d17b am: ff1c8c49c0
am: d39b826a04
am: c7587234fb
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1656461 Change-Id: I32f631bf90e2a30adaedd6a25cfa97a0dfbc2fae
This commit is contained in:
commit
a3c3ba8605
|
@ -226,11 +226,8 @@ type Javadoc struct {
|
|||
srcJars android.Paths
|
||||
srcFiles android.Paths
|
||||
sourcepaths android.Paths
|
||||
argFiles android.Paths
|
||||
implicits android.Paths
|
||||
|
||||
args []string
|
||||
|
||||
docZip android.WritablePath
|
||||
stubsSrcJar android.WritablePath
|
||||
}
|
||||
|
@ -480,15 +477,20 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
|
|||
j.sourcepaths = android.PathsForModuleSrc(ctx, []string{"."})
|
||||
}
|
||||
|
||||
j.argFiles = android.PathsForModuleSrc(ctx, j.properties.Arg_files)
|
||||
return deps
|
||||
}
|
||||
|
||||
func (j *Javadoc) expandArgs(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
|
||||
var argFiles android.Paths
|
||||
argFilesMap := map[string]string{}
|
||||
argFileLabels := []string{}
|
||||
|
||||
for _, label := range j.properties.Arg_files {
|
||||
var paths = android.PathsForModuleSrc(ctx, []string{label})
|
||||
if _, exists := argFilesMap[label]; !exists {
|
||||
argFilesMap[label] = strings.Join(paths.Strings(), " ")
|
||||
argFilesMap[label] = strings.Join(cmd.PathsForInputs(paths), " ")
|
||||
argFileLabels = append(argFileLabels, label)
|
||||
argFiles = append(argFiles, paths...)
|
||||
} else {
|
||||
ctx.ModuleErrorf("multiple arg_files for %q, %q and %q",
|
||||
label, argFilesMap[label], paths)
|
||||
|
@ -508,7 +510,7 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
|
|||
}
|
||||
|
||||
for _, flag := range flags {
|
||||
args, err := android.Expand(flag, func(name string) (string, error) {
|
||||
expanded, err := android.Expand(flag, func(name string) (string, error) {
|
||||
if strings.HasPrefix(name, "location ") {
|
||||
label := strings.TrimSpace(strings.TrimPrefix(name, "location "))
|
||||
if paths, ok := argFilesMap[label]; ok {
|
||||
|
@ -526,10 +528,10 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
|
|||
if err != nil {
|
||||
ctx.PropertyErrorf(argsPropertyName, "%s", err.Error())
|
||||
}
|
||||
j.args = append(j.args, args)
|
||||
cmd.Flag(expanded)
|
||||
}
|
||||
|
||||
return deps
|
||||
cmd.Implicits(argFiles)
|
||||
}
|
||||
|
||||
func (j *Javadoc) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
|
@ -563,6 +565,8 @@ func (j *Javadoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
Flag("-XDignore.symbol.file").
|
||||
Flag("-Xdoclint:none")
|
||||
|
||||
j.expandArgs(ctx, cmd)
|
||||
|
||||
rule.Command().
|
||||
BuiltTool("soong_zip").
|
||||
Flag("-write_if_changed").
|
||||
|
@ -821,7 +825,7 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
deps.bootClasspath, deps.classpath, d.Javadoc.sourcepaths)
|
||||
}
|
||||
|
||||
cmd.Flag(strings.Join(d.Javadoc.args, " ")).Implicits(d.Javadoc.argFiles)
|
||||
d.expandArgs(ctx, cmd)
|
||||
|
||||
if d.properties.Compat_config != nil {
|
||||
compatConfig := android.PathForModuleSrc(ctx, String(d.properties.Compat_config))
|
||||
|
|
|
@ -284,7 +284,7 @@ func (d *Droidstubs) annotationsFlags(ctx android.ModuleContext, cmd *android.Ru
|
|||
cmd.Flag("--include-annotations")
|
||||
|
||||
validatingNullability :=
|
||||
android.InList("--validate-nullability-from-merged-stubs", d.Javadoc.args) ||
|
||||
strings.Contains(String(d.Javadoc.properties.Args), "--validate-nullability-from-merged-stubs") ||
|
||||
String(d.properties.Validate_nullability_from_list) != ""
|
||||
|
||||
migratingNullability := String(d.properties.Previous_api) != ""
|
||||
|
@ -360,7 +360,16 @@ func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *a
|
|||
ctx.VisitDirectDepsWithTag(metalavaAPILevelsAnnotationsDirTag, func(m android.Module) {
|
||||
if t, ok := m.(*ExportedDroiddocDir); ok {
|
||||
for _, dep := range t.deps {
|
||||
if strings.HasSuffix(dep.String(), filename) {
|
||||
if dep.Base() == filename {
|
||||
cmd.Implicit(dep)
|
||||
}
|
||||
if filename != "android.jar" && dep.Base() == "android.jar" {
|
||||
// Metalava implicitly searches these patterns:
|
||||
// prebuilts/tools/common/api-versions/android-%/android.jar
|
||||
// prebuilts/sdk/%/public/android.jar
|
||||
// Add android.jar files from the api_levels_annotations_dirs directories to try
|
||||
// to satisfy these patterns. If Metalava can't find a match for an API level
|
||||
// between 1 and 28 in at least one pattern it will fail.
|
||||
cmd.Implicit(dep)
|
||||
}
|
||||
}
|
||||
|
@ -509,14 +518,8 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
d.inclusionAnnotationsFlags(ctx, cmd)
|
||||
d.apiLevelsAnnotationsFlags(ctx, cmd)
|
||||
|
||||
if android.InList("--generate-documentation", d.Javadoc.args) {
|
||||
// Currently Metalava have the ability to invoke Javadoc in a separate process.
|
||||
// Pass "-nodocs" to suppress the Javadoc invocation when Metalava receives
|
||||
// "--generate-documentation" arg. This is not needed when Metalava removes this feature.
|
||||
d.Javadoc.args = append(d.Javadoc.args, "-nodocs")
|
||||
}
|
||||
d.expandArgs(ctx, cmd)
|
||||
|
||||
cmd.Flag(strings.Join(d.Javadoc.args, " ")).Implicits(d.Javadoc.argFiles)
|
||||
for _, o := range d.Javadoc.properties.Out {
|
||||
cmd.ImplicitOutput(android.PathForModuleGen(ctx, o))
|
||||
}
|
||||
|
|
|
@ -81,10 +81,19 @@ func TestDroidstubs(t *testing.T) {
|
|||
|
||||
func TestDroidstubsSandbox(t *testing.T) {
|
||||
ctx, _ := testJavaWithFS(t, `
|
||||
genrule {
|
||||
name: "foo",
|
||||
out: ["foo.txt"],
|
||||
cmd: "touch $(out)",
|
||||
}
|
||||
|
||||
droidstubs {
|
||||
name: "bar-stubs",
|
||||
srcs: ["bar-doc/a.java"],
|
||||
sandbox: true,
|
||||
|
||||
args: "--reference $(location :foo)",
|
||||
arg_files: [":foo"],
|
||||
}
|
||||
`,
|
||||
map[string][]byte{
|
||||
|
@ -96,6 +105,11 @@ func TestDroidstubsSandbox(t *testing.T) {
|
|||
if g, w := metalava.Inputs.Strings(), []string{"bar-doc/a.java"}; !reflect.DeepEqual(w, g) {
|
||||
t.Errorf("Expected inputs %q, got %q", w, g)
|
||||
}
|
||||
|
||||
manifest := android.RuleBuilderSboxProtoForTests(t, m.Output("metalava.sbox.textproto"))
|
||||
if g, w := manifest.Commands[0].GetCommand(), "reference __SBOX_SANDBOX_DIR__/out/.intermediates/foo/gen/foo.txt"; !strings.Contains(g, w) {
|
||||
t.Errorf("Expected command to contain %q, got %q", w, g)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDroidstubsWithSystemModules(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue