Merge "Export dex implementation jars from prebuilt_apex"
diff --git a/cc/config/tidy.go b/cc/config/tidy.go
index 4ac9e58..b3a86f3 100644
--- a/cc/config/tidy.go
+++ b/cc/config/tidy.go
@@ -20,24 +20,48 @@
)
func init() {
- // Most Android source files are not clang-tidy clean yet.
- // Global tidy checks include only google*, performance*,
- // and misc-macro-parentheses, but not google-readability*
- // or google-runtime-references.
+ // Many clang-tidy checks like altera-*, llvm-*, modernize-*
+ // are not designed for Android source code or creating too
+ // many (false-positive) warnings. The global default tidy checks
+ // should include only tested groups and exclude known noisy checks.
+ // See https://clang.llvm.org/extra/clang-tidy/checks/list.html
pctx.VariableFunc("TidyDefaultGlobalChecks", func(ctx android.PackageVarContext) string {
if override := ctx.Config().Getenv("DEFAULT_GLOBAL_TIDY_CHECKS"); override != "" {
return override
}
return strings.Join([]string{
"-*",
- "bugprone*",
+ "abseil-*",
+ "android-*",
+ "bugprone-*",
+ "cert-*",
+ // clang-analyzer-* check is slow and enables clang-diagnostic-padded,
+ // which cannot be suppressed yet.
+ // "clang-analyzer-*",
"clang-diagnostic-unused-command-line-argument",
- "google*",
- "misc-macro-parentheses",
- "performance*",
+ "google-*",
+ "misc-*",
+ "performance-*",
+ "portability-*",
"-bugprone-narrowing-conversions",
"-google-readability*",
"-google-runtime-references",
+ "-misc-no-recursion",
+ "-misc-non-private-member-variables-in-classes",
+ "-misc-unused-parameters",
+ // the following groups are excluded by -*
+ // -altera-*
+ // -cppcoreguidelines-*
+ // -darwin-*
+ // -fuchsia-*
+ // -hicpp-*
+ // -llvm-*
+ // -llvmlibc-*
+ // -modernize-*
+ // -mpi-*
+ // -objc-*
+ // -readability-*
+ // -zircon-*
}, ",")
})
diff --git a/cc/tidy.go b/cc/tidy.go
index 17471e6..972ad7b 100644
--- a/cc/tidy.go
+++ b/cc/tidy.go
@@ -15,6 +15,7 @@
package cc
import (
+ "regexp"
"strings"
"github.com/google/blueprint/proptools"
@@ -130,7 +131,31 @@
tidyChecks = tidyChecks + ",-bugprone-branch-clone"
flags.TidyFlags = append(flags.TidyFlags, tidyChecks)
- if len(tidy.Properties.Tidy_checks_as_errors) > 0 {
+ if ctx.Config().IsEnvTrue("WITH_TIDY") {
+ // WITH_TIDY=1 enables clang-tidy globally. There could be many unexpected
+ // warnings from new checks and many local tidy_checks_as_errors and
+ // -warnings-as-errors can break a global build.
+ // So allow all clang-tidy warnings.
+ inserted := false
+ for i, s := range flags.TidyFlags {
+ if strings.Contains(s, "-warnings-as-errors=") {
+ // clang-tidy accepts only one -warnings-as-errors
+ // replace the old one
+ re := regexp.MustCompile(`'?-?-warnings-as-errors=[^ ]* *`)
+ newFlag := re.ReplaceAllString(s, "")
+ if newFlag == "" {
+ flags.TidyFlags[i] = "-warnings-as-errors=-*"
+ } else {
+ flags.TidyFlags[i] = newFlag + " -warnings-as-errors=-*"
+ }
+ inserted = true
+ break
+ }
+ }
+ if !inserted {
+ flags.TidyFlags = append(flags.TidyFlags, "-warnings-as-errors=-*")
+ }
+ } else if len(tidy.Properties.Tidy_checks_as_errors) > 0 {
tidyChecksAsErrors := "-warnings-as-errors=" + strings.Join(esc(tidy.Properties.Tidy_checks_as_errors), ",")
flags.TidyFlags = append(flags.TidyFlags, tidyChecksAsErrors)
}
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index 907bed3..1b7ac55 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -57,7 +57,7 @@
return configuration.IsEnvTrue("CONVERT_TO_BAZEL")
}
-func newContext(srcDir string, configuration android.Config) *android.Context {
+func newContext(configuration android.Config) *android.Context {
ctx := android.NewContext(configuration)
if bazelConversionRequested(configuration) {
// Register an alternate set of singletons and mutators for bazel
@@ -106,7 +106,7 @@
// needed to correctly evaluate the tree in the second pass.
// TODO(cparsons): Don't output any ninja file, as the second pass will overwrite
// the incorrect results from the first pass, and file I/O is expensive.
- firstCtx := newContext(srcDir, configuration)
+ firstCtx := newContext(configuration)
configuration.SetStopBefore(bootstrap.StopBeforeWriteNinja)
bootstrap.Main(firstCtx.Context, configuration, extraNinjaDeps...)
// Invoke bazel commands and save results for second pass.
@@ -120,10 +120,10 @@
fmt.Fprintf(os.Stderr, "%s", err)
os.Exit(1)
}
- ctx = newContext(srcDir, secondPassConfig)
+ ctx = newContext(secondPassConfig)
bootstrap.Main(ctx.Context, secondPassConfig, extraNinjaDeps...)
} else {
- ctx = newContext(srcDir, configuration)
+ ctx = newContext(configuration)
bootstrap.Main(ctx.Context, configuration, extraNinjaDeps...)
}
diff --git a/scripts/manifest_fixer.py b/scripts/manifest_fixer.py
index c59732b..55d0fd1 100755
--- a/scripts/manifest_fixer.py
+++ b/scripts/manifest_fixer.py
@@ -121,7 +121,7 @@
# is empty. Set it to something low so that it will be overriden by the
# main manifest, but high enough that it doesn't cause implicit
# permissions grants.
- target_attr.value = '15'
+ target_attr.value = '16'
else:
target_attr.value = target_sdk_version
element.setAttributeNode(target_attr)
diff --git a/scripts/manifest_fixer_test.py b/scripts/manifest_fixer_test.py
index d6e7f26..3a0a25d 100755
--- a/scripts/manifest_fixer_test.py
+++ b/scripts/manifest_fixer_test.py
@@ -173,7 +173,7 @@
"""Tests inserting targetSdkVersion when minSdkVersion exists."""
manifest_input = self.manifest_tmpl % self.uses_sdk(min='27')
- expected = self.manifest_tmpl % self.uses_sdk(min='28', target='15')
+ expected = self.manifest_tmpl % self.uses_sdk(min='28', target='16')
output = self.raise_min_sdk_version_test(manifest_input, '28', '29', True)
self.assertEqual(output, expected)
@@ -189,7 +189,7 @@
"""Tests inserting targetSdkVersion when minSdkVersion does not exist."""
manifest_input = self.manifest_tmpl % ''
- expected = self.manifest_tmpl % self.uses_sdk(min='28', target='15')
+ expected = self.manifest_tmpl % self.uses_sdk(min='28', target='16')
output = self.raise_min_sdk_version_test(manifest_input, '28', '29', True)
self.assertEqual(output, expected)
diff --git a/sysprop/sysprop_library.go b/sysprop/sysprop_library.go
index 38306ad..2ccce15 100644
--- a/sysprop/sysprop_library.go
+++ b/sysprop/sysprop_library.go
@@ -19,6 +19,7 @@
import (
"fmt"
"io"
+ "os"
"path"
"sync"
@@ -125,8 +126,8 @@
properties syspropLibraryProperties
checkApiFileTimeStamp android.WritablePath
- latestApiFile android.Path
- currentApiFile android.Path
+ latestApiFile android.OptionalPath
+ currentApiFile android.OptionalPath
dumpedApiFile android.WritablePath
}
@@ -224,7 +225,7 @@
return proptools.Bool(m.properties.Public_stub)
}
-func (m *syspropLibrary) CurrentSyspropApiFile() android.Path {
+func (m *syspropLibrary) CurrentSyspropApiFile() android.OptionalPath {
return m.currentApiFile
}
@@ -243,8 +244,11 @@
return
}
- m.currentApiFile = android.PathForSource(ctx, ctx.ModuleDir(), "api", baseModuleName+"-current.txt")
- m.latestApiFile = android.PathForSource(ctx, ctx.ModuleDir(), "api", baseModuleName+"-latest.txt")
+ apiDirectoryPath := path.Join(ctx.ModuleDir(), "api")
+ currentApiFilePath := path.Join(apiDirectoryPath, baseModuleName+"-current.txt")
+ latestApiFilePath := path.Join(apiDirectoryPath, baseModuleName+"-latest.txt")
+ m.currentApiFile = android.ExistentPathForSource(ctx, currentApiFilePath)
+ m.latestApiFile = android.ExistentPathForSource(ctx, latestApiFilePath)
// dump API rule
rule := android.NewRuleBuilder(pctx, ctx)
@@ -258,19 +262,37 @@
// check API rule
rule = android.NewRuleBuilder(pctx, ctx)
+ // We allow that the API txt files don't exist, when the sysprop_library only contains internal
+ // properties. But we have to feed current api file and latest api file to the rule builder.
+ // Currently we can't get android.Path representing the null device, so we add any existing API
+ // txt files to implicits, and then directly feed string paths, rather than calling Input(Path)
+ // method.
+ var apiFileList android.Paths
+ currentApiArgument := os.DevNull
+ if m.currentApiFile.Valid() {
+ apiFileList = append(apiFileList, m.currentApiFile.Path())
+ currentApiArgument = m.currentApiFile.String()
+ }
+
+ latestApiArgument := os.DevNull
+ if m.latestApiFile.Valid() {
+ apiFileList = append(apiFileList, m.latestApiFile.Path())
+ latestApiArgument = m.latestApiFile.String()
+ }
+
// 1. compares current.txt to api-dump.txt
// current.txt should be identical to api-dump.txt.
msg := fmt.Sprintf(`\n******************************\n`+
`API of sysprop_library %s doesn't match with current.txt\n`+
`Please update current.txt by:\n`+
- `m %s-dump-api && rm -rf %q && cp -f %q %q\n`+
+ `m %s-dump-api && mkdir -p %q && rm -rf %q && cp -f %q %q\n`+
`******************************\n`, baseModuleName, baseModuleName,
- m.currentApiFile.String(), m.dumpedApiFile.String(), m.currentApiFile.String())
+ apiDirectoryPath, currentApiFilePath, m.dumpedApiFile.String(), currentApiFilePath)
rule.Command().
Text("( cmp").Flag("-s").
Input(m.dumpedApiFile).
- Input(m.currentApiFile).
+ Text(currentApiArgument).
Text("|| ( echo").Flag("-e").
Flag(`"` + msg + `"`).
Text("; exit 38) )")
@@ -285,11 +307,12 @@
rule.Command().
Text("( ").
BuiltTool("sysprop_api_checker").
- Input(m.latestApiFile).
- Input(m.currentApiFile).
+ Text(latestApiArgument).
+ Text(currentApiArgument).
Text(" || ( echo").Flag("-e").
Flag(`"` + msg + `"`).
- Text("; exit 38) )")
+ Text("; exit 38) )").
+ Implicits(apiFileList)
m.checkApiFileTimeStamp = android.PathForModuleOut(ctx, "check_api.timestamp")
@@ -393,31 +416,6 @@
ctx.PropertyErrorf("srcs", "sysprop_library must specify srcs")
}
- missingApi := false
-
- for _, txt := range []string{"-current.txt", "-latest.txt"} {
- path := path.Join(ctx.ModuleDir(), "api", m.BaseModuleName()+txt)
- file := android.ExistentPathForSource(ctx, path)
- if !file.Valid() {
- ctx.ModuleErrorf("API file %#v doesn't exist", path)
- missingApi = true
- }
- }
-
- if missingApi {
- script := "build/soong/scripts/gen-sysprop-api-files.sh"
- p := android.ExistentPathForSource(ctx, script)
-
- if !p.Valid() {
- panic(fmt.Sprintf("script file %s doesn't exist", script))
- }
-
- ctx.ModuleErrorf("One or more api files are missing. "+
- "You can create them by:\n"+
- "%s %q %q", script, ctx.ModuleDir(), m.BaseModuleName())
- return
- }
-
// ctx's Platform or Specific functions represent where this sysprop_library installed.
installedInSystem := ctx.Platform() || ctx.SystemExtSpecific()
installedInVendorOrOdm := ctx.SocSpecific() || ctx.DeviceSpecific()