diff options
author | Nan Zhang <nanzhang@google.com> | 2018-08-24 15:59:17 +0000 |
---|---|---|
committer | Nan Zhang <nanzhang@google.com> | 2018-08-24 15:59:17 +0000 |
commit | ec716b4151a27ed115cfa50fb10a6e1f9efaac93 (patch) | |
tree | 3df24ba7e7a031d3ae262639a116752f7bffbaba /java/droiddoc.go | |
parent | ed0a39dba790268dbd99a930e27c7bcd21c3c932 (diff) | |
download | android_build_soong-ec716b4151a27ed115cfa50fb10a6e1f9efaac93.tar.gz android_build_soong-ec716b4151a27ed115cfa50fb10a6e1f9efaac93.tar.bz2 android_build_soong-ec716b4151a27ed115cfa50fb10a6e1f9efaac93.zip |
Revert "Make Metalava checkapi a seperate run."
This reverts commit ed0a39dba790268dbd99a930e27c7bcd21c3c932.
Reason for revert:
it seems checkapi can be passed successfully even if we didn't do update-api for new changes. roll-back for now and do more investigation.
Change-Id: Idd54ea8919671d54aa6401233156d6c0bcf5325f
Diffstat (limited to 'java/droiddoc.go')
-rw-r--r-- | java/droiddoc.go | 103 |
1 files changed, 44 insertions, 59 deletions
diff --git a/java/droiddoc.go b/java/droiddoc.go index 1538d91b..ac4f86f2 100644 --- a/java/droiddoc.go +++ b/java/droiddoc.go @@ -88,16 +88,6 @@ var ( }, "outDir", "srcJarDir", "stubsDir", "docStubsDir", "srcJars", "javaVersion", "bootclasspathArgs", "classpathArgs", "sourcepath", "opts", "docZip") - - metalavaApiCheck = pctx.AndroidStaticRule("metalavaApiCheck", - blueprint.RuleParams{ - Command: `( ${config.JavaCmd} -jar ${config.MetalavaJar} $opts && touch $out ) || (echo -e "$msg" ; exit 38)`, - CommandDeps: []string{ - "${config.JavaCmd}", - "${config.MetalavaJar}", - }, - }, - "opts", "msg") ) func init() { @@ -298,9 +288,10 @@ type droiddocBuilderFlags struct { doclavaDocsFlags string postDoclavaCmds string - metalavaStubsFlags string - metalavaAnnotationsFlags string - metalavaJavadocFlags string + metalavaStubsFlags string + metalavaAnnotationsFlags string + metalavaJavadocFlags string + metalavaCompatibilityCheckFlags string metalavaDokkaFlags string } @@ -1023,6 +1014,38 @@ func (d *Droiddoc) collectMetalavaDokkaFlags(ctx android.ModuleContext, implicit docStubsDir + " " + classpathArgs + " -format dac -dacRoot /reference/kotlin -output " + outDir } +func (d *Droiddoc) collectMetalavaCompatibilityCheckFlags(ctx android.ModuleContext, + implicits *android.Paths) string { + var flags string + if d.checkCurrentApi() && !ctx.Config().IsPdkBuild() { + apiFile := ctx.ExpandSource(String(d.properties.Check_api.Current.Api_file), + "check_api.current.api_file") + removedApiFile := ctx.ExpandSource(String(d.properties.Check_api.Current.Removed_api_file), + "check_api.current_removed_api_file") + + *implicits = append(*implicits, apiFile) + *implicits = append(*implicits, removedApiFile) + + flags = " --check-compatibility:api:current " + apiFile.String() + + " --check-compatibility:removed:current " + removedApiFile.String() + " " + } + + if d.checkLastReleasedApi() && !ctx.Config().IsPdkBuild() { + apiFile := ctx.ExpandSource(String(d.properties.Check_api.Last_released.Api_file), + "check_api.last_released.api_file") + removedApiFile := ctx.ExpandSource(String(d.properties.Check_api.Last_released.Removed_api_file), + "check_api.last_released.removed_api_file") + + *implicits = append(*implicits, apiFile) + *implicits = append(*implicits, removedApiFile) + + flags = flags + " --check-compatibility:api:released " + apiFile.String() + + " --check-compatibility:removed:released " + removedApiFile.String() + " " + } + + return flags +} + func (d *Droiddoc) transformMetalava(ctx android.ModuleContext, implicits android.Paths, implicitOutputs android.WritablePaths, outDir, docStubsDir, javaVersion, bootclasspathArgs, classpathArgs, opts string) { @@ -1094,21 +1117,6 @@ func (d *Droiddoc) transformCheckApi(ctx android.ModuleContext, apiFile, removed }) } -func (d *Droiddoc) transformMetalavaCheckApi(ctx android.ModuleContext, apiFile, removedApiFile android.Path, - msg, opts string, output android.WritablePath) { - ctx.Build(pctx, android.BuildParams{ - Rule: metalavaApiCheck, - Description: "Metalava Check API", - Output: output, - Inputs: nil, - Implicits: android.Paths{apiFile, removedApiFile, d.apiFile, d.removedApiFile}, - Args: map[string]string{ - "opts": opts, - "msg": msg, - }, - }) -} - func (d *Droiddoc) transformUpdateApi(ctx android.ModuleContext, apiFile, removedApiFile android.Path, output android.WritablePath) { ctx.Build(pctx, android.BuildParams{ @@ -1151,6 +1159,7 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) { flags.doclavaStubsFlags, flags.metalavaStubsFlags = d.collectStubsFlags(ctx, &implicitOutputs) if Bool(d.properties.Metalava_enabled) { flags.metalavaAnnotationsFlags = d.collectMetalavaAnnotationsFlags(ctx, &implicits, &implicitOutputs) + flags.metalavaCompatibilityCheckFlags = d.collectMetalavaCompatibilityCheckFlags(ctx, &implicits) outDir := android.PathForModuleOut(ctx, "out").String() docStubsDir := android.PathForModuleOut(ctx, "docStubsDir").String() // TODO(nanzhang): Add a Soong property to handle documentation args. @@ -1160,7 +1169,7 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) { flags.dokkaClasspathArgs, outDir, docStubsDir) d.transformMetalava(ctx, implicits, implicitOutputs, outDir, docStubsDir, javaVersion, flags.bootClasspathArgs, flags.classpathArgs, flags.metalavaStubsFlags+ - flags.metalavaAnnotationsFlags+" "+ + flags.metalavaAnnotationsFlags+" "+flags.metalavaCompatibilityCheckFlags+" "+ strings.Split(flags.args, "--generate-documentation")[0]+ flags.metalavaDokkaFlags+" "+strings.Split(flags.args, "--generate-documentation")[1]) } else { @@ -1169,7 +1178,7 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) { flags.doclavaDocsFlags = d.collectDoclavaDocsFlags(ctx, &implicits, jsilver, doclava) d.transformMetalava(ctx, implicits, implicitOutputs, outDir, docStubsDir, javaVersion, flags.bootClasspathArgs, flags.classpathArgs, flags.metalavaStubsFlags+ - flags.metalavaAnnotationsFlags+" "+ + flags.metalavaAnnotationsFlags+" "+flags.metalavaCompatibilityCheckFlags+" "+ strings.Split(flags.args, "--generate-documentation")[0]+ flags.metalavaJavadocFlags+flags.doclavaDocsFlags+ " "+strings.Split(flags.args, "--generate-documentation")[1]) @@ -1177,7 +1186,8 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) { } else { d.transformMetalava(ctx, implicits, implicitOutputs, outDir, docStubsDir, javaVersion, flags.bootClasspathArgs, flags.classpathArgs, - flags.metalavaStubsFlags+flags.metalavaAnnotationsFlags+" "+flags.args) + flags.metalavaStubsFlags+flags.metalavaAnnotationsFlags+" "+ + flags.metalavaCompatibilityCheckFlags+flags.args) } } else { flags.doclavaDocsFlags = d.collectDoclavaDocsFlags(ctx, &implicits, jsilver, doclava) @@ -1193,8 +1203,8 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) { removedApiFile := ctx.ExpandSource(String(d.properties.Check_api.Current.Removed_api_file), "check_api.current_removed_api_file") - d.checkCurrentApiTimestamp = android.PathForModuleOut(ctx, "check_current_api.timestamp") if !Bool(d.properties.Metalava_enabled) { + d.checkCurrentApiTimestamp = android.PathForModuleOut(ctx, "check_current_api.timestamp") d.transformCheckApi(ctx, apiFile, removedApiFile, checkApiClasspath, fmt.Sprintf(`\n******************************\n`+ `You have tried to change the API from what has been previously approved.\n\n`+ @@ -1207,22 +1217,6 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) { ` you will need approval.\n`+ `******************************\n`, ctx.ModuleName()), String(d.properties.Check_api.Current.Args), d.checkCurrentApiTimestamp) - } else { - opts := " --check-compatibility:api:current " + apiFile.String() + - " --check-compatibility:removed:current " + removedApiFile.String() + " " - - d.transformMetalavaCheckApi(ctx, apiFile, removedApiFile, - 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()), opts, - d.checkCurrentApiTimestamp) } d.updateCurrentApiTimestamp = android.PathForModuleOut(ctx, "update_current_api.timestamp") @@ -1235,24 +1229,15 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) { removedApiFile := ctx.ExpandSource(String(d.properties.Check_api.Last_released.Removed_api_file), "check_api.last_released.removed_api_file") - d.checkLastReleasedApiTimestamp = android.PathForModuleOut(ctx, "check_last_released_api.timestamp") if !Bool(d.properties.Metalava_enabled) { + d.checkLastReleasedApiTimestamp = android.PathForModuleOut(ctx, "check_last_released_api.timestamp") + d.transformCheckApi(ctx, apiFile, removedApiFile, checkApiClasspath, `\n******************************\n`+ `You have tried to change the API from what has been previously released in\n`+ `an SDK. Please fix the errors listed above.\n`+ `******************************\n`, String(d.properties.Check_api.Last_released.Args), d.checkLastReleasedApiTimestamp) - } else { - opts := " --check-compatibility:api:released " + apiFile.String() + - " --check-compatibility:removed:released " + removedApiFile.String() + " " - - d.transformMetalavaCheckApi(ctx, apiFile, removedApiFile, - `\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`, opts, - d.checkLastReleasedApiTimestamp) } } } |