Merge "remove hwasan-use-after-scope=1 which is default now" into main am: cba8307c25 am: 38e8695b9e
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3067687
Change-Id: I24113d2670db76fa92a7b0f1f93aa22f4fdc856e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/aconfig/aconfig_declarations.go b/aconfig/aconfig_declarations.go
index d29e312..71a64dd 100644
--- a/aconfig/aconfig_declarations.go
+++ b/aconfig/aconfig_declarations.go
@@ -73,8 +73,9 @@
if len(module.properties.Package) == 0 {
ctx.PropertyErrorf("package", "missing package property")
}
- // TODO(b/311155208): Add mandatory check for container after all pre-existing
- // ones are changed.
+ if len(module.properties.Container) == 0 {
+ ctx.PropertyErrorf("container", "missing container property")
+ }
// Add a dependency on the aconfig_value_sets defined in
// RELEASE_ACONFIG_VALUE_SETS, and add any aconfig_values that
diff --git a/aconfig/aconfig_declarations_test.go b/aconfig/aconfig_declarations_test.go
index 5201fed..c37274c 100644
--- a/aconfig/aconfig_declarations_test.go
+++ b/aconfig/aconfig_declarations_test.go
@@ -88,19 +88,49 @@
android.AssertStringEquals(t, "rule must contain container", rule.Args["container"], "--container com.android.foo")
}
-func TestAconfigDeclarationsWithoutContainer(t *testing.T) {
- bp := `
- aconfig_declarations {
- name: "module_name",
- package: "com.example.package",
- srcs: [
- "foo.aconfig",
- ],
- }
- `
- result := runTest(t, android.FixtureExpectsNoErrors, bp)
-
- module := result.ModuleForTests("module_name", "")
- rule := module.Rule("aconfig")
- android.AssertIntEquals(t, "rule must not contain container", len(rule.Args["container"]), 0)
+func TestMandatoryProperties(t *testing.T) {
+ testCases := []struct {
+ name string
+ expectedError string
+ bp string
+ }{
+ {
+ name: "Srcs missing from aconfig_declarations",
+ bp: `
+ aconfig_declarations {
+ name: "my_aconfig_declarations_foo",
+ package: "com.example.package",
+ container: "otherapex",
+ }`,
+ expectedError: `missing source files`,
+ },
+ {
+ name: "Package missing from aconfig_declarations",
+ bp: `
+ aconfig_declarations {
+ name: "my_aconfig_declarations_foo",
+ container: "otherapex",
+ srcs: ["foo.aconfig"],
+ }`,
+ expectedError: `missing package property`,
+ },
+ {
+ name: "Container missing from aconfig_declarations",
+ bp: `
+ aconfig_declarations {
+ name: "my_aconfig_declarations_foo",
+ package: "com.example.package",
+ srcs: ["foo.aconfig"],
+ }`,
+ expectedError: `missing container property`,
+ },
+ }
+ for _, test := range testCases {
+ t.Run(test.name, func(t *testing.T) {
+ errorHandler := android.FixtureExpectsAtLeastOneErrorMatchingPattern(test.expectedError)
+ android.GroupFixturePreparers(PrepareForTestWithAconfigBuildComponents).
+ ExtendWithErrorHandler(errorHandler).
+ RunTestWithBp(t, test.bp)
+ })
+ }
}
diff --git a/aconfig/codegen/aconfig_declarations_group_test.go b/aconfig/codegen/aconfig_declarations_group_test.go
index ec7cea3..c69d21f 100644
--- a/aconfig/codegen/aconfig_declarations_group_test.go
+++ b/aconfig/codegen/aconfig_declarations_group_test.go
@@ -15,9 +15,10 @@
package codegen
import (
+ "testing"
+
"android/soong/android"
"android/soong/java"
- "testing"
)
func TestAconfigDeclarationsGroup(t *testing.T) {
@@ -28,6 +29,7 @@
aconfig_declarations {
name: "foo-aconfig",
package: "com.example.package",
+ container: "com.android.foo",
srcs: ["foo.aconfig"],
}
@@ -39,6 +41,7 @@
aconfig_declarations {
name: "bar-aconfig",
package: "com.example.package",
+ container: "com.android.foo",
srcs: ["foo.aconfig"],
}
diff --git a/aconfig/codegen/cc_aconfig_library_test.go b/aconfig/codegen/cc_aconfig_library_test.go
index cf9ffbd..d01d13b 100644
--- a/aconfig/codegen/cc_aconfig_library_test.go
+++ b/aconfig/codegen/cc_aconfig_library_test.go
@@ -50,6 +50,7 @@
aconfig_declarations {
name: "my_aconfig_declarations",
package: "com.example.package",
+ container: "com.android.foo",
srcs: ["foo.aconfig"],
}
@@ -112,6 +113,7 @@
aconfig_declarations {
name: "my_aconfig_declarations",
package: "com.example.package",
+ container: "com.android.foo",
srcs: ["foo.aconfig"],
}
@@ -167,6 +169,7 @@
aconfig_declarations {
name: "my_aconfig_declarations_bar",
package: "com.example.package",
+ container: "com.android.foo",
srcs: ["bar.aconfig"],
}
@@ -241,6 +244,7 @@
aconfig_declarations {
name: "my_aconfig_declarations",
package: "com.example.package",
+ container: "com.android.foo",
srcs: ["foo.aconfig"],
}
diff --git a/aconfig/codegen/init.go b/aconfig/codegen/init.go
index 6182e14..98d288f 100644
--- a/aconfig/codegen/init.go
+++ b/aconfig/codegen/init.go
@@ -64,11 +64,12 @@
` && ${aconfig} create-rust-lib` +
` --mode ${mode}` +
` --cache ${in}` +
+ ` --allow-instrumentation ${debug}` +
` --out ${gendir}`,
CommandDeps: []string{
"$aconfig",
},
- }, "gendir", "mode")
+ }, "gendir", "mode", "debug")
)
func init() {
diff --git a/aconfig/codegen/java_aconfig_library_test.go b/aconfig/codegen/java_aconfig_library_test.go
index de45b5c..87b54a4 100644
--- a/aconfig/codegen/java_aconfig_library_test.go
+++ b/aconfig/codegen/java_aconfig_library_test.go
@@ -35,6 +35,7 @@
aconfig_declarations {
name: "my_aconfig_declarations_foo",
package: "com.example.package.foo",
+ container: "system",
srcs: ["foo.aconfig"],
}
@@ -46,6 +47,7 @@
aconfig_declarations {
name: "my_aconfig_declarations_bar",
package: "com.example.package.bar",
+ container: "system",
srcs: ["bar.aconfig"],
}
@@ -60,7 +62,7 @@
entry := android.AndroidMkEntriesForTest(t, result.TestContext, module)[0]
makeVar := entry.EntryMap["LOCAL_ACONFIG_FILES"]
- android.EnsureListContainsSuffix(t, makeVar, "android_common/aconfig_merged.pb")
+ android.EnsureListContainsSuffix(t, makeVar, "android_common/system/aconfig_merged.pb")
}
func TestAndroidMkJavaLibrary(t *testing.T) {
@@ -175,6 +177,7 @@
aconfig_declarations {
name: "my_aconfig_declarations",
package: "com.example.package",
+ container: "com.android.foo",
srcs: ["foo.aconfig"],
exportable: true,
}
@@ -200,6 +203,7 @@
aconfig_declarations {
name: "my_aconfig_declarations",
package: "com.example.package",
+ container: "com.android.foo",
srcs: ["foo.aconfig"],
}
@@ -234,3 +238,52 @@
func TestUnsupportedMode(t *testing.T) {
testCodegenModeWithError(t, "mode: `unsupported`,", "mode: \"unsupported\" is not a supported mode")
}
+
+func TestMkEntriesMatchedContainer(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ PrepareForTestWithAconfigBuildComponents,
+ java.PrepareForTestWithJavaDefaultModules).
+ ExtendWithErrorHandler(android.FixtureExpectsNoErrors).
+ RunTestWithBp(t, `
+ aconfig_declarations {
+ name: "my_aconfig_declarations_foo",
+ package: "com.example.package.foo",
+ container: "system",
+ srcs: ["foo.aconfig"],
+ }
+
+ java_aconfig_library {
+ name: "my_java_aconfig_library_foo",
+ aconfig_declarations: "my_aconfig_declarations_foo",
+ }
+
+ aconfig_declarations {
+ name: "my_aconfig_declarations_bar",
+ package: "com.example.package.bar",
+ container: "system_ext",
+ srcs: ["bar.aconfig"],
+ }
+
+ java_aconfig_library {
+ name: "my_java_aconfig_library_bar",
+ aconfig_declarations: "my_aconfig_declarations_bar",
+ }
+
+ java_library {
+ name: "my_module",
+ srcs: [
+ "src/foo.java",
+ ],
+ static_libs: [
+ "my_java_aconfig_library_foo",
+ "my_java_aconfig_library_bar",
+ ],
+ platform_apis: true,
+ }
+ `)
+
+ module := result.ModuleForTests("my_module", "android_common").Module()
+ entry := android.AndroidMkEntriesForTest(t, result.TestContext, module)[0]
+ makeVar := entry.EntryMap["LOCAL_ACONFIG_FILES"]
+ android.EnsureListContainsSuffix(t, makeVar, "my_aconfig_declarations_foo/intermediate.pb")
+}
diff --git a/aconfig/codegen/rust_aconfig_library.go b/aconfig/codegen/rust_aconfig_library.go
index ad8d632..4b896c3 100644
--- a/aconfig/codegen/rust_aconfig_library.go
+++ b/aconfig/codegen/rust_aconfig_library.go
@@ -2,6 +2,7 @@
import (
"fmt"
+ "strconv"
"android/soong/android"
"android/soong/rust"
@@ -82,6 +83,7 @@
Args: map[string]string{
"gendir": generatedDir.String(),
"mode": mode,
+ "debug": strconv.FormatBool(ctx.Config().ReleaseReadFromNewStorage()),
},
})
a.BaseSourceProvider.OutputFiles = android.Paths{generatedSource}
diff --git a/aconfig/codegen/rust_aconfig_library_test.go b/aconfig/codegen/rust_aconfig_library_test.go
index fe28f94..523b464 100644
--- a/aconfig/codegen/rust_aconfig_library_test.go
+++ b/aconfig/codegen/rust_aconfig_library_test.go
@@ -46,6 +46,7 @@
aconfig_declarations {
name: "my_aconfig_declarations",
package: "com.example.package",
+ container: "com.android.foo",
srcs: ["foo.aconfig"],
}
@@ -131,6 +132,7 @@
aconfig_declarations {
name: "my_aconfig_declarations",
package: "com.example.package",
+ container: "com.android.foo",
srcs: ["foo.aconfig"],
}
rust_aconfig_library {
@@ -193,6 +195,7 @@
aconfig_declarations {
name: "my_aconfig_declarations",
package: "com.example.package",
+ container: "com.android.foo",
srcs: ["foo.aconfig"],
}
rust_aconfig_library {
diff --git a/android/api_levels.go b/android/api_levels.go
index fab5fc7..8f2ff17 100644
--- a/android/api_levels.go
+++ b/android/api_levels.go
@@ -442,26 +442,27 @@
func getApiLevelsMapReleasedVersions() (map[string]int, error) {
return map[string]int{
- "G": 9,
- "I": 14,
- "J": 16,
- "J-MR1": 17,
- "J-MR2": 18,
- "K": 19,
- "L": 21,
- "L-MR1": 22,
- "M": 23,
- "N": 24,
- "N-MR1": 25,
- "O": 26,
- "O-MR1": 27,
- "P": 28,
- "Q": 29,
- "R": 30,
- "S": 31,
- "S-V2": 32,
- "Tiramisu": 33,
- "UpsideDownCake": 34,
+ "G": 9,
+ "I": 14,
+ "J": 16,
+ "J-MR1": 17,
+ "J-MR2": 18,
+ "K": 19,
+ "L": 21,
+ "L-MR1": 22,
+ "M": 23,
+ "N": 24,
+ "N-MR1": 25,
+ "O": 26,
+ "O-MR1": 27,
+ "P": 28,
+ "Q": 29,
+ "R": 30,
+ "S": 31,
+ "S-V2": 32,
+ "Tiramisu": 33,
+ "UpsideDownCake": 34,
+ "VanillaIceCream": 35,
}, nil
}
diff --git a/android/config.go b/android/config.go
index b60eb5c..872ff9d 100644
--- a/android/config.go
+++ b/android/config.go
@@ -239,6 +239,11 @@
Bool(c.config.productVariables.HiddenapiExportableStubs)
}
+// Enable read flag from new storage
+func (c Config) ReleaseReadFromNewStorage() bool {
+ return c.config.productVariables.GetBuildFlagBool("RELEASE_READ_FROM_NEW_STORAGE")
+}
+
// A DeviceConfig object represents the configuration for a particular device
// being built. For now there will only be one of these, but in the future there
// may be multiple devices being built.
diff --git a/android/updatable_modules.go b/android/updatable_modules.go
index 1548170..dd7dc2c 100644
--- a/android/updatable_modules.go
+++ b/android/updatable_modules.go
@@ -33,4 +33,4 @@
// * AOSP - xx9990000
// * x-mainline-prod - xx9990000
// * master - 990090000
-const DefaultUpdatableModuleVersion = "990090000"
+const DefaultUpdatableModuleVersion = "350090000"
diff --git a/android/variable.go b/android/variable.go
index 599f88e..793379e 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -181,8 +181,9 @@
// release_aidl_use_unfrozen is "true" when a device can
// use the unfrozen versions of AIDL interfaces.
Release_aidl_use_unfrozen struct {
- Cflags []string
- Cmd *string
+ Cflags []string
+ Cmd *string
+ Vintf_fragments []string
}
} `android:"arch_variant"`
}
diff --git a/apex/apex.go b/apex/apex.go
index ef57d7e..9a9b56f 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -18,7 +18,6 @@
import (
"fmt"
- "log"
"path/filepath"
"regexp"
"sort"
@@ -992,10 +991,8 @@
}
}
- //TODO: b/296491928 Vendor APEX should use libbinder.ndk instead of libbinder once VNDK is fully deprecated.
if useVndk && mctx.Config().IsVndkDeprecated() && child.Name() == "libbinder" {
- log.Print("Libbinder is linked from Vendor APEX ", a.Name(), " with module ", parent.Name())
- return false
+ mctx.ModuleErrorf("Module %s in the vendor APEX %s should not use libbinder. Use libbinder_ndk instead.", parent.Name(), a.Name())
}
// By default, all the transitive dependencies are collected, unless filtered out
@@ -2181,10 +2178,6 @@
return false
}
- //TODO: b/296491928 Vendor APEX should use libbinder.ndk instead of libbinder once VNDK is fully deprecated.
- if ch.InVendorOrProduct() && ctx.Config().IsVndkDeprecated() && child.Name() == "libbinder" {
- return false
- }
af := apexFileForNativeLibrary(ctx, ch, vctx.handleSpecialLibs)
af.transitiveDep = true
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 3e284b1..ce434de 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -9800,188 +9800,196 @@
}
}
-// TODO(b/193460475): Re-enable this test
-//func TestApexStrictUpdtabilityLint(t *testing.T) {
-// bpTemplate := `
-// apex {
-// name: "myapex",
-// key: "myapex.key",
-// java_libs: ["myjavalib"],
-// updatable: %v,
-// min_sdk_version: "29",
-// }
-// apex_key {
-// name: "myapex.key",
-// }
-// java_library {
-// name: "myjavalib",
-// srcs: ["MyClass.java"],
-// apex_available: [ "myapex" ],
-// lint: {
-// strict_updatability_linting: %v,
-// },
-// sdk_version: "current",
-// min_sdk_version: "29",
-// }
-// `
-// fs := android.MockFS{
-// "lint-baseline.xml": nil,
-// }
-//
-// testCases := []struct {
-// testCaseName string
-// apexUpdatable bool
-// javaStrictUpdtabilityLint bool
-// lintFileExists bool
-// disallowedFlagExpected bool
-// }{
-// {
-// testCaseName: "lint-baseline.xml does not exist, no disallowed flag necessary in lint cmd",
-// apexUpdatable: true,
-// javaStrictUpdtabilityLint: true,
-// lintFileExists: false,
-// disallowedFlagExpected: false,
-// },
-// {
-// testCaseName: "non-updatable apex respects strict_updatability of javalib",
-// apexUpdatable: false,
-// javaStrictUpdtabilityLint: false,
-// lintFileExists: true,
-// disallowedFlagExpected: false,
-// },
-// {
-// testCaseName: "non-updatable apex respects strict updatability of javalib",
-// apexUpdatable: false,
-// javaStrictUpdtabilityLint: true,
-// lintFileExists: true,
-// disallowedFlagExpected: true,
-// },
-// {
-// testCaseName: "updatable apex sets strict updatability of javalib to true",
-// apexUpdatable: true,
-// javaStrictUpdtabilityLint: false, // will be set to true by mutator
-// lintFileExists: true,
-// disallowedFlagExpected: true,
-// },
-// }
-//
-// for _, testCase := range testCases {
-// bp := fmt.Sprintf(bpTemplate, testCase.apexUpdatable, testCase.javaStrictUpdtabilityLint)
-// fixtures := []android.FixturePreparer{}
-// if testCase.lintFileExists {
-// fixtures = append(fixtures, fs.AddToFixture())
-// }
-//
-// result := testApex(t, bp, fixtures...)
-// myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29")
-// sboxProto := android.RuleBuilderSboxProtoForTests(t, myjavalib.Output("lint.sbox.textproto"))
-// disallowedFlagActual := strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml --disallowed_issues NewApi")
-//
-// if disallowedFlagActual != testCase.disallowedFlagExpected {
-// t.Errorf("Failed testcase: %v \nActual lint cmd: %v", testCase.testCaseName, *sboxProto.Commands[0].Command)
-// }
-// }
-//}
-//
-//func TestUpdatabilityLintSkipLibcore(t *testing.T) {
-// bp := `
-// apex {
-// name: "myapex",
-// key: "myapex.key",
-// java_libs: ["myjavalib"],
-// updatable: true,
-// min_sdk_version: "29",
-// }
-// apex_key {
-// name: "myapex.key",
-// }
-// java_library {
-// name: "myjavalib",
-// srcs: ["MyClass.java"],
-// apex_available: [ "myapex" ],
-// sdk_version: "current",
-// min_sdk_version: "29",
-// }
-// `
-//
-// testCases := []struct {
-// testCaseName string
-// moduleDirectory string
-// disallowedFlagExpected bool
-// }{
-// {
-// testCaseName: "lintable module defined outside libcore",
-// moduleDirectory: "",
-// disallowedFlagExpected: true,
-// },
-// {
-// testCaseName: "lintable module defined in libcore root directory",
-// moduleDirectory: "libcore/",
-// disallowedFlagExpected: false,
-// },
-// {
-// testCaseName: "lintable module defined in libcore child directory",
-// moduleDirectory: "libcore/childdir/",
-// disallowedFlagExpected: true,
-// },
-// }
-//
-// for _, testCase := range testCases {
-// lintFileCreator := android.FixtureAddTextFile(testCase.moduleDirectory+"lint-baseline.xml", "")
-// bpFileCreator := android.FixtureAddTextFile(testCase.moduleDirectory+"Android.bp", bp)
-// result := testApex(t, "", lintFileCreator, bpFileCreator)
-// myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29")
-// sboxProto := android.RuleBuilderSboxProtoForTests(t, myjavalib.Output("lint.sbox.textproto"))
-// cmdFlags := fmt.Sprintf("--baseline %vlint-baseline.xml --disallowed_issues NewApi", testCase.moduleDirectory)
-// disallowedFlagActual := strings.Contains(*sboxProto.Commands[0].Command, cmdFlags)
-//
-// if disallowedFlagActual != testCase.disallowedFlagExpected {
-// t.Errorf("Failed testcase: %v \nActual lint cmd: %v", testCase.testCaseName, *sboxProto.Commands[0].Command)
-// }
-// }
-//}
-//
-//// checks transtive deps of an apex coming from bootclasspath_fragment
-//func TestApexStrictUpdtabilityLintBcpFragmentDeps(t *testing.T) {
-// bp := `
-// apex {
-// name: "myapex",
-// key: "myapex.key",
-// bootclasspath_fragments: ["mybootclasspathfragment"],
-// updatable: true,
-// min_sdk_version: "29",
-// }
-// apex_key {
-// name: "myapex.key",
-// }
-// bootclasspath_fragment {
-// name: "mybootclasspathfragment",
-// contents: ["myjavalib"],
-// apex_available: ["myapex"],
-// hidden_api: {
-// split_packages: ["*"],
-// },
-// }
-// java_library {
-// name: "myjavalib",
-// srcs: ["MyClass.java"],
-// apex_available: [ "myapex" ],
-// sdk_version: "current",
-// min_sdk_version: "29",
-// compile_dex: true,
-// }
-// `
-// fs := android.MockFS{
-// "lint-baseline.xml": nil,
-// }
-//
-// result := testApex(t, bp, dexpreopt.FixtureSetApexBootJars("myapex:myjavalib"), fs.AddToFixture())
-// myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29")
-// sboxProto := android.RuleBuilderSboxProtoForTests(t, myjavalib.Output("lint.sbox.textproto"))
-// if !strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml --disallowed_issues NewApi") {
-// t.Errorf("Strict updabality lint missing in myjavalib coming from bootclasspath_fragment mybootclasspath-fragment\nActual lint cmd: %v", *sboxProto.Commands[0].Command)
-// }
-//}
+func TestApexStrictUpdtabilityLint(t *testing.T) {
+ bpTemplate := `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ java_libs: ["myjavalib"],
+ updatable: %v,
+ min_sdk_version: "29",
+ }
+ apex_key {
+ name: "myapex.key",
+ }
+ java_library {
+ name: "myjavalib",
+ srcs: ["MyClass.java"],
+ apex_available: [ "myapex" ],
+ lint: {
+ strict_updatability_linting: %v,
+ %s
+ },
+ sdk_version: "current",
+ min_sdk_version: "29",
+ }
+ `
+ fs := android.MockFS{
+ "lint-baseline.xml": nil,
+ }
+
+ testCases := []struct {
+ testCaseName string
+ apexUpdatable bool
+ javaStrictUpdtabilityLint bool
+ lintFileExists bool
+ disallowedFlagExpected bool
+ }{
+ {
+ testCaseName: "lint-baseline.xml does not exist, no disallowed flag necessary in lint cmd",
+ apexUpdatable: true,
+ javaStrictUpdtabilityLint: true,
+ lintFileExists: false,
+ disallowedFlagExpected: false,
+ },
+ {
+ testCaseName: "non-updatable apex respects strict_updatability of javalib",
+ apexUpdatable: false,
+ javaStrictUpdtabilityLint: false,
+ lintFileExists: true,
+ disallowedFlagExpected: false,
+ },
+ {
+ testCaseName: "non-updatable apex respects strict updatability of javalib",
+ apexUpdatable: false,
+ javaStrictUpdtabilityLint: true,
+ lintFileExists: true,
+ disallowedFlagExpected: true,
+ },
+ {
+ testCaseName: "updatable apex sets strict updatability of javalib to true",
+ apexUpdatable: true,
+ javaStrictUpdtabilityLint: false, // will be set to true by mutator
+ lintFileExists: true,
+ disallowedFlagExpected: true,
+ },
+ }
+
+ for _, testCase := range testCases {
+ fixtures := []android.FixturePreparer{}
+ baselineProperty := ""
+ if testCase.lintFileExists {
+ fixtures = append(fixtures, fs.AddToFixture())
+ baselineProperty = "baseline_filename: \"lint-baseline.xml\""
+ }
+ bp := fmt.Sprintf(bpTemplate, testCase.apexUpdatable, testCase.javaStrictUpdtabilityLint, baselineProperty)
+
+ result := testApex(t, bp, fixtures...)
+ myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29")
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, result, myjavalib.Output("lint.sbox.textproto"))
+ disallowedFlagActual := strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml --disallowed_issues NewApi")
+
+ if disallowedFlagActual != testCase.disallowedFlagExpected {
+ t.Errorf("Failed testcase: %v \nActual lint cmd: %v", testCase.testCaseName, *sboxProto.Commands[0].Command)
+ }
+ }
+}
+
+func TestUpdatabilityLintSkipLibcore(t *testing.T) {
+ bp := `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ java_libs: ["myjavalib"],
+ updatable: true,
+ min_sdk_version: "29",
+ }
+ apex_key {
+ name: "myapex.key",
+ }
+ java_library {
+ name: "myjavalib",
+ srcs: ["MyClass.java"],
+ apex_available: [ "myapex" ],
+ sdk_version: "current",
+ min_sdk_version: "29",
+ lint: {
+ baseline_filename: "lint-baseline.xml",
+ }
+ }
+ `
+
+ testCases := []struct {
+ testCaseName string
+ moduleDirectory string
+ disallowedFlagExpected bool
+ }{
+ {
+ testCaseName: "lintable module defined outside libcore",
+ moduleDirectory: "",
+ disallowedFlagExpected: true,
+ },
+ {
+ testCaseName: "lintable module defined in libcore root directory",
+ moduleDirectory: "libcore/",
+ disallowedFlagExpected: false,
+ },
+ {
+ testCaseName: "lintable module defined in libcore child directory",
+ moduleDirectory: "libcore/childdir/",
+ disallowedFlagExpected: true,
+ },
+ }
+
+ for _, testCase := range testCases {
+ lintFileCreator := android.FixtureAddTextFile(testCase.moduleDirectory+"lint-baseline.xml", "")
+ bpFileCreator := android.FixtureAddTextFile(testCase.moduleDirectory+"Android.bp", bp)
+ result := testApex(t, "", lintFileCreator, bpFileCreator)
+ myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29")
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, result, myjavalib.Output("lint.sbox.textproto"))
+ cmdFlags := fmt.Sprintf("--baseline %vlint-baseline.xml --disallowed_issues NewApi", testCase.moduleDirectory)
+ disallowedFlagActual := strings.Contains(*sboxProto.Commands[0].Command, cmdFlags)
+
+ if disallowedFlagActual != testCase.disallowedFlagExpected {
+ t.Errorf("Failed testcase: %v \nActual lint cmd: %v", testCase.testCaseName, *sboxProto.Commands[0].Command)
+ }
+ }
+}
+
+// checks transtive deps of an apex coming from bootclasspath_fragment
+func TestApexStrictUpdtabilityLintBcpFragmentDeps(t *testing.T) {
+ bp := `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ bootclasspath_fragments: ["mybootclasspathfragment"],
+ updatable: true,
+ min_sdk_version: "29",
+ }
+ apex_key {
+ name: "myapex.key",
+ }
+ bootclasspath_fragment {
+ name: "mybootclasspathfragment",
+ contents: ["myjavalib"],
+ apex_available: ["myapex"],
+ hidden_api: {
+ split_packages: ["*"],
+ },
+ }
+ java_library {
+ name: "myjavalib",
+ srcs: ["MyClass.java"],
+ apex_available: [ "myapex" ],
+ sdk_version: "current",
+ min_sdk_version: "29",
+ compile_dex: true,
+ lint: {
+ baseline_filename: "lint-baseline.xml",
+ }
+ }
+ `
+ fs := android.MockFS{
+ "lint-baseline.xml": nil,
+ }
+
+ result := testApex(t, bp, dexpreopt.FixtureSetApexBootJars("myapex:myjavalib"), fs.AddToFixture())
+ myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29")
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, result, myjavalib.Output("lint.sbox.textproto"))
+ if !strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml --disallowed_issues NewApi") {
+ t.Errorf("Strict updabality lint missing in myjavalib coming from bootclasspath_fragment mybootclasspath-fragment\nActual lint cmd: %v", *sboxProto.Commands[0].Command)
+ }
+}
// updatable apexes should propagate updatable=true to its apps
func TestUpdatableApexEnforcesAppUpdatability(t *testing.T) {
@@ -11428,6 +11436,7 @@
aconfig_declarations {
name: "%[1]s",
package: "com.example.package",
+ container: "system",
srcs: [
"%[1]s.aconfig",
],
diff --git a/java/aar_test.go b/java/aar_test.go
index d6dbe3c..18efd20 100644
--- a/java/aar_test.go
+++ b/java/aar_test.go
@@ -15,8 +15,9 @@
package java
import (
- "android/soong/android"
"testing"
+
+ "android/soong/android"
)
func TestAarImportProducesJniPackages(t *testing.T) {
@@ -98,6 +99,7 @@
aconfig_declarations {
name: "bar",
package: "com.example.package.bar",
+ container: "com.android.foo",
srcs: [
"bar.aconfig",
],
@@ -105,6 +107,7 @@
aconfig_declarations {
name: "baz",
package: "com.example.package.baz",
+ container: "com.android.foo",
srcs: [
"baz.aconfig",
],
diff --git a/java/app_test.go b/java/app_test.go
index eab40e7..a7c48a1 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -4382,6 +4382,7 @@
aconfig_declarations {
name: "bar",
package: "com.example.package.bar",
+ container: "com.android.foo",
srcs: [
"bar.aconfig",
],
@@ -4389,6 +4390,7 @@
aconfig_declarations {
name: "baz",
package: "com.example.package.baz",
+ container: "com.android.foo",
srcs: [
"baz.aconfig",
],
diff --git a/java/config/config.go b/java/config/config.go
index 2bb50f6..0d30fbd 100644
--- a/java/config/config.go
+++ b/java/config/config.go
@@ -51,6 +51,7 @@
"core-icu4j",
"core-oj",
"core-libart",
+ "wear-sdk.impl",
}
)
diff --git a/java/droidstubs.go b/java/droidstubs.go
index 08caf91..3b5d5ce 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -599,7 +599,8 @@
}
if apiVersions != nil {
cmd.FlagWithArg("--current-version ", ctx.Config().PlatformSdkVersion().String())
- cmd.FlagWithArg("--current-codename ", ctx.Config().PlatformSdkCodename())
+ // STOPSHIP: RESTORE THIS LOGIC WHEN DECLARING "REL" BUILD
+ // cmd.FlagWithArg("--current-codename ", ctx.Config().PlatformSdkCodename())
cmd.FlagWithInput("--apply-api-levels ", apiVersions)
}
}
diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go
index 8da695f..6a14f36 100644
--- a/java/droidstubs_test.go
+++ b/java/droidstubs_test.go
@@ -379,6 +379,7 @@
aconfig_declarations {
name: "bar",
package: "com.example.package",
+ container: "com.android.foo",
srcs: [
"bar.aconfig",
],
@@ -434,6 +435,7 @@
aconfig_declarations {
name: "bar",
package: "com.example.package",
+ container: "com.android.foo",
srcs: [
"bar.aconfig",
],
diff --git a/java/java_test.go b/java/java_test.go
index a1192bb..2f27932 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -2801,6 +2801,7 @@
aconfig_declarations {
name: "bar",
package: "com.example.package",
+ container: "com.android.foo",
srcs: [
"bar.aconfig",
],
diff --git a/java/lint.go b/java/lint.go
index 31e7f35..c79f6e7 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -319,25 +319,19 @@
cmd.FlagWithInput("@",
android.PathForSource(ctx, "build/soong/java/lint_defaults.txt"))
- if l.compileSdkKind == android.SdkPublic {
- cmd.FlagForEachArg("--error_check ", l.extraMainlineLintErrors)
- } else {
- // TODO(b/268261262): Remove this branch. We're demoting NewApi to a warning due to pre-existing issues that need to be fixed.
- cmd.FlagForEachArg("--warning_check ", l.extraMainlineLintErrors)
- }
+ cmd.FlagForEachArg("--error_check ", l.extraMainlineLintErrors)
cmd.FlagForEachArg("--disable_check ", l.properties.Lint.Disabled_checks)
cmd.FlagForEachArg("--warning_check ", l.properties.Lint.Warning_checks)
cmd.FlagForEachArg("--error_check ", l.properties.Lint.Error_checks)
cmd.FlagForEachArg("--fatal_check ", l.properties.Lint.Fatal_checks)
- // TODO(b/193460475): Re-enable strict updatability linting
- //if l.GetStrictUpdatabilityLinting() {
- // // Verify the module does not baseline issues that endanger safe updatability.
- // if baselinePath := l.getBaselineFilepath(ctx); baselinePath.Valid() {
- // cmd.FlagWithInput("--baseline ", baselinePath.Path())
- // cmd.FlagForEachArg("--disallowed_issues ", updatabilityChecks)
- // }
- //}
+ if l.GetStrictUpdatabilityLinting() {
+ // Verify the module does not baseline issues that endanger safe updatability.
+ if l.properties.Lint.Baseline_filename != nil {
+ cmd.FlagWithInput("--baseline ", android.PathForModuleSrc(ctx, *l.properties.Lint.Baseline_filename))
+ cmd.FlagForEachArg("--disallowed_issues ", updatabilityChecks)
+ }
+ }
return lintPaths{
projectXML: projectXMLPath,
diff --git a/java/lint_test.go b/java/lint_test.go
index 751b139..b51753f 100644
--- a/java/lint_test.go
+++ b/java/lint_test.go
@@ -91,9 +91,8 @@
t.Error("did not use the correct file for baseline")
}
- if !strings.Contains(*sboxProto.Commands[0].Command, "--warning_check NewApi") {
- // TODO(b/268261262): Change this to check for --error_check
- t.Error("should check NewApi warnings")
+ if !strings.Contains(*sboxProto.Commands[0].Command, "--error_check NewApi") {
+ t.Error("should check NewApi errors")
}
if !strings.Contains(*sboxProto.Commands[0].Command, "--error_check SomeCheck") {
@@ -153,52 +152,55 @@
}
}
-// TODO(b/193460475): Re-enable this test
-//func TestJavaLintStrictUpdatabilityLinting(t *testing.T) {
-// bp := `
-// java_library {
-// name: "foo",
-// srcs: [
-// "a.java",
-// ],
-// static_libs: ["bar"],
-// min_sdk_version: "29",
-// sdk_version: "current",
-// lint: {
-// strict_updatability_linting: true,
-// },
-// }
-//
-// java_library {
-// name: "bar",
-// srcs: [
-// "a.java",
-// ],
-// min_sdk_version: "29",
-// sdk_version: "current",
-// }
-// `
-// fs := android.MockFS{
-// "lint-baseline.xml": nil,
-// }
-//
-// result := android.GroupFixturePreparers(PrepareForTestWithJavaDefaultModules, fs.AddToFixture()).
-// RunTestWithBp(t, bp)
-//
-// foo := result.ModuleForTests("foo", "android_common")
-// sboxProto := android.RuleBuilderSboxProtoForTests(t, foo.Output("lint.sbox.textproto"))
-// if !strings.Contains(*sboxProto.Commands[0].Command,
-// "--baseline lint-baseline.xml --disallowed_issues NewApi") {
-// t.Error("did not restrict baselining NewApi")
-// }
-//
-// bar := result.ModuleForTests("bar", "android_common")
-// sboxProto = android.RuleBuilderSboxProtoForTests(t, bar.Output("lint.sbox.textproto"))
-// if !strings.Contains(*sboxProto.Commands[0].Command,
-// "--baseline lint-baseline.xml --disallowed_issues NewApi") {
-// t.Error("did not restrict baselining NewApi")
-// }
-//}
+func TestJavaLintStrictUpdatabilityLinting(t *testing.T) {
+ bp := `
+ java_library {
+ name: "foo",
+ srcs: [
+ "a.java",
+ ],
+ static_libs: ["bar"],
+ min_sdk_version: "29",
+ sdk_version: "current",
+ lint: {
+ strict_updatability_linting: true,
+ baseline_filename: "lint-baseline.xml",
+ },
+ }
+
+ java_library {
+ name: "bar",
+ srcs: [
+ "a.java",
+ ],
+ min_sdk_version: "29",
+ sdk_version: "current",
+ lint: {
+ baseline_filename: "lint-baseline.xml",
+ }
+ }
+ `
+ fs := android.MockFS{
+ "lint-baseline.xml": nil,
+ }
+
+ result := android.GroupFixturePreparers(PrepareForTestWithJavaDefaultModules, fs.AddToFixture()).
+ RunTestWithBp(t, bp)
+
+ foo := result.ModuleForTests("foo", "android_common")
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, result.TestContext, foo.Output("lint.sbox.textproto"))
+ if !strings.Contains(*sboxProto.Commands[0].Command,
+ "--baseline lint-baseline.xml --disallowed_issues NewApi") {
+ t.Error("did not restrict baselining NewApi")
+ }
+
+ bar := result.ModuleForTests("bar", "android_common")
+ sboxProto = android.RuleBuilderSboxProtoForTests(t, result.TestContext, bar.Output("lint.sbox.textproto"))
+ if !strings.Contains(*sboxProto.Commands[0].Command,
+ "--baseline lint-baseline.xml --disallowed_issues NewApi") {
+ t.Error("did not restrict baselining NewApi")
+ }
+}
func TestJavaLintDatabaseSelectionFull(t *testing.T) {
testCases := []struct {
diff --git a/java/rro_test.go b/java/rro_test.go
index d697ec6..742c839 100644
--- a/java/rro_test.go
+++ b/java/rro_test.go
@@ -421,6 +421,7 @@
aconfig_declarations {
name: "bar",
package: "com.example.package.bar",
+ container: "com.android.foo",
srcs: [
"bar.aconfig",
],
@@ -428,6 +429,7 @@
aconfig_declarations {
name: "baz",
package: "com.example.package.baz",
+ container: "com.android.foo",
srcs: [
"baz.aconfig",
],
diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go
index 0f163e6..34c63ac 100644
--- a/java/sdk_library_test.go
+++ b/java/sdk_library_test.go
@@ -1715,6 +1715,7 @@
aconfig_declarations {
name: "bar",
package: "com.example.package",
+ container: "com.android.foo",
srcs: [
"bar.aconfig",
],