2018-01-11 08:06:12 +08: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-24 03:18:47 +08:00
|
|
|
"path/filepath"
|
2018-06-05 02:28:01 +08:00
|
|
|
"runtime"
|
2018-01-11 08:06:12 +08: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 07:24:10 +08:00
|
|
|
`${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` +
|
2018-06-20 06:15:38 +08:00
|
|
|
`${config.JavadocCmd} -encoding UTF-8 @$out.rsp @$srcJarDir/list ` +
|
2018-01-11 08:06:12 +08:00
|
|
|
`$opts $bootclasspathArgs $classpathArgs -sourcepath $sourcepath ` +
|
|
|
|
`-d $outDir -quiet && ` +
|
|
|
|
`${config.SoongZipCmd} -write_if_changed -d -o $docZip -C $outDir -D $outDir && ` +
|
2018-07-12 06:16:55 +08:00
|
|
|
`${config.SoongZipCmd} -write_if_changed -jar -o $out -C $stubsDir -D $stubsDir $postDoclavaCmds`,
|
2018-01-11 08:06:12 +08:00
|
|
|
CommandDeps: []string{
|
2018-03-16 07:24:10 +08:00
|
|
|
"${config.ZipSyncCmd}",
|
2018-01-11 08:06:12 +08:00
|
|
|
"${config.JavadocCmd}",
|
|
|
|
"${config.SoongZipCmd}",
|
|
|
|
},
|
|
|
|
Rspfile: "$out.rsp",
|
|
|
|
RspfileContent: "$in",
|
|
|
|
Restat: true,
|
|
|
|
},
|
2018-06-20 06:15:38 +08:00
|
|
|
"outDir", "srcJarDir", "stubsDir", "srcJars", "opts",
|
2018-07-12 06:16:55 +08:00
|
|
|
"bootclasspathArgs", "classpathArgs", "sourcepath", "docZip", "postDoclavaCmds")
|
2018-05-05 09:49:16 +08:00
|
|
|
|
|
|
|
apiCheck = pctx.AndroidStaticRule("apiCheck",
|
|
|
|
blueprint.RuleParams{
|
|
|
|
Command: `( ${config.ApiCheckCmd} -JXmx1024m -J"classpath $classpath" $opts ` +
|
|
|
|
`$apiFile $apiFileToCheck $removedApiFile $removedApiFileToCheck ` +
|
2018-05-12 21:21:20 +08:00
|
|
|
`&& touch $out ) || (echo -e "$msg" ; exit 38)`,
|
2018-05-05 09:49:16 +08:00
|
|
|
CommandDeps: []string{
|
|
|
|
"${config.ApiCheckCmd}",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"classpath", "opts", "apiFile", "apiFileToCheck", "removedApiFile", "removedApiFileToCheck", "msg")
|
|
|
|
|
|
|
|
updateApi = pctx.AndroidStaticRule("updateApi",
|
|
|
|
blueprint.RuleParams{
|
|
|
|
Command: `( ( cp -f $apiFileToCheck $apiFile && cp -f $removedApiFileToCheck $removedApiFile ) ` +
|
|
|
|
`&& touch $out ) || (echo failed to update public API ; exit 38)`,
|
|
|
|
},
|
|
|
|
"apiFile", "apiFileToCheck", "removedApiFile", "removedApiFileToCheck")
|
2018-04-20 09:03:39 +08:00
|
|
|
|
|
|
|
metalava = pctx.AndroidStaticRule("metalava",
|
|
|
|
blueprint.RuleParams{
|
2018-08-09 07:32:21 +08:00
|
|
|
Command: `rm -rf "$outDir" "$srcJarDir" "$stubsDir" "$docStubsDir" && ` +
|
|
|
|
`mkdir -p "$outDir" "$srcJarDir" "$stubsDir" "$docStubsDir" && ` +
|
2018-04-20 09:03:39 +08:00
|
|
|
`${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` +
|
2018-04-18 08:38:36 +08:00
|
|
|
`${config.JavaCmd} -jar ${config.MetalavaJar} -encoding UTF-8 -source $javaVersion @$out.rsp @$srcJarDir/list ` +
|
2018-06-14 08:42:48 +08:00
|
|
|
`$bootclasspathArgs $classpathArgs -sourcepath $sourcepath --no-banner --color --quiet ` +
|
|
|
|
`--stubs $stubsDir $opts && ` +
|
2018-04-20 09:03:39 +08:00
|
|
|
`${config.SoongZipCmd} -write_if_changed -d -o $docZip -C $outDir -D $outDir && ` +
|
|
|
|
`${config.SoongZipCmd} -write_if_changed -jar -o $out -C $stubsDir -D $stubsDir`,
|
|
|
|
CommandDeps: []string{
|
|
|
|
"${config.ZipSyncCmd}",
|
|
|
|
"${config.JavaCmd}",
|
|
|
|
"${config.MetalavaJar}",
|
|
|
|
"${config.JavadocCmd}",
|
|
|
|
"${config.SoongZipCmd}",
|
|
|
|
},
|
|
|
|
Rspfile: "$out.rsp",
|
|
|
|
RspfileContent: "$in",
|
|
|
|
Restat: true,
|
|
|
|
},
|
2018-08-09 07:32:21 +08:00
|
|
|
"outDir", "srcJarDir", "stubsDir", "docStubsDir", "srcJars", "javaVersion", "bootclasspathArgs",
|
2018-04-18 08:38:36 +08:00
|
|
|
"classpathArgs", "sourcepath", "opts", "docZip")
|
2018-08-25 01:32:54 +08:00
|
|
|
|
|
|
|
metalavaApiCheck = pctx.AndroidStaticRule("metalavaApiCheck",
|
|
|
|
blueprint.RuleParams{
|
|
|
|
Command: `( rm -rf "$srcJarDir" && mkdir -p "$srcJarDir" && ` +
|
|
|
|
`${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` +
|
|
|
|
`${config.JavaCmd} -jar ${config.MetalavaJar} -encoding UTF-8 -source $javaVersion @$out.rsp @$srcJarDir/list ` +
|
|
|
|
`$bootclasspathArgs $classpathArgs -sourcepath $sourcepath --no-banner --color --quiet ` +
|
|
|
|
`$opts && touch $out ) || ` +
|
|
|
|
`( echo -e "$msg" ; exit 38 )`,
|
|
|
|
CommandDeps: []string{
|
|
|
|
"${config.ZipSyncCmd}",
|
|
|
|
"${config.JavaCmd}",
|
|
|
|
"${config.MetalavaJar}",
|
|
|
|
},
|
|
|
|
Rspfile: "$out.rsp",
|
|
|
|
RspfileContent: "$in",
|
|
|
|
},
|
|
|
|
"srcJarDir", "srcJars", "javaVersion", "bootclasspathArgs", "classpathArgs", "sourcepath", "opts", "msg")
|
2018-01-11 08:06:12 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2018-02-24 03:18:47 +08:00
|
|
|
android.RegisterModuleType("doc_defaults", DocDefaultsFactory)
|
|
|
|
|
2018-01-11 08:06:12 +08:00
|
|
|
android.RegisterModuleType("droiddoc", DroiddocFactory)
|
|
|
|
android.RegisterModuleType("droiddoc_host", DroiddocHostFactory)
|
2018-08-02 06:00:28 +08:00
|
|
|
android.RegisterModuleType("droiddoc_exported_dir", ExportedDroiddocDirFactory)
|
2018-01-11 08:06:12 +08:00
|
|
|
android.RegisterModuleType("javadoc", JavadocFactory)
|
|
|
|
android.RegisterModuleType("javadoc_host", JavadocHostFactory)
|
|
|
|
}
|
|
|
|
|
2018-06-21 06:19:39 +08:00
|
|
|
var (
|
|
|
|
srcsLibTag = dependencyTag{name: "sources from javalib"}
|
|
|
|
)
|
|
|
|
|
2018-01-11 08:06:12 +08:00
|
|
|
type JavadocProperties struct {
|
|
|
|
// list of source files used to compile the Java module. May be .java, .logtags, .proto,
|
|
|
|
// or .aidl files.
|
|
|
|
Srcs []string `android:"arch_variant"`
|
|
|
|
|
|
|
|
// 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-24 03:18:47 +08:00
|
|
|
Local_sourcepaths []string
|
2018-01-11 08:06:12 +08: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.
|
|
|
|
Exclude_srcs []string `android:"arch_variant"`
|
|
|
|
|
2018-02-24 03:18:47 +08:00
|
|
|
// list of java libraries that will be in the classpath.
|
2018-01-11 08:06:12 +08:00
|
|
|
Libs []string `android:"arch_variant"`
|
|
|
|
|
2018-03-07 04:59:27 +08:00
|
|
|
// don't build against the framework libraries (legacy-test, core-junit,
|
|
|
|
// ext, and framework for device targets)
|
|
|
|
No_framework_libs *bool
|
|
|
|
|
2018-02-24 03:18:47 +08: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 08:06:12 +08:00
|
|
|
// If set to false, don't allow this module(-docs.zip) to be exported. Defaults to true.
|
2018-02-24 03:18:47 +08:00
|
|
|
Installable *bool
|
2018-01-11 08:06:12 +08:00
|
|
|
|
|
|
|
// if not blank, set to the version of the sdk to compile against
|
|
|
|
Sdk_version *string `android:"arch_variant"`
|
2018-05-23 17:42:04 +08: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 08:38:36 +08:00
|
|
|
|
|
|
|
// If not blank, set the java version passed to javadoc as -source
|
|
|
|
Java_version *string
|
2018-01-11 08:06:12 +08:00
|
|
|
}
|
|
|
|
|
2018-05-05 09:49:16 +08:00
|
|
|
type ApiToCheck struct {
|
2018-05-12 21:21:20 +08: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).
|
2018-05-05 09:49:16 +08:00
|
|
|
Api_file *string
|
|
|
|
|
2018-05-12 21:21:20 +08: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).
|
2018-05-05 09:49:16 +08:00
|
|
|
Removed_api_file *string
|
|
|
|
|
2018-05-12 21:21:20 +08:00
|
|
|
// Arguments to the apicheck tool.
|
2018-05-05 09:49:16 +08:00
|
|
|
Args *string
|
|
|
|
}
|
|
|
|
|
2018-01-11 08:06:12 +08:00
|
|
|
type DroiddocProperties struct {
|
|
|
|
// directory relative to top of the source tree that contains doc templates files.
|
2018-02-24 03:18:47 +08:00
|
|
|
Custom_template *string
|
2018-01-11 08:06:12 +08:00
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
// directories under current module source which contains html/jd files.
|
2018-02-24 03:18:47 +08:00
|
|
|
Html_dirs []string
|
2018-01-11 08:06:12 +08:00
|
|
|
|
|
|
|
// set a value in the Clearsilver hdf namespace.
|
2018-02-24 03:18:47 +08:00
|
|
|
Hdf []string
|
2018-01-11 08:06:12 +08:00
|
|
|
|
|
|
|
// proofread file contains all of the text content of the javadocs concatenated into one file,
|
|
|
|
// suitable for spell-checking and other goodness.
|
2018-02-24 03:18:47 +08:00
|
|
|
Proofread_file *string
|
2018-01-11 08:06:12 +08:00
|
|
|
|
|
|
|
// a todo file lists the program elements that are missing documentation.
|
|
|
|
// At some point, this might be improved to show more warnings.
|
2018-02-24 03:18:47 +08:00
|
|
|
Todo_file *string
|
|
|
|
|
|
|
|
// directory under current module source that provide additional resources (images).
|
|
|
|
Resourcesdir *string
|
|
|
|
|
|
|
|
// resources output directory under out/soong/.intermediates.
|
|
|
|
Resourcesoutdir *string
|
2018-01-11 08:06:12 +08:00
|
|
|
|
|
|
|
// local files that are used within user customized droiddoc options.
|
2018-02-24 03:18:47 +08:00
|
|
|
Arg_files []string
|
2018-01-11 08:06:12 +08:00
|
|
|
|
|
|
|
// user customized droiddoc args.
|
|
|
|
// Available variables for substitution:
|
|
|
|
//
|
|
|
|
// $(location <label>): the path to the arg_files with name <label>
|
2018-02-24 03:18:47 +08:00
|
|
|
Args *string
|
2018-01-11 08:06:12 +08:00
|
|
|
|
|
|
|
// names of the output files used in args that will be generated
|
2018-02-24 03:18:47 +08:00
|
|
|
Out []string
|
2018-01-11 08:06:12 +08:00
|
|
|
|
2018-07-12 06:16:55 +08: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.
|
|
|
|
Static_doc_index_redirect *string
|
|
|
|
|
|
|
|
// source.properties under current module will be copied to docs out dir, if not null.
|
|
|
|
Static_doc_properties *string
|
|
|
|
|
2018-01-11 08:06:12 +08: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.
|
2018-02-24 03:18:47 +08:00
|
|
|
Knowntags []string
|
2018-03-14 07:17:01 +08: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 20:56:46 +08:00
|
|
|
// the generated public Dex API filename by Doclava.
|
|
|
|
Dex_api_filename *string
|
|
|
|
|
2018-03-14 07:17:01 +08: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 23:23:29 +08:00
|
|
|
// the generated removed Dex API filename by Doclava.
|
|
|
|
Removed_dex_api_filename *string
|
|
|
|
|
2018-06-22 22:28:11 +08: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 07:17:01 +08:00
|
|
|
// the generated exact API filename by Doclava.
|
|
|
|
Exact_api_filename *string
|
2018-04-13 07:55:56 +08:00
|
|
|
|
2018-08-15 11:41:04 +08:00
|
|
|
// the generated proguard filename by Doclava.
|
|
|
|
Proguard_filename *string
|
|
|
|
|
2018-04-13 07:55:56 +08:00
|
|
|
// if set to false, don't allow droiddoc to generate stubs source files. Defaults to true.
|
|
|
|
Create_stubs *bool
|
2018-05-05 09:49:16 +08:00
|
|
|
|
|
|
|
Check_api struct {
|
|
|
|
Last_released ApiToCheck
|
|
|
|
|
|
|
|
Current ApiToCheck
|
|
|
|
}
|
2018-04-20 09:03:39 +08:00
|
|
|
|
|
|
|
// if set to true, create stubs through Metalava instead of Doclava. Javadoc/Doclava is
|
|
|
|
// currently still used for documentation generation, and will be replaced by Dokka soon.
|
|
|
|
Metalava_enabled *bool
|
|
|
|
|
|
|
|
// user can specify the version of previous released API file in order to do compatibility check.
|
|
|
|
Metalava_previous_api *string
|
|
|
|
|
|
|
|
// is set to true, Metalava will allow framework SDK to contain annotations.
|
|
|
|
Metalava_annotations_enabled *bool
|
|
|
|
|
2018-07-20 00:56:49 +08:00
|
|
|
// a list of top-level directories containing files to merge annotations from.
|
|
|
|
Metalava_merge_annotations_dirs []string
|
2018-08-10 06:33:27 +08:00
|
|
|
|
|
|
|
// if set to true, generate docs through Dokka instead of Doclava. Valid only when
|
|
|
|
// metalava_enabled is set to true.
|
|
|
|
Dokka_enabled *bool
|
2018-01-11 08:06:12 +08:00
|
|
|
}
|
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
//
|
|
|
|
// Common flags passed down to build rule
|
|
|
|
//
|
|
|
|
type droiddocBuilderFlags struct {
|
2018-08-10 06:33:27 +08:00
|
|
|
args string
|
|
|
|
bootClasspathArgs string
|
|
|
|
classpathArgs string
|
|
|
|
dokkaClasspathArgs string
|
|
|
|
aidlFlags string
|
2018-08-02 03:48:00 +08:00
|
|
|
|
|
|
|
doclavaStubsFlags string
|
2018-08-10 06:33:27 +08:00
|
|
|
doclavaDocsFlags string
|
2018-08-02 03:48:00 +08:00
|
|
|
postDoclavaCmds string
|
|
|
|
|
2018-08-25 01:32:54 +08:00
|
|
|
metalavaStubsFlags string
|
|
|
|
metalavaAnnotationsFlags string
|
|
|
|
metalavaJavadocFlags string
|
2018-08-02 03:48:00 +08:00
|
|
|
|
2018-08-10 06:33:27 +08:00
|
|
|
metalavaDokkaFlags string
|
2018-08-02 03:48:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func InitDroiddocModule(module android.DefaultableModule, hod android.HostOrDeviceSupported) {
|
|
|
|
android.InitAndroidArchModule(module, hod, android.MultilibCommon)
|
|
|
|
android.InitDefaultableModule(module)
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Javadoc
|
|
|
|
//
|
2018-01-11 08:06:12 +08:00
|
|
|
type Javadoc struct {
|
|
|
|
android.ModuleBase
|
|
|
|
android.DefaultableModuleBase
|
|
|
|
|
|
|
|
properties JavadocProperties
|
|
|
|
|
|
|
|
srcJars android.Paths
|
|
|
|
srcFiles android.Paths
|
|
|
|
sourcepaths android.Paths
|
|
|
|
|
2018-03-09 09:26:16 +08:00
|
|
|
docZip android.WritablePath
|
|
|
|
stubsSrcJar android.WritablePath
|
2018-01-11 08:06:12 +08:00
|
|
|
}
|
|
|
|
|
2018-02-24 03:18:47 +08:00
|
|
|
func (j *Javadoc) Srcs() android.Paths {
|
|
|
|
return android.Paths{j.stubsSrcJar}
|
|
|
|
}
|
|
|
|
|
2018-01-11 08:06:12 +08: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
|
|
|
|
}
|
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
var _ android.SourceFileProducer = (*Javadoc)(nil)
|
2018-01-11 08:06:12 +08:00
|
|
|
|
2018-06-26 06:48:06 +08:00
|
|
|
func (j *Javadoc) sdkVersion() string {
|
|
|
|
return String(j.properties.Sdk_version)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (j *Javadoc) minSdkVersion() string {
|
|
|
|
return j.sdkVersion()
|
|
|
|
}
|
|
|
|
|
2018-01-11 08:06:12 +08:00
|
|
|
func (j *Javadoc) addDeps(ctx android.BottomUpMutatorContext) {
|
|
|
|
if ctx.Device() {
|
2018-06-26 06:48:06 +08:00
|
|
|
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
2018-01-11 08:06:12 +08:00
|
|
|
if sdkDep.useDefaultLibs {
|
2018-08-30 05:10:52 +08:00
|
|
|
ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...)
|
2018-04-18 08:38:36 +08:00
|
|
|
if ctx.Config().TargetOpenJDK9() {
|
2018-08-30 05:10:52 +08:00
|
|
|
ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules)
|
2018-04-18 08:38:36 +08:00
|
|
|
}
|
2018-03-22 08:56:39 +08:00
|
|
|
if !Bool(j.properties.No_framework_libs) {
|
2018-08-30 05:10:52 +08:00
|
|
|
ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...)
|
2018-03-07 04:59:27 +08:00
|
|
|
}
|
2018-01-11 08:06:12 +08:00
|
|
|
} else if sdkDep.useModule {
|
2018-04-18 08:38:36 +08:00
|
|
|
if ctx.Config().TargetOpenJDK9() {
|
2018-08-30 05:10:52 +08:00
|
|
|
ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules)
|
2018-04-18 08:38:36 +08:00
|
|
|
}
|
2018-08-30 05:10:52 +08:00
|
|
|
ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.modules...)
|
2018-01-11 08:06:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-30 05:10:52 +08:00
|
|
|
ctx.AddVariationDependencies(nil, libTag, j.properties.Libs...)
|
2018-06-21 06:19:39 +08:00
|
|
|
if j.properties.Srcs_lib != nil {
|
2018-08-30 05:10:52 +08:00
|
|
|
ctx.AddVariationDependencies(nil, srcsLibTag, *j.properties.Srcs_lib)
|
2018-06-21 06:19:39 +08:00
|
|
|
}
|
2018-01-11 08:06:12 +08:00
|
|
|
|
|
|
|
android.ExtractSourcesDeps(ctx, j.properties.Srcs)
|
|
|
|
|
|
|
|
// exclude_srcs may contain filegroup or genrule.
|
|
|
|
android.ExtractSourcesDeps(ctx, j.properties.Exclude_srcs)
|
|
|
|
}
|
|
|
|
|
2018-02-24 03:18:47 +08: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 20:41:26 +08:00
|
|
|
// convert foo.bar.baz to foo/bar/baz
|
|
|
|
pkgAsPath := filepath.Join(strings.Split(pkg, ".")...)
|
|
|
|
prefix := filepath.Join(dir, pkgAsPath)
|
2018-02-24 03:18:47 +08:00
|
|
|
if _, found := whitelistPathPrefixes[prefix]; !found {
|
|
|
|
whitelistPathPrefixes[prefix] = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
func (j *Javadoc) collectAidlFlags(ctx android.ModuleContext, deps deps) droiddocBuilderFlags {
|
|
|
|
var flags droiddocBuilderFlags
|
2018-05-23 17:42:04 +08:00
|
|
|
|
|
|
|
// aidl flags.
|
|
|
|
aidlFlags := j.aidlFlags(ctx, deps.aidlPreprocess, deps.aidlIncludeDirs)
|
|
|
|
if len(aidlFlags) > 0 {
|
|
|
|
// optimization.
|
|
|
|
ctx.Variable(pctx, "aidlFlags", strings.Join(aidlFlags, " "))
|
|
|
|
flags.aidlFlags = "$aidlFlags"
|
|
|
|
}
|
|
|
|
|
|
|
|
return flags
|
|
|
|
}
|
|
|
|
|
|
|
|
func (j *Javadoc) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath,
|
|
|
|
aidlIncludeDirs android.Paths) []string {
|
|
|
|
|
|
|
|
aidlIncludes := android.PathsForModuleSrc(ctx, j.properties.Aidl.Local_include_dirs)
|
|
|
|
aidlIncludes = append(aidlIncludes, android.PathsForSource(ctx, j.properties.Aidl.Include_dirs)...)
|
|
|
|
|
|
|
|
var flags []string
|
|
|
|
if aidlPreprocess.Valid() {
|
|
|
|
flags = append(flags, "-p"+aidlPreprocess.String())
|
|
|
|
} 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())
|
|
|
|
}
|
|
|
|
|
|
|
|
return flags
|
|
|
|
}
|
|
|
|
|
|
|
|
func (j *Javadoc) genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
2018-08-02 03:48:00 +08:00
|
|
|
flags droiddocBuilderFlags) android.Paths {
|
2018-05-23 17:42:04 +08:00
|
|
|
|
|
|
|
outSrcFiles := make(android.Paths, 0, len(srcFiles))
|
|
|
|
|
|
|
|
for _, srcFile := range srcFiles {
|
|
|
|
switch srcFile.Ext() {
|
|
|
|
case ".aidl":
|
|
|
|
javaFile := genAidl(ctx, srcFile, flags.aidlFlags)
|
|
|
|
outSrcFiles = append(outSrcFiles, javaFile)
|
|
|
|
default:
|
|
|
|
outSrcFiles = append(outSrcFiles, srcFile)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return outSrcFiles
|
|
|
|
}
|
|
|
|
|
2018-01-11 08:06:12 +08:00
|
|
|
func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
|
|
|
|
var deps deps
|
|
|
|
|
2018-06-26 06:48:06 +08:00
|
|
|
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
2018-01-11 08:06:12 +08:00
|
|
|
if sdkDep.invalidVersion {
|
2018-05-30 05:44:55 +08:00
|
|
|
ctx.AddMissingDependencies(sdkDep.modules)
|
2018-01-11 08:06:12 +08:00
|
|
|
} else if sdkDep.useFiles {
|
2018-05-30 05:44:55 +08:00
|
|
|
deps.bootClasspath = append(deps.bootClasspath, sdkDep.jars...)
|
2018-01-11 08:06:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ctx.VisitDirectDeps(func(module android.Module) {
|
|
|
|
otherName := ctx.OtherModuleName(module)
|
|
|
|
tag := ctx.OtherModuleDependencyTag(module)
|
|
|
|
|
2018-05-24 01:59:18 +08:00
|
|
|
switch tag {
|
|
|
|
case bootClasspathTag:
|
|
|
|
if dep, ok := module.(Dependency); ok {
|
2018-01-11 08:06:12 +08:00
|
|
|
deps.bootClasspath = append(deps.bootClasspath, dep.ImplementationJars()...)
|
2018-05-24 01:59:18 +08:00
|
|
|
} else {
|
|
|
|
panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
|
|
|
|
}
|
|
|
|
case libTag:
|
|
|
|
switch dep := module.(type) {
|
|
|
|
case Dependency:
|
2018-01-11 08:06:12 +08:00
|
|
|
deps.classpath = append(deps.classpath, dep.ImplementationJars()...)
|
2018-05-24 01:59:18 +08:00
|
|
|
case SdkLibraryDependency:
|
2018-06-26 06:48:06 +08:00
|
|
|
sdkVersion := j.sdkVersion()
|
2018-04-10 12:07:10 +08:00
|
|
|
linkType := javaSdk
|
|
|
|
if strings.HasPrefix(sdkVersion, "system_") || strings.HasPrefix(sdkVersion, "test_") {
|
|
|
|
linkType = javaSystem
|
|
|
|
} else if sdkVersion == "" {
|
|
|
|
linkType = javaPlatform
|
|
|
|
}
|
2018-07-13 15:16:44 +08:00
|
|
|
deps.classpath = append(deps.classpath, dep.ImplementationJars(linkType)...)
|
2018-05-24 01:59:18 +08:00
|
|
|
case android.SourceFileProducer:
|
2018-01-11 08:06:12 +08:00
|
|
|
checkProducesJars(ctx, dep)
|
|
|
|
deps.classpath = append(deps.classpath, dep.Srcs()...)
|
|
|
|
default:
|
|
|
|
ctx.ModuleErrorf("depends on non-java module %q", otherName)
|
|
|
|
}
|
2018-06-21 06:19:39 +08: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.
|
|
|
|
for k, _ := range whitelistPathPrefixes {
|
|
|
|
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 08:38:36 +08: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 08:06:12 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
// do not pass exclude_srcs directly when expanding srcFiles since exclude_srcs
|
|
|
|
// may contain filegroup or genrule.
|
|
|
|
srcFiles := ctx.ExpandSources(j.properties.Srcs, j.properties.Exclude_srcs)
|
2018-08-02 03:48:00 +08:00
|
|
|
flags := j.collectAidlFlags(ctx, deps)
|
2018-05-23 17:42:04 +08:00
|
|
|
srcFiles = j.genSources(ctx, srcFiles, flags)
|
2018-01-11 08:06:12 +08:00
|
|
|
|
|
|
|
// srcs may depend on some genrule output.
|
|
|
|
j.srcJars = srcFiles.FilterByExt(".srcjar")
|
2018-02-24 03:18:47 +08:00
|
|
|
j.srcJars = append(j.srcJars, deps.srcJars...)
|
|
|
|
|
2018-01-11 08:06:12 +08:00
|
|
|
j.srcFiles = srcFiles.FilterOutByExt(".srcjar")
|
2018-02-24 03:18:47 +08:00
|
|
|
j.srcFiles = append(j.srcFiles, deps.srcs...)
|
2018-01-11 08:06:12 +08:00
|
|
|
|
|
|
|
j.docZip = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"docs.zip")
|
2018-03-09 09:26:16 +08:00
|
|
|
j.stubsSrcJar = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"stubs.srcjar")
|
2018-01-11 08:06:12 +08:00
|
|
|
|
|
|
|
if j.properties.Local_sourcepaths == nil {
|
|
|
|
j.properties.Local_sourcepaths = append(j.properties.Local_sourcepaths, ".")
|
|
|
|
}
|
|
|
|
j.sourcepaths = android.PathsForModuleSrc(ctx, j.properties.Local_sourcepaths)
|
|
|
|
|
|
|
|
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...)
|
|
|
|
|
|
|
|
var bootClasspathArgs, classpathArgs string
|
2018-04-18 08:38:36 +08:00
|
|
|
|
2018-06-26 06:48:06 +08:00
|
|
|
javaVersion := getJavaVersion(ctx, String(j.properties.Java_version), sdkContext(j))
|
2018-06-20 13:49:39 +08:00
|
|
|
if len(deps.bootClasspath) > 0 {
|
|
|
|
var systemModules classpath
|
|
|
|
if deps.systemModules != nil {
|
|
|
|
systemModules = append(systemModules, deps.systemModules)
|
2018-01-11 08:06:12 +08:00
|
|
|
}
|
2018-06-20 13:49:39 +08:00
|
|
|
bootClasspathArgs = systemModules.FormJavaSystemModulesPath("--system ", ctx.Device())
|
|
|
|
bootClasspathArgs = bootClasspathArgs + " --patch-module java.base=."
|
2018-01-11 08:06:12 +08:00
|
|
|
}
|
|
|
|
if len(deps.classpath.Strings()) > 0 {
|
|
|
|
classpathArgs = "-classpath " + strings.Join(deps.classpath.Strings(), ":")
|
|
|
|
}
|
|
|
|
|
|
|
|
implicits = append(implicits, j.srcJars...)
|
|
|
|
|
2018-06-20 06:15:38 +08:00
|
|
|
opts := "-source " + javaVersion + " -J-Xmx1024m -XDignore.symbol.file -Xdoclint:none"
|
2018-01-11 08:06:12 +08:00
|
|
|
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: javadoc,
|
|
|
|
Description: "Javadoc",
|
2018-03-09 09:26:16 +08:00
|
|
|
Output: j.stubsSrcJar,
|
2018-01-11 08:06:12 +08:00
|
|
|
ImplicitOutput: j.docZip,
|
|
|
|
Inputs: j.srcFiles,
|
|
|
|
Implicits: implicits,
|
|
|
|
Args: map[string]string{
|
2018-08-09 07:32:21 +08:00
|
|
|
"outDir": android.PathForModuleOut(ctx, "out").String(),
|
|
|
|
"srcJarDir": android.PathForModuleOut(ctx, "srcjars").String(),
|
|
|
|
"stubsDir": android.PathForModuleOut(ctx, "stubsDir").String(),
|
2018-01-11 08:06:12 +08:00
|
|
|
"srcJars": strings.Join(j.srcJars.Strings(), " "),
|
|
|
|
"opts": opts,
|
2018-04-13 07:55:56 +08:00
|
|
|
"bootclasspathArgs": bootClasspathArgs,
|
2018-01-11 08:06:12 +08:00
|
|
|
"classpathArgs": classpathArgs,
|
|
|
|
"sourcepath": strings.Join(j.sourcepaths.Strings(), ":"),
|
|
|
|
"docZip": j.docZip.String(),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-08-02 03:48:00 +08: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 11:41:04 +08:00
|
|
|
proguardFile android.WritablePath
|
2018-08-02 03:48:00 +08:00
|
|
|
|
|
|
|
checkCurrentApiTimestamp android.WritablePath
|
|
|
|
updateCurrentApiTimestamp android.WritablePath
|
|
|
|
checkLastReleasedApiTimestamp android.WritablePath
|
|
|
|
|
|
|
|
annotationsZip android.WritablePath
|
|
|
|
|
|
|
|
apiFilePath android.Path
|
|
|
|
}
|
|
|
|
|
|
|
|
type ApiFilePath interface {
|
|
|
|
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-05-05 09:49:16 +08:00
|
|
|
func (d *Droiddoc) checkCurrentApi() bool {
|
|
|
|
if String(d.properties.Check_api.Current.Api_file) != "" &&
|
|
|
|
String(d.properties.Check_api.Current.Removed_api_file) != "" {
|
|
|
|
return true
|
|
|
|
} else if String(d.properties.Check_api.Current.Api_file) != "" {
|
|
|
|
panic("check_api.current.removed_api_file: has to be non empty!")
|
|
|
|
} else if String(d.properties.Check_api.Current.Removed_api_file) != "" {
|
|
|
|
panic("check_api.current.api_file: has to be non empty!")
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Droiddoc) checkLastReleasedApi() bool {
|
|
|
|
if String(d.properties.Check_api.Last_released.Api_file) != "" &&
|
|
|
|
String(d.properties.Check_api.Last_released.Removed_api_file) != "" {
|
|
|
|
return true
|
|
|
|
} else if String(d.properties.Check_api.Last_released.Api_file) != "" {
|
|
|
|
panic("check_api.last_released.removed_api_file: has to be non empty!")
|
|
|
|
} else if String(d.properties.Check_api.Last_released.Removed_api_file) != "" {
|
|
|
|
panic("check_api.last_released.api_file: has to be non empty!")
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2018-01-11 08:06:12 +08:00
|
|
|
func (d *Droiddoc) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|
|
|
d.Javadoc.addDeps(ctx)
|
|
|
|
|
2018-04-20 09:03:39 +08: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-27 06:33:31 +08:00
|
|
|
ctx.AddDependency(ctx.Module(), droiddocTemplateTag, String(d.properties.Custom_template))
|
|
|
|
}
|
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
// arg_files may contains filegroup or genrule.
|
2018-01-11 08:06:12 +08:00
|
|
|
android.ExtractSourcesDeps(ctx, d.properties.Arg_files)
|
|
|
|
|
|
|
|
// knowntags may contain filegroup or genrule.
|
|
|
|
android.ExtractSourcesDeps(ctx, d.properties.Knowntags)
|
2018-05-05 09:49:16 +08:00
|
|
|
|
2018-07-12 06:16:55 +08:00
|
|
|
if String(d.properties.Static_doc_index_redirect) != "" {
|
|
|
|
android.ExtractSourceDeps(ctx, d.properties.Static_doc_index_redirect)
|
|
|
|
}
|
|
|
|
|
|
|
|
if String(d.properties.Static_doc_properties) != "" {
|
|
|
|
android.ExtractSourceDeps(ctx, d.properties.Static_doc_properties)
|
|
|
|
}
|
|
|
|
|
2018-05-05 09:49:16 +08:00
|
|
|
if d.checkCurrentApi() {
|
|
|
|
android.ExtractSourceDeps(ctx, d.properties.Check_api.Current.Api_file)
|
|
|
|
android.ExtractSourceDeps(ctx, d.properties.Check_api.Current.Removed_api_file)
|
|
|
|
}
|
|
|
|
|
|
|
|
if d.checkLastReleasedApi() {
|
|
|
|
android.ExtractSourceDeps(ctx, d.properties.Check_api.Last_released.Api_file)
|
|
|
|
android.ExtractSourceDeps(ctx, d.properties.Check_api.Last_released.Removed_api_file)
|
|
|
|
}
|
2018-04-20 09:03:39 +08:00
|
|
|
|
|
|
|
if String(d.properties.Metalava_previous_api) != "" {
|
|
|
|
android.ExtractSourceDeps(ctx, d.properties.Metalava_previous_api)
|
|
|
|
}
|
2018-08-02 06:00:28 +08:00
|
|
|
|
|
|
|
if len(d.properties.Metalava_merge_annotations_dirs) != 0 {
|
|
|
|
for _, mergeAnnotationsDir := range d.properties.Metalava_merge_annotations_dirs {
|
|
|
|
ctx.AddDependency(ctx.Module(), metalavaMergeAnnotationsDirTag, mergeAnnotationsDir)
|
|
|
|
}
|
|
|
|
}
|
2018-01-11 08:06:12 +08:00
|
|
|
}
|
|
|
|
|
2018-08-15 11:41:04 +08:00
|
|
|
func (d *Droiddoc) initBuilderFlags(ctx android.ModuleContext, implicits *android.Paths,
|
|
|
|
deps deps) (droiddocBuilderFlags, error) {
|
2018-08-02 03:48:00 +08:00
|
|
|
var flags droiddocBuilderFlags
|
2018-01-11 08:06:12 +08:00
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
*implicits = append(*implicits, deps.bootClasspath...)
|
|
|
|
*implicits = append(*implicits, deps.classpath...)
|
2018-01-11 08:06:12 +08:00
|
|
|
|
2018-06-27 01:02:26 +08:00
|
|
|
// 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.
|
2018-08-02 03:48:00 +08:00
|
|
|
flags.bootClasspathArgs = deps.bootClasspath.FormJavaClassPath("-bootclasspath")
|
2018-04-18 08:38:36 +08:00
|
|
|
}
|
2018-08-02 03:48:00 +08:00
|
|
|
flags.classpathArgs = deps.classpath.FormJavaClassPath("-classpath")
|
2018-08-10 06:33:27 +08:00
|
|
|
// Dokka doesn't support boocClasspath, so combine these two classpath vars for Dokka.
|
|
|
|
dokkaClasspath := classpath{}
|
|
|
|
dokkaClasspath = append(dokkaClasspath, deps.bootClasspath...)
|
|
|
|
dokkaClasspath = append(dokkaClasspath, deps.classpath...)
|
|
|
|
flags.dokkaClasspathArgs = dokkaClasspath.FormJavaClassPath("-classpath")
|
2018-04-20 09:03:39 +08:00
|
|
|
|
2018-01-11 08:06:12 +08:00
|
|
|
argFiles := ctx.ExpandSources(d.properties.Arg_files, nil)
|
|
|
|
argFilesMap := map[string]android.Path{}
|
|
|
|
|
|
|
|
for _, f := range argFiles {
|
2018-08-02 03:48:00 +08:00
|
|
|
*implicits = append(*implicits, f)
|
2018-01-11 08:06:12 +08:00
|
|
|
if _, exists := argFilesMap[f.Rel()]; !exists {
|
|
|
|
argFilesMap[f.Rel()] = f
|
|
|
|
} else {
|
|
|
|
ctx.ModuleErrorf("multiple arg_files for %q, %q and %q",
|
|
|
|
f, argFilesMap[f.Rel()], f.Rel())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
var err error
|
|
|
|
flags.args, err = android.Expand(String(d.properties.Args), func(name string) (string, error) {
|
2018-01-11 08:06:12 +08:00
|
|
|
if strings.HasPrefix(name, "location ") {
|
|
|
|
label := strings.TrimSpace(strings.TrimPrefix(name, "location "))
|
|
|
|
if f, ok := argFilesMap[label]; ok {
|
|
|
|
return f.String(), nil
|
|
|
|
} else {
|
|
|
|
return "", fmt.Errorf("unknown location label %q", label)
|
|
|
|
}
|
|
|
|
} else if name == "genDir" {
|
|
|
|
return android.PathForModuleGen(ctx).String(), nil
|
|
|
|
}
|
|
|
|
return "", fmt.Errorf("unknown variable '$(%s)'", name)
|
|
|
|
})
|
|
|
|
|
|
|
|
if err != nil {
|
2018-04-20 09:03:39 +08:00
|
|
|
ctx.PropertyErrorf("args", "%s", err.Error())
|
2018-08-02 03:48:00 +08:00
|
|
|
return droiddocBuilderFlags{}, err
|
2018-01-11 08:06:12 +08:00
|
|
|
}
|
2018-08-02 03:48:00 +08:00
|
|
|
return flags, nil
|
|
|
|
}
|
2018-01-11 08:06:12 +08:00
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
func (d *Droiddoc) collectDoclavaDocsFlags(ctx android.ModuleContext, implicits *android.Paths,
|
2018-08-21 11:58:28 +08:00
|
|
|
jsilver, doclava android.Path) string {
|
2018-01-11 08:06:12 +08:00
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
*implicits = append(*implicits, jsilver)
|
|
|
|
*implicits = append(*implicits, doclava)
|
2018-01-11 08:06:12 +08:00
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
var date string
|
|
|
|
if runtime.GOOS == "darwin" {
|
|
|
|
date = `date -r`
|
|
|
|
} else {
|
|
|
|
date = `date -d`
|
|
|
|
}
|
2018-01-11 08:06:12 +08:00
|
|
|
|
2018-08-21 11:58:28 +08: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-02 03:48:00 +08: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-27 06:33:31 +08:00
|
|
|
|
2018-08-02 03:48:00 +08: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 08:06:12 +08:00
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
ctx.VisitDirectDepsWithTag(droiddocTemplateTag, func(m android.Module) {
|
2018-08-02 06:00:28 +08:00
|
|
|
if t, ok := m.(*ExportedDroiddocDir); ok {
|
2018-08-02 03:48:00 +08: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 09:03:39 +08:00
|
|
|
}
|
2018-08-02 03:48:00 +08:00
|
|
|
})
|
2018-01-11 08:06:12 +08:00
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
if len(d.properties.Html_dirs) > 0 {
|
|
|
|
htmlDir := android.PathForModuleSrc(ctx, d.properties.Html_dirs[0])
|
|
|
|
*implicits = append(*implicits, ctx.Glob(htmlDir.Join(ctx, "**/*").String(), nil)...)
|
|
|
|
args = args + " -htmldir " + htmlDir.String()
|
|
|
|
}
|
2018-01-11 08:06:12 +08:00
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
if len(d.properties.Html_dirs) > 1 {
|
|
|
|
htmlDir2 := android.PathForModuleSrc(ctx, d.properties.Html_dirs[1])
|
|
|
|
*implicits = append(*implicits, ctx.Glob(htmlDir2.Join(ctx, "**/*").String(), nil)...)
|
|
|
|
args = args + " -htmldir2 " + htmlDir2.String()
|
|
|
|
}
|
2018-02-24 03:18:47 +08:00
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
if len(d.properties.Html_dirs) > 2 {
|
|
|
|
ctx.PropertyErrorf("html_dirs", "Droiddoc only supports up to 2 html dirs")
|
|
|
|
}
|
2018-01-11 08:06:12 +08:00
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
knownTags := ctx.ExpandSources(d.properties.Knowntags, nil)
|
|
|
|
*implicits = append(*implicits, knownTags...)
|
2018-04-20 09:03:39 +08:00
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
for _, kt := range knownTags {
|
|
|
|
args = args + " -knowntags " + kt.String()
|
|
|
|
}
|
2018-04-20 09:03:39 +08:00
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
for _, hdf := range d.properties.Hdf {
|
|
|
|
args = args + " -hdf " + hdf
|
|
|
|
}
|
2018-04-20 09:03:39 +08:00
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
if String(d.properties.Proofread_file) != "" {
|
|
|
|
proofreadFile := android.PathForModuleOut(ctx, String(d.properties.Proofread_file))
|
|
|
|
args = args + " -proofread " + proofreadFile.String()
|
2018-02-24 03:18:47 +08:00
|
|
|
}
|
|
|
|
|
2018-08-02 03:48:00 +08: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-24 03:18:47 +08:00
|
|
|
}
|
|
|
|
|
2018-08-02 03:48:00 +08: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 09:49:16 +08:00
|
|
|
|
2018-08-02 03:48:00 +08: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
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Droiddoc) collectStubsFlags(ctx android.ModuleContext, implicitOutputs *android.WritablePaths) (string, string) {
|
|
|
|
var doclavaFlags, MetalavaFlags string
|
2018-05-05 09:49:16 +08:00
|
|
|
if d.checkCurrentApi() || d.checkLastReleasedApi() || String(d.properties.Api_filename) != "" {
|
|
|
|
d.apiFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_api.txt")
|
2018-08-02 03:48:00 +08:00
|
|
|
doclavaFlags += " -api " + d.apiFile.String()
|
|
|
|
MetalavaFlags = MetalavaFlags + " --api " + d.apiFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.apiFile)
|
2018-07-24 10:19:26 +08:00
|
|
|
d.apiFilePath = d.apiFile
|
2018-03-14 07:17:01 +08:00
|
|
|
}
|
|
|
|
|
2018-05-05 09:49:16 +08:00
|
|
|
if d.checkCurrentApi() || d.checkLastReleasedApi() || String(d.properties.Removed_api_filename) != "" {
|
|
|
|
d.removedApiFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_removed.txt")
|
2018-08-02 03:48:00 +08:00
|
|
|
doclavaFlags += " -removedApi " + d.removedApiFile.String()
|
|
|
|
MetalavaFlags = MetalavaFlags + " --removed-api " + d.removedApiFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.removedApiFile)
|
2018-05-05 09:49:16 +08:00
|
|
|
}
|
|
|
|
|
2018-03-14 07:17:01 +08:00
|
|
|
if String(d.properties.Private_api_filename) != "" {
|
|
|
|
d.privateApiFile = android.PathForModuleOut(ctx, String(d.properties.Private_api_filename))
|
2018-08-02 03:48:00 +08:00
|
|
|
doclavaFlags += " -privateApi " + d.privateApiFile.String()
|
|
|
|
MetalavaFlags = MetalavaFlags + " --private-api " + d.privateApiFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.privateApiFile)
|
2018-03-14 07:17:01 +08:00
|
|
|
}
|
|
|
|
|
2018-05-31 20:56:46 +08:00
|
|
|
if String(d.properties.Dex_api_filename) != "" {
|
|
|
|
d.dexApiFile = android.PathForModuleOut(ctx, String(d.properties.Dex_api_filename))
|
2018-08-02 03:48:00 +08:00
|
|
|
doclavaFlags += " -dexApi " + d.dexApiFile.String()
|
2018-08-22 07:24:38 +08:00
|
|
|
MetalavaFlags += " --dex-api " + d.dexApiFile.String()
|
2018-08-02 03:48:00 +08:00
|
|
|
*implicitOutputs = append(*implicitOutputs, d.dexApiFile)
|
2018-05-31 20:56:46 +08:00
|
|
|
}
|
|
|
|
|
2018-03-14 07:17:01 +08:00
|
|
|
if String(d.properties.Private_dex_api_filename) != "" {
|
|
|
|
d.privateDexApiFile = android.PathForModuleOut(ctx, String(d.properties.Private_dex_api_filename))
|
2018-08-02 03:48:00 +08:00
|
|
|
doclavaFlags += " -privateDexApi " + d.privateDexApiFile.String()
|
|
|
|
MetalavaFlags = MetalavaFlags + " --private-dex-api " + d.privateDexApiFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.privateDexApiFile)
|
2018-03-14 07:17:01 +08:00
|
|
|
}
|
|
|
|
|
2018-04-24 23:23:29 +08:00
|
|
|
if String(d.properties.Removed_dex_api_filename) != "" {
|
|
|
|
d.removedDexApiFile = android.PathForModuleOut(ctx, String(d.properties.Removed_dex_api_filename))
|
2018-08-02 03:48:00 +08:00
|
|
|
doclavaFlags += " -removedDexApi " + d.removedDexApiFile.String()
|
|
|
|
MetalavaFlags = MetalavaFlags + " --removed-dex-api " + d.removedDexApiFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.removedDexApiFile)
|
2018-04-24 23:23:29 +08:00
|
|
|
}
|
|
|
|
|
2018-03-14 07:17:01 +08:00
|
|
|
if String(d.properties.Exact_api_filename) != "" {
|
|
|
|
d.exactApiFile = android.PathForModuleOut(ctx, String(d.properties.Exact_api_filename))
|
2018-08-02 03:48:00 +08:00
|
|
|
doclavaFlags += " -exactApi " + d.exactApiFile.String()
|
|
|
|
MetalavaFlags = MetalavaFlags + " --exact-api " + d.exactApiFile.String()
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.exactApiFile)
|
2018-03-14 07:17:01 +08:00
|
|
|
}
|
|
|
|
|
2018-06-22 22:28:11 +08:00
|
|
|
if String(d.properties.Dex_mapping_filename) != "" {
|
|
|
|
d.apiMappingFile = android.PathForModuleOut(ctx, String(d.properties.Dex_mapping_filename))
|
2018-08-02 03:48:00 +08:00
|
|
|
doclavaFlags += " -apiMapping " + d.apiMappingFile.String()
|
2018-06-22 22:28:11 +08:00
|
|
|
// Omitted: metalava support
|
2018-08-02 03:48:00 +08:00
|
|
|
*implicitOutputs = append(*implicitOutputs, d.apiMappingFile)
|
2018-06-22 22:28:11 +08:00
|
|
|
}
|
|
|
|
|
2018-08-15 11:41:04 +08:00
|
|
|
if String(d.properties.Proguard_filename) != "" {
|
|
|
|
d.proguardFile = android.PathForModuleOut(ctx, String(d.properties.Proguard_filename))
|
|
|
|
doclavaFlags += " -proguard " + d.proguardFile.String()
|
|
|
|
// Omitted: metalava support
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.proguardFile)
|
|
|
|
}
|
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
if BoolDefault(d.properties.Create_stubs, true) {
|
2018-08-09 07:32:21 +08:00
|
|
|
doclavaFlags += " -stubs " + android.PathForModuleOut(ctx, "stubsDir").String()
|
2018-08-02 03:48:00 +08:00
|
|
|
}
|
2018-01-11 08:06:12 +08:00
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
if Bool(d.properties.Write_sdk_values) {
|
2018-08-09 07:32:21 +08:00
|
|
|
doclavaFlags += " -sdkvalues " + android.PathForModuleOut(ctx, "out").String()
|
2018-04-20 09:03:39 +08:00
|
|
|
}
|
2018-08-02 03:48:00 +08:00
|
|
|
return doclavaFlags, MetalavaFlags
|
|
|
|
}
|
2018-04-20 09:03:39 +08:00
|
|
|
|
2018-08-02 03:48:00 +08: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 07:32:21 +08:00
|
|
|
android.PathForModuleOut(ctx, "out", "index.html").String()
|
2018-08-02 03:48:00 +08:00
|
|
|
}
|
2018-04-24 00:59:14 +08:00
|
|
|
|
2018-08-02 03:48:00 +08: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 07:32:21 +08:00
|
|
|
android.PathForModuleOut(ctx, "out", "source.properties").String()
|
2018-06-05 02:28:01 +08:00
|
|
|
}
|
2018-08-02 03:48:00 +08:00
|
|
|
return cmds
|
|
|
|
}
|
2018-06-05 02:28:01 +08:00
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
func (d *Droiddoc) collectMetalavaAnnotationsFlags(
|
|
|
|
ctx android.ModuleContext, implicits *android.Paths, implicitOutputs *android.WritablePaths) string {
|
|
|
|
var flags string
|
|
|
|
if Bool(d.properties.Metalava_annotations_enabled) {
|
|
|
|
if String(d.properties.Metalava_previous_api) == "" {
|
|
|
|
ctx.PropertyErrorf("metalava_previous_api",
|
|
|
|
"has to be non-empty if annotations was enabled!")
|
|
|
|
}
|
2018-08-09 07:32:21 +08:00
|
|
|
previousApi := ctx.ExpandSource(String(d.properties.Metalava_previous_api),
|
|
|
|
"metalava_previous_api")
|
|
|
|
*implicits = append(*implicits, previousApi)
|
|
|
|
|
2018-08-16 04:28:54 +08:00
|
|
|
flags += " --include-annotations --migrate-nullness " + previousApi.String()
|
2018-01-11 08:06:12 +08:00
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
d.annotationsZip = android.PathForModuleOut(ctx, ctx.ModuleName()+"_annotations.zip")
|
|
|
|
*implicitOutputs = append(*implicitOutputs, d.annotationsZip)
|
2018-01-11 08:06:12 +08:00
|
|
|
|
2018-08-02 06:00:28 +08:00
|
|
|
flags += " --extract-annotations " + d.annotationsZip.String()
|
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
if len(d.properties.Metalava_merge_annotations_dirs) == 0 {
|
|
|
|
ctx.PropertyErrorf("metalava_merge_annotations_dirs",
|
|
|
|
"has to be non-empty if annotations was enabled!")
|
2018-04-20 09:03:39 +08:00
|
|
|
}
|
2018-08-02 06:00:28 +08:00
|
|
|
ctx.VisitDirectDepsWithTag(metalavaMergeAnnotationsDirTag, func(m android.Module) {
|
|
|
|
if t, ok := m.(*ExportedDroiddocDir); ok {
|
|
|
|
*implicits = append(*implicits, t.deps...)
|
|
|
|
flags += " --merge-annotations " + t.dir.String()
|
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("metalava_merge_annotations_dirs",
|
|
|
|
"module %q is not a metalava merge-annotations dir", ctx.OtherModuleName(m))
|
|
|
|
}
|
|
|
|
})
|
2018-08-02 03:48:00 +08:00
|
|
|
// TODO(tnorbye): find owners to fix these warnings when annotation was enabled.
|
|
|
|
flags += " --hide HiddenTypedefConstant --hide SuperfluousPrefix --hide AnnotationExtraction "
|
|
|
|
}
|
2018-07-12 06:16:55 +08:00
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
return flags
|
|
|
|
}
|
2018-07-12 06:16:55 +08:00
|
|
|
|
2018-08-10 06:33:27 +08:00
|
|
|
func (d *Droiddoc) collectMetalavaJavadocFlags(ctx android.ModuleContext,
|
2018-08-09 07:32:21 +08:00
|
|
|
bootClasspathArgs, classpathArgs, outDir, docStubsDir string) string {
|
|
|
|
return " --doc-stubs " + docStubsDir +
|
|
|
|
" --write-doc-stubs-source-list " + android.PathForModuleOut(ctx, "doc_stubs.srclist").String() +
|
2018-08-02 03:48:00 +08:00
|
|
|
" --generate-documentation ${config.JavadocCmd} -encoding UTF-8 DOC_STUBS_SOURCE_LIST " +
|
|
|
|
bootClasspathArgs + " " + classpathArgs + " " + " -sourcepath " +
|
2018-08-09 07:32:21 +08:00
|
|
|
docStubsDir + " -quiet -d " + outDir
|
2018-08-02 03:48:00 +08:00
|
|
|
}
|
|
|
|
|
2018-08-10 06:33:27 +08:00
|
|
|
func (d *Droiddoc) collectMetalavaDokkaFlags(ctx android.ModuleContext, implicits *android.Paths,
|
|
|
|
classpathArgs, outDir, docStubsDir string) string {
|
|
|
|
dokka := android.PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "framework", "dokka.jar")
|
|
|
|
*implicits = append(*implicits, dokka)
|
|
|
|
|
|
|
|
return " --doc-stubs " + docStubsDir + " --write-doc-stubs-source-list " +
|
|
|
|
android.PathForModuleOut(ctx, "doc_stubs.srclist").String() +
|
|
|
|
" --generate-documentation ${config.JavaCmd} -jar " + dokka.String() + " " +
|
|
|
|
docStubsDir + " " + classpathArgs + " -format dac -dacRoot /reference/kotlin -output " + outDir
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Droiddoc) transformMetalava(ctx android.ModuleContext, implicits android.Paths,
|
|
|
|
implicitOutputs android.WritablePaths, outDir, docStubsDir, javaVersion,
|
|
|
|
bootclasspathArgs, classpathArgs, opts string) {
|
|
|
|
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{
|
|
|
|
"outDir": outDir,
|
|
|
|
"srcJarDir": android.PathForModuleOut(ctx, "srcjars").String(),
|
|
|
|
"stubsDir": android.PathForModuleOut(ctx, "stubsDir").String(),
|
|
|
|
"docStubsDir": docStubsDir,
|
|
|
|
"srcJars": strings.Join(d.Javadoc.srcJars.Strings(), " "),
|
|
|
|
"javaVersion": javaVersion,
|
|
|
|
"bootclasspathArgs": bootclasspathArgs,
|
|
|
|
"classpathArgs": classpathArgs,
|
|
|
|
"sourcepath": strings.Join(d.Javadoc.sourcepaths.Strings(), ":"),
|
|
|
|
"docZip": d.Javadoc.docZip.String(),
|
|
|
|
"opts": opts,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Droiddoc) transformDoclava(ctx android.ModuleContext, implicits android.Paths,
|
|
|
|
implicitOutputs android.WritablePaths, bootclasspathArgs, classpathArgs, 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,
|
|
|
|
"sourcepath": strings.Join(d.Javadoc.sourcepaths.Strings(), ":"),
|
|
|
|
"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,
|
2018-08-21 11:33:38 +08:00
|
|
|
Description: "Doclava Check API",
|
2018-08-10 06:33:27 +08:00
|
|
|
Output: output,
|
|
|
|
Inputs: nil,
|
|
|
|
Implicits: append(android.Paths{apiFile, removedApiFile, d.apiFile, d.removedApiFile},
|
|
|
|
checkApiClasspath...),
|
|
|
|
Args: map[string]string{
|
|
|
|
"classpath": checkApiClasspath.FormJavaClassPath(""),
|
|
|
|
"opts": opts,
|
|
|
|
"apiFile": apiFile.String(),
|
|
|
|
"apiFileToCheck": d.apiFile.String(),
|
|
|
|
"removedApiFile": removedApiFile.String(),
|
|
|
|
"removedApiFileToCheck": d.removedApiFile.String(),
|
2018-08-30 06:36:33 +08:00
|
|
|
"msg": msg,
|
2018-08-10 06:33:27 +08:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-08-25 01:32:54 +08:00
|
|
|
func (d *Droiddoc) transformMetalavaCheckApi(ctx android.ModuleContext, apiFile, removedApiFile android.Path,
|
|
|
|
implicits android.Paths, javaVersion, bootclasspathArgs, classpathArgs, opts, msg string,
|
|
|
|
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{
|
|
|
|
"srcJarDir": android.PathForModuleOut(ctx, "srcjars").String(),
|
|
|
|
"srcJars": strings.Join(d.Javadoc.srcJars.Strings(), " "),
|
|
|
|
"javaVersion": javaVersion,
|
|
|
|
"bootclasspathArgs": bootclasspathArgs,
|
|
|
|
"classpathArgs": classpathArgs,
|
|
|
|
"sourcepath": strings.Join(d.Javadoc.sourcepaths.Strings(), ":"),
|
|
|
|
"opts": opts,
|
|
|
|
"msg": msg,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-08-10 06:33:27 +08:00
|
|
|
func (d *Droiddoc) transformUpdateApi(ctx android.ModuleContext, apiFile, removedApiFile android.Path,
|
|
|
|
output android.WritablePath) {
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: updateApi,
|
|
|
|
Description: "Update API",
|
|
|
|
Output: output,
|
|
|
|
Implicits: append(android.Paths{}, apiFile, removedApiFile, d.apiFile, d.removedApiFile),
|
|
|
|
Args: map[string]string{
|
|
|
|
"apiFile": apiFile.String(),
|
|
|
|
"apiFileToCheck": d.apiFile.String(),
|
|
|
|
"removedApiFile": removedApiFile.String(),
|
|
|
|
"removedApiFileToCheck": d.removedApiFile.String(),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
|
|
deps := d.Javadoc.collectDeps(ctx)
|
2018-07-12 06:16:55 +08:00
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
javaVersion := getJavaVersion(ctx, String(d.Javadoc.properties.Java_version), sdkContext(d))
|
|
|
|
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...)
|
|
|
|
|
|
|
|
var implicitOutputs android.WritablePaths
|
|
|
|
implicitOutputs = append(implicitOutputs, d.Javadoc.docZip)
|
|
|
|
for _, o := range d.properties.Out {
|
|
|
|
implicitOutputs = append(implicitOutputs, android.PathForModuleGen(ctx, o))
|
|
|
|
}
|
|
|
|
|
|
|
|
flags, err := d.initBuilderFlags(ctx, &implicits, deps)
|
2018-08-25 01:32:54 +08:00
|
|
|
metalavaCheckApiImplicits := implicits
|
2018-08-02 03:48:00 +08:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
flags.doclavaStubsFlags, flags.metalavaStubsFlags = d.collectStubsFlags(ctx, &implicitOutputs)
|
|
|
|
if Bool(d.properties.Metalava_enabled) {
|
|
|
|
flags.metalavaAnnotationsFlags = d.collectMetalavaAnnotationsFlags(ctx, &implicits, &implicitOutputs)
|
2018-08-10 06:33:27 +08:00
|
|
|
outDir := android.PathForModuleOut(ctx, "out").String()
|
2018-08-09 07:32:21 +08:00
|
|
|
docStubsDir := android.PathForModuleOut(ctx, "docStubsDir").String()
|
2018-08-10 06:33:27 +08:00
|
|
|
// TODO(nanzhang): Add a Soong property to handle documentation args.
|
|
|
|
if strings.Contains(flags.args, "--generate-documentation") { // enable docs generation
|
|
|
|
if Bool(d.properties.Dokka_enabled) {
|
|
|
|
flags.metalavaDokkaFlags = d.collectMetalavaDokkaFlags(ctx, &implicits,
|
|
|
|
flags.dokkaClasspathArgs, outDir, docStubsDir)
|
|
|
|
d.transformMetalava(ctx, implicits, implicitOutputs, outDir, docStubsDir, javaVersion,
|
|
|
|
flags.bootClasspathArgs, flags.classpathArgs, flags.metalavaStubsFlags+
|
2018-08-25 01:32:54 +08:00
|
|
|
flags.metalavaAnnotationsFlags+" "+
|
2018-08-21 11:33:38 +08:00
|
|
|
strings.Split(flags.args, "--generate-documentation")[0]+
|
2018-08-10 06:33:27 +08:00
|
|
|
flags.metalavaDokkaFlags+" "+strings.Split(flags.args, "--generate-documentation")[1])
|
|
|
|
} else {
|
|
|
|
flags.metalavaJavadocFlags = d.collectMetalavaJavadocFlags(
|
|
|
|
ctx, flags.bootClasspathArgs, flags.classpathArgs, outDir, docStubsDir)
|
2018-08-21 11:58:28 +08:00
|
|
|
flags.doclavaDocsFlags = d.collectDoclavaDocsFlags(ctx, &implicits, jsilver, doclava)
|
2018-08-10 06:33:27 +08:00
|
|
|
d.transformMetalava(ctx, implicits, implicitOutputs, outDir, docStubsDir, javaVersion,
|
|
|
|
flags.bootClasspathArgs, flags.classpathArgs, flags.metalavaStubsFlags+
|
2018-08-25 01:32:54 +08:00
|
|
|
flags.metalavaAnnotationsFlags+" "+
|
2018-08-21 11:33:38 +08:00
|
|
|
strings.Split(flags.args, "--generate-documentation")[0]+
|
2018-08-10 06:33:27 +08:00
|
|
|
flags.metalavaJavadocFlags+flags.doclavaDocsFlags+
|
|
|
|
" "+strings.Split(flags.args, "--generate-documentation")[1])
|
|
|
|
}
|
2018-08-02 03:48:00 +08:00
|
|
|
} else {
|
2018-08-10 06:33:27 +08:00
|
|
|
d.transformMetalava(ctx, implicits, implicitOutputs, outDir, docStubsDir, javaVersion,
|
|
|
|
flags.bootClasspathArgs, flags.classpathArgs,
|
2018-08-25 01:32:54 +08:00
|
|
|
flags.metalavaStubsFlags+flags.metalavaAnnotationsFlags+" "+flags.args)
|
2018-08-02 03:48:00 +08:00
|
|
|
}
|
2018-04-20 09:03:39 +08:00
|
|
|
} else {
|
2018-08-21 11:58:28 +08:00
|
|
|
flags.doclavaDocsFlags = d.collectDoclavaDocsFlags(ctx, &implicits, jsilver, doclava)
|
2018-08-02 03:48:00 +08:00
|
|
|
flags.postDoclavaCmds = d.getPostDoclavaCmds(ctx, &implicits)
|
2018-08-10 06:33:27 +08:00
|
|
|
d.transformDoclava(ctx, implicits, implicitOutputs, flags.bootClasspathArgs, flags.classpathArgs,
|
|
|
|
flags.doclavaDocsFlags+flags.doclavaStubsFlags+" "+flags.args,
|
|
|
|
flags.postDoclavaCmds)
|
2018-04-20 09:03:39 +08:00
|
|
|
}
|
2018-05-05 09:49:16 +08:00
|
|
|
|
|
|
|
if d.checkCurrentApi() && !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")
|
|
|
|
|
2018-08-25 01:32:54 +08:00
|
|
|
d.checkCurrentApiTimestamp = android.PathForModuleOut(ctx, "check_current_api.timestamp")
|
2018-08-17 07:23:11 +08:00
|
|
|
if !Bool(d.properties.Metalava_enabled) {
|
|
|
|
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)
|
2018-08-25 01:32:54 +08:00
|
|
|
} else {
|
|
|
|
opts := flags.args + " --check-compatibility:api:current " + apiFile.String() +
|
|
|
|
" --check-compatibility:removed:current " + removedApiFile.String() + " "
|
|
|
|
|
|
|
|
d.transformMetalavaCheckApi(ctx, apiFile, removedApiFile, metalavaCheckApiImplicits,
|
|
|
|
javaVersion, flags.bootClasspathArgs, flags.classpathArgs, opts,
|
|
|
|
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-08-17 07:23:11 +08:00
|
|
|
}
|
2018-05-05 09:49:16 +08:00
|
|
|
|
|
|
|
d.updateCurrentApiTimestamp = android.PathForModuleOut(ctx, "update_current_api.timestamp")
|
2018-08-10 06:33:27 +08:00
|
|
|
d.transformUpdateApi(ctx, apiFile, removedApiFile, d.updateCurrentApiTimestamp)
|
2018-05-05 09:49:16 +08:00
|
|
|
}
|
2018-08-02 03:48:00 +08:00
|
|
|
|
2018-05-05 09:49:16 +08:00
|
|
|
if d.checkLastReleasedApi() && !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")
|
|
|
|
|
2018-08-25 01:32:54 +08:00
|
|
|
d.checkLastReleasedApiTimestamp = android.PathForModuleOut(ctx, "check_last_released_api.timestamp")
|
2018-08-21 11:33:38 +08:00
|
|
|
if !Bool(d.properties.Metalava_enabled) {
|
|
|
|
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)
|
2018-08-25 01:32:54 +08:00
|
|
|
} else {
|
|
|
|
opts := flags.args + " --check-compatibility:api:released " + apiFile.String() +
|
|
|
|
" --check-compatibility:removed:released " + removedApiFile.String() + " "
|
|
|
|
|
|
|
|
d.transformMetalavaCheckApi(ctx, apiFile, removedApiFile, metalavaCheckApiImplicits,
|
|
|
|
javaVersion, flags.bootClasspathArgs, flags.classpathArgs, opts,
|
|
|
|
`\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-08-21 11:33:38 +08:00
|
|
|
}
|
2018-05-05 09:49:16 +08:00
|
|
|
}
|
2018-01-11 08:06:12 +08: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-27 06:33:31 +08:00
|
|
|
|
2018-08-02 03:48:00 +08:00
|
|
|
//
|
2018-08-02 06:00:28 +08:00
|
|
|
// Exported Droiddoc Directory
|
2018-08-02 03:48:00 +08: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-27 06:33:31 +08:00
|
|
|
var droiddocTemplateTag = dependencyTag{name: "droiddoc-template"}
|
2018-08-02 06:00:28 +08:00
|
|
|
var metalavaMergeAnnotationsDirTag = dependencyTag{name: "metalava-merge-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-27 06:33:31 +08:00
|
|
|
|
2018-08-02 06:00:28 +08: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-27 06:33:31 +08:00
|
|
|
Path *string
|
|
|
|
}
|
|
|
|
|
2018-08-02 06:00:28 +08: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-27 06:33:31 +08:00
|
|
|
android.ModuleBase
|
|
|
|
|
2018-08-02 06:00:28 +08: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-27 06:33:31 +08:00
|
|
|
|
|
|
|
deps android.Paths
|
|
|
|
dir android.Path
|
|
|
|
}
|
|
|
|
|
2018-08-02 06:00:28 +08: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-27 06:33:31 +08:00
|
|
|
module.AddProperties(&module.properties)
|
|
|
|
android.InitAndroidModule(module)
|
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
2018-08-02 06:00:28 +08: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-27 06:33:31 +08:00
|
|
|
|
2018-08-02 06:00:28 +08:00
|
|
|
func (d *ExportedDroiddocDir) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
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-27 06:33:31 +08:00
|
|
|
path := android.PathForModuleSrc(ctx, String(d.properties.Path))
|
|
|
|
d.dir = path
|
|
|
|
d.deps = ctx.Glob(path.Join(ctx, "**/*").String(), nil)
|
|
|
|
}
|
2018-02-24 03:18:47 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Defaults
|
|
|
|
//
|
|
|
|
type DocDefaults struct {
|
|
|
|
android.ModuleBase
|
|
|
|
android.DefaultsModuleBase
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*DocDefaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *DocDefaults) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|
|
|
}
|
|
|
|
|
|
|
|
func DocDefaultsFactory() android.Module {
|
|
|
|
module := &DocDefaults{}
|
|
|
|
|
|
|
|
module.AddProperties(
|
|
|
|
&JavadocProperties{},
|
|
|
|
&DroiddocProperties{},
|
|
|
|
)
|
|
|
|
|
|
|
|
android.InitDefaultsModule(module)
|
|
|
|
|
|
|
|
return module
|
|
|
|
}
|