2018-01-11 01:06:12 +01:00
|
|
|
// Copyright 2018 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package java
|
|
|
|
|
|
|
|
import (
|
|
|
|
"android/soong/android"
|
|
|
|
"android/soong/java/config"
|
|
|
|
"fmt"
|
2018-02-23 20:18:47 +01:00
|
|
|
"path/filepath"
|
2018-06-04 20:28:01 +02:00
|
|
|
"runtime"
|
2018-01-11 01:06:12 +01:00
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/google/blueprint"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
javadoc = pctx.AndroidStaticRule("javadoc",
|
|
|
|
blueprint.RuleParams{
|
|
|
|
Command: `rm -rf "$outDir" "$srcJarDir" "$stubsDir" && mkdir -p "$outDir" "$srcJarDir" "$stubsDir" && ` +
|
2018-03-16 00:24:10 +01:00
|
|
|
`${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` +
|
2018-10-03 01:11:17 +02:00
|
|
|
`${config.SoongJavacWrapper} ${config.JavadocCmd} -encoding UTF-8 @$out.rsp @$srcJarDir/list ` +
|
2018-09-05 02:14:32 +02:00
|
|
|
`$opts $bootclasspathArgs $classpathArgs $sourcepathArgs ` +
|
2018-01-11 01:06:12 +01:00
|
|
|
`-d $outDir -quiet && ` +
|
|
|
|
`${config.SoongZipCmd} -write_if_changed -d -o $docZip -C $outDir -D $outDir && ` +
|
2019-01-25 01:36:57 +01:00
|
|
|
`${config.SoongZipCmd} -write_if_changed -jar -o $out -C $stubsDir -D $stubsDir $postDoclavaCmds && ` +
|
|
|
|
`rm -rf "$srcJarDir"`,
|
|
|
|
|
2018-01-11 01:06:12 +01:00
|
|
|
CommandDeps: []string{
|
2018-03-16 00:24:10 +01:00
|
|
|
"${config.ZipSyncCmd}",
|
2018-01-11 01:06:12 +01:00
|
|
|
"${config.JavadocCmd}",
|
|
|
|
"${config.SoongZipCmd}",
|
|
|
|
},
|
2018-10-03 01:11:17 +02:00
|
|
|
CommandOrderOnly: []string{"${config.SoongJavacWrapper}"},
|
|
|
|
Rspfile: "$out.rsp",
|
|
|
|
RspfileContent: "$in",
|
|
|
|
Restat: true,
|
2018-01-11 01:06:12 +01:00
|
|
|
},
|
2018-06-20 00:15:38 +02:00
|
|
|
"outDir", "srcJarDir", "stubsDir", "srcJars", "opts",
|
2018-09-05 02:14:32 +02:00
|
|
|
"bootclasspathArgs", "classpathArgs", "sourcepathArgs", "docZip", "postDoclavaCmds")
|
2018-05-05 03:49:16 +02:00
|
|
|
|
|
|
|
apiCheck = pctx.AndroidStaticRule("apiCheck",
|
|
|
|
blueprint.RuleParams{
|
|
|
|
Command: `( ${config.ApiCheckCmd} -JXmx1024m -J"classpath $classpath" $opts ` +
|
|
|
|
`$apiFile $apiFileToCheck $removedApiFile $removedApiFileToCheck ` +
|
2018-05-12 15:21:20 +02:00
|
|
|
`&& touch $out ) || (echo -e "$msg" ; exit 38)`,
|
2018-05-05 03:49:16 +02:00
|
|
|
CommandDeps: []string{
|
|
|
|
"${config.ApiCheckCmd}",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"classpath", "opts", "apiFile", "apiFileToCheck", "removedApiFile", "removedApiFileToCheck", "msg")
|
|
|
|
|
|
|
|
updateApi = pctx.AndroidStaticRule("updateApi",
|
|
|
|
blueprint.RuleParams{
|
2018-09-05 02:14:32 +02:00
|
|
|
Command: `( ( cp -f $srcApiFile $destApiFile && cp -f $srcRemovedApiFile $destRemovedApiFile ) ` +
|
2018-05-05 03:49:16 +02:00
|
|
|
`&& touch $out ) || (echo failed to update public API ; exit 38)`,
|
|
|
|
},
|
2018-09-05 02:14:32 +02:00
|
|
|
"srcApiFile", "destApiFile", "srcRemovedApiFile", "destRemovedApiFile")
|
2018-04-20 03:03:39 +02:00
|
|
|
|
|
|
|
metalava = pctx.AndroidStaticRule("metalava",
|
|
|
|
blueprint.RuleParams{
|
2018-09-05 02:14:32 +02:00
|
|
|
Command: `rm -rf "$outDir" "$srcJarDir" "$stubsDir" && ` +
|
|
|
|
`mkdir -p "$outDir" "$srcJarDir" "$stubsDir" && ` +
|
2018-04-20 03:03:39 +02:00
|
|
|
`${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` +
|
2019-05-31 05:15:55 +02:00
|
|
|
`${config.JavaCmd} -jar ${config.MetalavaJar} -encoding UTF-8 -source $javaVersion @$out.rsp @$srcJarDir/list ` +
|
2018-12-27 05:34:29 +01:00
|
|
|
`$bootclasspathArgs $classpathArgs $sourcepathArgs --no-banner --color --quiet --format=v2 ` +
|
2018-09-05 02:14:32 +02:00
|
|
|
`$opts && ` +
|
2019-01-25 01:36:57 +01:00
|
|
|
`${config.SoongZipCmd} -write_if_changed -jar -o $out -C $stubsDir -D $stubsDir && ` +
|
|
|
|
`rm -rf "$srcJarDir"`,
|
2018-04-20 03:03:39 +02:00
|
|
|
CommandDeps: []string{
|
|
|
|
"${config.ZipSyncCmd}",
|
|
|
|
"${config.JavaCmd}",
|
|
|
|
"${config.MetalavaJar}",
|
|
|
|
"${config.SoongZipCmd}",
|
|
|
|
},
|
|
|
|
Rspfile: "$out.rsp",
|
|
|
|
RspfileContent: "$in",
|
|
|
|
Restat: true,
|
|
|
|
},
|
2018-09-05 02:14:32 +02:00
|
|
|
"outDir", "srcJarDir", "stubsDir", "srcJars", "javaVersion", "bootclasspathArgs",
|
|
|
|
"classpathArgs", "sourcepathArgs", "opts")
|
2018-08-24 19:32:54 +02:00
|
|
|
|
|
|
|
metalavaApiCheck = pctx.AndroidStaticRule("metalavaApiCheck",
|
|
|
|
blueprint.RuleParams{
|
|
|
|
Command: `( rm -rf "$srcJarDir" && mkdir -p "$srcJarDir" && ` +
|
|
|
|
`${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` +
|
2019-05-31 05:15:55 +02:00
|
|
|
`${config.JavaCmd} -jar ${config.MetalavaJar} -encoding UTF-8 -source $javaVersion @$out.rsp @$srcJarDir/list ` +
|
2018-12-27 05:34:29 +01:00
|
|
|
`$bootclasspathArgs $classpathArgs $sourcepathArgs --no-banner --color --quiet --format=v2 ` +
|
2019-01-25 01:36:57 +01:00
|
|
|
`$opts && touch $out && rm -rf "$srcJarDir") || ` +
|
2018-08-24 19:32:54 +02:00
|
|
|
`( echo -e "$msg" ; exit 38 )`,
|
|
|
|
CommandDeps: []string{
|
|
|
|
"${config.ZipSyncCmd}",
|
|
|
|
"${config.JavaCmd}",
|
|
|
|
"${config.MetalavaJar}",
|
|
|
|
},
|
|
|
|
Rspfile: "$out.rsp",
|
|
|
|
RspfileContent: "$in",
|
|
|
|
},
|
2018-09-05 02:14:32 +02:00
|
|
|
"srcJarDir", "srcJars", "javaVersion", "bootclasspathArgs", "classpathArgs", "sourcepathArgs", "opts", "msg")
|
|
|
|
|
2018-10-22 16:55:04 +02:00
|
|
|
nullabilityWarningsCheck = pctx.AndroidStaticRule("nullabilityWarningsCheck",
|
|
|
|
blueprint.RuleParams{
|
|
|
|
Command: `( diff $expected $actual && touch $out ) || ( echo -e "$msg" ; exit 38 )`,
|
|
|
|
},
|
|
|
|
"expected", "actual", "msg")
|
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
dokka = pctx.AndroidStaticRule("dokka",
|
|
|
|
blueprint.RuleParams{
|
|
|
|
Command: `rm -rf "$outDir" "$srcJarDir" "$stubsDir" && ` +
|
|
|
|
`mkdir -p "$outDir" "$srcJarDir" "$stubsDir" && ` +
|
|
|
|
`${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` +
|
2019-05-31 05:15:55 +02:00
|
|
|
`${config.JavaCmd} -jar ${config.DokkaJar} $srcJarDir ` +
|
2018-09-05 02:14:32 +02:00
|
|
|
`$classpathArgs -format dac -dacRoot /reference/kotlin -output $outDir $opts && ` +
|
|
|
|
`${config.SoongZipCmd} -write_if_changed -d -o $docZip -C $outDir -D $outDir && ` +
|
2019-01-25 01:36:57 +01:00
|
|
|
`${config.SoongZipCmd} -write_if_changed -jar -o $out -C $stubsDir -D $stubsDir && ` +
|
|
|
|
`rm -rf "$srcJarDir"`,
|
2018-09-05 02:14:32 +02:00
|
|
|
CommandDeps: []string{
|
|
|
|
"${config.ZipSyncCmd}",
|
|
|
|
"${config.DokkaJar}",
|
|
|
|
"${config.MetalavaJar}",
|
|
|
|
"${config.SoongZipCmd}",
|
|
|
|
},
|
|
|
|
Restat: true,
|
|
|
|
},
|
|
|
|
"outDir", "srcJarDir", "stubsDir", "srcJars", "classpathArgs", "opts", "docZip")
|
2018-01-11 01:06:12 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2018-02-23 20:18:47 +01:00
|
|
|
android.RegisterModuleType("doc_defaults", DocDefaultsFactory)
|
2018-09-05 02:14:32 +02:00
|
|
|
android.RegisterModuleType("stubs_defaults", StubsDefaultsFactory)
|
2018-02-23 20:18:47 +01:00
|
|
|
|
2018-01-11 01:06:12 +01:00
|
|
|
android.RegisterModuleType("droiddoc", DroiddocFactory)
|
|
|
|
android.RegisterModuleType("droiddoc_host", DroiddocHostFactory)
|
2018-08-02 00:00:28 +02:00
|
|
|
android.RegisterModuleType("droiddoc_exported_dir", ExportedDroiddocDirFactory)
|
2018-01-11 01:06:12 +01:00
|
|
|
android.RegisterModuleType("javadoc", JavadocFactory)
|
|
|
|
android.RegisterModuleType("javadoc_host", JavadocHostFactory)
|
2018-09-05 02:14:32 +02:00
|
|
|
|
|
|
|
android.RegisterModuleType("droidstubs", DroidstubsFactory)
|
|
|
|
android.RegisterModuleType("droidstubs_host", DroidstubsHostFactory)
|
2018-01-11 01:06:12 +01:00
|
|
|
}
|
|
|
|
|
2018-06-21 00:19:39 +02:00
|
|
|
var (
|
|
|
|
srcsLibTag = dependencyTag{name: "sources from javalib"}
|
|
|
|
)
|
|
|
|
|
2018-01-11 01:06:12 +01:00
|
|
|
type JavadocProperties struct {
|
|
|
|
// list of source files used to compile the Java module. May be .java, .logtags, .proto,
|
|
|
|
// or .aidl files.
|
2019-03-05 07:35:41 +01:00
|
|
|
Srcs []string `android:"path,arch_variant"`
|
2018-01-11 01:06:12 +01:00
|
|
|
|
|
|
|
// list of directories rooted at the Android.bp file that will
|
|
|
|
// be added to the search paths for finding source files when passing package names.
|
2018-02-23 20:18:47 +01:00
|
|
|
Local_sourcepaths []string
|
2018-01-11 01:06:12 +01:00
|
|
|
|
|
|
|
// list of source files that should not be used to build the Java module.
|
|
|
|
// This is most useful in the arch/multilib variants to remove non-common files
|
|
|
|
// filegroup or genrule can be included within this property.
|
2019-03-05 07:35:41 +01:00
|
|
|
Exclude_srcs []string `android:"path,arch_variant"`
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2018-02-23 20:18:47 +01:00
|
|
|
// list of java libraries that will be in the classpath.
|
2018-01-11 01:06:12 +01:00
|
|
|
Libs []string `android:"arch_variant"`
|
|
|
|
|
2019-02-13 13:49:33 +01:00
|
|
|
// don't build against the default libraries (bootclasspath, ext, and framework for device
|
|
|
|
// targets)
|
2018-09-22 01:39:51 +02:00
|
|
|
No_standard_libs *bool
|
|
|
|
|
2019-02-13 13:49:33 +01:00
|
|
|
// don't build against the framework libraries (ext, and framework for device targets)
|
2018-03-06 21:59:27 +01:00
|
|
|
No_framework_libs *bool
|
|
|
|
|
2018-02-23 20:18:47 +01:00
|
|
|
// the java library (in classpath) for documentation that provides java srcs and srcjars.
|
|
|
|
Srcs_lib *string
|
|
|
|
|
|
|
|
// the base dirs under srcs_lib will be scanned for java srcs.
|
|
|
|
Srcs_lib_whitelist_dirs []string
|
|
|
|
|
|
|
|
// the sub dirs under srcs_lib_whitelist_dirs will be scanned for java srcs.
|
|
|
|
Srcs_lib_whitelist_pkgs []string
|
|
|
|
|
2018-01-11 01:06:12 +01:00
|
|
|
// If set to false, don't allow this module(-docs.zip) to be exported. Defaults to true.
|
2018-02-23 20:18:47 +01:00
|
|
|
Installable *bool
|
2018-01-11 01:06:12 +01:00
|
|
|
|
|
|
|
// if not blank, set to the version of the sdk to compile against
|
|
|
|
Sdk_version *string `android:"arch_variant"`
|
2018-05-23 11:42:04 +02:00
|
|
|
|
|
|
|
Aidl struct {
|
|
|
|
// Top level directories to pass to aidl tool
|
|
|
|
Include_dirs []string
|
|
|
|
|
|
|
|
// Directories rooted at the Android.bp file to pass to aidl tool
|
|
|
|
Local_include_dirs []string
|
|
|
|
}
|
2018-04-18 02:38:36 +02:00
|
|
|
|
|
|
|
// If not blank, set the java version passed to javadoc as -source
|
|
|
|
Java_version *string
|
2018-09-05 02:14:32 +02:00
|
|
|
|
|
|
|
// local files that are used within user customized droiddoc options.
|
2019-03-05 07:35:41 +01:00
|
|
|
Arg_files []string `android:"path"`
|
2018-09-05 02:14:32 +02:00
|
|
|
|
|
|
|
// user customized droiddoc args.
|
|
|
|
// Available variables for substitution:
|
|
|
|
//
|
|
|
|
// $(location <label>): the path to the arg_files with name <label>
|
2019-05-28 19:17:14 +02:00
|
|
|
// $$: a literal $
|
2018-09-05 02:14:32 +02:00
|
|
|
Args *string
|
|
|
|
|
|
|
|
// names of the output files used in args that will be generated
|
|
|
|
Out []string
|
2018-01-11 01:06:12 +01:00
|
|
|
}
|
|
|
|
|
2018-05-05 03:49:16 +02:00
|
|
|
type ApiToCheck struct {
|
2018-05-12 15:21:20 +02:00
|
|
|
// path to the API txt file that the new API extracted from source code is checked
|
|
|
|
// against. The path can be local to the module or from other module (via :module syntax).
|
2019-03-05 07:35:41 +01:00
|
|
|
Api_file *string `android:"path"`
|
2018-05-05 03:49:16 +02:00
|
|
|
|
2018-05-12 15:21:20 +02:00
|
|
|
// path to the API txt file that the new @removed API extractd from source code is
|
|
|
|
// checked against. The path can be local to the module or from other module (via
|
|
|
|
// :module syntax).
|
2019-03-05 07:35:41 +01:00
|
|
|
Removed_api_file *string `android:"path"`
|
2018-05-05 03:49:16 +02:00
|
|
|
|
2018-05-12 15:21:20 +02:00
|
|
|
// Arguments to the apicheck tool.
|
2018-05-05 03:49:16 +02:00
|
|
|
Args *string
|
|
|
|
}
|
|
|
|
|
2018-01-11 01:06:12 +01:00
|
|
|
type DroiddocProperties struct {
|
|
|
|
// directory relative to top of the source tree that contains doc templates files.
|
2018-02-23 20:18:47 +01:00
|
|
|
Custom_template *string
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
// directories under current module source which contains html/jd files.
|
2018-02-23 20:18:47 +01:00
|
|
|
Html_dirs []string
|
2018-01-11 01:06:12 +01:00
|
|
|
|
|
|
|
// set a value in the Clearsilver hdf namespace.
|
2018-02-23 20:18:47 +01:00
|
|
|
Hdf []string
|
2018-01-11 01:06:12 +01:00
|
|
|
|
|
|
|
// proofread file contains all of the text content of the javadocs concatenated into one file,
|
|
|
|
// suitable for spell-checking and other goodness.
|
2019-03-05 07:35:41 +01:00
|
|
|
Proofread_file *string `android:"path"`
|
2018-01-11 01:06:12 +01:00
|
|
|
|
|
|
|
// a todo file lists the program elements that are missing documentation.
|
|
|
|
// At some point, this might be improved to show more warnings.
|
2019-03-05 07:35:41 +01:00
|
|
|
Todo_file *string `android:"path"`
|
2018-02-23 20:18:47 +01:00
|
|
|
|
|
|
|
// directory under current module source that provide additional resources (images).
|
|
|
|
Resourcesdir *string
|
|
|
|
|
|
|
|
// resources output directory under out/soong/.intermediates.
|
|
|
|
Resourcesoutdir *string
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2018-07-12 00:16:55 +02:00
|
|
|
// if set to true, collect the values used by the Dev tools and
|
|
|
|
// write them in files packaged with the SDK. Defaults to false.
|
|
|
|
Write_sdk_values *bool
|
|
|
|
|
|
|
|
// index.html under current module will be copied to docs out dir, if not null.
|
2019-03-05 07:35:41 +01:00
|
|
|
Static_doc_index_redirect *string `android:"path"`
|
2018-07-12 00:16:55 +02:00
|
|
|
|
|
|
|
// source.properties under current module will be copied to docs out dir, if not null.
|
2019-03-05 07:35:41 +01:00
|
|
|
Static_doc_properties *string `android:"path"`
|
2018-07-12 00:16:55 +02:00
|
|
|
|
2018-01-11 01:06:12 +01:00
|
|
|
// a list of files under current module source dir which contains known tags in Java sources.
|
|
|
|
// filegroup or genrule can be included within this property.
|
2019-03-05 07:35:41 +01:00
|
|
|
Knowntags []string `android:"path"`
|
2018-03-14 00:17:01 +01:00
|
|
|
|
|
|
|
// the tag name used to distinguish if the API files belong to public/system/test.
|
|
|
|
Api_tag_name *string
|
|
|
|
|
|
|
|
// the generated public API filename by Doclava.
|
|
|
|
Api_filename *string
|
|
|
|
|
2018-05-31 14:56:46 +02:00
|
|
|
// the generated public Dex API filename by Doclava.
|
|
|
|
Dex_api_filename *string
|
|
|
|
|
2018-03-14 00:17:01 +01:00
|
|
|
// the generated private API filename by Doclava.
|
|
|
|
Private_api_filename *string
|
|
|
|
|
|
|
|
// the generated private Dex API filename by Doclava.
|
|
|
|
Private_dex_api_filename *string
|
|
|
|
|
|
|
|
// the generated removed API filename by Doclava.
|
|
|
|
Removed_api_filename *string
|
|
|
|
|
2018-04-24 17:23:29 +02:00
|
|
|
// the generated removed Dex API filename by Doclava.
|
|
|
|
Removed_dex_api_filename *string
|
|
|
|
|
2018-06-22 16:28:11 +02:00
|
|
|
// mapping of dex signatures to source file and line number. This is a temporary property and
|
|
|
|
// will be deleted; you probably shouldn't be using it.
|
|
|
|
Dex_mapping_filename *string
|
|
|
|
|
2018-03-14 00:17:01 +01:00
|
|
|
// the generated exact API filename by Doclava.
|
|
|
|
Exact_api_filename *string
|
2018-04-13 01:55:56 +02:00
|
|
|
|
2018-08-15 05:41:04 +02:00
|
|
|
// the generated proguard filename by Doclava.
|
|
|
|
Proguard_filename *string
|
|
|
|
|
2018-04-13 01:55:56 +02:00
|
|
|
// if set to false, don't allow droiddoc to generate stubs source files. Defaults to true.
|
|
|
|
Create_stubs *bool
|
2018-05-05 03:49:16 +02:00
|
|
|
|
|
|
|
Check_api struct {
|
|
|
|
Last_released ApiToCheck
|
|
|
|
|
|
|
|
Current ApiToCheck
|
2019-02-28 06:24:05 +01:00
|
|
|
|
|
|
|
// do not perform API check against Last_released, in the case that both two specified API
|
|
|
|
// files by Last_released are modules which don't exist.
|
|
|
|
Ignore_missing_latest_api *bool `blueprint:"mutated"`
|
2018-05-05 03:49:16 +02:00
|
|
|
}
|
2018-04-20 03:03:39 +02:00
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
// if set to true, generate docs through Dokka instead of Doclava.
|
|
|
|
Dokka_enabled *bool
|
|
|
|
}
|
|
|
|
|
|
|
|
type DroidstubsProperties struct {
|
|
|
|
// the tag name used to distinguish if the API files belong to public/system/test.
|
|
|
|
Api_tag_name *string
|
|
|
|
|
2018-09-19 21:40:06 +02:00
|
|
|
// the generated public API filename by Metalava.
|
2018-09-05 02:14:32 +02:00
|
|
|
Api_filename *string
|
|
|
|
|
2018-09-19 21:40:06 +02:00
|
|
|
// the generated public Dex API filename by Metalava.
|
2018-09-05 02:14:32 +02:00
|
|
|
Dex_api_filename *string
|
|
|
|
|
2018-09-19 21:40:06 +02:00
|
|
|
// the generated private API filename by Metalava.
|
2018-09-05 02:14:32 +02:00
|
|
|
Private_api_filename *string
|
|
|
|
|
2018-09-19 21:40:06 +02:00
|
|
|
// the generated private Dex API filename by Metalava.
|
2018-09-05 02:14:32 +02:00
|
|
|
Private_dex_api_filename *string
|
|
|
|
|
2018-09-19 21:40:06 +02:00
|
|
|
// the generated removed API filename by Metalava.
|
2018-09-05 02:14:32 +02:00
|
|
|
Removed_api_filename *string
|
|
|
|
|
2018-09-19 21:40:06 +02:00
|
|
|
// the generated removed Dex API filename by Metalava.
|
2018-09-05 02:14:32 +02:00
|
|
|
Removed_dex_api_filename *string
|
|
|
|
|
2018-08-22 19:22:08 +02:00
|
|
|
// mapping of dex signatures to source file and line number. This is a temporary property and
|
|
|
|
// will be deleted; you probably shouldn't be using it.
|
|
|
|
Dex_mapping_filename *string
|
|
|
|
|
2018-09-19 21:40:06 +02:00
|
|
|
// the generated exact API filename by Metalava.
|
2018-09-05 02:14:32 +02:00
|
|
|
Exact_api_filename *string
|
|
|
|
|
2018-09-19 21:40:06 +02:00
|
|
|
// the generated proguard filename by Metalava.
|
|
|
|
Proguard_filename *string
|
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
Check_api struct {
|
|
|
|
Last_released ApiToCheck
|
|
|
|
|
|
|
|
Current ApiToCheck
|
2019-02-28 06:24:05 +01:00
|
|
|
|
|
|
|
// do not perform API check against Last_released, in the case that both two specified API
|
|
|
|
// files by Last_released are modules which don't exist.
|
|
|
|
Ignore_missing_latest_api *bool `blueprint:"mutated"`
|
2018-09-05 02:14:32 +02:00
|
|
|
}
|
2018-04-20 03:03:39 +02:00
|
|
|
|
|
|
|
// user can specify the version of previous released API file in order to do compatibility check.
|
2019-03-05 07:35:41 +01:00
|
|
|
Previous_api *string `android:"path"`
|
2018-04-20 03:03:39 +02:00
|
|
|
|
|
|
|
// is set to true, Metalava will allow framework SDK to contain annotations.
|
2018-09-05 02:14:32 +02:00
|
|
|
Annotations_enabled *bool
|
2018-04-20 03:03:39 +02:00
|
|
|
|
2018-09-19 19:16:26 +02:00
|
|
|
// a list of top-level directories containing files to merge qualifier annotations (i.e. those intended to be included in the stubs written) from.
|
2018-09-05 02:14:32 +02:00
|
|
|
Merge_annotations_dirs []string
|
2018-08-10 00:33:27 +02:00
|
|
|
|
2018-09-19 19:16:26 +02:00
|
|
|
// a list of top-level directories containing Java stub files to merge show/hide annotations from.
|
|
|
|
Merge_inclusion_annotations_dirs []string
|
|
|
|
|
2018-11-14 19:45:46 +01:00
|
|
|
// a file containing a list of classes to do nullability validation for.
|
|
|
|
Validate_nullability_from_list *string
|
|
|
|
|
2018-10-22 16:55:04 +02:00
|
|
|
// a file containing expected warnings produced by validation of nullability annotations.
|
|
|
|
Check_nullability_warnings *string
|
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
// if set to true, allow Metalava to generate doc_stubs source files. Defaults to false.
|
|
|
|
Create_doc_stubs *bool
|
2018-08-22 19:22:08 +02:00
|
|
|
|
|
|
|
// is set to true, Metalava will allow framework SDK to contain API levels annotations.
|
|
|
|
Api_levels_annotations_enabled *bool
|
|
|
|
|
|
|
|
// the dirs which Metalava extracts API levels annotations from.
|
|
|
|
Api_levels_annotations_dirs []string
|
|
|
|
|
|
|
|
// if set to true, collect the values used by the Dev tools and
|
|
|
|
// write them in files packaged with the SDK. Defaults to false.
|
|
|
|
Write_sdk_values *bool
|
2018-09-17 23:32:21 +02:00
|
|
|
|
|
|
|
// If set to true, .xml based public API file will be also generated, and
|
|
|
|
// JDiff tool will be invoked to genreate javadoc files. Defaults to false.
|
|
|
|
Jdiff_enabled *bool
|
2018-01-11 01:06:12 +01:00
|
|
|
}
|
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
//
|
|
|
|
// Common flags passed down to build rule
|
|
|
|
//
|
|
|
|
type droiddocBuilderFlags struct {
|
2018-08-10 00:33:27 +02:00
|
|
|
bootClasspathArgs string
|
|
|
|
classpathArgs string
|
2018-09-05 02:14:32 +02:00
|
|
|
sourcepathArgs string
|
2018-08-10 00:33:27 +02:00
|
|
|
dokkaClasspathArgs string
|
|
|
|
aidlFlags string
|
2019-04-18 19:56:44 +02:00
|
|
|
aidlDeps android.Paths
|
2018-08-01 21:48:00 +02:00
|
|
|
|
|
|
|
doclavaStubsFlags string
|
2018-08-10 00:33:27 +02:00
|
|
|
doclavaDocsFlags string
|
2018-08-01 21:48:00 +02:00
|
|
|
postDoclavaCmds string
|
|
|
|
|
2018-08-22 19:22:08 +02:00
|
|
|
metalavaStubsFlags string
|
|
|
|
metalavaAnnotationsFlags string
|
2018-12-27 01:06:37 +01:00
|
|
|
metalavaMergeAnnoDirFlags string
|
2018-10-21 23:13:19 +02:00
|
|
|
metalavaInclusionAnnotationsFlags string
|
2018-08-22 19:22:08 +02:00
|
|
|
metalavaApiLevelsAnnotationsFlags string
|
2018-08-01 21:48:00 +02:00
|
|
|
|
2018-09-17 23:32:21 +02:00
|
|
|
metalavaApiToXmlFlags string
|
2018-08-01 21:48:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func InitDroiddocModule(module android.DefaultableModule, hod android.HostOrDeviceSupported) {
|
|
|
|
android.InitAndroidArchModule(module, hod, android.MultilibCommon)
|
|
|
|
android.InitDefaultableModule(module)
|
|
|
|
}
|
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
func apiCheckEnabled(apiToCheck ApiToCheck, apiVersionTag string) bool {
|
|
|
|
if String(apiToCheck.Api_file) != "" && String(apiToCheck.Removed_api_file) != "" {
|
|
|
|
return true
|
|
|
|
} else if String(apiToCheck.Api_file) != "" {
|
|
|
|
panic("for " + apiVersionTag + " removed_api_file has to be non-empty!")
|
|
|
|
} else if String(apiToCheck.Removed_api_file) != "" {
|
|
|
|
panic("for " + apiVersionTag + " api_file has to be non-empty!")
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-02-28 06:24:05 +01:00
|
|
|
func ignoreMissingModules(ctx android.BottomUpMutatorContext, apiToCheck *ApiToCheck) {
|
|
|
|
api_file := String(apiToCheck.Api_file)
|
|
|
|
removed_api_file := String(apiToCheck.Removed_api_file)
|
|
|
|
|
|
|
|
api_module := android.SrcIsModule(api_file)
|
|
|
|
removed_api_module := android.SrcIsModule(removed_api_file)
|
|
|
|
|
|
|
|
if api_module == "" || removed_api_module == "" {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if ctx.OtherModuleExists(api_module) || ctx.OtherModuleExists(removed_api_module) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
apiToCheck.Api_file = nil
|
|
|
|
apiToCheck.Removed_api_file = nil
|
|
|
|
}
|
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
type ApiFilePath interface {
|
|
|
|
ApiFilePath() android.Path
|
|
|
|
}
|
|
|
|
|
|
|
|
func transformUpdateApi(ctx android.ModuleContext, destApiFile, destRemovedApiFile,
|
|
|
|
srcApiFile, srcRemovedApiFile android.Path, output android.WritablePath) {
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: updateApi,
|
|
|
|
Description: "Update API",
|
|
|
|
Output: output,
|
|
|
|
Implicits: append(android.Paths{}, srcApiFile, srcRemovedApiFile,
|
|
|
|
destApiFile, destRemovedApiFile),
|
|
|
|
Args: map[string]string{
|
|
|
|
"destApiFile": destApiFile.String(),
|
|
|
|
"srcApiFile": srcApiFile.String(),
|
|
|
|
"destRemovedApiFile": destRemovedApiFile.String(),
|
|
|
|
"srcRemovedApiFile": srcRemovedApiFile.String(),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
//
|
|
|
|
// Javadoc
|
|
|
|
//
|
2018-01-11 01:06:12 +01:00
|
|
|
type Javadoc struct {
|
|
|
|
android.ModuleBase
|
|
|
|
android.DefaultableModuleBase
|
|
|
|
|
|
|
|
properties JavadocProperties
|
|
|
|
|
|
|
|
srcJars android.Paths
|
|
|
|
srcFiles android.Paths
|
|
|
|
sourcepaths android.Paths
|
2018-09-05 02:14:32 +02:00
|
|
|
argFiles android.Paths
|
|
|
|
|
|
|
|
args string
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2018-03-09 02:26:16 +01:00
|
|
|
docZip android.WritablePath
|
|
|
|
stubsSrcJar android.WritablePath
|
2018-01-11 01:06:12 +01:00
|
|
|
}
|
|
|
|
|
2019-05-29 23:40:35 +02:00
|
|
|
func (j *Javadoc) OutputFiles(tag string) (android.Paths, error) {
|
|
|
|
switch tag {
|
|
|
|
case "":
|
|
|
|
return android.Paths{j.stubsSrcJar}, nil
|
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
|
|
|
|
}
|
2018-02-23 20:18:47 +01:00
|
|
|
}
|
|
|
|
|
2018-01-11 01:06:12 +01:00
|
|
|
func JavadocFactory() android.Module {
|
|
|
|
module := &Javadoc{}
|
|
|
|
|
|
|
|
module.AddProperties(&module.properties)
|
|
|
|
|
|
|
|
InitDroiddocModule(module, android.HostAndDeviceSupported)
|
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
|
|
|
func JavadocHostFactory() android.Module {
|
|
|
|
module := &Javadoc{}
|
|
|
|
|
|
|
|
module.AddProperties(&module.properties)
|
|
|
|
|
|
|
|
InitDroiddocModule(module, android.HostSupported)
|
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
2019-05-29 23:40:35 +02:00
|
|
|
var _ android.OutputFileProducer = (*Javadoc)(nil)
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2018-06-26 00:48:06 +02:00
|
|
|
func (j *Javadoc) sdkVersion() string {
|
|
|
|
return String(j.properties.Sdk_version)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (j *Javadoc) minSdkVersion() string {
|
|
|
|
return j.sdkVersion()
|
|
|
|
}
|
|
|
|
|
2018-10-31 23:28:47 +01:00
|
|
|
func (j *Javadoc) targetSdkVersion() string {
|
|
|
|
return j.sdkVersion()
|
|
|
|
}
|
|
|
|
|
2018-01-11 01:06:12 +01:00
|
|
|
func (j *Javadoc) addDeps(ctx android.BottomUpMutatorContext) {
|
|
|
|
if ctx.Device() {
|
2018-09-22 01:39:51 +02:00
|
|
|
if !Bool(j.properties.No_standard_libs) {
|
|
|
|
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
|
|
|
if sdkDep.useDefaultLibs {
|
|
|
|
ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...)
|
|
|
|
if ctx.Config().TargetOpenJDK9() {
|
|
|
|
ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules)
|
|
|
|
}
|
|
|
|
if !Bool(j.properties.No_framework_libs) {
|
|
|
|
ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...)
|
|
|
|
}
|
|
|
|
} else if sdkDep.useModule {
|
|
|
|
if ctx.Config().TargetOpenJDK9() {
|
|
|
|
ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules)
|
|
|
|
}
|
|
|
|
ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.modules...)
|
2018-04-18 02:38:36 +02:00
|
|
|
}
|
2018-01-11 01:06:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-29 23:10:52 +02:00
|
|
|
ctx.AddVariationDependencies(nil, libTag, j.properties.Libs...)
|
2018-06-21 00:19:39 +02:00
|
|
|
if j.properties.Srcs_lib != nil {
|
2018-08-29 23:10:52 +02:00
|
|
|
ctx.AddVariationDependencies(nil, srcsLibTag, *j.properties.Srcs_lib)
|
2018-06-21 00:19:39 +02:00
|
|
|
}
|
2018-01-11 01:06:12 +01:00
|
|
|
}
|
|
|
|
|
2018-02-23 20:18:47 +01:00
|
|
|
func (j *Javadoc) genWhitelistPathPrefixes(whitelistPathPrefixes map[string]bool) {
|
|
|
|
for _, dir := range j.properties.Srcs_lib_whitelist_dirs {
|
|
|
|
for _, pkg := range j.properties.Srcs_lib_whitelist_pkgs {
|
2018-04-23 14:41:26 +02:00
|
|
|
// convert foo.bar.baz to foo/bar/baz
|
|
|
|
pkgAsPath := filepath.Join(strings.Split(pkg, ".")...)
|
|
|
|
prefix := filepath.Join(dir, pkgAsPath)
|
2018-02-23 20:18:47 +01:00
|
|
|
if _, found := whitelistPathPrefixes[prefix]; !found {
|
|
|
|
whitelistPathPrefixes[prefix] = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
func (j *Javadoc) collectAidlFlags(ctx android.ModuleContext, deps deps) droiddocBuilderFlags {
|
|
|
|
var flags droiddocBuilderFlags
|
2018-05-23 11:42:04 +02:00
|
|
|
|
2019-04-18 19:56:44 +02:00
|
|
|
flags.aidlFlags, flags.aidlDeps = j.aidlFlags(ctx, deps.aidlPreprocess, deps.aidlIncludeDirs)
|
2018-05-23 11:42:04 +02:00
|
|
|
|
|
|
|
return flags
|
|
|
|
}
|
|
|
|
|
|
|
|
func (j *Javadoc) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath,
|
2019-04-18 19:56:44 +02:00
|
|
|
aidlIncludeDirs android.Paths) (string, android.Paths) {
|
2018-05-23 11:42:04 +02:00
|
|
|
|
|
|
|
aidlIncludes := android.PathsForModuleSrc(ctx, j.properties.Aidl.Local_include_dirs)
|
|
|
|
aidlIncludes = append(aidlIncludes, android.PathsForSource(ctx, j.properties.Aidl.Include_dirs)...)
|
|
|
|
|
|
|
|
var flags []string
|
2019-04-18 19:56:44 +02:00
|
|
|
var deps android.Paths
|
|
|
|
|
2018-05-23 11:42:04 +02:00
|
|
|
if aidlPreprocess.Valid() {
|
|
|
|
flags = append(flags, "-p"+aidlPreprocess.String())
|
2019-04-18 19:56:44 +02:00
|
|
|
deps = append(deps, aidlPreprocess.Path())
|
2018-05-23 11:42:04 +02:00
|
|
|
} else {
|
|
|
|
flags = append(flags, android.JoinWithPrefix(aidlIncludeDirs.Strings(), "-I"))
|
|
|
|
}
|
|
|
|
|
|
|
|
flags = append(flags, android.JoinWithPrefix(aidlIncludes.Strings(), "-I"))
|
|
|
|
flags = append(flags, "-I"+android.PathForModuleSrc(ctx).String())
|
|
|
|
if src := android.ExistentPathForSource(ctx, ctx.ModuleDir(), "src"); src.Valid() {
|
|
|
|
flags = append(flags, "-I"+src.String())
|
|
|
|
}
|
|
|
|
|
2019-04-18 19:56:44 +02:00
|
|
|
return strings.Join(flags, " "), deps
|
2018-05-23 11:42:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (j *Javadoc) genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
2018-08-01 21:48:00 +02:00
|
|
|
flags droiddocBuilderFlags) android.Paths {
|
2018-05-23 11:42:04 +02:00
|
|
|
|
|
|
|
outSrcFiles := make(android.Paths, 0, len(srcFiles))
|
|
|
|
|
|
|
|
for _, srcFile := range srcFiles {
|
|
|
|
switch srcFile.Ext() {
|
|
|
|
case ".aidl":
|
2019-04-18 19:56:44 +02:00
|
|
|
javaFile := genAidl(ctx, srcFile, flags.aidlFlags, flags.aidlDeps)
|
2018-05-23 11:42:04 +02:00
|
|
|
outSrcFiles = append(outSrcFiles, javaFile)
|
2019-02-08 13:00:45 +01:00
|
|
|
case ".sysprop":
|
|
|
|
javaFile := genSysprop(ctx, srcFile)
|
|
|
|
outSrcFiles = append(outSrcFiles, javaFile)
|
2018-05-23 11:42:04 +02:00
|
|
|
default:
|
|
|
|
outSrcFiles = append(outSrcFiles, srcFile)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return outSrcFiles
|
|
|
|
}
|
|
|
|
|
2018-01-11 01:06:12 +01:00
|
|
|
func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
|
|
|
|
var deps deps
|
|
|
|
|
2018-06-26 00:48:06 +02:00
|
|
|
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
2018-01-11 01:06:12 +01:00
|
|
|
if sdkDep.invalidVersion {
|
2018-05-29 23:44:55 +02:00
|
|
|
ctx.AddMissingDependencies(sdkDep.modules)
|
2018-01-11 01:06:12 +01:00
|
|
|
} else if sdkDep.useFiles {
|
2018-05-29 23:44:55 +02:00
|
|
|
deps.bootClasspath = append(deps.bootClasspath, sdkDep.jars...)
|
2018-01-11 01:06:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ctx.VisitDirectDeps(func(module android.Module) {
|
|
|
|
otherName := ctx.OtherModuleName(module)
|
|
|
|
tag := ctx.OtherModuleDependencyTag(module)
|
|
|
|
|
2018-05-23 19:59:18 +02:00
|
|
|
switch tag {
|
|
|
|
case bootClasspathTag:
|
|
|
|
if dep, ok := module.(Dependency); ok {
|
2018-01-11 01:06:12 +01:00
|
|
|
deps.bootClasspath = append(deps.bootClasspath, dep.ImplementationJars()...)
|
2018-05-23 19:59:18 +02:00
|
|
|
} else {
|
|
|
|
panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
|
|
|
|
}
|
|
|
|
case libTag:
|
|
|
|
switch dep := module.(type) {
|
2019-02-11 23:03:51 +01:00
|
|
|
case SdkLibraryDependency:
|
|
|
|
deps.classpath = append(deps.classpath, dep.SdkImplementationJars(ctx, j.sdkVersion())...)
|
2018-05-23 19:59:18 +02:00
|
|
|
case Dependency:
|
2018-11-20 09:36:35 +01:00
|
|
|
deps.classpath = append(deps.classpath, dep.HeaderJars()...)
|
2018-05-23 19:59:18 +02:00
|
|
|
case android.SourceFileProducer:
|
2018-01-11 01:06:12 +01:00
|
|
|
checkProducesJars(ctx, dep)
|
|
|
|
deps.classpath = append(deps.classpath, dep.Srcs()...)
|
|
|
|
default:
|
|
|
|
ctx.ModuleErrorf("depends on non-java module %q", otherName)
|
|
|
|
}
|
2018-06-21 00:19:39 +02:00
|
|
|
case srcsLibTag:
|
|
|
|
switch dep := module.(type) {
|
|
|
|
case Dependency:
|
|
|
|
srcs := dep.(SrcDependency).CompiledSrcs()
|
|
|
|
whitelistPathPrefixes := make(map[string]bool)
|
|
|
|
j.genWhitelistPathPrefixes(whitelistPathPrefixes)
|
|
|
|
for _, src := range srcs {
|
|
|
|
if _, ok := src.(android.WritablePath); ok { // generated sources
|
|
|
|
deps.srcs = append(deps.srcs, src)
|
|
|
|
} else { // select source path for documentation based on whitelist path prefixs.
|
2018-09-05 02:14:32 +02:00
|
|
|
for k := range whitelistPathPrefixes {
|
2018-06-21 00:19:39 +02:00
|
|
|
if strings.HasPrefix(src.Rel(), k) {
|
|
|
|
deps.srcs = append(deps.srcs, src)
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
deps.srcJars = append(deps.srcJars, dep.(SrcDependency).CompiledSrcJars()...)
|
|
|
|
default:
|
|
|
|
ctx.ModuleErrorf("depends on non-java module %q", otherName)
|
|
|
|
}
|
2018-04-18 02:38:36 +02:00
|
|
|
case systemModulesTag:
|
|
|
|
if deps.systemModules != nil {
|
|
|
|
panic("Found two system module dependencies")
|
|
|
|
}
|
|
|
|
sm := module.(*SystemModules)
|
|
|
|
if sm.outputFile == nil {
|
|
|
|
panic("Missing directory for system module dependency")
|
|
|
|
}
|
|
|
|
deps.systemModules = sm.outputFile
|
2018-01-11 01:06:12 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
// do not pass exclude_srcs directly when expanding srcFiles since exclude_srcs
|
|
|
|
// may contain filegroup or genrule.
|
2019-03-06 07:25:09 +01:00
|
|
|
srcFiles := android.PathsForModuleSrcExcludes(ctx, j.properties.Srcs, j.properties.Exclude_srcs)
|
2018-08-01 21:48:00 +02:00
|
|
|
flags := j.collectAidlFlags(ctx, deps)
|
2018-05-23 11:42:04 +02:00
|
|
|
srcFiles = j.genSources(ctx, srcFiles, flags)
|
2018-01-11 01:06:12 +01:00
|
|
|
|
|
|
|
// srcs may depend on some genrule output.
|
|
|
|
j.srcJars = srcFiles.FilterByExt(".srcjar")
|
2018-02-23 20:18:47 +01:00
|
|
|
j.srcJars = append(j.srcJars, deps.srcJars...)
|
|
|
|
|
2018-01-11 01:06:12 +01:00
|
|
|
j.srcFiles = srcFiles.FilterOutByExt(".srcjar")
|
2018-02-23 20:18:47 +01:00
|
|
|
j.srcFiles = append(j.srcFiles, deps.srcs...)
|
2018-01-11 01:06:12 +01:00
|
|
|
|
|
|
|
j.docZip = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"docs.zip")
|
2018-03-09 02:26:16 +01:00
|
|
|
j.stubsSrcJar = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"stubs.srcjar")
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2018-08-22 19:22:08 +02:00
|
|
|
if j.properties.Local_sourcepaths == nil && len(j.srcFiles) > 0 {
|
2018-01-11 01:06:12 +01:00
|
|
|
j.properties.Local_sourcepaths = append(j.properties.Local_sourcepaths, ".")
|
|
|
|
}
|
|
|
|
j.sourcepaths = android.PathsForModuleSrc(ctx, j.properties.Local_sourcepaths)
|
|
|
|
|
2019-03-06 07:25:09 +01:00
|
|
|
j.argFiles = android.PathsForModuleSrc(ctx, j.properties.Arg_files)
|
2019-02-11 16:38:42 +01:00
|
|
|
argFilesMap := map[string]string{}
|
|
|
|
argFileLabels := []string{}
|
|
|
|
|
|
|
|
for _, label := range j.properties.Arg_files {
|
2019-03-06 07:25:09 +01:00
|
|
|
var paths = android.PathsForModuleSrc(ctx, []string{label})
|
2019-02-11 16:38:42 +01:00
|
|
|
if _, exists := argFilesMap[label]; !exists {
|
|
|
|
argFilesMap[label] = strings.Join(paths.Strings(), " ")
|
|
|
|
argFileLabels = append(argFileLabels, label)
|
2018-09-05 02:14:32 +02:00
|
|
|
} else {
|
|
|
|
ctx.ModuleErrorf("multiple arg_files for %q, %q and %q",
|
2019-02-11 16:38:42 +01:00
|
|
|
label, argFilesMap[label], paths)
|
2018-09-05 02:14:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
j.args, err = android.Expand(String(j.properties.Args), func(name string) (string, error) {
|
|
|
|
if strings.HasPrefix(name, "location ") {
|
|
|
|
label := strings.TrimSpace(strings.TrimPrefix(name, "location "))
|
2019-02-11 16:38:42 +01:00
|
|
|
if paths, ok := argFilesMap[label]; ok {
|
|
|
|
return paths, nil
|
2018-09-05 02:14:32 +02:00
|
|
|
} else {
|
2019-02-11 16:38:42 +01:00
|
|
|
return "", fmt.Errorf("unknown location label %q, expecting one of %q",
|
|
|
|
label, strings.Join(argFileLabels, ", "))
|
2018-09-05 02:14:32 +02:00
|
|
|
}
|
|
|
|
} else if name == "genDir" {
|
|
|
|
return android.PathForModuleGen(ctx).String(), nil
|
|
|
|
}
|
|
|
|
return "", fmt.Errorf("unknown variable '$(%s)'", name)
|
|
|
|
})
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
ctx.PropertyErrorf("args", "%s", err.Error())
|
|
|
|
}
|
|
|
|
|
2018-01-11 01:06:12 +01:00
|
|
|
return deps
|
|
|
|
}
|
|
|
|
|
|
|
|
func (j *Javadoc) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|
|
|
j.addDeps(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (j *Javadoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
|
|
deps := j.collectDeps(ctx)
|
|
|
|
|
|
|
|
var implicits android.Paths
|
|
|
|
implicits = append(implicits, deps.bootClasspath...)
|
|
|
|
implicits = append(implicits, deps.classpath...)
|
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
var bootClasspathArgs, classpathArgs, sourcepathArgs string
|
2018-04-18 02:38:36 +02:00
|
|
|
|
2018-06-26 00:48:06 +02:00
|
|
|
javaVersion := getJavaVersion(ctx, String(j.properties.Java_version), sdkContext(j))
|
2018-06-20 07:49:39 +02:00
|
|
|
if len(deps.bootClasspath) > 0 {
|
|
|
|
var systemModules classpath
|
|
|
|
if deps.systemModules != nil {
|
|
|
|
systemModules = append(systemModules, deps.systemModules)
|
2018-01-11 01:06:12 +01:00
|
|
|
}
|
2018-06-20 07:49:39 +02:00
|
|
|
bootClasspathArgs = systemModules.FormJavaSystemModulesPath("--system ", ctx.Device())
|
|
|
|
bootClasspathArgs = bootClasspathArgs + " --patch-module java.base=."
|
2018-01-11 01:06:12 +01:00
|
|
|
}
|
|
|
|
if len(deps.classpath.Strings()) > 0 {
|
|
|
|
classpathArgs = "-classpath " + strings.Join(deps.classpath.Strings(), ":")
|
|
|
|
}
|
|
|
|
|
|
|
|
implicits = append(implicits, j.srcJars...)
|
2018-09-05 02:14:32 +02:00
|
|
|
implicits = append(implicits, j.argFiles...)
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2018-06-20 00:15:38 +02:00
|
|
|
opts := "-source " + javaVersion + " -J-Xmx1024m -XDignore.symbol.file -Xdoclint:none"
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
sourcepathArgs = "-sourcepath " + strings.Join(j.sourcepaths.Strings(), ":")
|
|
|
|
|
2018-01-11 01:06:12 +01:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: javadoc,
|
|
|
|
Description: "Javadoc",
|
2018-03-09 02:26:16 +01:00
|
|
|
Output: j.stubsSrcJar,
|
2018-01-11 01:06:12 +01:00
|
|
|
ImplicitOutput: j.docZip,
|
|
|
|
Inputs: j.srcFiles,
|
|
|
|
Implicits: implicits,
|
|
|
|
Args: map[string]string{
|
2018-08-09 01:32:21 +02:00
|
|
|
"outDir": android.PathForModuleOut(ctx, "out").String(),
|
|
|
|
"srcJarDir": android.PathForModuleOut(ctx, "srcjars").String(),
|
|
|
|
"stubsDir": android.PathForModuleOut(ctx, "stubsDir").String(),
|
2018-01-11 01:06:12 +01:00
|
|
|
"srcJars": strings.Join(j.srcJars.Strings(), " "),
|
|
|
|
"opts": opts,
|
2018-04-13 01:55:56 +02:00
|
|
|
"bootclasspathArgs": bootClasspathArgs,
|
2018-01-11 01:06:12 +01:00
|
|
|
"classpathArgs": classpathArgs,
|
2018-09-05 02:14:32 +02:00
|
|
|
"sourcepathArgs": sourcepathArgs,
|
2018-01-11 01:06:12 +01:00
|
|
|
"docZip": j.docZip.String(),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
//
|
|
|
|
// Droiddoc
|
|
|
|
//
|
|
|
|
type Droiddoc struct {
|
|
|
|
Javadoc
|
|
|
|
|
|
|
|
properties DroiddocProperties
|
|
|
|
apiFile android.WritablePath
|
|
|
|
dexApiFile android.WritablePath
|
|
|
|
privateApiFile android.WritablePath
|
|
|
|
privateDexApiFile android.WritablePath
|
|
|
|
removedApiFile android.WritablePath
|
|
|
|
removedDexApiFile android.WritablePath
|
|
|
|
exactApiFile android.WritablePath
|
|
|
|
apiMappingFile android.WritablePath
|
2018-08-15 05:41:04 +02:00
|
|
|
proguardFile android.WritablePath
|
2018-08-01 21:48:00 +02:00
|
|
|
|
|
|
|
checkCurrentApiTimestamp android.WritablePath
|
|
|
|
updateCurrentApiTimestamp android.WritablePath
|
|
|
|
checkLastReleasedApiTimestamp android.WritablePath
|
|
|
|
|
|
|
|
apiFilePath android.Path
|
|
|
|
}
|
|
|
|
|
|
|
|
func DroiddocFactory() android.Module {
|
|
|
|
module := &Droiddoc{}
|
|
|
|
|
|
|
|
module.AddProperties(&module.properties,
|
|
|
|
&module.Javadoc.properties)
|
|
|
|
|
|
|
|
InitDroiddocModule(module, android.HostAndDeviceSupported)
|
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
|
|
|
func DroiddocHostFactory() android.Module {
|
|
|
|
module := &Droiddoc{}
|
|
|
|
|
|
|
|
module.AddProperties(&module.properties,
|
|
|
|
&module.Javadoc.properties)
|
|
|
|
|
|
|
|
InitDroiddocModule(module, android.HostSupported)
|
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Droiddoc) ApiFilePath() android.Path {
|
|
|
|
return d.apiFilePath
|
|
|
|
}
|
|
|
|
|
2018-01-11 01:06:12 +01:00
|
|
|
func (d *Droiddoc) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|
|
|
d.Javadoc.addDeps(ctx)
|
|
|
|
|
2019-02-28 06:24:05 +01:00
|
|
|
if Bool(d.properties.Check_api.Ignore_missing_latest_api) {
|
|
|
|
ignoreMissingModules(ctx, &d.properties.Check_api.Last_released)
|
|
|
|
}
|
|
|
|
|
2018-04-20 03:03:39 +02:00
|
|
|
if String(d.properties.Custom_template) != "" {
|
Add droiddoc_template
We prefer not to use absolute paths in modules, but to reference modules
that have associated paths. This a few benefits:
* it's easier to move a module than to update all the references
* if the module doesn't exist, we treat it as a normal missing
dependency, not having to deal with the missing dependency in path.go
* implementing visibility(etc) in the future would be simpler if there
was a module attached to the reference, so we don't have to do various
path-based lookups to try and match things up.
So define a `droiddoc_template` module, which takes a path, and will run
the glob once in that module. All of the `droiddoc` modules can then
specify it through the `custom_template` property, which will pull the
necessary data.
Also fix that htmldirs should be references from the local path, the
htmldir2 argument never being specified, and complain if more than two
htmldirs are specified, or if the custom template isn't specified.
Test: m core-docs
Test: out/soong/build.ninja is nearly identical
- line numbers in comments
- adds directories to droiddoc template dependency lists, which
is more correct, since we need to rerun on added or removed
files too.
Change-Id: Iff630bddb3818b8eeed439de7e41fc7fbe7cdcb0
2018-02-26 23:33:31 +01:00
|
|
|
ctx.AddDependency(ctx.Module(), droiddocTemplateTag, String(d.properties.Custom_template))
|
|
|
|
}
|
2018-01-11 01:06:12 +01:00
|
|
|
}
|
|
|
|
|
2018-08-15 05:41:04 +02:00
|
|
|
func (d *Droiddoc) initBuilderFlags(ctx android.ModuleContext, implicits *android.Paths,
|
|
|
|
deps deps) (droiddocBuilderFlags, error) {
|
2018-08-01 21:48:00 +02:00
|
|
|
var flags droiddocBuilderFlags
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
*implicits = append(*implicits, deps.bootClasspath...)
|
|
|
|
*implicits = append(*implicits, deps.classpath...)
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2018-06-26 19:02:26 +02:00
|
|
|
if len(deps.bootClasspath.Strings()) > 0 {
|
|
|
|
// For OpenJDK 8 we can use -bootclasspath to define the core libraries code.
|
2018-08-01 21:48:00 +02:00
|
|
|
flags.bootClasspathArgs = deps.bootClasspath.FormJavaClassPath("-bootclasspath")
|
2018-04-18 02:38:36 +02:00
|
|
|
}
|
2018-08-01 21:48:00 +02:00
|
|
|
flags.classpathArgs = deps.classpath.FormJavaClassPath("-classpath")
|
2018-09-05 02:14:32 +02:00
|
|
|
// Dokka doesn't support bootClasspath, so combine these two classpath vars for Dokka.
|
2018-08-10 00:33:27 +02:00
|
|
|
dokkaClasspath := classpath{}
|
|
|
|
dokkaClasspath = append(dokkaClasspath, deps.bootClasspath...)
|
|
|
|
dokkaClasspath = append(dokkaClasspath, deps.classpath...)
|
|
|
|
flags.dokkaClasspathArgs = dokkaClasspath.FormJavaClassPath("-classpath")
|
2018-04-20 03:03:39 +02:00
|
|
|
|
2018-08-22 19:22:08 +02:00
|
|
|
// TODO(nanzhang): Remove this if- statement once we finish migration for all Doclava
|
|
|
|
// based stubs generation.
|
|
|
|
// In the future, all the docs generation depends on Metalava stubs (droidstubs) srcjar
|
|
|
|
// dir. We need add the srcjar dir to -sourcepath arg, so that Javadoc can figure out
|
|
|
|
// the correct package name base path.
|
|
|
|
if len(d.Javadoc.properties.Local_sourcepaths) > 0 {
|
|
|
|
flags.sourcepathArgs = "-sourcepath " + strings.Join(d.Javadoc.sourcepaths.Strings(), ":")
|
|
|
|
} else {
|
|
|
|
flags.sourcepathArgs = "-sourcepath " + android.PathForModuleOut(ctx, "srcjars").String()
|
|
|
|
}
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
return flags, nil
|
|
|
|
}
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
func (d *Droiddoc) collectDoclavaDocsFlags(ctx android.ModuleContext, implicits *android.Paths,
|
2018-08-21 05:58:28 +02:00
|
|
|
jsilver, doclava android.Path) string {
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
*implicits = append(*implicits, jsilver)
|
|
|
|
*implicits = append(*implicits, doclava)
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
var date string
|
|
|
|
if runtime.GOOS == "darwin" {
|
|
|
|
date = `date -r`
|
|
|
|
} else {
|
|
|
|
date = `date -d`
|
|
|
|
}
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2018-08-21 05:58:28 +02:00
|
|
|
// Droiddoc always gets "-source 1.8" because it doesn't support 1.9 sources. For modules with 1.9
|
|
|
|
// sources, droiddoc will get sources produced by metalava which will have already stripped out the
|
|
|
|
// 1.9 language features.
|
|
|
|
args := " -source 1.8 -J-Xmx1600m -J-XX:-OmitStackTraceInFastThrow -XDignore.symbol.file " +
|
2018-08-01 21:48:00 +02:00
|
|
|
"-doclet com.google.doclava.Doclava -docletpath " + jsilver.String() + ":" + doclava.String() + " " +
|
|
|
|
"-hdf page.build " + ctx.Config().BuildId() + "-" + ctx.Config().BuildNumberFromFile() + " " +
|
|
|
|
`-hdf page.now "$$(` + date + ` @$$(cat ` + ctx.Config().Getenv("BUILD_DATETIME_FILE") + `) "+%d %b %Y %k:%M")" `
|
Add droiddoc_template
We prefer not to use absolute paths in modules, but to reference modules
that have associated paths. This a few benefits:
* it's easier to move a module than to update all the references
* if the module doesn't exist, we treat it as a normal missing
dependency, not having to deal with the missing dependency in path.go
* implementing visibility(etc) in the future would be simpler if there
was a module attached to the reference, so we don't have to do various
path-based lookups to try and match things up.
So define a `droiddoc_template` module, which takes a path, and will run
the glob once in that module. All of the `droiddoc` modules can then
specify it through the `custom_template` property, which will pull the
necessary data.
Also fix that htmldirs should be references from the local path, the
htmldir2 argument never being specified, and complain if more than two
htmldirs are specified, or if the custom template isn't specified.
Test: m core-docs
Test: out/soong/build.ninja is nearly identical
- line numbers in comments
- adds directories to droiddoc template dependency lists, which
is more correct, since we need to rerun on added or removed
files too.
Change-Id: Iff630bddb3818b8eeed439de7e41fc7fbe7cdcb0
2018-02-26 23:33:31 +01:00
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
if String(d.properties.Custom_template) == "" {
|
|
|
|
// TODO: This is almost always droiddoc-templates-sdk
|
|
|
|
ctx.PropertyErrorf("custom_template", "must specify a template")
|
|
|
|
}
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
ctx.VisitDirectDepsWithTag(droiddocTemplateTag, func(m android.Module) {
|
2018-08-02 00:00:28 +02:00
|
|
|
if t, ok := m.(*ExportedDroiddocDir); ok {
|
2018-08-01 21:48:00 +02:00
|
|
|
*implicits = append(*implicits, t.deps...)
|
|
|
|
args = args + " -templatedir " + t.dir.String()
|
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("custom_template", "module %q is not a droiddoc_template", ctx.OtherModuleName(m))
|
2018-04-20 03:03:39 +02:00
|
|
|
}
|
2018-08-01 21:48:00 +02:00
|
|
|
})
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
if len(d.properties.Html_dirs) > 0 {
|
2019-03-05 21:46:40 +01:00
|
|
|
htmlDir := d.properties.Html_dirs[0]
|
2019-03-06 07:25:09 +01:00
|
|
|
*implicits = append(*implicits, android.PathsForModuleSrc(ctx, []string{filepath.Join(d.properties.Html_dirs[0], "**/*")})...)
|
2019-03-05 21:46:40 +01:00
|
|
|
args = args + " -htmldir " + htmlDir
|
2018-08-01 21:48:00 +02:00
|
|
|
}
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
if len(d.properties.Html_dirs) > 1 {
|
2019-03-05 21:46:40 +01:00
|
|
|
htmlDir2 := d.properties.Html_dirs[1]
|
2019-03-06 07:25:09 +01:00
|
|
|
*implicits = append(*implicits, android.PathsForModuleSrc(ctx, []string{filepath.Join(htmlDir2, "**/*")})...)
|
2019-03-05 21:46:40 +01:00
|
|
|
args = args + " -htmldir2 " + htmlDir2
|
2018-08-01 21:48:00 +02:00
|
|
|
}
|
2018-02-23 20:18:47 +01:00
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
if len(d.properties.Html_dirs) > 2 {
|
|
|
|
ctx.PropertyErrorf("html_dirs", "Droiddoc only supports up to 2 html dirs")
|
|
|
|
}
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2019-03-06 07:25:09 +01:00
|
|
|
knownTags := android.PathsForModuleSrc(ctx, d.properties.Knowntags)
|
2018-08-01 21:48:00 +02:00
|
|
|
*implicits = append(*implicits, knownTags...)
|
2018-04-20 03:03:39 +02:00
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
for _, kt := range knownTags {
|
|
|
|
args = args + " -knowntags " + kt.String()
|
|
|
|
}
|
2018-04-20 03:03:39 +02:00
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
for _, hdf := range d.properties.Hdf {
|
|
|
|
args = args + " -hdf " + hdf
|
|
|
|
}
|
2018-04-20 03:03:39 +02:00
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
if String(d.properties.Proofread_file) != "" {
|
|
|
|
proofreadFile := android.PathForModuleOut(ctx, String(d.properties.Proofread_file))
|
|
|
|
args = args + " -proofread " + proofreadFile.String()
|
2018-02-23 20:18:47 +01:00
|
|
|
}
|
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
if String(d.properties.Todo_file) != "" {
|
|
|
|
// tricky part:
|
|
|
|
// we should not compute full path for todo_file through PathForModuleOut().
|
|
|
|
// the non-standard doclet will get the full path relative to "-o".
|
|
|
|
args = args + " -todo " + String(d.properties.Todo_file)
|
2018-02-23 20:18:47 +01:00
|
|
|
}
|
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
if String(d.properties.Resourcesdir) != "" {
|
|
|
|
// TODO: should we add files under resourcesDir to the implicits? It seems that
|
|
|
|
// resourcesDir is one sub dir of htmlDir
|
|
|
|
resourcesDir := android.PathForModuleSrc(ctx, String(d.properties.Resourcesdir))
|
|
|
|
args = args + " -resourcesdir " + resourcesDir.String()
|
|
|
|
}
|
2018-05-05 03:49:16 +02:00
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
if String(d.properties.Resourcesoutdir) != "" {
|
|
|
|
// TODO: it seems -resourceoutdir reference/android/images/ didn't get generated anywhere.
|
|
|
|
args = args + " -resourcesoutdir " + String(d.properties.Resourcesoutdir)
|
|
|
|
}
|
|
|
|
return args
|
|
|
|
}
|
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
func (d *Droiddoc) collectStubsFlags(ctx android.ModuleContext,
|
|
|
|
implicitOutputs *android.WritablePaths) string {
|
|
|
|
var doclavaFlags string
|
|
|
|
if apiCheckEnabled(d.properties.Check_api.Current, "current") ||
|
|
|
|
apiCheckEnabled(d.properties.Check_api.Last_released, "last_released") ||
|
|
|
|
String(d.properties.Api_filename) != "" {
|
2018-05-05 03:49:16 +02:00
|
|
|
d.apiFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_api.txt")
|
2018-08-01 21:48:00 +02:00
|
|
|
doclavaFlags += " -api " + d.apiFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.apiFile)
|
2018-07-24 04:19:26 +02:00
|
|
|
d.apiFilePath = d.apiFile
|
2018-03-14 00:17:01 +01:00
|
|
|
}
|
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
if apiCheckEnabled(d.properties.Check_api.Current, "current") ||
|
|
|
|
apiCheckEnabled(d.properties.Check_api.Last_released, "last_released") ||
|
|
|
|
String(d.properties.Removed_api_filename) != "" {
|
2018-05-05 03:49:16 +02:00
|
|
|
d.removedApiFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_removed.txt")
|
2018-08-01 21:48:00 +02:00
|
|
|
doclavaFlags += " -removedApi " + d.removedApiFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.removedApiFile)
|
2018-05-05 03:49:16 +02:00
|
|
|
}
|
|
|
|
|
2018-03-14 00:17:01 +01:00
|
|
|
if String(d.properties.Private_api_filename) != "" {
|
|
|
|
d.privateApiFile = android.PathForModuleOut(ctx, String(d.properties.Private_api_filename))
|
2018-08-01 21:48:00 +02:00
|
|
|
doclavaFlags += " -privateApi " + d.privateApiFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.privateApiFile)
|
2018-03-14 00:17:01 +01:00
|
|
|
}
|
|
|
|
|
2018-05-31 14:56:46 +02:00
|
|
|
if String(d.properties.Dex_api_filename) != "" {
|
|
|
|
d.dexApiFile = android.PathForModuleOut(ctx, String(d.properties.Dex_api_filename))
|
2018-08-01 21:48:00 +02:00
|
|
|
doclavaFlags += " -dexApi " + d.dexApiFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.dexApiFile)
|
2018-05-31 14:56:46 +02:00
|
|
|
}
|
|
|
|
|
2018-03-14 00:17:01 +01:00
|
|
|
if String(d.properties.Private_dex_api_filename) != "" {
|
|
|
|
d.privateDexApiFile = android.PathForModuleOut(ctx, String(d.properties.Private_dex_api_filename))
|
2018-08-01 21:48:00 +02:00
|
|
|
doclavaFlags += " -privateDexApi " + d.privateDexApiFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.privateDexApiFile)
|
2018-03-14 00:17:01 +01:00
|
|
|
}
|
|
|
|
|
2018-04-24 17:23:29 +02:00
|
|
|
if String(d.properties.Removed_dex_api_filename) != "" {
|
|
|
|
d.removedDexApiFile = android.PathForModuleOut(ctx, String(d.properties.Removed_dex_api_filename))
|
2018-08-01 21:48:00 +02:00
|
|
|
doclavaFlags += " -removedDexApi " + d.removedDexApiFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.removedDexApiFile)
|
2018-04-24 17:23:29 +02:00
|
|
|
}
|
|
|
|
|
2018-03-14 00:17:01 +01:00
|
|
|
if String(d.properties.Exact_api_filename) != "" {
|
|
|
|
d.exactApiFile = android.PathForModuleOut(ctx, String(d.properties.Exact_api_filename))
|
2018-08-01 21:48:00 +02:00
|
|
|
doclavaFlags += " -exactApi " + d.exactApiFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.exactApiFile)
|
2018-03-14 00:17:01 +01:00
|
|
|
}
|
|
|
|
|
2018-06-22 16:28:11 +02:00
|
|
|
if String(d.properties.Dex_mapping_filename) != "" {
|
|
|
|
d.apiMappingFile = android.PathForModuleOut(ctx, String(d.properties.Dex_mapping_filename))
|
2018-08-01 21:48:00 +02:00
|
|
|
doclavaFlags += " -apiMapping " + d.apiMappingFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.apiMappingFile)
|
2018-06-22 16:28:11 +02:00
|
|
|
}
|
|
|
|
|
2018-08-15 05:41:04 +02:00
|
|
|
if String(d.properties.Proguard_filename) != "" {
|
|
|
|
d.proguardFile = android.PathForModuleOut(ctx, String(d.properties.Proguard_filename))
|
|
|
|
doclavaFlags += " -proguard " + d.proguardFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.proguardFile)
|
|
|
|
}
|
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
if BoolDefault(d.properties.Create_stubs, true) {
|
2018-08-09 01:32:21 +02:00
|
|
|
doclavaFlags += " -stubs " + android.PathForModuleOut(ctx, "stubsDir").String()
|
2018-08-01 21:48:00 +02:00
|
|
|
}
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
if Bool(d.properties.Write_sdk_values) {
|
2018-08-09 01:32:21 +02:00
|
|
|
doclavaFlags += " -sdkvalues " + android.PathForModuleOut(ctx, "out").String()
|
2018-04-20 03:03:39 +02:00
|
|
|
}
|
2018-09-05 02:14:32 +02:00
|
|
|
|
|
|
|
return doclavaFlags
|
2018-08-01 21:48:00 +02:00
|
|
|
}
|
2018-04-20 03:03:39 +02:00
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
func (d *Droiddoc) getPostDoclavaCmds(ctx android.ModuleContext, implicits *android.Paths) string {
|
|
|
|
var cmds string
|
|
|
|
if String(d.properties.Static_doc_index_redirect) != "" {
|
|
|
|
static_doc_index_redirect := ctx.ExpandSource(String(d.properties.Static_doc_index_redirect),
|
|
|
|
"static_doc_index_redirect")
|
|
|
|
*implicits = append(*implicits, static_doc_index_redirect)
|
|
|
|
cmds = cmds + " && cp " + static_doc_index_redirect.String() + " " +
|
2018-08-09 01:32:21 +02:00
|
|
|
android.PathForModuleOut(ctx, "out", "index.html").String()
|
2018-08-01 21:48:00 +02:00
|
|
|
}
|
2018-04-23 18:59:14 +02:00
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
if String(d.properties.Static_doc_properties) != "" {
|
|
|
|
static_doc_properties := ctx.ExpandSource(String(d.properties.Static_doc_properties),
|
|
|
|
"static_doc_properties")
|
|
|
|
*implicits = append(*implicits, static_doc_properties)
|
|
|
|
cmds = cmds + " && cp " + static_doc_properties.String() + " " +
|
2018-08-09 01:32:21 +02:00
|
|
|
android.PathForModuleOut(ctx, "out", "source.properties").String()
|
2018-06-04 20:28:01 +02:00
|
|
|
}
|
2018-08-01 21:48:00 +02:00
|
|
|
return cmds
|
|
|
|
}
|
2018-06-04 20:28:01 +02:00
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
func (d *Droiddoc) transformDoclava(ctx android.ModuleContext, implicits android.Paths,
|
|
|
|
implicitOutputs android.WritablePaths,
|
|
|
|
bootclasspathArgs, classpathArgs, sourcepathArgs, opts, postDoclavaCmds string) {
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: javadoc,
|
|
|
|
Description: "Doclava",
|
|
|
|
Output: d.Javadoc.stubsSrcJar,
|
|
|
|
Inputs: d.Javadoc.srcFiles,
|
|
|
|
Implicits: implicits,
|
|
|
|
ImplicitOutputs: implicitOutputs,
|
|
|
|
Args: map[string]string{
|
|
|
|
"outDir": android.PathForModuleOut(ctx, "out").String(),
|
|
|
|
"srcJarDir": android.PathForModuleOut(ctx, "srcjars").String(),
|
|
|
|
"stubsDir": android.PathForModuleOut(ctx, "stubsDir").String(),
|
|
|
|
"srcJars": strings.Join(d.Javadoc.srcJars.Strings(), " "),
|
|
|
|
"opts": opts,
|
|
|
|
"bootclasspathArgs": bootclasspathArgs,
|
|
|
|
"classpathArgs": classpathArgs,
|
|
|
|
"sourcepathArgs": sourcepathArgs,
|
|
|
|
"docZip": d.Javadoc.docZip.String(),
|
|
|
|
"postDoclavaCmds": postDoclavaCmds,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Droiddoc) transformCheckApi(ctx android.ModuleContext, apiFile, removedApiFile android.Path,
|
|
|
|
checkApiClasspath classpath, msg, opts string, output android.WritablePath) {
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: apiCheck,
|
|
|
|
Description: "Doclava Check API",
|
|
|
|
Output: output,
|
|
|
|
Inputs: nil,
|
|
|
|
Implicits: append(android.Paths{apiFile, removedApiFile, d.apiFile, d.removedApiFile},
|
|
|
|
checkApiClasspath...),
|
|
|
|
Args: map[string]string{
|
|
|
|
"msg": msg,
|
|
|
|
"classpath": checkApiClasspath.FormJavaClassPath(""),
|
|
|
|
"opts": opts,
|
|
|
|
"apiFile": apiFile.String(),
|
|
|
|
"apiFileToCheck": d.apiFile.String(),
|
|
|
|
"removedApiFile": removedApiFile.String(),
|
|
|
|
"removedApiFileToCheck": d.removedApiFile.String(),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Droiddoc) transformDokka(ctx android.ModuleContext, implicits android.Paths,
|
|
|
|
classpathArgs, opts string) {
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: dokka,
|
|
|
|
Description: "Dokka",
|
|
|
|
Output: d.Javadoc.stubsSrcJar,
|
|
|
|
Inputs: d.Javadoc.srcFiles,
|
|
|
|
Implicits: implicits,
|
|
|
|
Args: map[string]string{
|
2018-11-29 19:42:47 +01:00
|
|
|
"outDir": android.PathForModuleOut(ctx, "dokka-out").String(),
|
|
|
|
"srcJarDir": android.PathForModuleOut(ctx, "dokka-srcjars").String(),
|
|
|
|
"stubsDir": android.PathForModuleOut(ctx, "dokka-stubsDir").String(),
|
2018-09-05 02:14:32 +02:00
|
|
|
"srcJars": strings.Join(d.Javadoc.srcJars.Strings(), " "),
|
|
|
|
"classpathArgs": classpathArgs,
|
|
|
|
"opts": opts,
|
|
|
|
"docZip": d.Javadoc.docZip.String(),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
|
|
deps := d.Javadoc.collectDeps(ctx)
|
|
|
|
|
|
|
|
jsilver := android.PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "framework", "jsilver.jar")
|
|
|
|
doclava := android.PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "framework", "doclava.jar")
|
|
|
|
java8Home := ctx.Config().Getenv("ANDROID_JAVA8_HOME")
|
|
|
|
checkApiClasspath := classpath{jsilver, doclava, android.PathForSource(ctx, java8Home, "lib/tools.jar")}
|
|
|
|
|
|
|
|
var implicits android.Paths
|
|
|
|
implicits = append(implicits, d.Javadoc.srcJars...)
|
|
|
|
implicits = append(implicits, d.Javadoc.argFiles...)
|
|
|
|
|
|
|
|
var implicitOutputs android.WritablePaths
|
|
|
|
implicitOutputs = append(implicitOutputs, d.Javadoc.docZip)
|
|
|
|
for _, o := range d.Javadoc.properties.Out {
|
|
|
|
implicitOutputs = append(implicitOutputs, android.PathForModuleGen(ctx, o))
|
|
|
|
}
|
|
|
|
|
|
|
|
flags, err := d.initBuilderFlags(ctx, &implicits, deps)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
flags.doclavaStubsFlags = d.collectStubsFlags(ctx, &implicitOutputs)
|
|
|
|
if Bool(d.properties.Dokka_enabled) {
|
|
|
|
d.transformDokka(ctx, implicits, flags.classpathArgs, d.Javadoc.args)
|
|
|
|
} else {
|
|
|
|
flags.doclavaDocsFlags = d.collectDoclavaDocsFlags(ctx, &implicits, jsilver, doclava)
|
|
|
|
flags.postDoclavaCmds = d.getPostDoclavaCmds(ctx, &implicits)
|
|
|
|
d.transformDoclava(ctx, implicits, implicitOutputs, flags.bootClasspathArgs, flags.classpathArgs,
|
|
|
|
flags.sourcepathArgs, flags.doclavaDocsFlags+flags.doclavaStubsFlags+" "+d.Javadoc.args,
|
|
|
|
flags.postDoclavaCmds)
|
|
|
|
}
|
|
|
|
|
|
|
|
if apiCheckEnabled(d.properties.Check_api.Current, "current") &&
|
|
|
|
!ctx.Config().IsPdkBuild() {
|
|
|
|
apiFile := ctx.ExpandSource(String(d.properties.Check_api.Current.Api_file),
|
|
|
|
"check_api.current.api_file")
|
|
|
|
removedApiFile := ctx.ExpandSource(String(d.properties.Check_api.Current.Removed_api_file),
|
|
|
|
"check_api.current_removed_api_file")
|
|
|
|
|
|
|
|
d.checkCurrentApiTimestamp = android.PathForModuleOut(ctx, "check_current_api.timestamp")
|
|
|
|
d.transformCheckApi(ctx, apiFile, removedApiFile, checkApiClasspath,
|
|
|
|
fmt.Sprintf(`\n******************************\n`+
|
|
|
|
`You have tried to change the API from what has been previously approved.\n\n`+
|
|
|
|
`To make these errors go away, you have two choices:\n`+
|
|
|
|
` 1. You can add '@hide' javadoc comments to the methods, etc. listed in the\n`+
|
|
|
|
` errors above.\n\n`+
|
|
|
|
` 2. You can update current.txt by executing the following command:\n`+
|
|
|
|
` make %s-update-current-api\n\n`+
|
|
|
|
` To submit the revised current.txt to the main Android repository,\n`+
|
|
|
|
` you will need approval.\n`+
|
|
|
|
`******************************\n`, ctx.ModuleName()), String(d.properties.Check_api.Current.Args),
|
|
|
|
d.checkCurrentApiTimestamp)
|
|
|
|
|
|
|
|
d.updateCurrentApiTimestamp = android.PathForModuleOut(ctx, "update_current_api.timestamp")
|
|
|
|
transformUpdateApi(ctx, apiFile, removedApiFile, d.apiFile, d.removedApiFile,
|
|
|
|
d.updateCurrentApiTimestamp)
|
|
|
|
}
|
|
|
|
|
|
|
|
if apiCheckEnabled(d.properties.Check_api.Last_released, "last_released") &&
|
|
|
|
!ctx.Config().IsPdkBuild() {
|
|
|
|
apiFile := ctx.ExpandSource(String(d.properties.Check_api.Last_released.Api_file),
|
|
|
|
"check_api.last_released.api_file")
|
|
|
|
removedApiFile := ctx.ExpandSource(String(d.properties.Check_api.Last_released.Removed_api_file),
|
|
|
|
"check_api.last_released.removed_api_file")
|
|
|
|
|
|
|
|
d.checkLastReleasedApiTimestamp = android.PathForModuleOut(ctx, "check_last_released_api.timestamp")
|
|
|
|
d.transformCheckApi(ctx, apiFile, removedApiFile, checkApiClasspath,
|
|
|
|
`\n******************************\n`+
|
|
|
|
`You have tried to change the API from what has been previously released in\n`+
|
|
|
|
`an SDK. Please fix the errors listed above.\n`+
|
|
|
|
`******************************\n`, String(d.properties.Check_api.Last_released.Args),
|
|
|
|
d.checkLastReleasedApiTimestamp)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Droidstubs
|
|
|
|
//
|
|
|
|
type Droidstubs struct {
|
|
|
|
Javadoc
|
|
|
|
|
2018-10-22 16:55:04 +02:00
|
|
|
properties DroidstubsProperties
|
|
|
|
apiFile android.WritablePath
|
|
|
|
apiXmlFile android.WritablePath
|
|
|
|
lastReleasedApiXmlFile android.WritablePath
|
|
|
|
dexApiFile android.WritablePath
|
|
|
|
privateApiFile android.WritablePath
|
|
|
|
privateDexApiFile android.WritablePath
|
|
|
|
removedApiFile android.WritablePath
|
|
|
|
removedDexApiFile android.WritablePath
|
|
|
|
apiMappingFile android.WritablePath
|
|
|
|
exactApiFile android.WritablePath
|
|
|
|
proguardFile android.WritablePath
|
|
|
|
nullabilityWarningsFile android.WritablePath
|
2018-09-05 02:14:32 +02:00
|
|
|
|
|
|
|
checkCurrentApiTimestamp android.WritablePath
|
|
|
|
updateCurrentApiTimestamp android.WritablePath
|
|
|
|
checkLastReleasedApiTimestamp android.WritablePath
|
|
|
|
|
2018-10-22 16:55:04 +02:00
|
|
|
checkNullabilityWarningsTimestamp android.WritablePath
|
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
annotationsZip android.WritablePath
|
2018-08-22 19:22:08 +02:00
|
|
|
apiVersionsXml android.WritablePath
|
2018-09-05 02:14:32 +02:00
|
|
|
|
|
|
|
apiFilePath android.Path
|
2018-09-17 23:32:21 +02:00
|
|
|
|
|
|
|
jdiffDocZip android.WritablePath
|
|
|
|
jdiffStubsSrcJar android.WritablePath
|
2018-09-05 02:14:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func DroidstubsFactory() android.Module {
|
|
|
|
module := &Droidstubs{}
|
|
|
|
|
|
|
|
module.AddProperties(&module.properties,
|
|
|
|
&module.Javadoc.properties)
|
|
|
|
|
|
|
|
InitDroiddocModule(module, android.HostAndDeviceSupported)
|
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
|
|
|
func DroidstubsHostFactory() android.Module {
|
|
|
|
module := &Droidstubs{}
|
|
|
|
|
|
|
|
module.AddProperties(&module.properties,
|
|
|
|
&module.Javadoc.properties)
|
|
|
|
|
|
|
|
InitDroiddocModule(module, android.HostSupported)
|
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Droidstubs) ApiFilePath() android.Path {
|
|
|
|
return d.apiFilePath
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Droidstubs) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|
|
|
d.Javadoc.addDeps(ctx)
|
|
|
|
|
2019-02-28 06:24:05 +01:00
|
|
|
if Bool(d.properties.Check_api.Ignore_missing_latest_api) {
|
|
|
|
ignoreMissingModules(ctx, &d.properties.Check_api.Last_released)
|
|
|
|
}
|
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
if len(d.properties.Merge_annotations_dirs) != 0 {
|
|
|
|
for _, mergeAnnotationsDir := range d.properties.Merge_annotations_dirs {
|
|
|
|
ctx.AddDependency(ctx.Module(), metalavaMergeAnnotationsDirTag, mergeAnnotationsDir)
|
|
|
|
}
|
|
|
|
}
|
2018-08-22 19:22:08 +02:00
|
|
|
|
2018-09-19 19:16:26 +02:00
|
|
|
if len(d.properties.Merge_inclusion_annotations_dirs) != 0 {
|
|
|
|
for _, mergeInclusionAnnotationsDir := range d.properties.Merge_inclusion_annotations_dirs {
|
|
|
|
ctx.AddDependency(ctx.Module(), metalavaMergeInclusionAnnotationsDirTag, mergeInclusionAnnotationsDir)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-22 19:22:08 +02:00
|
|
|
if len(d.properties.Api_levels_annotations_dirs) != 0 {
|
|
|
|
for _, apiLevelsAnnotationsDir := range d.properties.Api_levels_annotations_dirs {
|
|
|
|
ctx.AddDependency(ctx.Module(), metalavaAPILevelsAnnotationsDirTag, apiLevelsAnnotationsDir)
|
|
|
|
}
|
|
|
|
}
|
2018-09-05 02:14:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Droidstubs) initBuilderFlags(ctx android.ModuleContext, implicits *android.Paths,
|
|
|
|
deps deps) (droiddocBuilderFlags, error) {
|
|
|
|
var flags droiddocBuilderFlags
|
|
|
|
|
|
|
|
*implicits = append(*implicits, deps.bootClasspath...)
|
|
|
|
*implicits = append(*implicits, deps.classpath...)
|
|
|
|
|
|
|
|
// continue to use -bootclasspath even if Metalava under -source 1.9 is enabled
|
|
|
|
// since it doesn't support system modules yet.
|
|
|
|
if len(deps.bootClasspath.Strings()) > 0 {
|
|
|
|
// For OpenJDK 8 we can use -bootclasspath to define the core libraries code.
|
|
|
|
flags.bootClasspathArgs = deps.bootClasspath.FormJavaClassPath("-bootclasspath")
|
|
|
|
}
|
|
|
|
flags.classpathArgs = deps.classpath.FormJavaClassPath("-classpath")
|
|
|
|
|
2018-10-05 11:41:09 +02:00
|
|
|
flags.sourcepathArgs = "-sourcepath \"" + strings.Join(d.Javadoc.sourcepaths.Strings(), ":") + "\""
|
2018-09-05 02:14:32 +02:00
|
|
|
return flags, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Droidstubs) collectStubsFlags(ctx android.ModuleContext,
|
|
|
|
implicitOutputs *android.WritablePaths) string {
|
|
|
|
var metalavaFlags string
|
|
|
|
if apiCheckEnabled(d.properties.Check_api.Current, "current") ||
|
|
|
|
apiCheckEnabled(d.properties.Check_api.Last_released, "last_released") ||
|
|
|
|
String(d.properties.Api_filename) != "" {
|
|
|
|
d.apiFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_api.txt")
|
|
|
|
metalavaFlags = metalavaFlags + " --api " + d.apiFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.apiFile)
|
|
|
|
d.apiFilePath = d.apiFile
|
|
|
|
}
|
|
|
|
|
|
|
|
if apiCheckEnabled(d.properties.Check_api.Current, "current") ||
|
|
|
|
apiCheckEnabled(d.properties.Check_api.Last_released, "last_released") ||
|
|
|
|
String(d.properties.Removed_api_filename) != "" {
|
|
|
|
d.removedApiFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_removed.txt")
|
|
|
|
metalavaFlags = metalavaFlags + " --removed-api " + d.removedApiFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.removedApiFile)
|
|
|
|
}
|
|
|
|
|
|
|
|
if String(d.properties.Private_api_filename) != "" {
|
|
|
|
d.privateApiFile = android.PathForModuleOut(ctx, String(d.properties.Private_api_filename))
|
|
|
|
metalavaFlags = metalavaFlags + " --private-api " + d.privateApiFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.privateApiFile)
|
|
|
|
}
|
|
|
|
|
|
|
|
if String(d.properties.Dex_api_filename) != "" {
|
|
|
|
d.dexApiFile = android.PathForModuleOut(ctx, String(d.properties.Dex_api_filename))
|
|
|
|
metalavaFlags += " --dex-api " + d.dexApiFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.dexApiFile)
|
|
|
|
}
|
|
|
|
|
|
|
|
if String(d.properties.Private_dex_api_filename) != "" {
|
|
|
|
d.privateDexApiFile = android.PathForModuleOut(ctx, String(d.properties.Private_dex_api_filename))
|
|
|
|
metalavaFlags = metalavaFlags + " --private-dex-api " + d.privateDexApiFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.privateDexApiFile)
|
|
|
|
}
|
|
|
|
|
|
|
|
if String(d.properties.Removed_dex_api_filename) != "" {
|
|
|
|
d.removedDexApiFile = android.PathForModuleOut(ctx, String(d.properties.Removed_dex_api_filename))
|
|
|
|
metalavaFlags = metalavaFlags + " --removed-dex-api " + d.removedDexApiFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.removedDexApiFile)
|
|
|
|
}
|
|
|
|
|
|
|
|
if String(d.properties.Exact_api_filename) != "" {
|
|
|
|
d.exactApiFile = android.PathForModuleOut(ctx, String(d.properties.Exact_api_filename))
|
|
|
|
metalavaFlags = metalavaFlags + " --exact-api " + d.exactApiFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.exactApiFile)
|
|
|
|
}
|
|
|
|
|
2018-08-22 19:22:08 +02:00
|
|
|
if String(d.properties.Dex_mapping_filename) != "" {
|
|
|
|
d.apiMappingFile = android.PathForModuleOut(ctx, String(d.properties.Dex_mapping_filename))
|
|
|
|
metalavaFlags = metalavaFlags + " --dex-api-mapping " + d.apiMappingFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.apiMappingFile)
|
|
|
|
}
|
|
|
|
|
2018-09-19 21:40:06 +02:00
|
|
|
if String(d.properties.Proguard_filename) != "" {
|
|
|
|
d.proguardFile = android.PathForModuleOut(ctx, String(d.properties.Proguard_filename))
|
|
|
|
metalavaFlags += " --proguard " + d.proguardFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.proguardFile)
|
|
|
|
}
|
|
|
|
|
2018-08-22 19:22:08 +02:00
|
|
|
if Bool(d.properties.Write_sdk_values) {
|
|
|
|
metalavaFlags = metalavaFlags + " --sdk-values " + android.PathForModuleOut(ctx, "out").String()
|
|
|
|
}
|
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
if Bool(d.properties.Create_doc_stubs) {
|
|
|
|
metalavaFlags += " --doc-stubs " + android.PathForModuleOut(ctx, "stubsDir").String()
|
|
|
|
} else {
|
|
|
|
metalavaFlags += " --stubs " + android.PathForModuleOut(ctx, "stubsDir").String()
|
|
|
|
}
|
|
|
|
return metalavaFlags
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Droidstubs) collectAnnotationsFlags(ctx android.ModuleContext,
|
2018-12-27 01:06:37 +01:00
|
|
|
implicits *android.Paths, implicitOutputs *android.WritablePaths) (string, string) {
|
|
|
|
var flags, mergeAnnoDirFlags string
|
2018-09-05 02:14:32 +02:00
|
|
|
if Bool(d.properties.Annotations_enabled) {
|
2018-09-14 15:25:48 +02:00
|
|
|
flags += " --include-annotations"
|
2018-11-14 19:45:46 +01:00
|
|
|
validatingNullability :=
|
|
|
|
strings.Contains(d.Javadoc.args, "--validate-nullability-from-merged-stubs") ||
|
|
|
|
String(d.properties.Validate_nullability_from_list) != ""
|
2018-09-14 15:25:48 +02:00
|
|
|
migratingNullability := String(d.properties.Previous_api) != ""
|
|
|
|
if !(migratingNullability || validatingNullability) {
|
|
|
|
ctx.PropertyErrorf("previous_api",
|
|
|
|
"has to be non-empty if annotations was enabled (unless validating nullability)")
|
|
|
|
}
|
|
|
|
if migratingNullability {
|
2019-03-06 07:25:09 +01:00
|
|
|
previousApi := android.PathForModuleSrc(ctx, String(d.properties.Previous_api))
|
2018-09-14 15:25:48 +02:00
|
|
|
*implicits = append(*implicits, previousApi)
|
|
|
|
flags += " --migrate-nullness " + previousApi.String()
|
|
|
|
}
|
2018-11-14 19:45:46 +01:00
|
|
|
if s := String(d.properties.Validate_nullability_from_list); s != "" {
|
2019-03-06 07:25:09 +01:00
|
|
|
flags += " --validate-nullability-from-list " + android.PathForModuleSrc(ctx, s).String()
|
2018-11-14 19:45:46 +01:00
|
|
|
}
|
2018-09-14 15:25:48 +02:00
|
|
|
if validatingNullability {
|
2018-10-22 16:55:04 +02:00
|
|
|
d.nullabilityWarningsFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_nullability_warnings.txt")
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.nullabilityWarningsFile)
|
|
|
|
flags += " --nullability-warnings-txt " + d.nullabilityWarningsFile.String()
|
2018-08-01 21:48:00 +02:00
|
|
|
}
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
d.annotationsZip = android.PathForModuleOut(ctx, ctx.ModuleName()+"_annotations.zip")
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.annotationsZip)
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2018-08-02 00:00:28 +02:00
|
|
|
flags += " --extract-annotations " + d.annotationsZip.String()
|
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
if len(d.properties.Merge_annotations_dirs) == 0 {
|
2018-08-22 19:22:08 +02:00
|
|
|
ctx.PropertyErrorf("merge_annotations_dirs",
|
2018-08-01 21:48:00 +02:00
|
|
|
"has to be non-empty if annotations was enabled!")
|
2018-04-20 03:03:39 +02:00
|
|
|
}
|
2018-08-02 00:00:28 +02:00
|
|
|
ctx.VisitDirectDepsWithTag(metalavaMergeAnnotationsDirTag, func(m android.Module) {
|
|
|
|
if t, ok := m.(*ExportedDroiddocDir); ok {
|
|
|
|
*implicits = append(*implicits, t.deps...)
|
2018-12-27 01:06:37 +01:00
|
|
|
mergeAnnoDirFlags += " --merge-qualifier-annotations " + t.dir.String()
|
2018-08-02 00:00:28 +02:00
|
|
|
} else {
|
2018-08-22 19:22:08 +02:00
|
|
|
ctx.PropertyErrorf("merge_annotations_dirs",
|
2018-08-02 00:00:28 +02:00
|
|
|
"module %q is not a metalava merge-annotations dir", ctx.OtherModuleName(m))
|
|
|
|
}
|
|
|
|
})
|
2018-12-27 01:06:37 +01:00
|
|
|
flags += mergeAnnoDirFlags
|
2018-08-01 21:48:00 +02:00
|
|
|
// TODO(tnorbye): find owners to fix these warnings when annotation was enabled.
|
2018-10-21 23:13:19 +02:00
|
|
|
flags += " --hide HiddenTypedefConstant --hide SuperfluousPrefix --hide AnnotationExtraction"
|
2018-08-01 21:48:00 +02:00
|
|
|
}
|
2018-10-21 23:13:19 +02:00
|
|
|
|
2018-12-27 01:06:37 +01:00
|
|
|
return flags, mergeAnnoDirFlags
|
2018-10-21 23:13:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Droidstubs) collectInclusionAnnotationsFlags(ctx android.ModuleContext,
|
|
|
|
implicits *android.Paths, implicitOutputs *android.WritablePaths) string {
|
|
|
|
var flags string
|
2018-09-19 19:16:26 +02:00
|
|
|
ctx.VisitDirectDepsWithTag(metalavaMergeInclusionAnnotationsDirTag, func(m android.Module) {
|
|
|
|
if t, ok := m.(*ExportedDroiddocDir); ok {
|
|
|
|
*implicits = append(*implicits, t.deps...)
|
|
|
|
flags += " --merge-inclusion-annotations " + t.dir.String()
|
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("merge_inclusion_annotations_dirs",
|
|
|
|
"module %q is not a metalava merge-annotations dir", ctx.OtherModuleName(m))
|
|
|
|
}
|
|
|
|
})
|
2018-07-12 00:16:55 +02:00
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
return flags
|
|
|
|
}
|
2018-07-12 00:16:55 +02:00
|
|
|
|
2018-08-22 19:22:08 +02:00
|
|
|
func (d *Droidstubs) collectAPILevelsAnnotationsFlags(ctx android.ModuleContext,
|
|
|
|
implicits *android.Paths, implicitOutputs *android.WritablePaths) string {
|
|
|
|
var flags string
|
|
|
|
if Bool(d.properties.Api_levels_annotations_enabled) {
|
|
|
|
d.apiVersionsXml = android.PathForModuleOut(ctx, "api-versions.xml")
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.apiVersionsXml)
|
|
|
|
|
|
|
|
if len(d.properties.Api_levels_annotations_dirs) == 0 {
|
|
|
|
ctx.PropertyErrorf("api_levels_annotations_dirs",
|
|
|
|
"has to be non-empty if api levels annotations was enabled!")
|
|
|
|
}
|
|
|
|
|
|
|
|
flags = " --generate-api-levels " + d.apiVersionsXml.String() + " --apply-api-levels " +
|
|
|
|
d.apiVersionsXml.String() + " --current-version " + ctx.Config().PlatformSdkVersion() +
|
|
|
|
" --current-codename " + ctx.Config().PlatformSdkCodename() + " "
|
|
|
|
|
|
|
|
ctx.VisitDirectDepsWithTag(metalavaAPILevelsAnnotationsDirTag, func(m android.Module) {
|
|
|
|
if t, ok := m.(*ExportedDroiddocDir); ok {
|
|
|
|
var androidJars android.Paths
|
|
|
|
for _, dep := range t.deps {
|
|
|
|
if strings.HasSuffix(dep.String(), "android.jar") {
|
|
|
|
androidJars = append(androidJars, dep)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*implicits = append(*implicits, androidJars...)
|
2019-01-24 20:05:46 +01:00
|
|
|
flags += " --android-jar-pattern " + t.dir.String() + "/%/public/android.jar "
|
2018-08-22 19:22:08 +02:00
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("api_levels_annotations_dirs",
|
|
|
|
"module %q is not a metalava api-levels-annotations dir", ctx.OtherModuleName(m))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return flags
|
|
|
|
}
|
|
|
|
|
2018-09-17 23:32:21 +02:00
|
|
|
func (d *Droidstubs) collectApiToXmlFlags(ctx android.ModuleContext, implicits *android.Paths,
|
|
|
|
implicitOutputs *android.WritablePaths) string {
|
|
|
|
var flags string
|
|
|
|
if Bool(d.properties.Jdiff_enabled) && !ctx.Config().IsPdkBuild() {
|
|
|
|
if d.apiFile.String() == "" {
|
|
|
|
ctx.ModuleErrorf("API signature file has to be specified in Metalava when jdiff is enabled.")
|
|
|
|
}
|
|
|
|
|
|
|
|
d.apiXmlFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_api.xml")
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.apiXmlFile)
|
|
|
|
|
|
|
|
flags = " --api-xml " + d.apiXmlFile.String()
|
|
|
|
|
|
|
|
if String(d.properties.Check_api.Last_released.Api_file) == "" {
|
|
|
|
ctx.PropertyErrorf("check_api.last_released.api_file",
|
|
|
|
"has to be non-empty if jdiff was enabled!")
|
|
|
|
}
|
|
|
|
lastReleasedApi := ctx.ExpandSource(String(d.properties.Check_api.Last_released.Api_file),
|
|
|
|
"check_api.last_released.api_file")
|
|
|
|
*implicits = append(*implicits, lastReleasedApi)
|
|
|
|
|
|
|
|
d.lastReleasedApiXmlFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_last_released_api.xml")
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.lastReleasedApiXmlFile)
|
|
|
|
|
|
|
|
flags += " --convert-to-jdiff " + lastReleasedApi.String() + " " +
|
|
|
|
d.lastReleasedApiXmlFile.String()
|
|
|
|
}
|
|
|
|
|
|
|
|
return flags
|
|
|
|
}
|
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
func (d *Droidstubs) transformMetalava(ctx android.ModuleContext, implicits android.Paths,
|
|
|
|
implicitOutputs android.WritablePaths, javaVersion,
|
|
|
|
bootclasspathArgs, classpathArgs, sourcepathArgs, opts string) {
|
2018-08-22 19:22:08 +02:00
|
|
|
|
2018-08-10 00:33:27 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: metalava,
|
|
|
|
Description: "Metalava",
|
|
|
|
Output: d.Javadoc.stubsSrcJar,
|
|
|
|
Inputs: d.Javadoc.srcFiles,
|
|
|
|
Implicits: implicits,
|
|
|
|
ImplicitOutputs: implicitOutputs,
|
|
|
|
Args: map[string]string{
|
2018-09-05 02:14:32 +02:00
|
|
|
"outDir": android.PathForModuleOut(ctx, "out").String(),
|
2018-08-10 00:33:27 +02:00
|
|
|
"srcJarDir": android.PathForModuleOut(ctx, "srcjars").String(),
|
|
|
|
"stubsDir": android.PathForModuleOut(ctx, "stubsDir").String(),
|
|
|
|
"srcJars": strings.Join(d.Javadoc.srcJars.Strings(), " "),
|
|
|
|
"javaVersion": javaVersion,
|
|
|
|
"bootclasspathArgs": bootclasspathArgs,
|
|
|
|
"classpathArgs": classpathArgs,
|
2018-09-05 02:14:32 +02:00
|
|
|
"sourcepathArgs": sourcepathArgs,
|
2018-08-10 00:33:27 +02:00
|
|
|
"opts": opts,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
func (d *Droidstubs) transformCheckApi(ctx android.ModuleContext,
|
|
|
|
apiFile, removedApiFile android.Path, implicits android.Paths,
|
2019-01-25 01:32:44 +01:00
|
|
|
javaVersion, bootclasspathArgs, classpathArgs, sourcepathArgs, opts, subdir, msg string,
|
2018-08-24 19:32:54 +02:00
|
|
|
output android.WritablePath) {
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: metalavaApiCheck,
|
|
|
|
Description: "Metalava Check API",
|
|
|
|
Output: output,
|
|
|
|
Inputs: d.Javadoc.srcFiles,
|
|
|
|
Implicits: append(android.Paths{apiFile, removedApiFile, d.apiFile, d.removedApiFile},
|
|
|
|
implicits...),
|
|
|
|
Args: map[string]string{
|
2019-01-25 01:32:44 +01:00
|
|
|
"srcJarDir": android.PathForModuleOut(ctx, subdir, "srcjars").String(),
|
2018-08-24 19:32:54 +02:00
|
|
|
"srcJars": strings.Join(d.Javadoc.srcJars.Strings(), " "),
|
|
|
|
"javaVersion": javaVersion,
|
|
|
|
"bootclasspathArgs": bootclasspathArgs,
|
|
|
|
"classpathArgs": classpathArgs,
|
2018-09-05 02:14:32 +02:00
|
|
|
"sourcepathArgs": sourcepathArgs,
|
2018-08-24 19:32:54 +02:00
|
|
|
"opts": opts,
|
|
|
|
"msg": msg,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-09-17 23:32:21 +02:00
|
|
|
func (d *Droidstubs) transformJdiff(ctx android.ModuleContext, implicits android.Paths,
|
|
|
|
implicitOutputs android.WritablePaths,
|
|
|
|
bootclasspathArgs, classpathArgs, sourcepathArgs, opts string) {
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: javadoc,
|
|
|
|
Description: "Jdiff",
|
|
|
|
Output: d.jdiffStubsSrcJar,
|
|
|
|
Inputs: d.Javadoc.srcFiles,
|
|
|
|
Implicits: implicits,
|
|
|
|
ImplicitOutputs: implicitOutputs,
|
|
|
|
Args: map[string]string{
|
2018-09-19 20:19:39 +02:00
|
|
|
"outDir": android.PathForModuleOut(ctx, "jdiff-out").String(),
|
|
|
|
"srcJarDir": android.PathForModuleOut(ctx, "jdiff-srcjars").String(),
|
|
|
|
"stubsDir": android.PathForModuleOut(ctx, "jdiff-stubsDir").String(),
|
2018-09-17 23:32:21 +02:00
|
|
|
"srcJars": strings.Join(d.Javadoc.srcJars.Strings(), " "),
|
|
|
|
"opts": opts,
|
|
|
|
"bootclasspathArgs": bootclasspathArgs,
|
|
|
|
"classpathArgs": classpathArgs,
|
|
|
|
"sourcepathArgs": sourcepathArgs,
|
|
|
|
"docZip": d.jdiffDocZip.String(),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
2018-08-01 21:48:00 +02:00
|
|
|
deps := d.Javadoc.collectDeps(ctx)
|
2018-07-12 00:16:55 +02:00
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
javaVersion := getJavaVersion(ctx, String(d.Javadoc.properties.Java_version), sdkContext(d))
|
|
|
|
|
|
|
|
var implicits android.Paths
|
|
|
|
implicits = append(implicits, d.Javadoc.srcJars...)
|
2018-09-05 02:14:32 +02:00
|
|
|
implicits = append(implicits, d.Javadoc.argFiles...)
|
2018-08-01 21:48:00 +02:00
|
|
|
|
|
|
|
var implicitOutputs android.WritablePaths
|
2018-09-05 02:14:32 +02:00
|
|
|
for _, o := range d.Javadoc.properties.Out {
|
2018-08-01 21:48:00 +02:00
|
|
|
implicitOutputs = append(implicitOutputs, android.PathForModuleGen(ctx, o))
|
|
|
|
}
|
|
|
|
|
|
|
|
flags, err := d.initBuilderFlags(ctx, &implicits, deps)
|
2018-08-24 19:32:54 +02:00
|
|
|
metalavaCheckApiImplicits := implicits
|
2018-09-17 23:32:21 +02:00
|
|
|
jdiffImplicits := implicits
|
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
flags.metalavaStubsFlags = d.collectStubsFlags(ctx, &implicitOutputs)
|
2018-12-27 01:06:37 +01:00
|
|
|
flags.metalavaAnnotationsFlags, flags.metalavaMergeAnnoDirFlags =
|
|
|
|
d.collectAnnotationsFlags(ctx, &implicits, &implicitOutputs)
|
2018-10-21 23:13:19 +02:00
|
|
|
flags.metalavaInclusionAnnotationsFlags = d.collectInclusionAnnotationsFlags(ctx, &implicits, &implicitOutputs)
|
2018-08-22 19:22:08 +02:00
|
|
|
flags.metalavaApiLevelsAnnotationsFlags = d.collectAPILevelsAnnotationsFlags(ctx, &implicits, &implicitOutputs)
|
2018-09-17 23:32:21 +02:00
|
|
|
flags.metalavaApiToXmlFlags = d.collectApiToXmlFlags(ctx, &implicits, &implicitOutputs)
|
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
if strings.Contains(d.Javadoc.args, "--generate-documentation") {
|
|
|
|
// Currently Metalava have the ability to invoke Javadoc in a seperate 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 = d.Javadoc.args + " -nodocs "
|
2018-04-20 03:03:39 +02:00
|
|
|
}
|
2018-09-05 02:14:32 +02:00
|
|
|
d.transformMetalava(ctx, implicits, implicitOutputs, javaVersion,
|
|
|
|
flags.bootClasspathArgs, flags.classpathArgs, flags.sourcepathArgs,
|
2018-10-21 23:13:19 +02:00
|
|
|
flags.metalavaStubsFlags+flags.metalavaAnnotationsFlags+flags.metalavaInclusionAnnotationsFlags+
|
2018-09-17 23:32:21 +02:00
|
|
|
flags.metalavaApiLevelsAnnotationsFlags+flags.metalavaApiToXmlFlags+" "+d.Javadoc.args)
|
2018-05-05 03:49:16 +02:00
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
if apiCheckEnabled(d.properties.Check_api.Current, "current") &&
|
|
|
|
!ctx.Config().IsPdkBuild() {
|
2018-05-05 03:49:16 +02:00
|
|
|
apiFile := ctx.ExpandSource(String(d.properties.Check_api.Current.Api_file),
|
|
|
|
"check_api.current.api_file")
|
|
|
|
removedApiFile := ctx.ExpandSource(String(d.properties.Check_api.Current.Removed_api_file),
|
|
|
|
"check_api.current_removed_api_file")
|
|
|
|
|
2018-08-24 19:32:54 +02:00
|
|
|
d.checkCurrentApiTimestamp = android.PathForModuleOut(ctx, "check_current_api.timestamp")
|
2018-10-21 23:13:19 +02:00
|
|
|
opts := " " + d.Javadoc.args + " --check-compatibility:api:current " + apiFile.String() +
|
|
|
|
" --check-compatibility:removed:current " + removedApiFile.String() +
|
2018-12-27 01:06:37 +01:00
|
|
|
flags.metalavaInclusionAnnotationsFlags + flags.metalavaMergeAnnoDirFlags + " "
|
2018-09-05 02:14:32 +02:00
|
|
|
|
|
|
|
d.transformCheckApi(ctx, apiFile, removedApiFile, metalavaCheckApiImplicits,
|
2019-01-25 01:32:44 +01:00
|
|
|
javaVersion, flags.bootClasspathArgs, flags.classpathArgs, flags.sourcepathArgs, opts, "current-apicheck",
|
2018-09-05 02:14:32 +02:00
|
|
|
fmt.Sprintf(`\n******************************\n`+
|
|
|
|
`You have tried to change the API from what has been previously approved.\n\n`+
|
|
|
|
`To make these errors go away, you have two choices:\n`+
|
|
|
|
` 1. You can add '@hide' javadoc comments to the methods, etc. listed in the\n`+
|
|
|
|
` errors above.\n\n`+
|
|
|
|
` 2. You can update current.txt by executing the following command:\n`+
|
|
|
|
` make %s-update-current-api\n\n`+
|
|
|
|
` To submit the revised current.txt to the main Android repository,\n`+
|
|
|
|
` you will need approval.\n`+
|
|
|
|
`******************************\n`, ctx.ModuleName()),
|
|
|
|
d.checkCurrentApiTimestamp)
|
2018-05-05 03:49:16 +02:00
|
|
|
|
|
|
|
d.updateCurrentApiTimestamp = android.PathForModuleOut(ctx, "update_current_api.timestamp")
|
2018-09-05 02:14:32 +02:00
|
|
|
transformUpdateApi(ctx, apiFile, removedApiFile, d.apiFile, d.removedApiFile,
|
|
|
|
d.updateCurrentApiTimestamp)
|
2018-05-05 03:49:16 +02:00
|
|
|
}
|
2018-08-01 21:48:00 +02:00
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
if apiCheckEnabled(d.properties.Check_api.Last_released, "last_released") &&
|
|
|
|
!ctx.Config().IsPdkBuild() {
|
2018-05-05 03:49:16 +02:00
|
|
|
apiFile := ctx.ExpandSource(String(d.properties.Check_api.Last_released.Api_file),
|
|
|
|
"check_api.last_released.api_file")
|
|
|
|
removedApiFile := ctx.ExpandSource(String(d.properties.Check_api.Last_released.Removed_api_file),
|
|
|
|
"check_api.last_released.removed_api_file")
|
|
|
|
|
2018-08-24 19:32:54 +02:00
|
|
|
d.checkLastReleasedApiTimestamp = android.PathForModuleOut(ctx, "check_last_released_api.timestamp")
|
2018-10-21 23:13:19 +02:00
|
|
|
opts := " " + d.Javadoc.args + " --check-compatibility:api:released " + apiFile.String() +
|
|
|
|
flags.metalavaInclusionAnnotationsFlags + " --check-compatibility:removed:released " +
|
2018-12-27 01:06:37 +01:00
|
|
|
removedApiFile.String() + flags.metalavaMergeAnnoDirFlags + " "
|
2018-09-05 02:14:32 +02:00
|
|
|
|
|
|
|
d.transformCheckApi(ctx, apiFile, removedApiFile, metalavaCheckApiImplicits,
|
2019-01-25 01:32:44 +01:00
|
|
|
javaVersion, flags.bootClasspathArgs, flags.classpathArgs, flags.sourcepathArgs, opts, "last-apicheck",
|
2018-09-05 02:14:32 +02:00
|
|
|
`\n******************************\n`+
|
|
|
|
`You have tried to change the API from what has been previously released in\n`+
|
|
|
|
`an SDK. Please fix the errors listed above.\n`+
|
|
|
|
`******************************\n`,
|
|
|
|
d.checkLastReleasedApiTimestamp)
|
2018-05-05 03:49:16 +02:00
|
|
|
}
|
2018-09-17 23:32:21 +02:00
|
|
|
|
2018-10-22 16:55:04 +02:00
|
|
|
if String(d.properties.Check_nullability_warnings) != "" {
|
|
|
|
if d.nullabilityWarningsFile == nil {
|
|
|
|
ctx.PropertyErrorf("check_nullability_warnings",
|
|
|
|
"Cannot specify check_nullability_warnings unless validating nullability")
|
|
|
|
}
|
|
|
|
checkNullabilityWarnings := ctx.ExpandSource(String(d.properties.Check_nullability_warnings),
|
|
|
|
"check_nullability_warnings")
|
|
|
|
d.checkNullabilityWarningsTimestamp = android.PathForModuleOut(ctx, "check_nullability_warnings.timestamp")
|
|
|
|
msg := fmt.Sprintf(`\n******************************\n`+
|
|
|
|
`The warnings encountered during nullability annotation validation did\n`+
|
|
|
|
`not match the checked in file of expected warnings. The diffs are shown\n`+
|
|
|
|
`above. You have two options:\n`+
|
|
|
|
` 1. Resolve the differences by editing the nullability annotations.\n`+
|
|
|
|
` 2. Update the file of expected warnings by running:\n`+
|
|
|
|
` cp %s %s\n`+
|
|
|
|
` and submitting the updated file as part of your change.`,
|
|
|
|
d.nullabilityWarningsFile, checkNullabilityWarnings)
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: nullabilityWarningsCheck,
|
|
|
|
Description: "Nullability Warnings Check",
|
|
|
|
Output: d.checkNullabilityWarningsTimestamp,
|
|
|
|
Implicits: android.Paths{checkNullabilityWarnings, d.nullabilityWarningsFile},
|
|
|
|
Args: map[string]string{
|
|
|
|
"expected": checkNullabilityWarnings.String(),
|
|
|
|
"actual": d.nullabilityWarningsFile.String(),
|
|
|
|
"msg": msg,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-09-17 23:32:21 +02:00
|
|
|
if Bool(d.properties.Jdiff_enabled) && !ctx.Config().IsPdkBuild() {
|
|
|
|
|
2018-09-22 02:09:21 +02:00
|
|
|
// Please sync with android-api-council@ before making any changes for the name of jdiffDocZip below
|
|
|
|
// since there's cron job downstream that fetch this .zip file periodically.
|
|
|
|
// See b/116221385 for reference.
|
2018-09-17 23:32:21 +02:00
|
|
|
d.jdiffDocZip = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"jdiff-docs.zip")
|
|
|
|
d.jdiffStubsSrcJar = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"jdiff-stubs.srcjar")
|
|
|
|
|
|
|
|
var jdiffImplicitOutputs android.WritablePaths
|
|
|
|
jdiffImplicitOutputs = append(jdiffImplicitOutputs, d.jdiffDocZip)
|
|
|
|
|
|
|
|
jdiff := android.PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "framework", "jdiff.jar")
|
|
|
|
jdiffImplicits = append(jdiffImplicits, android.Paths{jdiff, d.apiXmlFile, d.lastReleasedApiXmlFile}...)
|
|
|
|
|
|
|
|
opts := " -encoding UTF-8 -source 1.8 -J-Xmx1600m -XDignore.symbol.file " +
|
|
|
|
"-doclet jdiff.JDiff -docletpath " + jdiff.String() + " -quiet " +
|
|
|
|
"-newapi " + strings.TrimSuffix(d.apiXmlFile.Base(), d.apiXmlFile.Ext()) +
|
|
|
|
" -newapidir " + filepath.Dir(d.apiXmlFile.String()) +
|
|
|
|
" -oldapi " + strings.TrimSuffix(d.lastReleasedApiXmlFile.Base(), d.lastReleasedApiXmlFile.Ext()) +
|
|
|
|
" -oldapidir " + filepath.Dir(d.lastReleasedApiXmlFile.String())
|
|
|
|
|
|
|
|
d.transformJdiff(ctx, jdiffImplicits, jdiffImplicitOutputs, flags.bootClasspathArgs, flags.classpathArgs,
|
|
|
|
flags.sourcepathArgs, opts)
|
|
|
|
}
|
2018-01-11 01:06:12 +01:00
|
|
|
}
|
Add droiddoc_template
We prefer not to use absolute paths in modules, but to reference modules
that have associated paths. This a few benefits:
* it's easier to move a module than to update all the references
* if the module doesn't exist, we treat it as a normal missing
dependency, not having to deal with the missing dependency in path.go
* implementing visibility(etc) in the future would be simpler if there
was a module attached to the reference, so we don't have to do various
path-based lookups to try and match things up.
So define a `droiddoc_template` module, which takes a path, and will run
the glob once in that module. All of the `droiddoc` modules can then
specify it through the `custom_template` property, which will pull the
necessary data.
Also fix that htmldirs should be references from the local path, the
htmldir2 argument never being specified, and complain if more than two
htmldirs are specified, or if the custom template isn't specified.
Test: m core-docs
Test: out/soong/build.ninja is nearly identical
- line numbers in comments
- adds directories to droiddoc template dependency lists, which
is more correct, since we need to rerun on added or removed
files too.
Change-Id: Iff630bddb3818b8eeed439de7e41fc7fbe7cdcb0
2018-02-26 23:33:31 +01:00
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
//
|
2018-08-02 00:00:28 +02:00
|
|
|
// Exported Droiddoc Directory
|
2018-08-01 21:48:00 +02:00
|
|
|
//
|
Add droiddoc_template
We prefer not to use absolute paths in modules, but to reference modules
that have associated paths. This a few benefits:
* it's easier to move a module than to update all the references
* if the module doesn't exist, we treat it as a normal missing
dependency, not having to deal with the missing dependency in path.go
* implementing visibility(etc) in the future would be simpler if there
was a module attached to the reference, so we don't have to do various
path-based lookups to try and match things up.
So define a `droiddoc_template` module, which takes a path, and will run
the glob once in that module. All of the `droiddoc` modules can then
specify it through the `custom_template` property, which will pull the
necessary data.
Also fix that htmldirs should be references from the local path, the
htmldir2 argument never being specified, and complain if more than two
htmldirs are specified, or if the custom template isn't specified.
Test: m core-docs
Test: out/soong/build.ninja is nearly identical
- line numbers in comments
- adds directories to droiddoc template dependency lists, which
is more correct, since we need to rerun on added or removed
files too.
Change-Id: Iff630bddb3818b8eeed439de7e41fc7fbe7cdcb0
2018-02-26 23:33:31 +01:00
|
|
|
var droiddocTemplateTag = dependencyTag{name: "droiddoc-template"}
|
2018-08-02 00:00:28 +02:00
|
|
|
var metalavaMergeAnnotationsDirTag = dependencyTag{name: "metalava-merge-annotations-dir"}
|
2018-09-19 19:16:26 +02:00
|
|
|
var metalavaMergeInclusionAnnotationsDirTag = dependencyTag{name: "metalava-merge-inclusion-annotations-dir"}
|
2018-08-22 19:22:08 +02:00
|
|
|
var metalavaAPILevelsAnnotationsDirTag = dependencyTag{name: "metalava-api-levels-annotations-dir"}
|
Add droiddoc_template
We prefer not to use absolute paths in modules, but to reference modules
that have associated paths. This a few benefits:
* it's easier to move a module than to update all the references
* if the module doesn't exist, we treat it as a normal missing
dependency, not having to deal with the missing dependency in path.go
* implementing visibility(etc) in the future would be simpler if there
was a module attached to the reference, so we don't have to do various
path-based lookups to try and match things up.
So define a `droiddoc_template` module, which takes a path, and will run
the glob once in that module. All of the `droiddoc` modules can then
specify it through the `custom_template` property, which will pull the
necessary data.
Also fix that htmldirs should be references from the local path, the
htmldir2 argument never being specified, and complain if more than two
htmldirs are specified, or if the custom template isn't specified.
Test: m core-docs
Test: out/soong/build.ninja is nearly identical
- line numbers in comments
- adds directories to droiddoc template dependency lists, which
is more correct, since we need to rerun on added or removed
files too.
Change-Id: Iff630bddb3818b8eeed439de7e41fc7fbe7cdcb0
2018-02-26 23:33:31 +01:00
|
|
|
|
2018-08-02 00:00:28 +02:00
|
|
|
type ExportedDroiddocDirProperties struct {
|
|
|
|
// path to the directory containing Droiddoc related files.
|
Add droiddoc_template
We prefer not to use absolute paths in modules, but to reference modules
that have associated paths. This a few benefits:
* it's easier to move a module than to update all the references
* if the module doesn't exist, we treat it as a normal missing
dependency, not having to deal with the missing dependency in path.go
* implementing visibility(etc) in the future would be simpler if there
was a module attached to the reference, so we don't have to do various
path-based lookups to try and match things up.
So define a `droiddoc_template` module, which takes a path, and will run
the glob once in that module. All of the `droiddoc` modules can then
specify it through the `custom_template` property, which will pull the
necessary data.
Also fix that htmldirs should be references from the local path, the
htmldir2 argument never being specified, and complain if more than two
htmldirs are specified, or if the custom template isn't specified.
Test: m core-docs
Test: out/soong/build.ninja is nearly identical
- line numbers in comments
- adds directories to droiddoc template dependency lists, which
is more correct, since we need to rerun on added or removed
files too.
Change-Id: Iff630bddb3818b8eeed439de7e41fc7fbe7cdcb0
2018-02-26 23:33:31 +01:00
|
|
|
Path *string
|
|
|
|
}
|
|
|
|
|
2018-08-02 00:00:28 +02:00
|
|
|
type ExportedDroiddocDir struct {
|
Add droiddoc_template
We prefer not to use absolute paths in modules, but to reference modules
that have associated paths. This a few benefits:
* it's easier to move a module than to update all the references
* if the module doesn't exist, we treat it as a normal missing
dependency, not having to deal with the missing dependency in path.go
* implementing visibility(etc) in the future would be simpler if there
was a module attached to the reference, so we don't have to do various
path-based lookups to try and match things up.
So define a `droiddoc_template` module, which takes a path, and will run
the glob once in that module. All of the `droiddoc` modules can then
specify it through the `custom_template` property, which will pull the
necessary data.
Also fix that htmldirs should be references from the local path, the
htmldir2 argument never being specified, and complain if more than two
htmldirs are specified, or if the custom template isn't specified.
Test: m core-docs
Test: out/soong/build.ninja is nearly identical
- line numbers in comments
- adds directories to droiddoc template dependency lists, which
is more correct, since we need to rerun on added or removed
files too.
Change-Id: Iff630bddb3818b8eeed439de7e41fc7fbe7cdcb0
2018-02-26 23:33:31 +01:00
|
|
|
android.ModuleBase
|
|
|
|
|
2018-08-02 00:00:28 +02:00
|
|
|
properties ExportedDroiddocDirProperties
|
Add droiddoc_template
We prefer not to use absolute paths in modules, but to reference modules
that have associated paths. This a few benefits:
* it's easier to move a module than to update all the references
* if the module doesn't exist, we treat it as a normal missing
dependency, not having to deal with the missing dependency in path.go
* implementing visibility(etc) in the future would be simpler if there
was a module attached to the reference, so we don't have to do various
path-based lookups to try and match things up.
So define a `droiddoc_template` module, which takes a path, and will run
the glob once in that module. All of the `droiddoc` modules can then
specify it through the `custom_template` property, which will pull the
necessary data.
Also fix that htmldirs should be references from the local path, the
htmldir2 argument never being specified, and complain if more than two
htmldirs are specified, or if the custom template isn't specified.
Test: m core-docs
Test: out/soong/build.ninja is nearly identical
- line numbers in comments
- adds directories to droiddoc template dependency lists, which
is more correct, since we need to rerun on added or removed
files too.
Change-Id: Iff630bddb3818b8eeed439de7e41fc7fbe7cdcb0
2018-02-26 23:33:31 +01:00
|
|
|
|
|
|
|
deps android.Paths
|
|
|
|
dir android.Path
|
|
|
|
}
|
|
|
|
|
2018-08-02 00:00:28 +02:00
|
|
|
func ExportedDroiddocDirFactory() android.Module {
|
|
|
|
module := &ExportedDroiddocDir{}
|
Add droiddoc_template
We prefer not to use absolute paths in modules, but to reference modules
that have associated paths. This a few benefits:
* it's easier to move a module than to update all the references
* if the module doesn't exist, we treat it as a normal missing
dependency, not having to deal with the missing dependency in path.go
* implementing visibility(etc) in the future would be simpler if there
was a module attached to the reference, so we don't have to do various
path-based lookups to try and match things up.
So define a `droiddoc_template` module, which takes a path, and will run
the glob once in that module. All of the `droiddoc` modules can then
specify it through the `custom_template` property, which will pull the
necessary data.
Also fix that htmldirs should be references from the local path, the
htmldir2 argument never being specified, and complain if more than two
htmldirs are specified, or if the custom template isn't specified.
Test: m core-docs
Test: out/soong/build.ninja is nearly identical
- line numbers in comments
- adds directories to droiddoc template dependency lists, which
is more correct, since we need to rerun on added or removed
files too.
Change-Id: Iff630bddb3818b8eeed439de7e41fc7fbe7cdcb0
2018-02-26 23:33:31 +01:00
|
|
|
module.AddProperties(&module.properties)
|
|
|
|
android.InitAndroidModule(module)
|
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
2018-08-02 00:00:28 +02:00
|
|
|
func (d *ExportedDroiddocDir) DepsMutator(android.BottomUpMutatorContext) {}
|
Add droiddoc_template
We prefer not to use absolute paths in modules, but to reference modules
that have associated paths. This a few benefits:
* it's easier to move a module than to update all the references
* if the module doesn't exist, we treat it as a normal missing
dependency, not having to deal with the missing dependency in path.go
* implementing visibility(etc) in the future would be simpler if there
was a module attached to the reference, so we don't have to do various
path-based lookups to try and match things up.
So define a `droiddoc_template` module, which takes a path, and will run
the glob once in that module. All of the `droiddoc` modules can then
specify it through the `custom_template` property, which will pull the
necessary data.
Also fix that htmldirs should be references from the local path, the
htmldir2 argument never being specified, and complain if more than two
htmldirs are specified, or if the custom template isn't specified.
Test: m core-docs
Test: out/soong/build.ninja is nearly identical
- line numbers in comments
- adds directories to droiddoc template dependency lists, which
is more correct, since we need to rerun on added or removed
files too.
Change-Id: Iff630bddb3818b8eeed439de7e41fc7fbe7cdcb0
2018-02-26 23:33:31 +01:00
|
|
|
|
2018-08-02 00:00:28 +02:00
|
|
|
func (d *ExportedDroiddocDir) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
2019-03-05 21:46:40 +01:00
|
|
|
path := String(d.properties.Path)
|
|
|
|
d.dir = android.PathForModuleSrc(ctx, path)
|
2019-03-06 07:25:09 +01:00
|
|
|
d.deps = android.PathsForModuleSrc(ctx, []string{filepath.Join(path, "**/*")})
|
Add droiddoc_template
We prefer not to use absolute paths in modules, but to reference modules
that have associated paths. This a few benefits:
* it's easier to move a module than to update all the references
* if the module doesn't exist, we treat it as a normal missing
dependency, not having to deal with the missing dependency in path.go
* implementing visibility(etc) in the future would be simpler if there
was a module attached to the reference, so we don't have to do various
path-based lookups to try and match things up.
So define a `droiddoc_template` module, which takes a path, and will run
the glob once in that module. All of the `droiddoc` modules can then
specify it through the `custom_template` property, which will pull the
necessary data.
Also fix that htmldirs should be references from the local path, the
htmldir2 argument never being specified, and complain if more than two
htmldirs are specified, or if the custom template isn't specified.
Test: m core-docs
Test: out/soong/build.ninja is nearly identical
- line numbers in comments
- adds directories to droiddoc template dependency lists, which
is more correct, since we need to rerun on added or removed
files too.
Change-Id: Iff630bddb3818b8eeed439de7e41fc7fbe7cdcb0
2018-02-26 23:33:31 +01:00
|
|
|
}
|
2018-02-23 20:18:47 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Defaults
|
|
|
|
//
|
|
|
|
type DocDefaults struct {
|
|
|
|
android.ModuleBase
|
|
|
|
android.DefaultsModuleBase
|
|
|
|
}
|
|
|
|
|
|
|
|
func DocDefaultsFactory() android.Module {
|
|
|
|
module := &DocDefaults{}
|
|
|
|
|
|
|
|
module.AddProperties(
|
|
|
|
&JavadocProperties{},
|
|
|
|
&DroiddocProperties{},
|
|
|
|
)
|
|
|
|
|
|
|
|
android.InitDefaultsModule(module)
|
|
|
|
|
|
|
|
return module
|
|
|
|
}
|
2018-09-05 02:14:32 +02:00
|
|
|
|
|
|
|
func StubsDefaultsFactory() android.Module {
|
|
|
|
module := &DocDefaults{}
|
|
|
|
|
|
|
|
module.AddProperties(
|
|
|
|
&JavadocProperties{},
|
|
|
|
&DroidstubsProperties{},
|
|
|
|
)
|
|
|
|
|
|
|
|
android.InitDefaultsModule(module)
|
|
|
|
|
|
|
|
return module
|
|
|
|
}
|