Merge "Store order of the components used by the tests"
diff --git a/android/fixture.go b/android/fixture.go
index 2c8997b..2085e43 100644
--- a/android/fixture.go
+++ b/android/fixture.go
@@ -564,7 +564,11 @@
}
func (f *fixtureFactory) Extend(preparers ...FixturePreparer) FixtureFactory {
- all := append(f.preparers, dedupAndFlattenPreparers(f.preparers, preparers)...)
+ // Create a new slice to avoid accidentally sharing the preparers slice from this factory with
+ // the extending factories.
+ var all []*simpleFixturePreparer
+ all = append(all, f.preparers...)
+ all = append(all, dedupAndFlattenPreparers(f.preparers, preparers)...)
// Copy the existing factory.
extendedFactory := &fixtureFactory{}
*extendedFactory = *f
diff --git a/build_kzip.bash b/build_kzip.bash
index 9564723..a4659d4 100755
--- a/build_kzip.bash
+++ b/build_kzip.bash
@@ -16,6 +16,7 @@
: ${BUILD_NUMBER:=$(uuidgen)}
: ${KYTHE_JAVA_SOURCE_BATCH_SIZE:=500}
: ${KYTHE_KZIP_ENCODING:=proto}
+: ${XREF_CORPUS:?should be set}
export KYTHE_JAVA_SOURCE_BATCH_SIZE KYTHE_KZIP_ENCODING
# The extraction might fail for some source files, so run with -k and then check that
@@ -29,11 +30,15 @@
declare -r abspath_out=$(realpath "${out}")
declare -r go_extractor=$(realpath prebuilts/build-tools/linux-x86/bin/go_extractor)
declare -r go_root=$(realpath prebuilts/go/linux-x86)
-declare -r vnames_path=$(realpath build/soong/vnames.go.json)
declare -r source_root=$PWD
+
+# TODO(asmundak): Until b/182183061 is fixed, default corpus has to be specified
+# in the rules file. Generate this file on the fly with corpus value set from the
+# environment variable.
for dir in blueprint soong; do
(cd "build/$dir";
- KYTHE_ROOT_DIRECTORY="${source_root}" "$go_extractor" --goroot="$go_root" --rules="${vnames_path}" \
+ KYTHE_ROOT_DIRECTORY="${source_root}" "$go_extractor" --goroot="$go_root" \
+ --rules=<(printf '[{"pattern": "(.*)","vname": {"path": "@1@", "corpus":"%s"}}]' "${XREF_CORPUS}") \
--canonicalize_package_corpus --output "${abspath_out}/soong/build_${dir}.go.kzip" ./...
)
done
diff --git a/sysprop/sysprop_library.go b/sysprop/sysprop_library.go
index 4ad68ea..892a16c 100644
--- a/sysprop/sysprop_library.go
+++ b/sysprop/sysprop_library.go
@@ -165,6 +165,12 @@
// Forwarded to cc_library.min_sdk_version
Min_sdk_version *string
}
+
+ Java struct {
+ // Minimum sdk version that the artifact should support when it runs as part of mainline modules(APEX).
+ // Forwarded to java_library.min_sdk_version
+ Min_sdk_version *string
+ }
}
var (
@@ -403,6 +409,8 @@
Libs []string
Stem *string
SyspropPublicStub string
+ Apex_available []string
+ Min_sdk_version *string
}
func syspropLibraryHook(ctx android.LoadHookContext, m *syspropLibrary) {
@@ -508,6 +516,8 @@
Sdk_version: proptools.StringPtr("core_current"),
Libs: []string{javaSyspropStub},
SyspropPublicStub: publicStub,
+ Apex_available: m.ApexProperties.Apex_available,
+ Min_sdk_version: m.properties.Java.Min_sdk_version,
})
if publicStub != "" {
diff --git a/sysprop/sysprop_test.go b/sysprop/sysprop_test.go
index 9d914e3..fde41d6 100644
--- a/sysprop/sysprop_test.go
+++ b/sysprop/sysprop_test.go
@@ -81,6 +81,51 @@
}
func testConfig(env map[string]string, bp string, fs map[string][]byte) android.Config {
+ bp += `
+ cc_library {
+ name: "libbase",
+ host_supported: true,
+ }
+
+ cc_library_headers {
+ name: "libbase_headers",
+ vendor_available: true,
+ recovery_available: true,
+ }
+
+ cc_library {
+ name: "liblog",
+ no_libcrt: true,
+ nocrt: true,
+ system_shared_libs: [],
+ recovery_available: true,
+ host_supported: true,
+ llndk_stubs: "liblog.llndk",
+ }
+
+ llndk_library {
+ name: "liblog.llndk",
+ symbol_file: "",
+ }
+
+ java_library {
+ name: "sysprop-library-stub-platform",
+ sdk_version: "core_current",
+ }
+
+ java_library {
+ name: "sysprop-library-stub-vendor",
+ soc_specific: true,
+ sdk_version: "core_current",
+ }
+
+ java_library {
+ name: "sysprop-library-stub-product",
+ product_specific: true,
+ sdk_version: "core_current",
+ }
+ `
+
bp += cc.GatherRequiredDepsForTest(android.Android)
mockFS := map[string][]byte{
@@ -250,54 +295,11 @@
static_libs: ["sysprop-platform", "sysprop-vendor"],
}
- cc_library {
- name: "libbase",
- host_supported: true,
- }
-
- cc_library_headers {
- name: "libbase_headers",
- vendor_available: true,
- recovery_available: true,
- }
-
- cc_library {
- name: "liblog",
- no_libcrt: true,
- nocrt: true,
- system_shared_libs: [],
- recovery_available: true,
- host_supported: true,
- llndk_stubs: "liblog.llndk",
- }
-
cc_binary_host {
name: "hostbin",
static_libs: ["sysprop-platform"],
}
-
- llndk_library {
- name: "liblog.llndk",
- symbol_file: "",
- }
-
- java_library {
- name: "sysprop-library-stub-platform",
- sdk_version: "core_current",
- }
-
- java_library {
- name: "sysprop-library-stub-vendor",
- soc_specific: true,
- sdk_version: "core_current",
- }
-
- java_library {
- name: "sysprop-library-stub-product",
- product_specific: true,
- sdk_version: "core_current",
- }
- `)
+ `)
// Check for generated cc_library
for _, variant := range []string{
@@ -391,3 +393,62 @@
t.Errorf("system api client should use public stub %q, got %q", w, g)
}
}
+
+func TestApexAvailabilityIsForwarded(t *testing.T) {
+ ctx := test(t, `
+ sysprop_library {
+ name: "sysprop-platform",
+ apex_available: ["//apex_available:platform"],
+ srcs: ["android/sysprop/PlatformProperties.sysprop"],
+ api_packages: ["android.sysprop"],
+ property_owner: "Platform",
+ }
+ `)
+
+ expected := []string{"//apex_available:platform"}
+
+ ccModule := ctx.ModuleForTests("libsysprop-platform", "android_arm64_armv8-a_shared").Module().(*cc.Module)
+ propFromCc := ccModule.ApexProperties.Apex_available
+ if !reflect.DeepEqual(propFromCc, expected) {
+ t.Errorf("apex_available not forwarded to cc module. expected %#v, got %#v",
+ expected, propFromCc)
+ }
+
+ javaModule := ctx.ModuleForTests("sysprop-platform", "android_common").Module().(*java.Library)
+ propFromJava := javaModule.ApexProperties.Apex_available
+ if !reflect.DeepEqual(propFromJava, expected) {
+ t.Errorf("apex_available not forwarded to java module. expected %#v, got %#v",
+ expected, propFromJava)
+ }
+}
+
+func TestMinSdkVersionIsForwarded(t *testing.T) {
+ ctx := test(t, `
+ sysprop_library {
+ name: "sysprop-platform",
+ srcs: ["android/sysprop/PlatformProperties.sysprop"],
+ api_packages: ["android.sysprop"],
+ property_owner: "Platform",
+ cpp: {
+ min_sdk_version: "29",
+ },
+ java: {
+ min_sdk_version: "30",
+ },
+ }
+ `)
+
+ ccModule := ctx.ModuleForTests("libsysprop-platform", "android_arm64_armv8-a_shared").Module().(*cc.Module)
+ propFromCc := proptools.String(ccModule.Properties.Min_sdk_version)
+ if propFromCc != "29" {
+ t.Errorf("min_sdk_version not forwarded to cc module. expected %#v, got %#v",
+ "29", propFromCc)
+ }
+
+ javaModule := ctx.ModuleForTests("sysprop-platform", "android_common").Module().(*java.Library)
+ propFromJava := javaModule.MinSdkVersion()
+ if propFromJava != "30" {
+ t.Errorf("min_sdk_version not forwarded to java module. expected %#v, got %#v",
+ "30", propFromJava)
+ }
+}
diff --git a/vnames.go.json b/vnames.go.json
deleted file mode 100644
index f8c6b7f..0000000
--- a/vnames.go.json
+++ /dev/null
@@ -1,8 +0,0 @@
-[
- {
- "pattern": "(.*)",
- "vname": {
- "path": "@1@"
- }
- }
-]