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 (
|
|
|
|
"fmt"
|
2018-02-23 20:18:47 +01:00
|
|
|
"path/filepath"
|
2018-01-11 01:06:12 +01:00
|
|
|
"strings"
|
|
|
|
|
2019-11-28 15:31:38 +01:00
|
|
|
"github.com/google/blueprint"
|
2019-06-25 09:26:18 +02:00
|
|
|
"github.com/google/blueprint/proptools"
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2019-07-16 01:13:59 +02:00
|
|
|
"android/soong/android"
|
|
|
|
"android/soong/java/config"
|
2020-04-30 09:08:37 +02:00
|
|
|
"android/soong/remoteexec"
|
2018-01-11 01:06:12 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2019-12-19 11:21:09 +01:00
|
|
|
RegisterDocsBuildComponents(android.InitRegistrationContext)
|
|
|
|
RegisterStubsBuildComponents(android.InitRegistrationContext)
|
2019-12-13 12:22:16 +01:00
|
|
|
|
|
|
|
// Register sdk member type.
|
|
|
|
android.RegisterSdkMemberType(&droidStubsSdkMemberType{
|
|
|
|
SdkMemberTypeBase: android.SdkMemberTypeBase{
|
|
|
|
PropertyName: "stubs_sources",
|
2019-12-16 18:43:48 +01:00
|
|
|
// stubs_sources can be used with sdk to provide the source stubs for APIs provided by
|
|
|
|
// the APEX.
|
|
|
|
SupportsSdk: true,
|
2019-12-13 12:22:16 +01:00
|
|
|
},
|
|
|
|
})
|
2018-01-11 01:06:12 +01:00
|
|
|
}
|
|
|
|
|
2019-12-19 11:21:09 +01:00
|
|
|
func RegisterDocsBuildComponents(ctx android.RegistrationContext) {
|
|
|
|
ctx.RegisterModuleType("doc_defaults", DocDefaultsFactory)
|
|
|
|
|
|
|
|
ctx.RegisterModuleType("droiddoc", DroiddocFactory)
|
|
|
|
ctx.RegisterModuleType("droiddoc_host", DroiddocHostFactory)
|
|
|
|
ctx.RegisterModuleType("droiddoc_exported_dir", ExportedDroiddocDirFactory)
|
|
|
|
ctx.RegisterModuleType("javadoc", JavadocFactory)
|
|
|
|
ctx.RegisterModuleType("javadoc_host", JavadocHostFactory)
|
|
|
|
}
|
|
|
|
|
|
|
|
func RegisterStubsBuildComponents(ctx android.RegistrationContext) {
|
|
|
|
ctx.RegisterModuleType("stubs_defaults", StubsDefaultsFactory)
|
|
|
|
|
|
|
|
ctx.RegisterModuleType("droidstubs", DroidstubsFactory)
|
|
|
|
ctx.RegisterModuleType("droidstubs_host", DroidstubsHostFactory)
|
|
|
|
|
|
|
|
ctx.RegisterModuleType("prebuilt_stubs_sources", PrebuiltStubsSourcesFactory)
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2019-09-13 13:56:14 +02:00
|
|
|
// list of package names that should actually be used. If this property is left unspecified,
|
|
|
|
// all the sources from the srcs property is used.
|
|
|
|
Filter_packages []string
|
|
|
|
|
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"`
|
|
|
|
|
|
|
|
// 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
|
|
|
|
2019-10-11 14:50:28 +02:00
|
|
|
// if not blank, set to the version of the sdk to compile against.
|
|
|
|
// Defaults to compiling against the current platform.
|
2018-01-11 01:06:12 +01:00
|
|
|
Sdk_version *string `android:"arch_variant"`
|
2018-05-23 11:42:04 +02:00
|
|
|
|
2019-10-11 14:50:28 +02:00
|
|
|
// When targeting 1.9 and above, override the modules to use with --system,
|
|
|
|
// otherwise provides defaults libraries to add to the bootclasspath.
|
|
|
|
// Defaults to "none"
|
|
|
|
System_modules *string
|
|
|
|
|
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
|
|
|
|
2019-08-12 17:54:09 +02:00
|
|
|
// If not blank, path to the baseline txt file for approved API check violations.
|
|
|
|
Baseline_file *string `android:"path"`
|
|
|
|
|
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-07-16 01:13:59 +02:00
|
|
|
Proofread_file *string
|
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 generated public API filename by Doclava.
|
|
|
|
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-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
|
2019-12-19 15:27:08 +01:00
|
|
|
|
|
|
|
// Compat config XML. Generates compat change documentation if set.
|
|
|
|
Compat_config *string `android:"path"`
|
2018-09-05 02:14:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type DroidstubsProperties struct {
|
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 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
|
|
|
|
|
|
|
|
Check_api struct {
|
|
|
|
Last_released ApiToCheck
|
|
|
|
|
|
|
|
Current ApiToCheck
|
2019-02-28 06:24:05 +01:00
|
|
|
|
2020-05-10 20:32:20 +02:00
|
|
|
// The java_sdk_library module generates references to modules (i.e. filegroups)
|
|
|
|
// from which information about the latest API version can be obtained. As those
|
|
|
|
// modules may not exist (e.g. because a previous version has not been released) it
|
|
|
|
// sets ignore_missing_latest_api=true on the droidstubs modules it creates so
|
|
|
|
// that droidstubs can ignore those references if the modules do not yet exist.
|
|
|
|
//
|
|
|
|
// If true then this will ignore module references for modules that do not exist
|
|
|
|
// in properties that supply the previous version of the API.
|
|
|
|
//
|
|
|
|
// There are two sets of those:
|
|
|
|
// * Api_file, Removed_api_file in check_api.last_released
|
|
|
|
// * New_since in check_api.api_lint.new_since
|
|
|
|
//
|
|
|
|
// The first two must be set as a pair, so either they should both exist or neither
|
|
|
|
// should exist - in which case when this property is true they are ignored. If one
|
|
|
|
// exists and the other does not then it is an error.
|
2019-02-28 06:24:05 +01:00
|
|
|
Ignore_missing_latest_api *bool `blueprint:"mutated"`
|
2019-10-10 12:07:03 +02:00
|
|
|
|
|
|
|
Api_lint struct {
|
|
|
|
Enabled *bool
|
|
|
|
|
|
|
|
// If set, performs api_lint on any new APIs not found in the given signature file
|
|
|
|
New_since *string `android:"path"`
|
|
|
|
|
|
|
|
// If not blank, path to the baseline txt file for approved API lint violations.
|
|
|
|
Baseline_file *string `android:"path"`
|
|
|
|
}
|
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
|
|
|
|
2020-04-08 19:18:03 +02:00
|
|
|
// if set to false then do not write out stubs. Defaults to true.
|
|
|
|
//
|
|
|
|
// TODO(b/146727827): Remove capability when we do not need to generate stubs and API separately.
|
|
|
|
Generate_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
|
|
|
|
}
|
|
|
|
|
|
|
|
func InitDroiddocModule(module android.DefaultableModule, hod android.HostOrDeviceSupported) {
|
|
|
|
android.InitAndroidArchModule(module, hod, android.MultilibCommon)
|
|
|
|
android.InitDefaultableModule(module)
|
|
|
|
}
|
|
|
|
|
2019-09-01 21:49:45 +02:00
|
|
|
func apiCheckEnabled(ctx android.ModuleContext, apiToCheck ApiToCheck, apiVersionTag string) bool {
|
|
|
|
if ctx.Config().IsEnvTrue("WITHOUT_CHECK_API") {
|
|
|
|
return false
|
|
|
|
} else if String(apiToCheck.Api_file) != "" && String(apiToCheck.Removed_api_file) != "" {
|
2018-09-05 02:14:32 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2020-04-09 01:10:17 +02:00
|
|
|
// Used by xsd_config
|
2018-09-05 02:14:32 +02:00
|
|
|
type ApiFilePath interface {
|
|
|
|
ApiFilePath() android.Path
|
|
|
|
}
|
|
|
|
|
2020-04-09 01:10:17 +02:00
|
|
|
// Provider of information about API stubs, used by java_sdk_library.
|
|
|
|
type ApiStubsProvider interface {
|
|
|
|
ApiFilePath
|
2020-04-09 02:08:11 +02:00
|
|
|
RemovedApiFilePath() android.Path
|
2020-04-09 01:10:17 +02:00
|
|
|
StubsSrcJar() android.Path
|
|
|
|
}
|
|
|
|
|
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
|
2019-08-12 22:11:40 +02:00
|
|
|
case ".docs.zip":
|
|
|
|
return android.Paths{j.docZip}, nil
|
2019-05-29 23:40:35 +02:00
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
|
|
|
|
}
|
2018-02-23 20:18:47 +01:00
|
|
|
}
|
|
|
|
|
2019-07-09 01:48:04 +02:00
|
|
|
// javadoc converts .java source files to documentation using javadoc.
|
2018-01-11 01:06:12 +01:00
|
|
|
func JavadocFactory() android.Module {
|
|
|
|
module := &Javadoc{}
|
|
|
|
|
|
|
|
module.AddProperties(&module.properties)
|
|
|
|
|
|
|
|
InitDroiddocModule(module, android.HostAndDeviceSupported)
|
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
2019-07-09 01:48:04 +02:00
|
|
|
// javadoc_host converts .java source files to documentation using javadoc.
|
2018-01-11 01:06:12 +01:00
|
|
|
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
|
|
|
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-20 18:03:43 +01:00
|
|
|
func (j *Javadoc) sdkVersion() sdkSpec {
|
|
|
|
return sdkSpecFrom(String(j.properties.Sdk_version))
|
2018-06-26 00:48:06 +02:00
|
|
|
}
|
|
|
|
|
2019-10-11 14:50:28 +02:00
|
|
|
func (j *Javadoc) systemModules() string {
|
|
|
|
return proptools.String(j.properties.System_modules)
|
|
|
|
}
|
|
|
|
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-20 18:03:43 +01:00
|
|
|
func (j *Javadoc) minSdkVersion() sdkSpec {
|
2018-06-26 00:48:06 +02:00
|
|
|
return j.sdkVersion()
|
|
|
|
}
|
|
|
|
|
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-20 18:03:43 +01:00
|
|
|
func (j *Javadoc) targetSdkVersion() sdkSpec {
|
2018-10-31 23:28:47 +01:00
|
|
|
return j.sdkVersion()
|
|
|
|
}
|
|
|
|
|
2018-01-11 01:06:12 +01:00
|
|
|
func (j *Javadoc) addDeps(ctx android.BottomUpMutatorContext) {
|
|
|
|
if ctx.Device() {
|
2019-06-07 11:44:37 +02:00
|
|
|
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
2019-10-28 23:10:03 +01:00
|
|
|
if sdkDep.useDefaultLibs {
|
|
|
|
ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...)
|
|
|
|
ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules)
|
|
|
|
if sdkDep.hasFrameworkLibs() {
|
|
|
|
ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...)
|
2018-04-18 02:38:36 +02:00
|
|
|
}
|
2019-10-28 23:10:03 +01:00
|
|
|
} else if sdkDep.useModule {
|
2019-10-17 23:23:50 +02:00
|
|
|
ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.bootclasspath...)
|
2019-10-11 14:50:28 +02:00
|
|
|
ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules)
|
2019-10-17 23:23:50 +02:00
|
|
|
ctx.AddVariationDependencies(nil, java9LibTag, sdkDep.java9Classpath...)
|
2018-01-11 01:06:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-29 23:10:52 +02:00
|
|
|
ctx.AddVariationDependencies(nil, libTag, j.properties.Libs...)
|
2018-01-11 01:06:12 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-08-20 15:49:19 +02:00
|
|
|
// TODO: remove the duplication between this and the one in gen.go
|
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))
|
2019-06-15 03:51:47 +02:00
|
|
|
var aidlSrcs android.Paths
|
2018-05-23 11:42:04 +02:00
|
|
|
|
2019-08-16 14:12:10 +02:00
|
|
|
aidlIncludeFlags := genAidlIncludeFlags(srcFiles)
|
|
|
|
|
2018-05-23 11:42:04 +02:00
|
|
|
for _, srcFile := range srcFiles {
|
|
|
|
switch srcFile.Ext() {
|
|
|
|
case ".aidl":
|
2019-06-15 03:51:47 +02:00
|
|
|
aidlSrcs = append(aidlSrcs, srcFile)
|
2019-08-20 15:49:19 +02:00
|
|
|
case ".logtags":
|
|
|
|
javaFile := genLogtags(ctx, srcFile)
|
|
|
|
outSrcFiles = append(outSrcFiles, javaFile)
|
2018-05-23 11:42:04 +02:00
|
|
|
default:
|
|
|
|
outSrcFiles = append(outSrcFiles, srcFile)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-15 03:51:47 +02:00
|
|
|
// Process all aidl files together to support sharding them into one or more rules that produce srcjars.
|
|
|
|
if len(aidlSrcs) > 0 {
|
|
|
|
srcJarFiles := genAidl(ctx, aidlSrcs, flags.aidlFlags+aidlIncludeFlags, flags.aidlDeps)
|
|
|
|
outSrcFiles = append(outSrcFiles, srcJarFiles...)
|
|
|
|
}
|
|
|
|
|
2018-05-23 11:42:04 +02:00
|
|
|
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 {
|
2019-10-17 23:23:50 +02:00
|
|
|
ctx.AddMissingDependencies(sdkDep.bootclasspath)
|
|
|
|
ctx.AddMissingDependencies(sdkDep.java9Classpath)
|
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...)
|
2020-02-08 21:26:29 +01:00
|
|
|
deps.aidlPreprocess = sdkDep.aidl
|
|
|
|
} else {
|
|
|
|
deps.aidlPreprocess = sdkDep.aidl
|
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()...)
|
2019-11-19 20:44:10 +01:00
|
|
|
} else if sm, ok := module.(SystemModulesProvider); ok {
|
2019-10-11 14:50:28 +02:00
|
|
|
// A system modules dependency has been added to the bootclasspath
|
|
|
|
// so add its libs to the bootclasspath.
|
2019-11-19 20:44:10 +01:00
|
|
|
deps.bootClasspath = append(deps.bootClasspath, sm.HeaderJars()...)
|
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()...)
|
2019-07-10 09:59:31 +02:00
|
|
|
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
|
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)
|
|
|
|
}
|
2019-10-17 23:23:50 +02:00
|
|
|
case java9LibTag:
|
|
|
|
switch dep := module.(type) {
|
|
|
|
case Dependency:
|
|
|
|
deps.java9Classpath = append(deps.java9Classpath, dep.HeaderJars()...)
|
|
|
|
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")
|
|
|
|
}
|
2019-11-19 20:44:10 +01:00
|
|
|
sm := module.(SystemModulesProvider)
|
|
|
|
outputDir, outputDeps := sm.OutputDirAndDeps()
|
|
|
|
deps.systemModules = &systemModules{outputDir, outputDeps}
|
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)
|
2019-09-13 13:56:14 +02:00
|
|
|
|
|
|
|
filterByPackage := func(srcs []android.Path, filterPackages []string) []android.Path {
|
|
|
|
if filterPackages == nil {
|
|
|
|
return srcs
|
|
|
|
}
|
|
|
|
filtered := []android.Path{}
|
|
|
|
for _, src := range srcs {
|
|
|
|
if src.Ext() != ".java" {
|
|
|
|
// Don't filter-out non-Java (=generated sources) by package names. This is not ideal,
|
|
|
|
// but otherwise metalava emits stub sources having references to the generated AIDL classes
|
|
|
|
// in filtered-out pacages (e.g. com.android.internal.*).
|
|
|
|
// TODO(b/141149570) We need to fix this by introducing default private constructors or
|
|
|
|
// fixing metalava to not emit constructors having references to unknown classes.
|
|
|
|
filtered = append(filtered, src)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
packageName := strings.ReplaceAll(filepath.Dir(src.Rel()), "/", ".")
|
2020-02-11 16:54:35 +01:00
|
|
|
if android.HasAnyPrefix(packageName, filterPackages) {
|
|
|
|
filtered = append(filtered, src)
|
2019-09-13 13:56:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return filtered
|
|
|
|
}
|
|
|
|
srcFiles = filterByPackage(srcFiles, j.properties.Filter_packages)
|
|
|
|
|
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
|
|
|
|
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
|
2019-07-11 20:11:35 +02:00
|
|
|
j.args, err = android.Expand(String(j.properties.Args), func(name string) (string, error) {
|
2018-09-05 02:14:32 +02:00
|
|
|
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 {
|
2019-07-11 20:11:35 +02:00
|
|
|
return paths, nil
|
2018-09-05 02:14:32 +02:00
|
|
|
} else {
|
2019-07-11 20:11:35 +02:00
|
|
|
return "", fmt.Errorf("unknown location label %q, expecting one of %q",
|
2019-02-11 16:38:42 +01:00
|
|
|
label, strings.Join(argFileLabels, ", "))
|
2018-09-05 02:14:32 +02:00
|
|
|
}
|
|
|
|
} else if name == "genDir" {
|
2019-07-11 20:11:35 +02:00
|
|
|
return android.PathForModuleGen(ctx).String(), nil
|
2018-09-05 02:14:32 +02:00
|
|
|
}
|
2019-07-11 20:11:35 +02:00
|
|
|
return "", fmt.Errorf("unknown variable '$(%s)'", name)
|
2018-09-05 02:14:32 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
2019-07-16 07:53:46 +02:00
|
|
|
j.docZip = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"docs.zip")
|
|
|
|
|
|
|
|
outDir := android.PathForModuleOut(ctx, "out")
|
|
|
|
srcJarDir := android.PathForModuleOut(ctx, "srcjars")
|
2018-01-11 01:06:12 +01:00
|
|
|
|
2019-07-16 07:53:46 +02:00
|
|
|
j.stubsSrcJar = nil
|
|
|
|
|
|
|
|
rule := android.NewRuleBuilder()
|
|
|
|
|
|
|
|
rule.Command().Text("rm -rf").Text(outDir.String())
|
|
|
|
rule.Command().Text("mkdir -p").Text(outDir.String())
|
|
|
|
|
|
|
|
srcJarList := zipSyncCmd(ctx, rule, srcJarDir, j.srcJars)
|
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))
|
2019-07-16 07:53:46 +02:00
|
|
|
|
|
|
|
cmd := javadocSystemModulesCmd(ctx, rule, j.srcFiles, outDir, srcJarDir, srcJarList,
|
|
|
|
deps.systemModules, deps.classpath, j.sourcepaths)
|
|
|
|
|
2019-10-28 19:37:20 +01:00
|
|
|
cmd.FlagWithArg("-source ", javaVersion.String()).
|
2019-07-16 07:53:46 +02:00
|
|
|
Flag("-J-Xmx1024m").
|
|
|
|
Flag("-XDignore.symbol.file").
|
|
|
|
Flag("-Xdoclint:none")
|
|
|
|
|
|
|
|
rule.Command().
|
|
|
|
BuiltTool(ctx, "soong_zip").
|
|
|
|
Flag("-write_if_changed").
|
|
|
|
Flag("-d").
|
|
|
|
FlagWithOutput("-o ", j.docZip).
|
|
|
|
FlagWithArg("-C ", outDir.String()).
|
|
|
|
FlagWithArg("-D ", outDir.String())
|
|
|
|
|
|
|
|
rule.Restat()
|
|
|
|
|
|
|
|
zipSyncCleanupCmd(rule, srcJarDir)
|
|
|
|
|
|
|
|
rule.Build(pctx, ctx, "javadoc", "javadoc")
|
2018-01-11 01:06:12 +01:00
|
|
|
}
|
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
//
|
|
|
|
// Droiddoc
|
|
|
|
//
|
|
|
|
type Droiddoc struct {
|
|
|
|
Javadoc
|
|
|
|
|
|
|
|
properties DroiddocProperties
|
|
|
|
apiFile android.WritablePath
|
|
|
|
privateApiFile android.WritablePath
|
|
|
|
removedApiFile android.WritablePath
|
|
|
|
removedDexApiFile android.WritablePath
|
|
|
|
|
|
|
|
checkCurrentApiTimestamp android.WritablePath
|
|
|
|
updateCurrentApiTimestamp android.WritablePath
|
|
|
|
checkLastReleasedApiTimestamp android.WritablePath
|
|
|
|
|
|
|
|
apiFilePath android.Path
|
|
|
|
}
|
|
|
|
|
2019-07-09 01:48:04 +02:00
|
|
|
// droiddoc converts .java source files to documentation using doclava or dokka.
|
2018-08-01 21:48:00 +02:00
|
|
|
func DroiddocFactory() android.Module {
|
|
|
|
module := &Droiddoc{}
|
|
|
|
|
|
|
|
module.AddProperties(&module.properties,
|
|
|
|
&module.Javadoc.properties)
|
|
|
|
|
|
|
|
InitDroiddocModule(module, android.HostAndDeviceSupported)
|
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
2019-07-09 01:48:04 +02:00
|
|
|
// droiddoc_host converts .java source files to documentation using doclava or dokka.
|
2018-08-01 21:48:00 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-07-16 01:13:59 +02:00
|
|
|
func (d *Droiddoc) doclavaDocsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, docletPath classpath) {
|
2020-02-22 01:55:46 +01:00
|
|
|
buildNumberFile := ctx.Config().BuildNumberFile(ctx)
|
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.
|
2019-07-16 01:13:59 +02:00
|
|
|
cmd.FlagWithArg("-source ", "1.8").
|
|
|
|
Flag("-J-Xmx1600m").
|
|
|
|
Flag("-J-XX:-OmitStackTraceInFastThrow").
|
|
|
|
Flag("-XDignore.symbol.file").
|
|
|
|
FlagWithArg("-doclet ", "com.google.doclava.Doclava").
|
|
|
|
FlagWithInputList("-docletpath ", docletPath.Paths(), ":").
|
2020-02-22 01:55:46 +01:00
|
|
|
FlagWithArg("-hdf page.build ", ctx.Config().BuildId()+"-$(cat "+buildNumberFile.String()+")").OrderOnly(buildNumberFile).
|
2019-09-13 00:05:13 +02:00
|
|
|
FlagWithArg("-hdf page.now ", `"$(date -d @$(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 {
|
2019-07-16 01:13:59 +02:00
|
|
|
cmd.FlagWithArg("-templatedir ", t.dir.String()).Implicits(t.deps)
|
2018-08-01 21:48:00 +02:00
|
|
|
} else {
|
2019-12-19 11:21:09 +01:00
|
|
|
ctx.PropertyErrorf("custom_template", "module %q is not a droiddoc_exported_dir", 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-07-16 01:13:59 +02:00
|
|
|
htmlDir := android.PathForModuleSrc(ctx, d.properties.Html_dirs[0])
|
|
|
|
cmd.FlagWithArg("-htmldir ", htmlDir.String()).
|
|
|
|
Implicits(android.PathsForModuleSrc(ctx, []string{filepath.Join(d.properties.Html_dirs[0], "**/*")}))
|
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-07-16 01:13:59 +02:00
|
|
|
htmlDir2 := android.PathForModuleSrc(ctx, d.properties.Html_dirs[1])
|
|
|
|
cmd.FlagWithArg("-htmldir2 ", htmlDir2.String()).
|
|
|
|
Implicits(android.PathsForModuleSrc(ctx, []string{filepath.Join(d.properties.Html_dirs[1], "**/*")}))
|
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)
|
2019-07-16 01:13:59 +02:00
|
|
|
cmd.FlagForEachInput("-knowntags ", knownTags)
|
2018-04-20 03:03:39 +02:00
|
|
|
|
2019-07-16 01:13:59 +02:00
|
|
|
cmd.FlagForEachArg("-hdf ", d.properties.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))
|
2019-07-16 01:13:59 +02:00
|
|
|
cmd.FlagWithOutput("-proofread ", proofreadFile)
|
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".
|
2019-07-16 01:13:59 +02:00
|
|
|
cmd.FlagWithArg("-todo ", String(d.properties.Todo_file)).
|
|
|
|
ImplicitOutput(android.PathForModuleOut(ctx, 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))
|
2019-07-16 01:13:59 +02:00
|
|
|
cmd.FlagWithArg("-resourcesdir ", resourcesDir.String())
|
2018-08-01 21:48:00 +02:00
|
|
|
}
|
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.
|
2019-07-16 01:13:59 +02:00
|
|
|
cmd.FlagWithArg("-resourcesoutdir ", String(d.properties.Resourcesoutdir))
|
2018-08-01 21:48:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-16 01:13:59 +02:00
|
|
|
func (d *Droiddoc) stubsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsDir android.WritablePath) {
|
2019-09-01 21:49:45 +02:00
|
|
|
if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") ||
|
|
|
|
apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released") ||
|
2018-09-05 02:14:32 +02:00
|
|
|
String(d.properties.Api_filename) != "" {
|
2019-07-16 01:13:59 +02:00
|
|
|
|
2018-05-05 03:49:16 +02:00
|
|
|
d.apiFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_api.txt")
|
2019-07-16 01:13:59 +02:00
|
|
|
cmd.FlagWithOutput("-api ", d.apiFile)
|
2018-07-24 04:19:26 +02:00
|
|
|
d.apiFilePath = d.apiFile
|
2018-03-14 00:17:01 +01:00
|
|
|
}
|
|
|
|
|
2019-09-01 21:49:45 +02:00
|
|
|
if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") ||
|
|
|
|
apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released") ||
|
2018-09-05 02:14:32 +02:00
|
|
|
String(d.properties.Removed_api_filename) != "" {
|
2018-05-05 03:49:16 +02:00
|
|
|
d.removedApiFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_removed.txt")
|
2019-07-16 01:13:59 +02:00
|
|
|
cmd.FlagWithOutput("-removedApi ", d.removedApiFile)
|
2018-05-05 03:49:16 +02: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))
|
2019-07-16 01:13:59 +02:00
|
|
|
cmd.FlagWithOutput("-removedDexApi ", d.removedDexApiFile)
|
2018-04-24 17:23:29 +02:00
|
|
|
}
|
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
if BoolDefault(d.properties.Create_stubs, true) {
|
2019-07-16 01:13:59 +02:00
|
|
|
cmd.FlagWithArg("-stubs ", 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) {
|
2019-07-16 01:13:59 +02:00
|
|
|
cmd.FlagWithArg("-sdkvalues ", android.PathForModuleOut(ctx, "out").String())
|
2018-04-20 03:03:39 +02:00
|
|
|
}
|
2018-08-01 21:48:00 +02:00
|
|
|
}
|
2018-04-20 03:03:39 +02:00
|
|
|
|
2019-07-16 01:13:59 +02:00
|
|
|
func (d *Droiddoc) postDoclavaCmds(ctx android.ModuleContext, rule *android.RuleBuilder) {
|
2018-08-01 21:48:00 +02:00
|
|
|
if String(d.properties.Static_doc_index_redirect) != "" {
|
2019-07-16 01:13:59 +02:00
|
|
|
staticDocIndexRedirect := android.PathForModuleSrc(ctx, String(d.properties.Static_doc_index_redirect))
|
|
|
|
rule.Command().Text("cp").
|
|
|
|
Input(staticDocIndexRedirect).
|
|
|
|
Output(android.PathForModuleOut(ctx, "out", "index.html"))
|
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) != "" {
|
2019-07-16 01:13:59 +02:00
|
|
|
staticDocProperties := android.PathForModuleSrc(ctx, String(d.properties.Static_doc_properties))
|
|
|
|
rule.Command().Text("cp").
|
|
|
|
Input(staticDocProperties).
|
|
|
|
Output(android.PathForModuleOut(ctx, "out", "source.properties"))
|
2018-06-04 20:28:01 +02:00
|
|
|
}
|
2018-08-01 21:48:00 +02:00
|
|
|
}
|
2018-06-04 20:28:01 +02:00
|
|
|
|
2019-07-16 01:13:59 +02:00
|
|
|
func javadocCmd(ctx android.ModuleContext, rule *android.RuleBuilder, srcs android.Paths,
|
2019-07-16 07:53:46 +02:00
|
|
|
outDir, srcJarDir, srcJarList android.Path, sourcepaths android.Paths) *android.RuleBuilderCommand {
|
2018-09-05 02:14:32 +02:00
|
|
|
|
2019-07-16 01:13:59 +02:00
|
|
|
cmd := rule.Command().
|
|
|
|
BuiltTool(ctx, "soong_javac_wrapper").Tool(config.JavadocCmd(ctx)).
|
|
|
|
Flag(config.JavacVmFlags).
|
|
|
|
FlagWithArg("-encoding ", "UTF-8").
|
|
|
|
FlagWithRspFileInputList("@", srcs).
|
|
|
|
FlagWithInput("@", srcJarList)
|
|
|
|
|
|
|
|
// TODO(ccross): 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(sourcepaths) > 0 {
|
|
|
|
cmd.FlagWithList("-sourcepath ", sourcepaths.Strings(), ":")
|
|
|
|
} else {
|
|
|
|
cmd.FlagWithArg("-sourcepath ", srcJarDir.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd.FlagWithArg("-d ", outDir.String()).
|
|
|
|
Flag("-quiet")
|
|
|
|
|
|
|
|
return cmd
|
2018-09-05 02:14:32 +02:00
|
|
|
}
|
|
|
|
|
2019-07-16 07:53:46 +02:00
|
|
|
func javadocSystemModulesCmd(ctx android.ModuleContext, rule *android.RuleBuilder, srcs android.Paths,
|
|
|
|
outDir, srcJarDir, srcJarList android.Path, systemModules *systemModules,
|
|
|
|
classpath classpath, sourcepaths android.Paths) *android.RuleBuilderCommand {
|
|
|
|
|
|
|
|
cmd := javadocCmd(ctx, rule, srcs, outDir, srcJarDir, srcJarList, sourcepaths)
|
|
|
|
|
|
|
|
flag, deps := systemModules.FormJavaSystemModulesPath(ctx.Device())
|
|
|
|
cmd.Flag(flag).Implicits(deps)
|
|
|
|
|
|
|
|
cmd.FlagWithArg("--patch-module ", "java.base=.")
|
|
|
|
|
|
|
|
if len(classpath) > 0 {
|
|
|
|
cmd.FlagWithInputList("-classpath ", classpath.Paths(), ":")
|
|
|
|
}
|
|
|
|
|
|
|
|
return cmd
|
2018-09-05 02:14:32 +02:00
|
|
|
}
|
|
|
|
|
2019-07-16 07:53:46 +02:00
|
|
|
func javadocBootclasspathCmd(ctx android.ModuleContext, rule *android.RuleBuilder, srcs android.Paths,
|
|
|
|
outDir, srcJarDir, srcJarList android.Path, bootclasspath, classpath classpath,
|
|
|
|
sourcepaths android.Paths) *android.RuleBuilderCommand {
|
|
|
|
|
|
|
|
cmd := javadocCmd(ctx, rule, srcs, outDir, srcJarDir, srcJarList, sourcepaths)
|
|
|
|
|
|
|
|
if len(bootclasspath) == 0 && ctx.Device() {
|
|
|
|
// explicitly specify -bootclasspath "" if the bootclasspath is empty to
|
|
|
|
// ensure java does not fall back to the default bootclasspath.
|
|
|
|
cmd.FlagWithArg("-bootclasspath ", `""`)
|
|
|
|
} else if len(bootclasspath) > 0 {
|
|
|
|
cmd.FlagWithInputList("-bootclasspath ", bootclasspath.Paths(), ":")
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(classpath) > 0 {
|
|
|
|
cmd.FlagWithInputList("-classpath ", classpath.Paths(), ":")
|
|
|
|
}
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
2019-07-16 01:13:59 +02:00
|
|
|
func dokkaCmd(ctx android.ModuleContext, rule *android.RuleBuilder,
|
|
|
|
outDir, srcJarDir android.Path, bootclasspath, classpath classpath) *android.RuleBuilderCommand {
|
|
|
|
|
|
|
|
// Dokka doesn't support bootClasspath, so combine these two classpath vars for Dokka.
|
|
|
|
dokkaClasspath := append(bootclasspath.Paths(), classpath.Paths()...)
|
|
|
|
|
|
|
|
return rule.Command().
|
|
|
|
BuiltTool(ctx, "dokka").
|
|
|
|
Flag(config.JavacVmFlags).
|
|
|
|
Flag(srcJarDir.String()).
|
|
|
|
FlagWithInputList("-classpath ", dokkaClasspath, ":").
|
|
|
|
FlagWithArg("-format ", "dac").
|
|
|
|
FlagWithArg("-dacRoot ", "/reference/kotlin").
|
|
|
|
FlagWithArg("-output ", outDir.String())
|
2018-09-05 02:14:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
|
|
deps := d.Javadoc.collectDeps(ctx)
|
|
|
|
|
2019-07-16 07:53:46 +02:00
|
|
|
d.Javadoc.docZip = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"docs.zip")
|
|
|
|
d.Javadoc.stubsSrcJar = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"stubs.srcjar")
|
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
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")}
|
|
|
|
|
2019-07-16 01:13:59 +02:00
|
|
|
outDir := android.PathForModuleOut(ctx, "out")
|
|
|
|
srcJarDir := android.PathForModuleOut(ctx, "srcjars")
|
|
|
|
stubsDir := android.PathForModuleOut(ctx, "stubsDir")
|
2018-09-05 02:14:32 +02:00
|
|
|
|
2019-07-16 01:13:59 +02:00
|
|
|
rule := android.NewRuleBuilder()
|
2018-09-05 02:14:32 +02:00
|
|
|
|
2019-07-16 01:13:59 +02:00
|
|
|
rule.Command().Text("rm -rf").Text(outDir.String()).Text(stubsDir.String())
|
|
|
|
rule.Command().Text("mkdir -p").Text(outDir.String()).Text(stubsDir.String())
|
|
|
|
|
|
|
|
srcJarList := zipSyncCmd(ctx, rule, srcJarDir, d.Javadoc.srcJars)
|
|
|
|
|
|
|
|
var cmd *android.RuleBuilderCommand
|
|
|
|
if Bool(d.properties.Dokka_enabled) {
|
|
|
|
cmd = dokkaCmd(ctx, rule, outDir, srcJarDir, deps.bootClasspath, deps.classpath)
|
|
|
|
} else {
|
2019-07-16 07:53:46 +02:00
|
|
|
cmd = javadocBootclasspathCmd(ctx, rule, d.Javadoc.srcFiles, outDir, srcJarDir, srcJarList,
|
2019-07-16 01:13:59 +02:00
|
|
|
deps.bootClasspath, deps.classpath, d.Javadoc.sourcepaths)
|
2018-09-05 02:14:32 +02:00
|
|
|
}
|
|
|
|
|
2019-07-16 01:13:59 +02:00
|
|
|
d.stubsFlags(ctx, cmd, stubsDir)
|
|
|
|
|
|
|
|
cmd.Flag(d.Javadoc.args).Implicits(d.Javadoc.argFiles)
|
|
|
|
|
2019-12-19 15:27:08 +01:00
|
|
|
if d.properties.Compat_config != nil {
|
|
|
|
compatConfig := android.PathForModuleSrc(ctx, String(d.properties.Compat_config))
|
|
|
|
cmd.FlagWithInput("-compatconfig ", compatConfig)
|
|
|
|
}
|
|
|
|
|
2019-07-16 01:13:59 +02:00
|
|
|
var desc string
|
2018-09-05 02:14:32 +02:00
|
|
|
if Bool(d.properties.Dokka_enabled) {
|
2019-07-16 01:13:59 +02:00
|
|
|
desc = "dokka"
|
2018-09-05 02:14:32 +02:00
|
|
|
} else {
|
2019-07-16 01:13:59 +02:00
|
|
|
d.doclavaDocsFlags(ctx, cmd, classpath{jsilver, doclava})
|
|
|
|
|
|
|
|
for _, o := range d.Javadoc.properties.Out {
|
|
|
|
cmd.ImplicitOutput(android.PathForModuleGen(ctx, o))
|
|
|
|
}
|
|
|
|
|
|
|
|
d.postDoclavaCmds(ctx, rule)
|
|
|
|
desc = "doclava"
|
2018-09-05 02:14:32 +02:00
|
|
|
}
|
|
|
|
|
2019-07-16 01:13:59 +02:00
|
|
|
rule.Command().
|
|
|
|
BuiltTool(ctx, "soong_zip").
|
|
|
|
Flag("-write_if_changed").
|
|
|
|
Flag("-d").
|
|
|
|
FlagWithOutput("-o ", d.docZip).
|
|
|
|
FlagWithArg("-C ", outDir.String()).
|
|
|
|
FlagWithArg("-D ", outDir.String())
|
|
|
|
|
|
|
|
rule.Command().
|
|
|
|
BuiltTool(ctx, "soong_zip").
|
|
|
|
Flag("-write_if_changed").
|
|
|
|
Flag("-jar").
|
|
|
|
FlagWithOutput("-o ", d.stubsSrcJar).
|
|
|
|
FlagWithArg("-C ", stubsDir.String()).
|
|
|
|
FlagWithArg("-D ", stubsDir.String())
|
|
|
|
|
|
|
|
rule.Restat()
|
|
|
|
|
|
|
|
zipSyncCleanupCmd(rule, srcJarDir)
|
|
|
|
|
|
|
|
rule.Build(pctx, ctx, "javadoc", desc)
|
|
|
|
|
2019-09-01 21:49:45 +02:00
|
|
|
if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") &&
|
2018-09-05 02:14:32 +02:00
|
|
|
!ctx.Config().IsPdkBuild() {
|
2019-07-16 01:13:59 +02:00
|
|
|
|
|
|
|
apiFile := android.PathForModuleSrc(ctx, String(d.properties.Check_api.Current.Api_file))
|
|
|
|
removedApiFile := android.PathForModuleSrc(ctx, String(d.properties.Check_api.Current.Removed_api_file))
|
2018-09-05 02:14:32 +02:00
|
|
|
|
|
|
|
d.checkCurrentApiTimestamp = android.PathForModuleOut(ctx, "check_current_api.timestamp")
|
2019-07-16 01:13:59 +02:00
|
|
|
|
|
|
|
rule := android.NewRuleBuilder()
|
|
|
|
|
|
|
|
rule.Command().Text("( true")
|
|
|
|
|
|
|
|
rule.Command().
|
|
|
|
BuiltTool(ctx, "apicheck").
|
|
|
|
Flag("-JXmx1024m").
|
|
|
|
FlagWithInputList("-Jclasspath\\ ", checkApiClasspath.Paths(), ":").
|
|
|
|
OptionalFlag(d.properties.Check_api.Current.Args).
|
|
|
|
Input(apiFile).
|
|
|
|
Input(d.apiFile).
|
|
|
|
Input(removedApiFile).
|
|
|
|
Input(d.removedApiFile)
|
|
|
|
|
|
|
|
msg := 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())
|
|
|
|
|
|
|
|
rule.Command().
|
|
|
|
Text("touch").Output(d.checkCurrentApiTimestamp).
|
|
|
|
Text(") || (").
|
|
|
|
Text("echo").Flag("-e").Flag(`"` + msg + `"`).
|
|
|
|
Text("; exit 38").
|
|
|
|
Text(")")
|
|
|
|
|
|
|
|
rule.Build(pctx, ctx, "doclavaCurrentApiCheck", "check current API")
|
2018-09-05 02:14:32 +02:00
|
|
|
|
|
|
|
d.updateCurrentApiTimestamp = android.PathForModuleOut(ctx, "update_current_api.timestamp")
|
2019-07-16 01:13:59 +02:00
|
|
|
|
|
|
|
// update API rule
|
|
|
|
rule = android.NewRuleBuilder()
|
|
|
|
|
|
|
|
rule.Command().Text("( true")
|
|
|
|
|
|
|
|
rule.Command().
|
|
|
|
Text("cp").Flag("-f").
|
|
|
|
Input(d.apiFile).Flag(apiFile.String())
|
|
|
|
|
|
|
|
rule.Command().
|
|
|
|
Text("cp").Flag("-f").
|
|
|
|
Input(d.removedApiFile).Flag(removedApiFile.String())
|
|
|
|
|
|
|
|
msg = "failed to update public API"
|
|
|
|
|
|
|
|
rule.Command().
|
|
|
|
Text("touch").Output(d.updateCurrentApiTimestamp).
|
|
|
|
Text(") || (").
|
|
|
|
Text("echo").Flag("-e").Flag(`"` + msg + `"`).
|
|
|
|
Text("; exit 38").
|
|
|
|
Text(")")
|
|
|
|
|
|
|
|
rule.Build(pctx, ctx, "doclavaCurrentApiUpdate", "update current API")
|
2018-09-05 02:14:32 +02:00
|
|
|
}
|
|
|
|
|
2019-09-01 21:49:45 +02:00
|
|
|
if apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released") &&
|
2018-09-05 02:14:32 +02:00
|
|
|
!ctx.Config().IsPdkBuild() {
|
2019-07-16 01:13:59 +02:00
|
|
|
|
|
|
|
apiFile := android.PathForModuleSrc(ctx, String(d.properties.Check_api.Last_released.Api_file))
|
|
|
|
removedApiFile := android.PathForModuleSrc(ctx, String(d.properties.Check_api.Last_released.Removed_api_file))
|
2018-09-05 02:14:32 +02:00
|
|
|
|
|
|
|
d.checkLastReleasedApiTimestamp = android.PathForModuleOut(ctx, "check_last_released_api.timestamp")
|
2019-07-16 01:13:59 +02:00
|
|
|
|
|
|
|
rule := android.NewRuleBuilder()
|
|
|
|
|
|
|
|
rule.Command().
|
|
|
|
Text("(").
|
|
|
|
BuiltTool(ctx, "apicheck").
|
|
|
|
Flag("-JXmx1024m").
|
|
|
|
FlagWithInputList("-Jclasspath\\ ", checkApiClasspath.Paths(), ":").
|
|
|
|
OptionalFlag(d.properties.Check_api.Last_released.Args).
|
|
|
|
Input(apiFile).
|
|
|
|
Input(d.apiFile).
|
|
|
|
Input(removedApiFile).
|
|
|
|
Input(d.removedApiFile)
|
|
|
|
|
|
|
|
msg := `\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`
|
|
|
|
|
|
|
|
rule.Command().
|
|
|
|
Text("touch").Output(d.checkLastReleasedApiTimestamp).
|
|
|
|
Text(") || (").
|
|
|
|
Text("echo").Flag("-e").Flag(`"` + msg + `"`).
|
|
|
|
Text("; exit 38").
|
|
|
|
Text(")")
|
|
|
|
|
|
|
|
rule.Build(pctx, ctx, "doclavaLastApiCheck", "check last API")
|
2018-09-05 02:14:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Droidstubs
|
|
|
|
//
|
|
|
|
type Droidstubs struct {
|
|
|
|
Javadoc
|
2019-11-12 20:39:36 +01:00
|
|
|
android.SdkBase
|
2018-09-05 02:14:32 +02:00
|
|
|
|
2018-10-22 16:55:04 +02:00
|
|
|
properties DroidstubsProperties
|
|
|
|
apiFile android.WritablePath
|
|
|
|
apiXmlFile android.WritablePath
|
|
|
|
lastReleasedApiXmlFile android.WritablePath
|
|
|
|
privateApiFile android.WritablePath
|
|
|
|
removedApiFile android.WritablePath
|
|
|
|
removedDexApiFile android.WritablePath
|
|
|
|
nullabilityWarningsFile android.WritablePath
|
2018-09-05 02:14:32 +02:00
|
|
|
|
|
|
|
checkCurrentApiTimestamp android.WritablePath
|
|
|
|
updateCurrentApiTimestamp android.WritablePath
|
|
|
|
checkLastReleasedApiTimestamp android.WritablePath
|
2019-10-10 12:07:03 +02:00
|
|
|
apiLintTimestamp android.WritablePath
|
2019-11-01 13:42:39 +01:00
|
|
|
apiLintReport android.WritablePath
|
2018-09-05 02:14:32 +02:00
|
|
|
|
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
|
2019-10-10 20:29:11 +02:00
|
|
|
|
|
|
|
metadataZip android.WritablePath
|
|
|
|
metadataDir android.WritablePath
|
2018-09-05 02:14:32 +02:00
|
|
|
}
|
|
|
|
|
2019-07-09 01:48:04 +02:00
|
|
|
// droidstubs passes sources files through Metalava to generate stub .java files that only contain the API to be
|
|
|
|
// documented, filtering out hidden classes and methods. The resulting .java files are intended to be passed to
|
|
|
|
// a droiddoc module to generate documentation.
|
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)
|
2019-11-12 20:39:36 +01:00
|
|
|
android.InitSdkAwareModule(module)
|
2018-09-05 02:14:32 +02:00
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
2019-07-09 01:48:04 +02:00
|
|
|
// droidstubs_host passes sources files through Metalava to generate stub .java files that only contain the API
|
|
|
|
// to be documented, filtering out hidden classes and methods. The resulting .java files are intended to be
|
|
|
|
// passed to a droiddoc_host module to generate documentation. Use a droidstubs_host instead of a droidstubs
|
|
|
|
// module when symbols needed by the source files are provided by java_library_host modules.
|
2018-09-05 02:14:32 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2020-04-09 02:08:11 +02:00
|
|
|
func (d *Droidstubs) RemovedApiFilePath() android.Path {
|
|
|
|
return d.removedApiFile
|
|
|
|
}
|
|
|
|
|
2020-04-09 01:10:17 +02:00
|
|
|
func (d *Droidstubs) StubsSrcJar() android.Path {
|
|
|
|
return d.stubsSrcJar
|
|
|
|
}
|
|
|
|
|
2018-09-05 02:14:32 +02:00
|
|
|
func (d *Droidstubs) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|
|
|
d.Javadoc.addDeps(ctx)
|
|
|
|
|
2020-05-10 20:32:20 +02:00
|
|
|
// If requested clear any properties that provide information about the latest version
|
|
|
|
// of an API and which reference non-existent modules.
|
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)
|
2020-05-10 20:32:20 +02:00
|
|
|
|
|
|
|
// If the new_since references a module, e.g. :module-latest-api and the module
|
|
|
|
// does not exist then clear it.
|
|
|
|
newSinceSrc := d.properties.Check_api.Api_lint.New_since
|
|
|
|
newSinceSrcModule := android.SrcIsModule(proptools.String(newSinceSrc))
|
|
|
|
if newSinceSrcModule != "" && !ctx.OtherModuleExists(newSinceSrcModule) {
|
|
|
|
d.properties.Check_api.Api_lint.New_since = nil
|
|
|
|
}
|
2019-02-28 06:24:05 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-04-08 19:18:03 +02:00
|
|
|
func (d *Droidstubs) stubsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsDir android.OptionalPath) {
|
2019-09-01 21:49:45 +02:00
|
|
|
if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") ||
|
|
|
|
apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released") ||
|
2018-09-05 02:14:32 +02:00
|
|
|
String(d.properties.Api_filename) != "" {
|
|
|
|
d.apiFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_api.txt")
|
2019-07-11 20:01:22 +02:00
|
|
|
cmd.FlagWithOutput("--api ", d.apiFile)
|
2018-09-05 02:14:32 +02:00
|
|
|
d.apiFilePath = d.apiFile
|
|
|
|
}
|
|
|
|
|
2019-09-01 21:49:45 +02:00
|
|
|
if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") ||
|
|
|
|
apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released") ||
|
2018-09-05 02:14:32 +02:00
|
|
|
String(d.properties.Removed_api_filename) != "" {
|
|
|
|
d.removedApiFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_removed.txt")
|
2019-07-11 20:01:22 +02:00
|
|
|
cmd.FlagWithOutput("--removed-api ", d.removedApiFile)
|
2018-09-05 02:14:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if String(d.properties.Removed_dex_api_filename) != "" {
|
|
|
|
d.removedDexApiFile = android.PathForModuleOut(ctx, String(d.properties.Removed_dex_api_filename))
|
2019-07-11 20:01:22 +02:00
|
|
|
cmd.FlagWithOutput("--removed-dex-api ", d.removedDexApiFile)
|
2018-09-05 02:14:32 +02:00
|
|
|
}
|
|
|
|
|
2018-08-22 19:22:08 +02:00
|
|
|
if Bool(d.properties.Write_sdk_values) {
|
2019-10-10 20:29:11 +02:00
|
|
|
d.metadataDir = android.PathForModuleOut(ctx, "metadata")
|
|
|
|
cmd.FlagWithArg("--sdk-values ", d.metadataDir.String())
|
2018-08-22 19:22:08 +02:00
|
|
|
}
|
|
|
|
|
2020-04-08 19:18:03 +02:00
|
|
|
if stubsDir.Valid() {
|
|
|
|
if Bool(d.properties.Create_doc_stubs) {
|
|
|
|
cmd.FlagWithArg("--doc-stubs ", stubsDir.String())
|
|
|
|
} else {
|
|
|
|
cmd.FlagWithArg("--stubs ", stubsDir.String())
|
|
|
|
cmd.Flag("--exclude-documentation-from-stubs")
|
|
|
|
}
|
2018-09-05 02:14:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-11 20:01:22 +02:00
|
|
|
func (d *Droidstubs) annotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
|
2018-09-05 02:14:32 +02:00
|
|
|
if Bool(d.properties.Annotations_enabled) {
|
2019-07-11 20:01:22 +02:00
|
|
|
cmd.Flag("--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) != ""
|
2019-07-11 20:01:22 +02:00
|
|
|
|
2019-11-04 11:26:47 +01:00
|
|
|
migratingNullability := String(d.properties.Previous_api) != ""
|
2018-09-14 15:25:48 +02:00
|
|
|
if migratingNullability {
|
2019-03-06 07:25:09 +01:00
|
|
|
previousApi := android.PathForModuleSrc(ctx, String(d.properties.Previous_api))
|
2019-07-11 20:01:22 +02:00
|
|
|
cmd.FlagWithInput("--migrate-nullness ", previousApi)
|
2018-09-14 15:25:48 +02:00
|
|
|
}
|
2019-07-11 20:01:22 +02:00
|
|
|
|
2018-11-14 19:45:46 +01:00
|
|
|
if s := String(d.properties.Validate_nullability_from_list); s != "" {
|
2019-07-11 20:01:22 +02:00
|
|
|
cmd.FlagWithInput("--validate-nullability-from-list ", android.PathForModuleSrc(ctx, s))
|
2018-11-14 19:45:46 +01:00
|
|
|
}
|
2019-07-11 20:01:22 +02: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")
|
2019-07-11 20:01:22 +02:00
|
|
|
cmd.FlagWithOutput("--nullability-warnings-txt ", d.nullabilityWarningsFile)
|
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")
|
2019-07-11 20:01:22 +02:00
|
|
|
cmd.FlagWithOutput("--extract-annotations ", d.annotationsZip)
|
2018-08-02 00:00:28 +02:00
|
|
|
|
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
|
|
|
}
|
2019-07-11 20:01:22 +02:00
|
|
|
|
|
|
|
d.mergeAnnoDirFlags(ctx, cmd)
|
|
|
|
|
2018-08-01 21:48:00 +02:00
|
|
|
// TODO(tnorbye): find owners to fix these warnings when annotation was enabled.
|
2019-07-11 20:01:22 +02:00
|
|
|
cmd.FlagWithArg("--hide ", "HiddenTypedefConstant").
|
|
|
|
FlagWithArg("--hide ", "SuperfluousPrefix").
|
|
|
|
FlagWithArg("--hide ", "AnnotationExtraction")
|
2018-08-01 21:48:00 +02:00
|
|
|
}
|
2019-07-11 20:01:22 +02:00
|
|
|
}
|
2018-10-21 23:13:19 +02:00
|
|
|
|
2019-07-11 20:01:22 +02:00
|
|
|
func (d *Droidstubs) mergeAnnoDirFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
|
|
|
|
ctx.VisitDirectDepsWithTag(metalavaMergeAnnotationsDirTag, func(m android.Module) {
|
|
|
|
if t, ok := m.(*ExportedDroiddocDir); ok {
|
|
|
|
cmd.FlagWithArg("--merge-qualifier-annotations ", t.dir.String()).Implicits(t.deps)
|
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("merge_annotations_dirs",
|
|
|
|
"module %q is not a metalava merge-annotations dir", ctx.OtherModuleName(m))
|
|
|
|
}
|
|
|
|
})
|
2018-10-21 23:13:19 +02:00
|
|
|
}
|
|
|
|
|
2019-07-11 20:01:22 +02:00
|
|
|
func (d *Droidstubs) inclusionAnnotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
|
2018-09-19 19:16:26 +02:00
|
|
|
ctx.VisitDirectDepsWithTag(metalavaMergeInclusionAnnotationsDirTag, func(m android.Module) {
|
|
|
|
if t, ok := m.(*ExportedDroiddocDir); ok {
|
2019-07-11 20:01:22 +02:00
|
|
|
cmd.FlagWithArg("--merge-inclusion-annotations ", t.dir.String()).Implicits(t.deps)
|
2018-09-19 19:16:26 +02:00
|
|
|
} else {
|
|
|
|
ctx.PropertyErrorf("merge_inclusion_annotations_dirs",
|
|
|
|
"module %q is not a metalava merge-annotations dir", ctx.OtherModuleName(m))
|
|
|
|
}
|
|
|
|
})
|
2018-08-01 21:48:00 +02:00
|
|
|
}
|
2018-07-12 00:16:55 +02:00
|
|
|
|
2019-07-11 20:01:22 +02:00
|
|
|
func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
|
2018-08-22 19:22:08 +02:00
|
|
|
if Bool(d.properties.Api_levels_annotations_enabled) {
|
|
|
|
d.apiVersionsXml = android.PathForModuleOut(ctx, "api-versions.xml")
|
|
|
|
|
|
|
|
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!")
|
|
|
|
}
|
|
|
|
|
2019-07-11 20:01:22 +02:00
|
|
|
cmd.FlagWithOutput("--generate-api-levels ", d.apiVersionsXml)
|
|
|
|
cmd.FlagWithInput("--apply-api-levels ", d.apiVersionsXml)
|
|
|
|
cmd.FlagWithArg("--current-version ", ctx.Config().PlatformSdkVersion())
|
|
|
|
cmd.FlagWithArg("--current-codename ", ctx.Config().PlatformSdkCodename())
|
2018-08-22 19:22:08 +02:00
|
|
|
|
|
|
|
ctx.VisitDirectDepsWithTag(metalavaAPILevelsAnnotationsDirTag, func(m android.Module) {
|
|
|
|
if t, ok := m.(*ExportedDroiddocDir); ok {
|
|
|
|
for _, dep := range t.deps {
|
|
|
|
if strings.HasSuffix(dep.String(), "android.jar") {
|
2019-07-11 20:01:22 +02:00
|
|
|
cmd.Implicit(dep)
|
2018-08-22 19:22:08 +02:00
|
|
|
}
|
|
|
|
}
|
2019-07-11 20:01:22 +02:00
|
|
|
cmd.FlagWithArg("--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))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-11 20:01:22 +02:00
|
|
|
func (d *Droidstubs) apiToXmlFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
|
2018-09-17 23:32:21 +02:00
|
|
|
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")
|
2019-07-11 20:01:22 +02:00
|
|
|
cmd.FlagWithOutput("--api-xml ", d.apiXmlFile)
|
2018-09-17 23:32:21 +02:00
|
|
|
|
|
|
|
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!")
|
|
|
|
}
|
|
|
|
|
2019-07-11 20:01:22 +02:00
|
|
|
lastReleasedApi := android.PathForModuleSrc(ctx, String(d.properties.Check_api.Last_released.Api_file))
|
2018-09-17 23:32:21 +02:00
|
|
|
d.lastReleasedApiXmlFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_last_released_api.xml")
|
2019-07-11 20:01:22 +02:00
|
|
|
cmd.FlagWithInput("--convert-to-jdiff ", lastReleasedApi).Output(d.lastReleasedApiXmlFile)
|
2018-09-17 23:32:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-28 19:37:20 +01:00
|
|
|
func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersion javaVersion, srcs android.Paths,
|
2019-07-11 20:01:22 +02:00
|
|
|
srcJarList android.Path, bootclasspath, classpath classpath, sourcepaths android.Paths) *android.RuleBuilderCommand {
|
2019-11-15 22:18:43 +01:00
|
|
|
// Metalava uses lots of memory, restrict the number of metalava jobs that can run in parallel.
|
|
|
|
rule.HighMem()
|
2020-04-30 09:08:37 +02:00
|
|
|
cmd := rule.Command()
|
|
|
|
if ctx.Config().IsEnvTrue("RBE_METALAVA") {
|
|
|
|
rule.Remoteable(android.RemoteRuleSupports{RBE: true})
|
|
|
|
execStrategy := remoteexec.LocalExecStrategy
|
|
|
|
if v := ctx.Config().Getenv("RBE_METALAVA_EXEC_STRATEGY"); v != "" {
|
|
|
|
execStrategy = v
|
|
|
|
}
|
|
|
|
pool := "metalava"
|
|
|
|
if v := ctx.Config().Getenv("RBE_METALAVA_POOL"); v != "" {
|
|
|
|
pool = v
|
|
|
|
}
|
|
|
|
inputs := []string{android.PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "framework", "metalava.jar").String()}
|
2020-05-11 22:49:37 +02:00
|
|
|
inputs = append(inputs, sourcepaths.Strings()...)
|
2020-04-30 09:08:37 +02:00
|
|
|
if v := ctx.Config().Getenv("RBE_METALAVA_INPUTS"); v != "" {
|
|
|
|
inputs = append(inputs, strings.Split(v, ",")...)
|
|
|
|
}
|
|
|
|
cmd.Text((&remoteexec.REParams{
|
|
|
|
Labels: map[string]string{"type": "compile", "lang": "java", "compiler": "metalava"},
|
|
|
|
ExecStrategy: execStrategy,
|
|
|
|
Inputs: inputs,
|
|
|
|
ToolchainInputs: []string{config.JavaCmd(ctx).String()},
|
|
|
|
Platform: map[string]string{remoteexec.PoolKey: pool},
|
|
|
|
}).NoVarTemplate(ctx.Config()))
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd.BuiltTool(ctx, "metalava").
|
2019-07-11 20:01:22 +02:00
|
|
|
Flag(config.JavacVmFlags).
|
|
|
|
FlagWithArg("-encoding ", "UTF-8").
|
2019-10-28 19:37:20 +01:00
|
|
|
FlagWithArg("-source ", javaVersion.String()).
|
2019-07-11 20:01:22 +02:00
|
|
|
FlagWithRspFileInputList("@", srcs).
|
|
|
|
FlagWithInput("@", srcJarList)
|
2018-08-22 19:22:08 +02:00
|
|
|
|
2019-07-11 20:01:22 +02:00
|
|
|
if len(bootclasspath) > 0 {
|
|
|
|
cmd.FlagWithInputList("-bootclasspath ", bootclasspath.Paths(), ":")
|
2018-09-17 23:32:21 +02:00
|
|
|
}
|
|
|
|
|
2019-07-11 20:01:22 +02:00
|
|
|
if len(classpath) > 0 {
|
|
|
|
cmd.FlagWithInputList("-classpath ", classpath.Paths(), ":")
|
|
|
|
}
|
2018-09-17 23:32:21 +02:00
|
|
|
|
2019-07-11 20:01:22 +02:00
|
|
|
if len(sourcepaths) > 0 {
|
|
|
|
cmd.FlagWithList("-sourcepath ", sourcepaths.Strings(), ":")
|
|
|
|
} else {
|
|
|
|
cmd.FlagWithArg("-sourcepath ", `""`)
|
|
|
|
}
|
2018-08-10 00:33:27 +02:00
|
|
|
|
2019-07-11 20:01:22 +02:00
|
|
|
cmd.Flag("--no-banner").
|
|
|
|
Flag("--color").
|
|
|
|
Flag("--quiet").
|
|
|
|
Flag("--format=v2")
|
2018-08-24 19:32:54 +02:00
|
|
|
|
2019-07-11 20:01:22 +02:00
|
|
|
return cmd
|
2018-09-17 23:32:21 +02:00
|
|
|
}
|
|
|
|
|
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))
|
|
|
|
|
2019-07-11 20:01:22 +02:00
|
|
|
// Create rule for metalava
|
2018-08-01 21:48:00 +02:00
|
|
|
|
2019-07-11 20:01:22 +02:00
|
|
|
srcJarDir := android.PathForModuleOut(ctx, "srcjars")
|
2018-09-17 23:32:21 +02:00
|
|
|
|
2019-07-11 20:01:22 +02:00
|
|
|
rule := android.NewRuleBuilder()
|
2018-09-17 23:32:21 +02:00
|
|
|
|
2020-04-08 19:18:03 +02:00
|
|
|
generateStubs := BoolDefault(d.properties.Generate_stubs, true)
|
|
|
|
var stubsDir android.OptionalPath
|
|
|
|
if generateStubs {
|
|
|
|
d.Javadoc.stubsSrcJar = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"stubs.srcjar")
|
|
|
|
stubsDir = android.OptionalPathForPath(android.PathForModuleOut(ctx, "stubsDir"))
|
|
|
|
rule.Command().Text("rm -rf").Text(stubsDir.String())
|
|
|
|
rule.Command().Text("mkdir -p").Text(stubsDir.String())
|
|
|
|
}
|
2018-08-01 21:48:00 +02:00
|
|
|
|
2019-07-11 20:01:22 +02:00
|
|
|
srcJarList := zipSyncCmd(ctx, rule, srcJarDir, d.Javadoc.srcJars)
|
2018-08-01 21:48:00 +02:00
|
|
|
|
2019-07-11 20:01:22 +02:00
|
|
|
cmd := metalavaCmd(ctx, rule, javaVersion, d.Javadoc.srcFiles, srcJarList,
|
|
|
|
deps.bootClasspath, deps.classpath, d.Javadoc.sourcepaths)
|
|
|
|
|
|
|
|
d.stubsFlags(ctx, cmd, stubsDir)
|
|
|
|
|
|
|
|
d.annotationsFlags(ctx, cmd)
|
|
|
|
d.inclusionAnnotationsFlags(ctx, cmd)
|
|
|
|
d.apiLevelsAnnotationsFlags(ctx, cmd)
|
|
|
|
d.apiToXmlFlags(ctx, cmd)
|
2018-09-17 23:32:21 +02:00
|
|
|
|
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
|
|
|
}
|
2019-07-11 20:01:22 +02:00
|
|
|
|
|
|
|
cmd.Flag(d.Javadoc.args).Implicits(d.Javadoc.argFiles)
|
|
|
|
for _, o := range d.Javadoc.properties.Out {
|
|
|
|
cmd.ImplicitOutput(android.PathForModuleGen(ctx, o))
|
|
|
|
}
|
|
|
|
|
2020-04-28 02:22:16 +02:00
|
|
|
// Add options for the other optional tasks: API-lint and check-released.
|
|
|
|
// We generate separate timestamp files for them.
|
2019-10-10 20:29:11 +02:00
|
|
|
|
2020-04-28 02:22:16 +02:00
|
|
|
doApiLint := false
|
|
|
|
doCheckReleased := false
|
2019-07-11 20:01:22 +02:00
|
|
|
|
2020-04-28 02:22:16 +02:00
|
|
|
// Add API lint options.
|
2018-05-05 03:49:16 +02:00
|
|
|
|
2019-10-10 12:07:03 +02:00
|
|
|
if BoolDefault(d.properties.Check_api.Api_lint.Enabled, false) && !ctx.Config().IsPdkBuild() {
|
2020-04-28 02:22:16 +02:00
|
|
|
doApiLint = true
|
2019-10-14 16:32:41 +02:00
|
|
|
|
2019-10-10 12:07:03 +02:00
|
|
|
newSince := android.OptionalPathForModuleSrc(ctx, d.properties.Check_api.Api_lint.New_since)
|
|
|
|
if newSince.Valid() {
|
|
|
|
cmd.FlagWithInput("--api-lint ", newSince.Path())
|
|
|
|
} else {
|
|
|
|
cmd.Flag("--api-lint")
|
|
|
|
}
|
2019-11-01 13:42:39 +01:00
|
|
|
d.apiLintReport = android.PathForModuleOut(ctx, "api_lint_report.txt")
|
2020-04-28 02:22:16 +02:00
|
|
|
cmd.FlagWithOutput("--report-even-if-suppressed ", d.apiLintReport) // TODO: Change to ":api-lint"
|
2019-10-10 12:07:03 +02:00
|
|
|
|
|
|
|
baselineFile := android.OptionalPathForModuleSrc(ctx, d.properties.Check_api.Api_lint.Baseline_file)
|
|
|
|
updatedBaselineOutput := android.PathForModuleOut(ctx, "api_lint_baseline.txt")
|
|
|
|
d.apiLintTimestamp = android.PathForModuleOut(ctx, "api_lint.timestamp")
|
|
|
|
|
2020-04-28 02:22:16 +02:00
|
|
|
// Note this string includes a special shell quote $' ... ', which decodes the "\n"s.
|
|
|
|
// However, because $' ... ' doesn't expand environmental variables, we can't just embed
|
|
|
|
// $PWD, so we have to terminate $'...', use "$PWD", then start $' ... ' again,
|
|
|
|
// which is why we have '"$PWD"$' in it.
|
|
|
|
//
|
|
|
|
// TODO: metalava also has a slightly different message hardcoded. Should we unify this
|
|
|
|
// message and metalava's one?
|
|
|
|
msg := `$'` + // Enclose with $' ... '
|
2020-05-01 18:08:54 +02:00
|
|
|
`************************************************************\n` +
|
|
|
|
`Your API changes are triggering API Lint warnings or errors.\n` +
|
|
|
|
`To make these errors go away, fix the code according to the\n` +
|
|
|
|
`error and/or warning messages above.\n` +
|
|
|
|
`\n` +
|
2020-04-28 02:22:16 +02:00
|
|
|
`If it is not possible to do so, there are workarounds:\n` +
|
2020-05-01 18:08:54 +02:00
|
|
|
`\n` +
|
2020-04-28 02:22:16 +02:00
|
|
|
`1. You can suppress the errors with @SuppressLint("<id>")\n`
|
2020-05-01 18:08:54 +02:00
|
|
|
|
2019-10-10 12:07:03 +02:00
|
|
|
if baselineFile.Valid() {
|
2020-04-28 02:22:16 +02:00
|
|
|
cmd.FlagWithInput("--baseline:api-lint ", baselineFile.Path())
|
|
|
|
cmd.FlagWithOutput("--update-baseline:api-lint ", updatedBaselineOutput)
|
2020-05-01 18:08:54 +02:00
|
|
|
|
|
|
|
msg += fmt.Sprintf(``+
|
|
|
|
`2. You can update the baseline by executing the following\n`+
|
|
|
|
` command:\n`+
|
2020-05-11 16:38:31 +02:00
|
|
|
` cp \\\n`+
|
|
|
|
` "'"$PWD"$'/%s" \\\n`+
|
|
|
|
` "'"$PWD"$'/%s"\n`+
|
2020-05-01 18:08:54 +02:00
|
|
|
` To submit the revised baseline.txt to the main Android\n`+
|
|
|
|
` repository, you will need approval.\n`, updatedBaselineOutput, baselineFile.Path())
|
|
|
|
} else {
|
|
|
|
msg += fmt.Sprintf(``+
|
|
|
|
`2. You can add a baseline file of existing lint failures\n`+
|
|
|
|
` to the build rule of %s.\n`, d.Name())
|
2019-10-10 12:07:03 +02:00
|
|
|
}
|
2020-04-28 02:22:16 +02:00
|
|
|
// Note the message ends with a ' (single quote), to close the $' ... ' .
|
|
|
|
msg += `************************************************************\n'`
|
2019-10-10 12:07:03 +02:00
|
|
|
|
2020-04-28 02:22:16 +02:00
|
|
|
cmd.FlagWithArg("--error-message:api-lint ", msg)
|
|
|
|
}
|
2019-10-10 12:07:03 +02:00
|
|
|
|
2020-04-28 02:22:16 +02:00
|
|
|
// Add "check released" options. (Detect incompatible API changes from the last public release)
|
|
|
|
|
|
|
|
if apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released") &&
|
|
|
|
!ctx.Config().IsPdkBuild() {
|
|
|
|
doCheckReleased = true
|
|
|
|
|
|
|
|
if len(d.Javadoc.properties.Out) > 0 {
|
|
|
|
ctx.PropertyErrorf("out", "out property may not be combined with check_api")
|
|
|
|
}
|
|
|
|
|
|
|
|
apiFile := android.PathForModuleSrc(ctx, String(d.properties.Check_api.Last_released.Api_file))
|
|
|
|
removedApiFile := android.PathForModuleSrc(ctx, String(d.properties.Check_api.Last_released.Removed_api_file))
|
|
|
|
baselineFile := android.OptionalPathForModuleSrc(ctx, d.properties.Check_api.Last_released.Baseline_file)
|
|
|
|
updatedBaselineOutput := android.PathForModuleOut(ctx, "last_released_baseline.txt")
|
|
|
|
|
|
|
|
d.checkLastReleasedApiTimestamp = android.PathForModuleOut(ctx, "check_last_released_api.timestamp")
|
|
|
|
|
|
|
|
cmd.FlagWithInput("--check-compatibility:api:released ", apiFile)
|
|
|
|
cmd.FlagWithInput("--check-compatibility:removed:released ", removedApiFile)
|
|
|
|
|
|
|
|
if baselineFile.Valid() {
|
|
|
|
cmd.FlagWithInput("--baseline:compatibility:released ", baselineFile.Path())
|
|
|
|
cmd.FlagWithOutput("--update-baseline:compatibility:released ", updatedBaselineOutput)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Note this string includes quote ($' ... '), which decodes the "\n"s.
|
|
|
|
msg := `$'\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'`
|
|
|
|
|
|
|
|
cmd.FlagWithArg("--error-message:compatibility:released ", msg)
|
|
|
|
}
|
|
|
|
|
|
|
|
if generateStubs {
|
2019-10-10 12:07:03 +02:00
|
|
|
rule.Command().
|
2020-04-28 02:22:16 +02:00
|
|
|
BuiltTool(ctx, "soong_zip").
|
|
|
|
Flag("-write_if_changed").
|
|
|
|
Flag("-jar").
|
|
|
|
FlagWithOutput("-o ", d.Javadoc.stubsSrcJar).
|
|
|
|
FlagWithArg("-C ", stubsDir.String()).
|
|
|
|
FlagWithArg("-D ", stubsDir.String())
|
|
|
|
}
|
2019-10-10 12:07:03 +02:00
|
|
|
|
2020-04-28 02:22:16 +02:00
|
|
|
if Bool(d.properties.Write_sdk_values) {
|
|
|
|
d.metadataZip = android.PathForModuleOut(ctx, ctx.ModuleName()+"-metadata.zip")
|
|
|
|
rule.Command().
|
|
|
|
BuiltTool(ctx, "soong_zip").
|
|
|
|
Flag("-write_if_changed").
|
|
|
|
Flag("-d").
|
|
|
|
FlagWithOutput("-o ", d.metadataZip).
|
|
|
|
FlagWithArg("-C ", d.metadataDir.String()).
|
|
|
|
FlagWithArg("-D ", d.metadataDir.String())
|
|
|
|
}
|
2019-10-10 12:07:03 +02:00
|
|
|
|
2020-04-28 02:22:16 +02:00
|
|
|
// TODO: We don't really need two separate API files, but this is a reminiscence of how
|
|
|
|
// we used to run metalava separately for API lint and the "last_released" check. Unify them.
|
|
|
|
if doApiLint {
|
|
|
|
rule.Command().Text("touch").Output(d.apiLintTimestamp)
|
|
|
|
}
|
|
|
|
if doCheckReleased {
|
|
|
|
rule.Command().Text("touch").Output(d.checkLastReleasedApiTimestamp)
|
2019-10-10 12:07:03 +02:00
|
|
|
}
|
|
|
|
|
2020-04-28 02:22:16 +02:00
|
|
|
rule.Restat()
|
|
|
|
|
|
|
|
zipSyncCleanupCmd(rule, srcJarDir)
|
|
|
|
|
|
|
|
rule.Build(pctx, ctx, "metalava", "metalava merged")
|
|
|
|
|
2019-09-01 21:49:45 +02:00
|
|
|
if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") &&
|
2018-09-05 02:14:32 +02:00
|
|
|
!ctx.Config().IsPdkBuild() {
|
2019-07-11 20:01:22 +02:00
|
|
|
|
|
|
|
if len(d.Javadoc.properties.Out) > 0 {
|
|
|
|
ctx.PropertyErrorf("out", "out property may not be combined with check_api")
|
|
|
|
}
|
|
|
|
|
|
|
|
apiFile := android.PathForModuleSrc(ctx, String(d.properties.Check_api.Current.Api_file))
|
|
|
|
removedApiFile := android.PathForModuleSrc(ctx, String(d.properties.Check_api.Current.Removed_api_file))
|
2019-08-12 17:54:09 +02:00
|
|
|
baselineFile := android.OptionalPathForModuleSrc(ctx, d.properties.Check_api.Current.Baseline_file)
|
Don't use metalava for "check-current"
Because we already generate the latest current.txt and removed.txt
during the "main" metalava invocation (i.e. stub generation),
we don't have to use metalava for current API check.
Just use diff instead.
Bug: 151160048
Test: Remove @hide from Intent.EXTRA_INSTALL_RESULT, and do `m out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp`.
Result is:
```
FAILED: out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp
( true && diff -u -F '{ *$' frameworks/base/api/current.txt out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_api.txt && diff -u -F '{ *$' frameworks/base/api/removed.txt out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_removed.txt && touch out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp ) || ( echo -e "\n******************************\nYou have tried to change the API from what has been previously approved.\n\nTo make these errors go away, you have two choices:\n 1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)\n to the new methods, etc. shown in the above diff.\n\n 2. You can update current.txt and/or removed.txt by executing the following command:\n make api-stubs-docs-update-current-api\n\n To submit the revised current.txt to the main Android repository,\n you will need approval.\n******************************\n" ; exit 38 )
Change-Id: I63f237c6e046de8a6b6538c44ec0ab8bd8fbbdb1
--- frameworks/base/api/current.txt 2020-04-16 17:50:21.911899599 -0700
+++ out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_api.txt 2020-04-16 17:51:35.211792638 -0700
@@ -10415,6 +10415,7 @@ public class Intent implements java.lang
field public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
field public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
field public static final String EXTRA_INSTALLER_PACKAGE_NAME = "android.intent.extra.INSTALLER_PACKAGE_NAME";
+ field public static final String EXTRA_INSTALL_RESULT = "android.intent.extra.INSTALL_RESULT";
field public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
field public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
field public static final String EXTRA_LOCAL_ONLY = "android.intent.extra.LOCAL_ONLY";
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)
to the new methods, etc. shown in the above diff.
2. You can update current.txt and/or removed.txt by executing the following command:
make api-stubs-docs-update-current-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
ninja: build stopped: subcommand failed.
```
Test: Remove @removed and @SystemApi from Intent.ACTION_MASTER_CLEAR, and do `m out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/check_current_api.timestamp`
Result is:
```
( true && diff -u -F '{ *$' frameworks/base/api/system-current.txt out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_api.txt && diff -u -F '{ *$' frameworks/base/api/system-removed.txt out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_removed.txt && touch out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/check_current_api.timestamp ) || ( echo -e "\n******************************\nYou have tried to change the API from what has been previously approved.\n\nTo make these errors go away, you have two choices:\n 1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)\n to the new methods, etc. shown in the above diff.\n\n 2. You can update current.txt and/or removed.txt by executing the following command:\n make system-api-stubs-docs-update-current-api\n\n To submit the revised current.txt to the main Android repository,\n you will need approval.\n******************************\n" ; exit 38 )
--- frameworks/base/api/system-removed.txt 2020-04-16 17:50:21.911899599 -0700
+++ out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_removed.txt 2020-04-16 17:53:45.319602905 -0700
@@ -55,7 +55,6 @@ package android.content {
public class Intent implements java.lang.Cloneable android.os.Parcelable {
field @Deprecated public static final String ACTION_DEVICE_INITIALIZATION_WIZARD = "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
- field @Deprecated public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
field @Deprecated public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
field @Deprecated public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
field @Deprecated public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)
to the new methods, etc. shown in the above diff.
2. You can update current.txt and/or removed.txt by executing the following command:
make system-api-stubs-docs-update-current-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
```
Test: Add `baseline_file` to `check_api.current` and run `m`
FAILED: out/soong/build.ninja
out/soong/.bootstrap/bin/soong_build -t -l out/.module_paths/Android.bp.list -b out/soong -n out -d out/soong/build.ninja.d -globFile out/soong/.bootstrap/build-globs.ninja -o out/soong/build.ninja Android.bp
error: frameworks/base/StubLibraries.bp:86:1: module "api-stubs-docs" variant "android_common": current API check can't have a baseline file. (module %s): api-stubs-docs
ninja: build stopped: subcommand failed.
Test: With the above changes, run "m api-stubs-docs-update-current-api system-api-stubs-docs-update-current-api", make sure the API files got updated, and then run "m"
Change-Id: I47b146c6fe4caa65775ecf5425ab09b57f43f839
2020-04-17 02:02:40 +02:00
|
|
|
|
|
|
|
if baselineFile.Valid() {
|
2020-04-28 02:22:16 +02:00
|
|
|
ctx.PropertyErrorf("baseline_file", "current API check can't have a baseline file. (module %s)", ctx.ModuleName())
|
Don't use metalava for "check-current"
Because we already generate the latest current.txt and removed.txt
during the "main" metalava invocation (i.e. stub generation),
we don't have to use metalava for current API check.
Just use diff instead.
Bug: 151160048
Test: Remove @hide from Intent.EXTRA_INSTALL_RESULT, and do `m out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp`.
Result is:
```
FAILED: out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp
( true && diff -u -F '{ *$' frameworks/base/api/current.txt out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_api.txt && diff -u -F '{ *$' frameworks/base/api/removed.txt out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_removed.txt && touch out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp ) || ( echo -e "\n******************************\nYou have tried to change the API from what has been previously approved.\n\nTo make these errors go away, you have two choices:\n 1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)\n to the new methods, etc. shown in the above diff.\n\n 2. You can update current.txt and/or removed.txt by executing the following command:\n make api-stubs-docs-update-current-api\n\n To submit the revised current.txt to the main Android repository,\n you will need approval.\n******************************\n" ; exit 38 )
Change-Id: I63f237c6e046de8a6b6538c44ec0ab8bd8fbbdb1
--- frameworks/base/api/current.txt 2020-04-16 17:50:21.911899599 -0700
+++ out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_api.txt 2020-04-16 17:51:35.211792638 -0700
@@ -10415,6 +10415,7 @@ public class Intent implements java.lang
field public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
field public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
field public static final String EXTRA_INSTALLER_PACKAGE_NAME = "android.intent.extra.INSTALLER_PACKAGE_NAME";
+ field public static final String EXTRA_INSTALL_RESULT = "android.intent.extra.INSTALL_RESULT";
field public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
field public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
field public static final String EXTRA_LOCAL_ONLY = "android.intent.extra.LOCAL_ONLY";
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)
to the new methods, etc. shown in the above diff.
2. You can update current.txt and/or removed.txt by executing the following command:
make api-stubs-docs-update-current-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
ninja: build stopped: subcommand failed.
```
Test: Remove @removed and @SystemApi from Intent.ACTION_MASTER_CLEAR, and do `m out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/check_current_api.timestamp`
Result is:
```
( true && diff -u -F '{ *$' frameworks/base/api/system-current.txt out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_api.txt && diff -u -F '{ *$' frameworks/base/api/system-removed.txt out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_removed.txt && touch out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/check_current_api.timestamp ) || ( echo -e "\n******************************\nYou have tried to change the API from what has been previously approved.\n\nTo make these errors go away, you have two choices:\n 1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)\n to the new methods, etc. shown in the above diff.\n\n 2. You can update current.txt and/or removed.txt by executing the following command:\n make system-api-stubs-docs-update-current-api\n\n To submit the revised current.txt to the main Android repository,\n you will need approval.\n******************************\n" ; exit 38 )
--- frameworks/base/api/system-removed.txt 2020-04-16 17:50:21.911899599 -0700
+++ out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_removed.txt 2020-04-16 17:53:45.319602905 -0700
@@ -55,7 +55,6 @@ package android.content {
public class Intent implements java.lang.Cloneable android.os.Parcelable {
field @Deprecated public static final String ACTION_DEVICE_INITIALIZATION_WIZARD = "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
- field @Deprecated public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
field @Deprecated public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
field @Deprecated public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
field @Deprecated public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)
to the new methods, etc. shown in the above diff.
2. You can update current.txt and/or removed.txt by executing the following command:
make system-api-stubs-docs-update-current-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
```
Test: Add `baseline_file` to `check_api.current` and run `m`
FAILED: out/soong/build.ninja
out/soong/.bootstrap/bin/soong_build -t -l out/.module_paths/Android.bp.list -b out/soong -n out -d out/soong/build.ninja.d -globFile out/soong/.bootstrap/build-globs.ninja -o out/soong/build.ninja Android.bp
error: frameworks/base/StubLibraries.bp:86:1: module "api-stubs-docs" variant "android_common": current API check can't have a baseline file. (module %s): api-stubs-docs
ninja: build stopped: subcommand failed.
Test: With the above changes, run "m api-stubs-docs-update-current-api system-api-stubs-docs-update-current-api", make sure the API files got updated, and then run "m"
Change-Id: I47b146c6fe4caa65775ecf5425ab09b57f43f839
2020-04-17 02:02:40 +02:00
|
|
|
}
|
2018-05-05 03:49:16 +02:00
|
|
|
|
2018-08-24 19:32:54 +02:00
|
|
|
d.checkCurrentApiTimestamp = android.PathForModuleOut(ctx, "check_current_api.timestamp")
|
2018-09-05 02:14:32 +02:00
|
|
|
|
2019-07-11 20:01:22 +02:00
|
|
|
rule := android.NewRuleBuilder()
|
|
|
|
|
Don't use metalava for "check-current"
Because we already generate the latest current.txt and removed.txt
during the "main" metalava invocation (i.e. stub generation),
we don't have to use metalava for current API check.
Just use diff instead.
Bug: 151160048
Test: Remove @hide from Intent.EXTRA_INSTALL_RESULT, and do `m out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp`.
Result is:
```
FAILED: out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp
( true && diff -u -F '{ *$' frameworks/base/api/current.txt out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_api.txt && diff -u -F '{ *$' frameworks/base/api/removed.txt out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_removed.txt && touch out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp ) || ( echo -e "\n******************************\nYou have tried to change the API from what has been previously approved.\n\nTo make these errors go away, you have two choices:\n 1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)\n to the new methods, etc. shown in the above diff.\n\n 2. You can update current.txt and/or removed.txt by executing the following command:\n make api-stubs-docs-update-current-api\n\n To submit the revised current.txt to the main Android repository,\n you will need approval.\n******************************\n" ; exit 38 )
Change-Id: I63f237c6e046de8a6b6538c44ec0ab8bd8fbbdb1
--- frameworks/base/api/current.txt 2020-04-16 17:50:21.911899599 -0700
+++ out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_api.txt 2020-04-16 17:51:35.211792638 -0700
@@ -10415,6 +10415,7 @@ public class Intent implements java.lang
field public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
field public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
field public static final String EXTRA_INSTALLER_PACKAGE_NAME = "android.intent.extra.INSTALLER_PACKAGE_NAME";
+ field public static final String EXTRA_INSTALL_RESULT = "android.intent.extra.INSTALL_RESULT";
field public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
field public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
field public static final String EXTRA_LOCAL_ONLY = "android.intent.extra.LOCAL_ONLY";
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)
to the new methods, etc. shown in the above diff.
2. You can update current.txt and/or removed.txt by executing the following command:
make api-stubs-docs-update-current-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
ninja: build stopped: subcommand failed.
```
Test: Remove @removed and @SystemApi from Intent.ACTION_MASTER_CLEAR, and do `m out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/check_current_api.timestamp`
Result is:
```
( true && diff -u -F '{ *$' frameworks/base/api/system-current.txt out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_api.txt && diff -u -F '{ *$' frameworks/base/api/system-removed.txt out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_removed.txt && touch out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/check_current_api.timestamp ) || ( echo -e "\n******************************\nYou have tried to change the API from what has been previously approved.\n\nTo make these errors go away, you have two choices:\n 1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)\n to the new methods, etc. shown in the above diff.\n\n 2. You can update current.txt and/or removed.txt by executing the following command:\n make system-api-stubs-docs-update-current-api\n\n To submit the revised current.txt to the main Android repository,\n you will need approval.\n******************************\n" ; exit 38 )
--- frameworks/base/api/system-removed.txt 2020-04-16 17:50:21.911899599 -0700
+++ out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_removed.txt 2020-04-16 17:53:45.319602905 -0700
@@ -55,7 +55,6 @@ package android.content {
public class Intent implements java.lang.Cloneable android.os.Parcelable {
field @Deprecated public static final String ACTION_DEVICE_INITIALIZATION_WIZARD = "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
- field @Deprecated public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
field @Deprecated public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
field @Deprecated public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
field @Deprecated public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)
to the new methods, etc. shown in the above diff.
2. You can update current.txt and/or removed.txt by executing the following command:
make system-api-stubs-docs-update-current-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
```
Test: Add `baseline_file` to `check_api.current` and run `m`
FAILED: out/soong/build.ninja
out/soong/.bootstrap/bin/soong_build -t -l out/.module_paths/Android.bp.list -b out/soong -n out -d out/soong/build.ninja.d -globFile out/soong/.bootstrap/build-globs.ninja -o out/soong/build.ninja Android.bp
error: frameworks/base/StubLibraries.bp:86:1: module "api-stubs-docs" variant "android_common": current API check can't have a baseline file. (module %s): api-stubs-docs
ninja: build stopped: subcommand failed.
Test: With the above changes, run "m api-stubs-docs-update-current-api system-api-stubs-docs-update-current-api", make sure the API files got updated, and then run "m"
Change-Id: I47b146c6fe4caa65775ecf5425ab09b57f43f839
2020-04-17 02:02:40 +02:00
|
|
|
// Diff command line.
|
2020-04-28 02:22:16 +02:00
|
|
|
// -F matches the closest "opening" line, such as "package android {"
|
|
|
|
// and " public class Intent {".
|
Don't use metalava for "check-current"
Because we already generate the latest current.txt and removed.txt
during the "main" metalava invocation (i.e. stub generation),
we don't have to use metalava for current API check.
Just use diff instead.
Bug: 151160048
Test: Remove @hide from Intent.EXTRA_INSTALL_RESULT, and do `m out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp`.
Result is:
```
FAILED: out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp
( true && diff -u -F '{ *$' frameworks/base/api/current.txt out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_api.txt && diff -u -F '{ *$' frameworks/base/api/removed.txt out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_removed.txt && touch out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp ) || ( echo -e "\n******************************\nYou have tried to change the API from what has been previously approved.\n\nTo make these errors go away, you have two choices:\n 1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)\n to the new methods, etc. shown in the above diff.\n\n 2. You can update current.txt and/or removed.txt by executing the following command:\n make api-stubs-docs-update-current-api\n\n To submit the revised current.txt to the main Android repository,\n you will need approval.\n******************************\n" ; exit 38 )
Change-Id: I63f237c6e046de8a6b6538c44ec0ab8bd8fbbdb1
--- frameworks/base/api/current.txt 2020-04-16 17:50:21.911899599 -0700
+++ out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_api.txt 2020-04-16 17:51:35.211792638 -0700
@@ -10415,6 +10415,7 @@ public class Intent implements java.lang
field public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
field public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
field public static final String EXTRA_INSTALLER_PACKAGE_NAME = "android.intent.extra.INSTALLER_PACKAGE_NAME";
+ field public static final String EXTRA_INSTALL_RESULT = "android.intent.extra.INSTALL_RESULT";
field public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
field public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
field public static final String EXTRA_LOCAL_ONLY = "android.intent.extra.LOCAL_ONLY";
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)
to the new methods, etc. shown in the above diff.
2. You can update current.txt and/or removed.txt by executing the following command:
make api-stubs-docs-update-current-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
ninja: build stopped: subcommand failed.
```
Test: Remove @removed and @SystemApi from Intent.ACTION_MASTER_CLEAR, and do `m out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/check_current_api.timestamp`
Result is:
```
( true && diff -u -F '{ *$' frameworks/base/api/system-current.txt out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_api.txt && diff -u -F '{ *$' frameworks/base/api/system-removed.txt out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_removed.txt && touch out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/check_current_api.timestamp ) || ( echo -e "\n******************************\nYou have tried to change the API from what has been previously approved.\n\nTo make these errors go away, you have two choices:\n 1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)\n to the new methods, etc. shown in the above diff.\n\n 2. You can update current.txt and/or removed.txt by executing the following command:\n make system-api-stubs-docs-update-current-api\n\n To submit the revised current.txt to the main Android repository,\n you will need approval.\n******************************\n" ; exit 38 )
--- frameworks/base/api/system-removed.txt 2020-04-16 17:50:21.911899599 -0700
+++ out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_removed.txt 2020-04-16 17:53:45.319602905 -0700
@@ -55,7 +55,6 @@ package android.content {
public class Intent implements java.lang.Cloneable android.os.Parcelable {
field @Deprecated public static final String ACTION_DEVICE_INITIALIZATION_WIZARD = "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
- field @Deprecated public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
field @Deprecated public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
field @Deprecated public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
field @Deprecated public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)
to the new methods, etc. shown in the above diff.
2. You can update current.txt and/or removed.txt by executing the following command:
make system-api-stubs-docs-update-current-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
```
Test: Add `baseline_file` to `check_api.current` and run `m`
FAILED: out/soong/build.ninja
out/soong/.bootstrap/bin/soong_build -t -l out/.module_paths/Android.bp.list -b out/soong -n out -d out/soong/build.ninja.d -globFile out/soong/.bootstrap/build-globs.ninja -o out/soong/build.ninja Android.bp
error: frameworks/base/StubLibraries.bp:86:1: module "api-stubs-docs" variant "android_common": current API check can't have a baseline file. (module %s): api-stubs-docs
ninja: build stopped: subcommand failed.
Test: With the above changes, run "m api-stubs-docs-update-current-api system-api-stubs-docs-update-current-api", make sure the API files got updated, and then run "m"
Change-Id: I47b146c6fe4caa65775ecf5425ab09b57f43f839
2020-04-17 02:02:40 +02:00
|
|
|
diff := `diff -u -F '{ *$'`
|
2019-07-11 20:01:22 +02:00
|
|
|
|
Don't use metalava for "check-current"
Because we already generate the latest current.txt and removed.txt
during the "main" metalava invocation (i.e. stub generation),
we don't have to use metalava for current API check.
Just use diff instead.
Bug: 151160048
Test: Remove @hide from Intent.EXTRA_INSTALL_RESULT, and do `m out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp`.
Result is:
```
FAILED: out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp
( true && diff -u -F '{ *$' frameworks/base/api/current.txt out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_api.txt && diff -u -F '{ *$' frameworks/base/api/removed.txt out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_removed.txt && touch out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp ) || ( echo -e "\n******************************\nYou have tried to change the API from what has been previously approved.\n\nTo make these errors go away, you have two choices:\n 1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)\n to the new methods, etc. shown in the above diff.\n\n 2. You can update current.txt and/or removed.txt by executing the following command:\n make api-stubs-docs-update-current-api\n\n To submit the revised current.txt to the main Android repository,\n you will need approval.\n******************************\n" ; exit 38 )
Change-Id: I63f237c6e046de8a6b6538c44ec0ab8bd8fbbdb1
--- frameworks/base/api/current.txt 2020-04-16 17:50:21.911899599 -0700
+++ out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_api.txt 2020-04-16 17:51:35.211792638 -0700
@@ -10415,6 +10415,7 @@ public class Intent implements java.lang
field public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
field public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
field public static final String EXTRA_INSTALLER_PACKAGE_NAME = "android.intent.extra.INSTALLER_PACKAGE_NAME";
+ field public static final String EXTRA_INSTALL_RESULT = "android.intent.extra.INSTALL_RESULT";
field public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
field public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
field public static final String EXTRA_LOCAL_ONLY = "android.intent.extra.LOCAL_ONLY";
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)
to the new methods, etc. shown in the above diff.
2. You can update current.txt and/or removed.txt by executing the following command:
make api-stubs-docs-update-current-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
ninja: build stopped: subcommand failed.
```
Test: Remove @removed and @SystemApi from Intent.ACTION_MASTER_CLEAR, and do `m out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/check_current_api.timestamp`
Result is:
```
( true && diff -u -F '{ *$' frameworks/base/api/system-current.txt out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_api.txt && diff -u -F '{ *$' frameworks/base/api/system-removed.txt out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_removed.txt && touch out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/check_current_api.timestamp ) || ( echo -e "\n******************************\nYou have tried to change the API from what has been previously approved.\n\nTo make these errors go away, you have two choices:\n 1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)\n to the new methods, etc. shown in the above diff.\n\n 2. You can update current.txt and/or removed.txt by executing the following command:\n make system-api-stubs-docs-update-current-api\n\n To submit the revised current.txt to the main Android repository,\n you will need approval.\n******************************\n" ; exit 38 )
--- frameworks/base/api/system-removed.txt 2020-04-16 17:50:21.911899599 -0700
+++ out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_removed.txt 2020-04-16 17:53:45.319602905 -0700
@@ -55,7 +55,6 @@ package android.content {
public class Intent implements java.lang.Cloneable android.os.Parcelable {
field @Deprecated public static final String ACTION_DEVICE_INITIALIZATION_WIZARD = "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
- field @Deprecated public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
field @Deprecated public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
field @Deprecated public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
field @Deprecated public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)
to the new methods, etc. shown in the above diff.
2. You can update current.txt and/or removed.txt by executing the following command:
make system-api-stubs-docs-update-current-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
```
Test: Add `baseline_file` to `check_api.current` and run `m`
FAILED: out/soong/build.ninja
out/soong/.bootstrap/bin/soong_build -t -l out/.module_paths/Android.bp.list -b out/soong -n out -d out/soong/build.ninja.d -globFile out/soong/.bootstrap/build-globs.ninja -o out/soong/build.ninja Android.bp
error: frameworks/base/StubLibraries.bp:86:1: module "api-stubs-docs" variant "android_common": current API check can't have a baseline file. (module %s): api-stubs-docs
ninja: build stopped: subcommand failed.
Test: With the above changes, run "m api-stubs-docs-update-current-api system-api-stubs-docs-update-current-api", make sure the API files got updated, and then run "m"
Change-Id: I47b146c6fe4caa65775ecf5425ab09b57f43f839
2020-04-17 02:02:40 +02:00
|
|
|
rule.Command().Text("( true")
|
|
|
|
rule.Command().
|
|
|
|
Text(diff).
|
|
|
|
Input(apiFile).Input(d.apiFile)
|
2019-08-12 17:54:09 +02:00
|
|
|
|
Don't use metalava for "check-current"
Because we already generate the latest current.txt and removed.txt
during the "main" metalava invocation (i.e. stub generation),
we don't have to use metalava for current API check.
Just use diff instead.
Bug: 151160048
Test: Remove @hide from Intent.EXTRA_INSTALL_RESULT, and do `m out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp`.
Result is:
```
FAILED: out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp
( true && diff -u -F '{ *$' frameworks/base/api/current.txt out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_api.txt && diff -u -F '{ *$' frameworks/base/api/removed.txt out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_removed.txt && touch out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp ) || ( echo -e "\n******************************\nYou have tried to change the API from what has been previously approved.\n\nTo make these errors go away, you have two choices:\n 1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)\n to the new methods, etc. shown in the above diff.\n\n 2. You can update current.txt and/or removed.txt by executing the following command:\n make api-stubs-docs-update-current-api\n\n To submit the revised current.txt to the main Android repository,\n you will need approval.\n******************************\n" ; exit 38 )
Change-Id: I63f237c6e046de8a6b6538c44ec0ab8bd8fbbdb1
--- frameworks/base/api/current.txt 2020-04-16 17:50:21.911899599 -0700
+++ out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_api.txt 2020-04-16 17:51:35.211792638 -0700
@@ -10415,6 +10415,7 @@ public class Intent implements java.lang
field public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
field public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
field public static final String EXTRA_INSTALLER_PACKAGE_NAME = "android.intent.extra.INSTALLER_PACKAGE_NAME";
+ field public static final String EXTRA_INSTALL_RESULT = "android.intent.extra.INSTALL_RESULT";
field public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
field public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
field public static final String EXTRA_LOCAL_ONLY = "android.intent.extra.LOCAL_ONLY";
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)
to the new methods, etc. shown in the above diff.
2. You can update current.txt and/or removed.txt by executing the following command:
make api-stubs-docs-update-current-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
ninja: build stopped: subcommand failed.
```
Test: Remove @removed and @SystemApi from Intent.ACTION_MASTER_CLEAR, and do `m out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/check_current_api.timestamp`
Result is:
```
( true && diff -u -F '{ *$' frameworks/base/api/system-current.txt out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_api.txt && diff -u -F '{ *$' frameworks/base/api/system-removed.txt out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_removed.txt && touch out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/check_current_api.timestamp ) || ( echo -e "\n******************************\nYou have tried to change the API from what has been previously approved.\n\nTo make these errors go away, you have two choices:\n 1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)\n to the new methods, etc. shown in the above diff.\n\n 2. You can update current.txt and/or removed.txt by executing the following command:\n make system-api-stubs-docs-update-current-api\n\n To submit the revised current.txt to the main Android repository,\n you will need approval.\n******************************\n" ; exit 38 )
--- frameworks/base/api/system-removed.txt 2020-04-16 17:50:21.911899599 -0700
+++ out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_removed.txt 2020-04-16 17:53:45.319602905 -0700
@@ -55,7 +55,6 @@ package android.content {
public class Intent implements java.lang.Cloneable android.os.Parcelable {
field @Deprecated public static final String ACTION_DEVICE_INITIALIZATION_WIZARD = "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
- field @Deprecated public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
field @Deprecated public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
field @Deprecated public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
field @Deprecated public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)
to the new methods, etc. shown in the above diff.
2. You can update current.txt and/or removed.txt by executing the following command:
make system-api-stubs-docs-update-current-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
```
Test: Add `baseline_file` to `check_api.current` and run `m`
FAILED: out/soong/build.ninja
out/soong/.bootstrap/bin/soong_build -t -l out/.module_paths/Android.bp.list -b out/soong -n out -d out/soong/build.ninja.d -globFile out/soong/.bootstrap/build-globs.ninja -o out/soong/build.ninja Android.bp
error: frameworks/base/StubLibraries.bp:86:1: module "api-stubs-docs" variant "android_common": current API check can't have a baseline file. (module %s): api-stubs-docs
ninja: build stopped: subcommand failed.
Test: With the above changes, run "m api-stubs-docs-update-current-api system-api-stubs-docs-update-current-api", make sure the API files got updated, and then run "m"
Change-Id: I47b146c6fe4caa65775ecf5425ab09b57f43f839
2020-04-17 02:02:40 +02:00
|
|
|
rule.Command().
|
|
|
|
Text(diff).
|
|
|
|
Input(removedApiFile).Input(d.removedApiFile)
|
2019-07-11 20:01:22 +02:00
|
|
|
|
|
|
|
msg := 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`+
|
Don't use metalava for "check-current"
Because we already generate the latest current.txt and removed.txt
during the "main" metalava invocation (i.e. stub generation),
we don't have to use metalava for current API check.
Just use diff instead.
Bug: 151160048
Test: Remove @hide from Intent.EXTRA_INSTALL_RESULT, and do `m out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp`.
Result is:
```
FAILED: out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp
( true && diff -u -F '{ *$' frameworks/base/api/current.txt out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_api.txt && diff -u -F '{ *$' frameworks/base/api/removed.txt out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_removed.txt && touch out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp ) || ( echo -e "\n******************************\nYou have tried to change the API from what has been previously approved.\n\nTo make these errors go away, you have two choices:\n 1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)\n to the new methods, etc. shown in the above diff.\n\n 2. You can update current.txt and/or removed.txt by executing the following command:\n make api-stubs-docs-update-current-api\n\n To submit the revised current.txt to the main Android repository,\n you will need approval.\n******************************\n" ; exit 38 )
Change-Id: I63f237c6e046de8a6b6538c44ec0ab8bd8fbbdb1
--- frameworks/base/api/current.txt 2020-04-16 17:50:21.911899599 -0700
+++ out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_api.txt 2020-04-16 17:51:35.211792638 -0700
@@ -10415,6 +10415,7 @@ public class Intent implements java.lang
field public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
field public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
field public static final String EXTRA_INSTALLER_PACKAGE_NAME = "android.intent.extra.INSTALLER_PACKAGE_NAME";
+ field public static final String EXTRA_INSTALL_RESULT = "android.intent.extra.INSTALL_RESULT";
field public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
field public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
field public static final String EXTRA_LOCAL_ONLY = "android.intent.extra.LOCAL_ONLY";
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)
to the new methods, etc. shown in the above diff.
2. You can update current.txt and/or removed.txt by executing the following command:
make api-stubs-docs-update-current-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
ninja: build stopped: subcommand failed.
```
Test: Remove @removed and @SystemApi from Intent.ACTION_MASTER_CLEAR, and do `m out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/check_current_api.timestamp`
Result is:
```
( true && diff -u -F '{ *$' frameworks/base/api/system-current.txt out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_api.txt && diff -u -F '{ *$' frameworks/base/api/system-removed.txt out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_removed.txt && touch out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/check_current_api.timestamp ) || ( echo -e "\n******************************\nYou have tried to change the API from what has been previously approved.\n\nTo make these errors go away, you have two choices:\n 1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)\n to the new methods, etc. shown in the above diff.\n\n 2. You can update current.txt and/or removed.txt by executing the following command:\n make system-api-stubs-docs-update-current-api\n\n To submit the revised current.txt to the main Android repository,\n you will need approval.\n******************************\n" ; exit 38 )
--- frameworks/base/api/system-removed.txt 2020-04-16 17:50:21.911899599 -0700
+++ out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_removed.txt 2020-04-16 17:53:45.319602905 -0700
@@ -55,7 +55,6 @@ package android.content {
public class Intent implements java.lang.Cloneable android.os.Parcelable {
field @Deprecated public static final String ACTION_DEVICE_INITIALIZATION_WIZARD = "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
- field @Deprecated public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
field @Deprecated public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
field @Deprecated public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
field @Deprecated public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)
to the new methods, etc. shown in the above diff.
2. You can update current.txt and/or removed.txt by executing the following command:
make system-api-stubs-docs-update-current-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
```
Test: Add `baseline_file` to `check_api.current` and run `m`
FAILED: out/soong/build.ninja
out/soong/.bootstrap/bin/soong_build -t -l out/.module_paths/Android.bp.list -b out/soong -n out -d out/soong/build.ninja.d -globFile out/soong/.bootstrap/build-globs.ninja -o out/soong/build.ninja Android.bp
error: frameworks/base/StubLibraries.bp:86:1: module "api-stubs-docs" variant "android_common": current API check can't have a baseline file. (module %s): api-stubs-docs
ninja: build stopped: subcommand failed.
Test: With the above changes, run "m api-stubs-docs-update-current-api system-api-stubs-docs-update-current-api", make sure the API files got updated, and then run "m"
Change-Id: I47b146c6fe4caa65775ecf5425ab09b57f43f839
2020-04-17 02:02:40 +02:00
|
|
|
` 1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)\n`+
|
|
|
|
` to the new methods, etc. shown in the above diff.\n\n`+
|
|
|
|
` 2. You can update current.txt and/or removed.txt by executing the following command:\n`+
|
2019-07-11 20:01:22 +02:00
|
|
|
` 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())
|
|
|
|
|
|
|
|
rule.Command().
|
|
|
|
Text("touch").Output(d.checkCurrentApiTimestamp).
|
|
|
|
Text(") || (").
|
|
|
|
Text("echo").Flag("-e").Flag(`"` + msg + `"`).
|
|
|
|
Text("; exit 38").
|
|
|
|
Text(")")
|
|
|
|
|
Don't use metalava for "check-current"
Because we already generate the latest current.txt and removed.txt
during the "main" metalava invocation (i.e. stub generation),
we don't have to use metalava for current API check.
Just use diff instead.
Bug: 151160048
Test: Remove @hide from Intent.EXTRA_INSTALL_RESULT, and do `m out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp`.
Result is:
```
FAILED: out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp
( true && diff -u -F '{ *$' frameworks/base/api/current.txt out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_api.txt && diff -u -F '{ *$' frameworks/base/api/removed.txt out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_removed.txt && touch out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/check_current_api.timestamp ) || ( echo -e "\n******************************\nYou have tried to change the API from what has been previously approved.\n\nTo make these errors go away, you have two choices:\n 1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)\n to the new methods, etc. shown in the above diff.\n\n 2. You can update current.txt and/or removed.txt by executing the following command:\n make api-stubs-docs-update-current-api\n\n To submit the revised current.txt to the main Android repository,\n you will need approval.\n******************************\n" ; exit 38 )
Change-Id: I63f237c6e046de8a6b6538c44ec0ab8bd8fbbdb1
--- frameworks/base/api/current.txt 2020-04-16 17:50:21.911899599 -0700
+++ out/soong/.intermediates/frameworks/base/api-stubs-docs/android_common/api-stubs-docs_api.txt 2020-04-16 17:51:35.211792638 -0700
@@ -10415,6 +10415,7 @@ public class Intent implements java.lang
field public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
field public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
field public static final String EXTRA_INSTALLER_PACKAGE_NAME = "android.intent.extra.INSTALLER_PACKAGE_NAME";
+ field public static final String EXTRA_INSTALL_RESULT = "android.intent.extra.INSTALL_RESULT";
field public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
field public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
field public static final String EXTRA_LOCAL_ONLY = "android.intent.extra.LOCAL_ONLY";
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)
to the new methods, etc. shown in the above diff.
2. You can update current.txt and/or removed.txt by executing the following command:
make api-stubs-docs-update-current-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
ninja: build stopped: subcommand failed.
```
Test: Remove @removed and @SystemApi from Intent.ACTION_MASTER_CLEAR, and do `m out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/check_current_api.timestamp`
Result is:
```
( true && diff -u -F '{ *$' frameworks/base/api/system-current.txt out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_api.txt && diff -u -F '{ *$' frameworks/base/api/system-removed.txt out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_removed.txt && touch out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/check_current_api.timestamp ) || ( echo -e "\n******************************\nYou have tried to change the API from what has been previously approved.\n\nTo make these errors go away, you have two choices:\n 1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)\n to the new methods, etc. shown in the above diff.\n\n 2. You can update current.txt and/or removed.txt by executing the following command:\n make system-api-stubs-docs-update-current-api\n\n To submit the revised current.txt to the main Android repository,\n you will need approval.\n******************************\n" ; exit 38 )
--- frameworks/base/api/system-removed.txt 2020-04-16 17:50:21.911899599 -0700
+++ out/soong/.intermediates/frameworks/base/system-api-stubs-docs/android_common/system-api-stubs-docs_removed.txt 2020-04-16 17:53:45.319602905 -0700
@@ -55,7 +55,6 @@ package android.content {
public class Intent implements java.lang.Cloneable android.os.Parcelable {
field @Deprecated public static final String ACTION_DEVICE_INITIALIZATION_WIZARD = "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
- field @Deprecated public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
field @Deprecated public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
field @Deprecated public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
field @Deprecated public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1. You can add '@hide' javadoc comments (and remove @SystemApi/@TestApi/etc)
to the new methods, etc. shown in the above diff.
2. You can update current.txt and/or removed.txt by executing the following command:
make system-api-stubs-docs-update-current-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
```
Test: Add `baseline_file` to `check_api.current` and run `m`
FAILED: out/soong/build.ninja
out/soong/.bootstrap/bin/soong_build -t -l out/.module_paths/Android.bp.list -b out/soong -n out -d out/soong/build.ninja.d -globFile out/soong/.bootstrap/build-globs.ninja -o out/soong/build.ninja Android.bp
error: frameworks/base/StubLibraries.bp:86:1: module "api-stubs-docs" variant "android_common": current API check can't have a baseline file. (module %s): api-stubs-docs
ninja: build stopped: subcommand failed.
Test: With the above changes, run "m api-stubs-docs-update-current-api system-api-stubs-docs-update-current-api", make sure the API files got updated, and then run "m"
Change-Id: I47b146c6fe4caa65775ecf5425ab09b57f43f839
2020-04-17 02:02:40 +02:00
|
|
|
rule.Build(pctx, ctx, "metalavaCurrentApiCheck", "check current API")
|
2018-05-05 03:49:16 +02:00
|
|
|
|
|
|
|
d.updateCurrentApiTimestamp = android.PathForModuleOut(ctx, "update_current_api.timestamp")
|
2019-07-11 20:01:22 +02:00
|
|
|
|
|
|
|
// update API rule
|
|
|
|
rule = android.NewRuleBuilder()
|
|
|
|
|
|
|
|
rule.Command().Text("( true")
|
|
|
|
|
|
|
|
rule.Command().
|
|
|
|
Text("cp").Flag("-f").
|
|
|
|
Input(d.apiFile).Flag(apiFile.String())
|
|
|
|
|
|
|
|
rule.Command().
|
|
|
|
Text("cp").Flag("-f").
|
|
|
|
Input(d.removedApiFile).Flag(removedApiFile.String())
|
|
|
|
|
|
|
|
msg = "failed to update public API"
|
|
|
|
|
|
|
|
rule.Command().
|
|
|
|
Text("touch").Output(d.updateCurrentApiTimestamp).
|
|
|
|
Text(") || (").
|
|
|
|
Text("echo").Flag("-e").Flag(`"` + msg + `"`).
|
|
|
|
Text("; exit 38").
|
|
|
|
Text(")")
|
|
|
|
|
|
|
|
rule.Build(pctx, ctx, "metalavaCurrentApiUpdate", "update current API")
|
2018-05-05 03:49:16 +02:00
|
|
|
}
|
2018-08-01 21:48:00 +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")
|
|
|
|
}
|
2019-07-11 20:01:22 +02:00
|
|
|
|
|
|
|
checkNullabilityWarnings := android.PathForModuleSrc(ctx, String(d.properties.Check_nullability_warnings))
|
|
|
|
|
2018-10-22 16:55:04 +02:00
|
|
|
d.checkNullabilityWarningsTimestamp = android.PathForModuleOut(ctx, "check_nullability_warnings.timestamp")
|
2019-07-11 20:01:22 +02:00
|
|
|
|
2018-10-22 16:55:04 +02:00
|
|
|
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)
|
2019-07-11 20:01:22 +02:00
|
|
|
|
|
|
|
rule := android.NewRuleBuilder()
|
|
|
|
|
|
|
|
rule.Command().
|
|
|
|
Text("(").
|
|
|
|
Text("diff").Input(checkNullabilityWarnings).Input(d.nullabilityWarningsFile).
|
|
|
|
Text("&&").
|
|
|
|
Text("touch").Output(d.checkNullabilityWarningsTimestamp).
|
|
|
|
Text(") || (").
|
|
|
|
Text("echo").Flag("-e").Flag(`"` + msg + `"`).
|
|
|
|
Text("; exit 38").
|
|
|
|
Text(")")
|
|
|
|
|
|
|
|
rule.Build(pctx, ctx, "nullabilityWarningsCheck", "nullability warnings check")
|
2018-10-22 16:55:04 +02:00
|
|
|
}
|
|
|
|
|
2018-09-17 23:32:21 +02:00
|
|
|
if Bool(d.properties.Jdiff_enabled) && !ctx.Config().IsPdkBuild() {
|
2019-07-11 20:01:22 +02:00
|
|
|
if len(d.Javadoc.properties.Out) > 0 {
|
|
|
|
ctx.PropertyErrorf("out", "out property may not be combined with jdiff")
|
|
|
|
}
|
|
|
|
|
|
|
|
outDir := android.PathForModuleOut(ctx, "jdiff-out")
|
|
|
|
srcJarDir := android.PathForModuleOut(ctx, "jdiff-srcjars")
|
|
|
|
stubsDir := android.PathForModuleOut(ctx, "jdiff-stubsDir")
|
|
|
|
|
|
|
|
rule := android.NewRuleBuilder()
|
2018-09-17 23:32:21 +02:00
|
|
|
|
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")
|
|
|
|
|
|
|
|
jdiff := android.PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "framework", "jdiff.jar")
|
|
|
|
|
2019-07-11 20:01:22 +02:00
|
|
|
rule.Command().Text("rm -rf").Text(outDir.String()).Text(stubsDir.String())
|
|
|
|
rule.Command().Text("mkdir -p").Text(outDir.String()).Text(stubsDir.String())
|
|
|
|
|
|
|
|
srcJarList := zipSyncCmd(ctx, rule, srcJarDir, d.Javadoc.srcJars)
|
2018-09-17 23:32:21 +02:00
|
|
|
|
2019-07-16 07:53:46 +02:00
|
|
|
cmd := javadocBootclasspathCmd(ctx, rule, d.Javadoc.srcFiles, outDir, srcJarDir, srcJarList,
|
2019-07-16 01:13:59 +02:00
|
|
|
deps.bootClasspath, deps.classpath, d.sourcepaths)
|
|
|
|
|
|
|
|
cmd.Flag("-J-Xmx1600m").
|
2019-07-11 20:01:22 +02:00
|
|
|
Flag("-XDignore.symbol.file").
|
|
|
|
FlagWithArg("-doclet ", "jdiff.JDiff").
|
|
|
|
FlagWithInput("-docletpath ", jdiff).
|
|
|
|
Flag("-quiet").
|
|
|
|
FlagWithArg("-newapi ", strings.TrimSuffix(d.apiXmlFile.Base(), d.apiXmlFile.Ext())).
|
|
|
|
FlagWithArg("-newapidir ", filepath.Dir(d.apiXmlFile.String())).
|
|
|
|
Implicit(d.apiXmlFile).
|
|
|
|
FlagWithArg("-oldapi ", strings.TrimSuffix(d.lastReleasedApiXmlFile.Base(), d.lastReleasedApiXmlFile.Ext())).
|
|
|
|
FlagWithArg("-oldapidir ", filepath.Dir(d.lastReleasedApiXmlFile.String())).
|
|
|
|
Implicit(d.lastReleasedApiXmlFile)
|
|
|
|
|
|
|
|
rule.Command().
|
|
|
|
BuiltTool(ctx, "soong_zip").
|
|
|
|
Flag("-write_if_changed").
|
|
|
|
Flag("-d").
|
|
|
|
FlagWithOutput("-o ", d.jdiffDocZip).
|
|
|
|
FlagWithArg("-C ", outDir.String()).
|
|
|
|
FlagWithArg("-D ", outDir.String())
|
|
|
|
|
|
|
|
rule.Command().
|
|
|
|
BuiltTool(ctx, "soong_zip").
|
|
|
|
Flag("-write_if_changed").
|
|
|
|
Flag("-jar").
|
|
|
|
FlagWithOutput("-o ", d.jdiffStubsSrcJar).
|
|
|
|
FlagWithArg("-C ", stubsDir.String()).
|
|
|
|
FlagWithArg("-D ", stubsDir.String())
|
|
|
|
|
|
|
|
rule.Restat()
|
|
|
|
|
|
|
|
zipSyncCleanupCmd(rule, srcJarDir)
|
|
|
|
|
|
|
|
rule.Build(pctx, ctx, "jdiff", "jdiff")
|
2018-09-17 23:32:21 +02:00
|
|
|
}
|
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
|
|
|
|
}
|
|
|
|
|
2019-07-09 01:48:04 +02:00
|
|
|
// droiddoc_exported_dir exports a directory of html templates or nullability annotations for use by doclava.
|
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
|
|
|
|
}
|
2019-07-11 20:01:22 +02:00
|
|
|
|
|
|
|
func zipSyncCmd(ctx android.ModuleContext, rule *android.RuleBuilder,
|
|
|
|
srcJarDir android.ModuleOutPath, srcJars android.Paths) android.OutputPath {
|
|
|
|
|
|
|
|
rule.Command().Text("rm -rf").Text(srcJarDir.String())
|
|
|
|
rule.Command().Text("mkdir -p").Text(srcJarDir.String())
|
|
|
|
srcJarList := srcJarDir.Join(ctx, "list")
|
|
|
|
|
|
|
|
rule.Temporary(srcJarList)
|
|
|
|
|
|
|
|
rule.Command().BuiltTool(ctx, "zipsync").
|
|
|
|
FlagWithArg("-d ", srcJarDir.String()).
|
|
|
|
FlagWithOutput("-l ", srcJarList).
|
|
|
|
FlagWithArg("-f ", `"*.java"`).
|
|
|
|
Inputs(srcJars)
|
|
|
|
|
|
|
|
return srcJarList
|
|
|
|
}
|
|
|
|
|
|
|
|
func zipSyncCleanupCmd(rule *android.RuleBuilder, srcJarDir android.ModuleOutPath) {
|
|
|
|
rule.Command().Text("rm -rf").Text(srcJarDir.String())
|
|
|
|
}
|
2019-11-12 20:39:36 +01:00
|
|
|
|
|
|
|
var _ android.PrebuiltInterface = (*PrebuiltStubsSources)(nil)
|
|
|
|
|
|
|
|
type PrebuiltStubsSourcesProperties struct {
|
|
|
|
Srcs []string `android:"path"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type PrebuiltStubsSources struct {
|
|
|
|
android.ModuleBase
|
|
|
|
android.DefaultableModuleBase
|
|
|
|
prebuilt android.Prebuilt
|
|
|
|
android.SdkBase
|
|
|
|
|
|
|
|
properties PrebuiltStubsSourcesProperties
|
|
|
|
|
2019-12-10 14:41:51 +01:00
|
|
|
// The source directories containing stubs source files.
|
|
|
|
srcDirs android.Paths
|
2019-11-12 20:39:36 +01:00
|
|
|
stubsSrcJar android.ModuleOutPath
|
|
|
|
}
|
|
|
|
|
2019-12-10 14:41:51 +01:00
|
|
|
func (p *PrebuiltStubsSources) OutputFiles(tag string) (android.Paths, error) {
|
|
|
|
switch tag {
|
|
|
|
case "":
|
|
|
|
return android.Paths{p.stubsSrcJar}, nil
|
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-12 20:39:36 +01:00
|
|
|
func (p *PrebuiltStubsSources) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
2019-12-10 14:41:51 +01:00
|
|
|
p.stubsSrcJar = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"stubs.srcjar")
|
|
|
|
|
|
|
|
p.srcDirs = android.PathsForModuleSrc(ctx, p.properties.Srcs)
|
|
|
|
|
|
|
|
rule := android.NewRuleBuilder()
|
|
|
|
command := rule.Command().
|
|
|
|
BuiltTool(ctx, "soong_zip").
|
|
|
|
Flag("-write_if_changed").
|
|
|
|
Flag("-jar").
|
|
|
|
FlagWithOutput("-o ", p.stubsSrcJar)
|
|
|
|
|
|
|
|
for _, d := range p.srcDirs {
|
|
|
|
dir := d.String()
|
|
|
|
command.
|
|
|
|
FlagWithArg("-C ", dir).
|
|
|
|
FlagWithInput("-D ", d)
|
|
|
|
}
|
|
|
|
|
|
|
|
rule.Restat()
|
|
|
|
|
|
|
|
rule.Build(pctx, ctx, "zip src", "Create srcjar from prebuilt source")
|
2019-11-12 20:39:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *PrebuiltStubsSources) Prebuilt() *android.Prebuilt {
|
|
|
|
return &p.prebuilt
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *PrebuiltStubsSources) Name() string {
|
|
|
|
return p.prebuilt.Name(p.ModuleBase.Name())
|
|
|
|
}
|
|
|
|
|
|
|
|
// prebuilt_stubs_sources imports a set of java source files as if they were
|
|
|
|
// generated by droidstubs.
|
|
|
|
//
|
|
|
|
// By default, a prebuilt_stubs_sources has a single variant that expects a
|
|
|
|
// set of `.java` files generated by droidstubs.
|
|
|
|
//
|
|
|
|
// Specifying `host_supported: true` will produce two variants, one for use as a dependency of device modules and one
|
|
|
|
// for host modules.
|
|
|
|
//
|
|
|
|
// Intended only for use by sdk snapshots.
|
|
|
|
func PrebuiltStubsSourcesFactory() android.Module {
|
|
|
|
module := &PrebuiltStubsSources{}
|
|
|
|
|
|
|
|
module.AddProperties(&module.properties)
|
|
|
|
|
|
|
|
android.InitPrebuiltModule(module, &module.properties.Srcs)
|
|
|
|
android.InitSdkAwareModule(module)
|
|
|
|
InitDroiddocModule(module, android.HostAndDeviceSupported)
|
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
2019-11-28 15:31:38 +01:00
|
|
|
type droidStubsSdkMemberType struct {
|
2019-12-13 12:22:16 +01:00
|
|
|
android.SdkMemberTypeBase
|
2019-11-28 15:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (mt *droidStubsSdkMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) {
|
|
|
|
mctx.AddVariationDependencies(nil, dependencyTag, names...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mt *droidStubsSdkMemberType) IsInstance(module android.Module) bool {
|
|
|
|
_, ok := module.(*Droidstubs)
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2020-03-20 14:35:40 +01:00
|
|
|
func (mt *droidStubsSdkMemberType) AddPrebuiltModule(ctx android.SdkMemberContext, member android.SdkMember) android.BpModule {
|
|
|
|
return ctx.SnapshotBuilder().AddPrebuiltModule(member, "prebuilt_stubs_sources")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mt *droidStubsSdkMemberType) CreateVariantPropertiesStruct() android.SdkMemberProperties {
|
|
|
|
return &droidStubsInfoProperties{}
|
|
|
|
}
|
|
|
|
|
|
|
|
type droidStubsInfoProperties struct {
|
|
|
|
android.SdkMemberPropertiesBase
|
|
|
|
|
|
|
|
StubsSrcJar android.Path
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *droidStubsInfoProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) {
|
|
|
|
droidstubs := variant.(*Droidstubs)
|
|
|
|
p.StubsSrcJar = droidstubs.stubsSrcJar
|
|
|
|
}
|
2019-11-12 20:39:36 +01:00
|
|
|
|
2020-03-20 14:35:40 +01:00
|
|
|
func (p *droidStubsInfoProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
|
|
|
|
if p.StubsSrcJar != nil {
|
|
|
|
builder := ctx.SnapshotBuilder()
|
2019-11-12 20:39:36 +01:00
|
|
|
|
2020-03-20 14:35:40 +01:00
|
|
|
snapshotRelativeDir := filepath.Join("java", ctx.Name()+"_stubs_sources")
|
|
|
|
|
|
|
|
builder.UnzipToSnapshot(p.StubsSrcJar, snapshotRelativeDir)
|
|
|
|
|
|
|
|
propertySet.AddProperty("srcs", []string{snapshotRelativeDir})
|
|
|
|
}
|
2019-11-12 20:39:36 +01:00
|
|
|
}
|