Merge "Fix condition that misses packaging some fuzzers" into main
diff --git a/OWNERS b/OWNERS
index 58edc89..01025fb 100644
--- a/OWNERS
+++ b/OWNERS
@@ -12,4 +12,6 @@
mrziwang@google.com
spandandas@google.com
weiwli@google.com
-yudiliu@google.com
\ No newline at end of file
+yudiliu@google.com
+
+per-file build/soong/ui/build/androidmk_denylist.go = joeo@google.com, weiwli@google.com
\ No newline at end of file
diff --git a/aconfig/codegen/cc_aconfig_library.go b/aconfig/codegen/cc_aconfig_library.go
index 12c2dea..8df353d 100644
--- a/aconfig/codegen/cc_aconfig_library.go
+++ b/aconfig/codegen/cc_aconfig_library.go
@@ -40,6 +40,7 @@
// default mode is "production", the other accepted modes are:
// "test": to generate test mode version of the library
// "exported": to generate exported mode version of the library
+ // "force-read-only": to generate force-read-only mode version of the library
// an error will be thrown if the mode is not supported
Mode *string
}
diff --git a/aconfig/codegen/cc_aconfig_library_test.go b/aconfig/codegen/cc_aconfig_library_test.go
index 3de4626..d762e9b 100644
--- a/aconfig/codegen/cc_aconfig_library_test.go
+++ b/aconfig/codegen/cc_aconfig_library_test.go
@@ -29,6 +29,7 @@
{"mode: `production`,", "production"},
{"mode: `test`,", "test"},
{"mode: `exported`,", "exported"},
+ {"mode: `force-read-only`,", "force-read-only"},
}
func TestCCCodegenMode(t *testing.T) {
@@ -147,6 +148,7 @@
cc_library {
name: "server_configurable_flags",
srcs: ["server_configurable_flags.cc"],
+ vendor_available: true,
}
`
result := android.GroupFixturePreparers(
@@ -154,7 +156,7 @@
cc.PrepareForTestWithCcDefaultModules).
ExtendWithErrorHandler(android.FixtureExpectsNoErrors).RunTestWithBp(t, bp)
- module := result.ModuleForTests("my_cc_library", "android_arm64_armv8-a_shared").Module()
+ module := result.ModuleForTests("my_cc_library", "android_vendor_arm64_armv8-a_shared").Module()
entry := android.AndroidMkEntriesForTest(t, result.TestContext, module)[0]
diff --git a/aconfig/codegen/java_aconfig_library.go b/aconfig/codegen/java_aconfig_library.go
index c027815..e6817e0 100644
--- a/aconfig/codegen/java_aconfig_library.go
+++ b/aconfig/codegen/java_aconfig_library.go
@@ -30,7 +30,7 @@
var declarationsTag = declarationsTagType{}
-var aconfigSupportedModes = []string{"production", "test", "exported"}
+var aconfigSupportedModes = []string{"production", "test", "exported", "force-read-only"}
type JavaAconfigDeclarationsLibraryProperties struct {
// name of the aconfig_declarations module to generate a library for
@@ -39,6 +39,7 @@
// default mode is "production", the other accepted modes are:
// "test": to generate test mode version of the library
// "exported": to generate exported mode version of the library
+ // "force-read-only": to generate force-read-only mode version of the library
// an error will be thrown if the mode is not supported
Mode *string
}
diff --git a/aconfig/codegen/java_aconfig_library_test.go b/aconfig/codegen/java_aconfig_library_test.go
index 2523abc..8d54b5b 100644
--- a/aconfig/codegen/java_aconfig_library_test.go
+++ b/aconfig/codegen/java_aconfig_library_test.go
@@ -227,6 +227,10 @@
testCodegenMode(t, "mode: `exported`,", "exported")
}
+func TestForceReadOnlyMode(t *testing.T) {
+ testCodegenMode(t, "mode: `force-read-only`,", "force-read-only")
+}
+
func TestUnsupportedMode(t *testing.T) {
testCodegenModeWithError(t, "mode: `unsupported`,", "mode: \"unsupported\" is not a supported mode")
}
diff --git a/aconfig/codegen/rust_aconfig_library.go b/aconfig/codegen/rust_aconfig_library.go
index 73b6fec..2ab54b6 100644
--- a/aconfig/codegen/rust_aconfig_library.go
+++ b/aconfig/codegen/rust_aconfig_library.go
@@ -23,6 +23,7 @@
// default mode is "production", the other accepted modes are:
// "test": to generate test mode version of the library
// "exported": to generate exported mode version of the library
+ // "force-read-only": to generate force-read-only mode version of the library
// an error will be thrown if the mode is not supported
Mode *string
}
diff --git a/aconfig/codegen/rust_aconfig_library_test.go b/aconfig/codegen/rust_aconfig_library_test.go
index c09f701..60bc9f7 100644
--- a/aconfig/codegen/rust_aconfig_library_test.go
+++ b/aconfig/codegen/rust_aconfig_library_test.go
@@ -72,6 +72,7 @@
{"mode: `production`,", "production"},
{"mode: `test`,", "test"},
{"mode: `exported`,", "exported"},
+ {"mode: `force-read-only`,", "force-read-only"},
}
func TestRustCodegenMode(t *testing.T) {
diff --git a/android/Android.bp b/android/Android.bp
index b359df9..8de0c76 100644
--- a/android/Android.bp
+++ b/android/Android.bp
@@ -63,6 +63,7 @@
"metrics.go",
"module.go",
"module_context.go",
+ "module_info_json.go",
"mutator.go",
"namespace.go",
"neverallow.go",
@@ -81,6 +82,7 @@
"prebuilt_build_tool.go",
"proto.go",
"provider.go",
+ "raw_files.go",
"register.go",
"rule_builder.go",
"sandbox.go",
@@ -103,7 +105,6 @@
"apex_test.go",
"arch_test.go",
"config_test.go",
- "config_bp2build_test.go",
"configured_jars_test.go",
"csuite_config_test.go",
"defaults_test.go",
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index 07e1f12..a52bff3 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -14,30 +14,7 @@
package allowlists
-// Configuration to decide if modules in a directory should default to true/false for bp2build_available
-type Bp2BuildConfig map[string]BazelConversionConfigEntry
-type BazelConversionConfigEntry int
-
const (
- // iota + 1 ensures that the int value is not 0 when used in the Bp2buildAllowlist map,
- // which can also mean that the key doesn't exist in a lookup.
-
- // all modules in this package and subpackages default to bp2build_available: true.
- // allows modules to opt-out.
- Bp2BuildDefaultTrueRecursively BazelConversionConfigEntry = iota + 1
-
- // all modules in this package (not recursively) default to bp2build_available: true.
- // allows modules to opt-out.
- Bp2BuildDefaultTrue
-
- // all modules in this package (not recursively) default to bp2build_available: false.
- // allows modules to opt-in.
- Bp2BuildDefaultFalse
-
- // all modules in this package and subpackages default to bp2build_available: false.
- // allows modules to opt-in.
- Bp2BuildDefaultFalseRecursively
-
// Modules with build time of more than half a minute should have high priority.
DEFAULT_PRIORITIZED_WEIGHT = 1000
// Modules with build time of more than a few minute should have higher priority.
@@ -48,1633 +25,6 @@
)
var (
- Bp2buildDefaultConfig = Bp2BuildConfig{
- "art": Bp2BuildDefaultTrue,
- "art/libartbase": Bp2BuildDefaultTrueRecursively,
- "art/libartpalette": Bp2BuildDefaultTrueRecursively,
- "art/libdexfile": Bp2BuildDefaultTrueRecursively,
- "art/libnativebridge": Bp2BuildDefaultTrueRecursively,
- "art/runtime": Bp2BuildDefaultTrueRecursively,
- "art/tools": Bp2BuildDefaultTrue,
- "bionic": Bp2BuildDefaultTrueRecursively,
- "bootable/recovery/applypatch": Bp2BuildDefaultTrue,
- "bootable/recovery/minadbd": Bp2BuildDefaultTrue,
- "bootable/recovery/minui": Bp2BuildDefaultTrue,
- "bootable/recovery/recovery_utils": Bp2BuildDefaultTrue,
- "bootable/recovery/tools/recovery_l10n": Bp2BuildDefaultTrue,
-
- "build/bazel": Bp2BuildDefaultTrueRecursively,
- "build/make/target/product/security": Bp2BuildDefaultTrue,
- "build/make/tools": Bp2BuildDefaultTrue,
- "build/make/tools/protos": Bp2BuildDefaultTrue,
- "build/make/tools/releasetools": Bp2BuildDefaultTrue,
- "build/make/tools/sbom": Bp2BuildDefaultTrue,
- "build/make/tools/signapk": Bp2BuildDefaultTrue,
- "build/make/tools/zipalign": Bp2BuildDefaultTrueRecursively,
- "build/soong": Bp2BuildDefaultTrue,
- "build/soong/cc/libbuildversion": Bp2BuildDefaultTrue, // Skip tests subdir
- "build/soong/cc/ndkstubgen": Bp2BuildDefaultTrue,
- "build/soong/cc/symbolfile": Bp2BuildDefaultTrue,
- "build/soong/jar": Bp2BuildDefaultTrue,
- "build/soong/licenses": Bp2BuildDefaultTrue,
- "build/soong/linkerconfig": Bp2BuildDefaultTrueRecursively,
- "build/soong/response": Bp2BuildDefaultTrue,
- "build/soong/scripts": Bp2BuildDefaultTrueRecursively,
- "build/soong/third_party/zip": Bp2BuildDefaultTrue,
-
- "cts/common/device-side/nativetesthelper/jni": Bp2BuildDefaultTrueRecursively,
- "cts/flags/cc_tests": Bp2BuildDefaultTrueRecursively,
- "cts/libs/json": Bp2BuildDefaultTrueRecursively,
- "cts/tests/tests/gesture": Bp2BuildDefaultTrueRecursively,
-
- "dalvik/tools/dexdeps": Bp2BuildDefaultTrueRecursively,
-
- "development/apps/DevelopmentSettings": Bp2BuildDefaultTrue,
- "development/apps/Fallback": Bp2BuildDefaultTrue,
- "development/apps/WidgetPreview": Bp2BuildDefaultTrue,
- "development/python-packages/adb": Bp2BuildDefaultTrueRecursively,
- "development/samples/BasicGLSurfaceView": Bp2BuildDefaultTrue,
- "development/samples/BluetoothChat": Bp2BuildDefaultTrue,
- "development/samples/BrokenKeyDerivation": Bp2BuildDefaultTrue,
- "development/samples/Compass": Bp2BuildDefaultTrue,
- "development/samples/ContactManager": Bp2BuildDefaultTrue,
- "development/samples/FixedGridLayout": Bp2BuildDefaultTrue,
- "development/samples/HelloEffects": Bp2BuildDefaultTrue,
- "development/samples/Home": Bp2BuildDefaultTrue,
- "development/samples/HoneycombGallery": Bp2BuildDefaultTrue,
- "development/samples/JetBoy": Bp2BuildDefaultTrue,
- "development/samples/KeyChainDemo": Bp2BuildDefaultTrue,
- "development/samples/LceDemo": Bp2BuildDefaultTrue,
- "development/samples/LunarLander": Bp2BuildDefaultTrue,
- "development/samples/MultiResolution": Bp2BuildDefaultTrue,
- "development/samples/MultiWindow": Bp2BuildDefaultTrue,
- "development/samples/NotePad": Bp2BuildDefaultTrue,
- "development/samples/Obb": Bp2BuildDefaultTrue,
- "development/samples/RSSReader": Bp2BuildDefaultTrue,
- "development/samples/ReceiveShareDemo": Bp2BuildDefaultTrue,
- "development/samples/SearchableDictionary": Bp2BuildDefaultTrue,
- "development/samples/SipDemo": Bp2BuildDefaultTrue,
- "development/samples/SkeletonApp": Bp2BuildDefaultTrue,
- "development/samples/Snake": Bp2BuildDefaultTrue,
- "development/samples/SpellChecker/": Bp2BuildDefaultTrueRecursively,
- "development/samples/ThemedNavBarKeyboard": Bp2BuildDefaultTrue,
- "development/samples/ToyVpn": Bp2BuildDefaultTrue,
- "development/samples/TtsEngine": Bp2BuildDefaultTrue,
- "development/samples/USB/AdbTest": Bp2BuildDefaultTrue,
- "development/samples/USB/MissileLauncher": Bp2BuildDefaultTrue,
- "development/samples/VoiceRecognitionService": Bp2BuildDefaultTrue,
- "development/samples/VoicemailProviderDemo": Bp2BuildDefaultTrue,
- "development/samples/WiFiDirectDemo": Bp2BuildDefaultTrue,
- "development/sdk": Bp2BuildDefaultTrueRecursively,
-
- "external/aac": Bp2BuildDefaultTrueRecursively,
- "external/abseil-cpp": Bp2BuildDefaultTrueRecursively,
- "external/arm-optimized-routines": Bp2BuildDefaultTrueRecursively,
- "external/auto": Bp2BuildDefaultTrue,
- "external/auto/android-annotation-stubs": Bp2BuildDefaultTrueRecursively,
- "external/auto/common": Bp2BuildDefaultTrueRecursively,
- "external/auto/service": Bp2BuildDefaultTrueRecursively,
- "external/auto/value": Bp2BuildDefaultTrueRecursively,
- "external/boringssl": Bp2BuildDefaultTrueRecursively,
- "external/bouncycastle": Bp2BuildDefaultTrue,
- "external/brotli": Bp2BuildDefaultTrue,
- "external/bsdiff": Bp2BuildDefaultTrueRecursively,
- "external/bzip2": Bp2BuildDefaultTrueRecursively,
- "external/clang/lib": Bp2BuildDefaultTrue,
- "external/conscrypt": Bp2BuildDefaultTrue,
- "external/dexmaker": Bp2BuildDefaultTrueRecursively,
- "external/e2fsprogs": Bp2BuildDefaultTrueRecursively,
- "external/eigen": Bp2BuildDefaultTrueRecursively,
- "external/erofs-utils": Bp2BuildDefaultTrueRecursively,
- "external/error_prone": Bp2BuildDefaultTrueRecursively,
- "external/escapevelocity": Bp2BuildDefaultTrueRecursively,
- "external/expat": Bp2BuildDefaultTrueRecursively,
- "external/f2fs-tools": Bp2BuildDefaultTrue,
- "external/flac": Bp2BuildDefaultTrueRecursively,
- "external/flatbuffers": Bp2BuildDefaultTrueRecursively,
- "external/fmtlib": Bp2BuildDefaultTrueRecursively,
- "external/fsverity-utils": Bp2BuildDefaultTrueRecursively,
- "external/gflags": Bp2BuildDefaultTrueRecursively,
- "external/google-benchmark": Bp2BuildDefaultTrueRecursively,
- "external/googletest": Bp2BuildDefaultTrueRecursively,
- "external/guava": Bp2BuildDefaultTrueRecursively,
- "external/gwp_asan": Bp2BuildDefaultTrueRecursively,
- "external/hamcrest": Bp2BuildDefaultTrueRecursively,
- "external/icu": Bp2BuildDefaultTrueRecursively,
- "external/icu/android_icu4j": Bp2BuildDefaultFalse, // java rules incomplete
- "external/icu/icu4j": Bp2BuildDefaultFalse, // java rules incomplete
- "external/jacoco": Bp2BuildDefaultTrueRecursively,
- "external/jarjar": Bp2BuildDefaultTrueRecursively,
- "external/javaparser": Bp2BuildDefaultTrueRecursively,
- "external/javapoet": Bp2BuildDefaultTrueRecursively,
- "external/javassist": Bp2BuildDefaultTrueRecursively,
- "external/jemalloc_new": Bp2BuildDefaultTrueRecursively,
- "external/jsoncpp": Bp2BuildDefaultTrueRecursively,
- "external/jsr305": Bp2BuildDefaultTrueRecursively,
- "external/jsr330": Bp2BuildDefaultTrueRecursively,
- "external/junit": Bp2BuildDefaultTrueRecursively,
- "external/kotlinc": Bp2BuildDefaultTrueRecursively,
- "external/kotlinx.coroutines": Bp2BuildDefaultTrueRecursively,
- "external/libaom": Bp2BuildDefaultTrueRecursively,
- "external/libavc": Bp2BuildDefaultTrueRecursively,
- "external/libcap": Bp2BuildDefaultTrueRecursively,
- "external/libcxx": Bp2BuildDefaultTrueRecursively,
- "external/libcxxabi": Bp2BuildDefaultTrueRecursively,
- "external/libdivsufsort": Bp2BuildDefaultTrueRecursively,
- "external/libdrm": Bp2BuildDefaultTrue,
- "external/libevent": Bp2BuildDefaultTrueRecursively,
- "external/libgav1": Bp2BuildDefaultTrueRecursively,
- "external/libdav1d": Bp2BuildDefaultTrueRecursively,
- "external/libhevc": Bp2BuildDefaultTrueRecursively,
- "external/libjpeg-turbo": Bp2BuildDefaultTrueRecursively,
- "external/libmpeg2": Bp2BuildDefaultTrueRecursively,
- "external/libphonenumber": Bp2BuildDefaultTrueRecursively,
- "external/libpng": Bp2BuildDefaultTrueRecursively,
- "external/libvpx": Bp2BuildDefaultTrueRecursively,
- "external/libyuv": Bp2BuildDefaultTrueRecursively,
- "external/lz4/lib": Bp2BuildDefaultTrue,
- "external/lz4/programs": Bp2BuildDefaultTrue,
- "external/lzma/C": Bp2BuildDefaultTrueRecursively,
- "external/mdnsresponder": Bp2BuildDefaultTrueRecursively,
- "external/minijail": Bp2BuildDefaultTrueRecursively,
- "external/mockito": Bp2BuildDefaultTrueRecursively,
- "external/musl": Bp2BuildDefaultTrueRecursively,
- "external/objenesis": Bp2BuildDefaultTrueRecursively,
- "external/openscreen": Bp2BuildDefaultTrueRecursively,
- "external/ow2-asm": Bp2BuildDefaultTrueRecursively,
- "external/pcre": Bp2BuildDefaultTrueRecursively,
- "external/perfmark/api": Bp2BuildDefaultTrueRecursively,
- "external/perfetto": Bp2BuildDefaultTrue,
- "external/protobuf": Bp2BuildDefaultTrueRecursively,
- "external/python/jinja/src": Bp2BuildDefaultTrueRecursively,
- "external/python/markupsafe/src": Bp2BuildDefaultTrueRecursively,
- "external/python/pyfakefs/pyfakefs": Bp2BuildDefaultTrueRecursively,
- "external/python/pyyaml/lib/yaml": Bp2BuildDefaultTrueRecursively,
- "external/python/setuptools": Bp2BuildDefaultTrueRecursively,
- "external/python/six": Bp2BuildDefaultTrueRecursively,
- "external/rappor": Bp2BuildDefaultTrueRecursively,
- "external/rust/crates/rustc-demangle": Bp2BuildDefaultTrueRecursively,
- "external/rust/crates/rustc-demangle-capi": Bp2BuildDefaultTrueRecursively,
- "external/scudo": Bp2BuildDefaultTrueRecursively,
- "external/selinux/checkpolicy": Bp2BuildDefaultTrueRecursively,
- "external/selinux/libselinux": Bp2BuildDefaultTrueRecursively,
- "external/selinux/libsepol": Bp2BuildDefaultTrueRecursively,
- "external/speex": Bp2BuildDefaultTrueRecursively,
- "external/sqlite": Bp2BuildDefaultTrueRecursively,
- "external/tinyalsa": Bp2BuildDefaultTrueRecursively,
- "external/tinyalsa_new": Bp2BuildDefaultTrueRecursively,
- "external/toybox": Bp2BuildDefaultTrueRecursively,
- "external/truth": Bp2BuildDefaultTrueRecursively,
- "external/xz-java": Bp2BuildDefaultTrueRecursively,
- "external/zlib": Bp2BuildDefaultTrueRecursively,
- "external/zopfli": Bp2BuildDefaultTrueRecursively,
- "external/zstd": Bp2BuildDefaultTrueRecursively,
-
- "frameworks/av": Bp2BuildDefaultTrue,
- "frameworks/av/media/audioaidlconversion": Bp2BuildDefaultTrueRecursively,
- "frameworks/av/media/codec2/components/aom": Bp2BuildDefaultTrueRecursively,
- "frameworks/av/media/codecs": Bp2BuildDefaultTrueRecursively,
- "frameworks/av/media/liberror": Bp2BuildDefaultTrueRecursively,
- "frameworks/av/media/libmediahelper": Bp2BuildDefaultTrue,
- "frameworks/av/media/libshmem": Bp2BuildDefaultTrueRecursively,
- "frameworks/av/media/module/codecs": Bp2BuildDefaultTrueRecursively,
- "frameworks/av/media/module/foundation": Bp2BuildDefaultTrueRecursively,
- "frameworks/av/media/module/minijail": Bp2BuildDefaultTrueRecursively,
- "frameworks/av/services/minijail": Bp2BuildDefaultTrueRecursively,
- "frameworks/base/apex/jobscheduler/service/jni": Bp2BuildDefaultTrueRecursively,
- "frameworks/base/core/java": Bp2BuildDefaultTrue,
- "frameworks/base/core/res": Bp2BuildDefaultTrueRecursively,
- "frameworks/base/errorprone": Bp2BuildDefaultTrueRecursively,
- "frameworks/base/libs/androidfw": Bp2BuildDefaultTrue,
- "frameworks/base/libs/services": Bp2BuildDefaultTrue,
- "frameworks/base/media/tests/MediaDump": Bp2BuildDefaultTrue,
- "frameworks/base/mime": Bp2BuildDefaultTrueRecursively,
- "frameworks/base/proto": Bp2BuildDefaultTrue,
- "frameworks/base/services/tests/servicestests/aidl": Bp2BuildDefaultTrue,
- "frameworks/base/startop/apps/test": Bp2BuildDefaultTrue,
- "frameworks/base/tests/appwidgets/AppWidgetHostTest": Bp2BuildDefaultTrueRecursively,
- "frameworks/base/tools/aapt": Bp2BuildDefaultTrue,
- "frameworks/base/tools/aapt2": Bp2BuildDefaultTrue,
- "frameworks/base/tools/codegen": Bp2BuildDefaultTrueRecursively,
- "frameworks/base/tools/locked_region_code_injection": Bp2BuildDefaultTrueRecursively,
- "frameworks/base/tools/streaming_proto": Bp2BuildDefaultTrueRecursively,
- "frameworks/hardware/interfaces": Bp2BuildDefaultTrue,
- "frameworks/hardware/interfaces/displayservice": Bp2BuildDefaultTrueRecursively,
- "frameworks/hardware/interfaces/stats/aidl": Bp2BuildDefaultTrue,
- "frameworks/libs/modules-utils/build": Bp2BuildDefaultTrueRecursively,
- "frameworks/libs/modules-utils/java": Bp2BuildDefaultTrueRecursively,
- "frameworks/libs/modules-utils/java/com/android/modules/utils/testing": Bp2BuildDefaultFalseRecursively,
- "frameworks/native": Bp2BuildDefaultTrue,
- "frameworks/native/libs/adbd_auth": Bp2BuildDefaultTrueRecursively,
- "frameworks/native/libs/arect": Bp2BuildDefaultTrueRecursively,
- "frameworks/native/libs/binder": Bp2BuildDefaultTrue,
- "frameworks/native/libs/gui": Bp2BuildDefaultTrue,
- "frameworks/native/libs/math": Bp2BuildDefaultTrueRecursively,
- "frameworks/native/libs/nativebase": Bp2BuildDefaultTrueRecursively,
- "frameworks/native/libs/permission": Bp2BuildDefaultTrueRecursively,
- "frameworks/native/libs/ui": Bp2BuildDefaultTrue,
- "frameworks/native/libs/vr": Bp2BuildDefaultTrueRecursively,
- "frameworks/native/opengl/tests/gl2_cameraeye": Bp2BuildDefaultTrue,
- "frameworks/native/opengl/tests/gl2_java": Bp2BuildDefaultTrue,
- "frameworks/native/opengl/tests/testLatency": Bp2BuildDefaultTrue,
- "frameworks/native/opengl/tests/testPauseResume": Bp2BuildDefaultTrue,
- "frameworks/native/opengl/tests/testViewport": Bp2BuildDefaultTrue,
- "frameworks/native/services/batteryservice": Bp2BuildDefaultTrue,
- "frameworks/proto_logging/stats": Bp2BuildDefaultTrueRecursively,
-
- "hardware/interfaces": Bp2BuildDefaultTrue,
- "hardware/interfaces/audio/aidl": Bp2BuildDefaultTrue,
- "hardware/interfaces/audio/aidl/common": Bp2BuildDefaultTrue,
- "hardware/interfaces/audio/aidl/default": Bp2BuildDefaultTrue,
- "hardware/interfaces/audio/aidl/sounddose": Bp2BuildDefaultTrue,
- "hardware/interfaces/camera/metadata/aidl": Bp2BuildDefaultTrueRecursively,
- "hardware/interfaces/common/aidl": Bp2BuildDefaultTrue,
- "hardware/interfaces/common/fmq/aidl": Bp2BuildDefaultTrue,
- "hardware/interfaces/common/support": Bp2BuildDefaultTrue,
- "hardware/interfaces/configstore/1.0": Bp2BuildDefaultTrue,
- "hardware/interfaces/configstore/1.1": Bp2BuildDefaultTrue,
- "hardware/interfaces/configstore/utils": Bp2BuildDefaultTrue,
- "hardware/interfaces/contexthub/aidl": Bp2BuildDefaultTrue,
- "hardware/interfaces/graphics/allocator/2.0": Bp2BuildDefaultTrue,
- "hardware/interfaces/graphics/allocator/3.0": Bp2BuildDefaultTrue,
- "hardware/interfaces/graphics/allocator/4.0": Bp2BuildDefaultTrue,
- "hardware/interfaces/graphics/allocator/aidl": Bp2BuildDefaultTrue,
- "hardware/interfaces/graphics/bufferqueue/1.0": Bp2BuildDefaultTrue,
- "hardware/interfaces/graphics/bufferqueue/2.0": Bp2BuildDefaultTrue,
- "hardware/interfaces/graphics/common/1.0": Bp2BuildDefaultTrue,
- "hardware/interfaces/graphics/common/1.1": Bp2BuildDefaultTrue,
- "hardware/interfaces/graphics/common/1.2": Bp2BuildDefaultTrue,
- "hardware/interfaces/graphics/common/aidl": Bp2BuildDefaultTrue,
- "hardware/interfaces/graphics/mapper/2.0": Bp2BuildDefaultTrue,
- "hardware/interfaces/graphics/mapper/2.1": Bp2BuildDefaultTrue,
- "hardware/interfaces/graphics/mapper/3.0": Bp2BuildDefaultTrue,
- "hardware/interfaces/graphics/mapper/4.0": Bp2BuildDefaultTrue,
- "hardware/interfaces/health/1.0": Bp2BuildDefaultTrue,
- "hardware/interfaces/health/1.0/default": Bp2BuildDefaultTrue,
- "hardware/interfaces/health/2.0": Bp2BuildDefaultTrue,
- "hardware/interfaces/health/2.0/default": Bp2BuildDefaultTrue,
- "hardware/interfaces/health/2.0/utils": Bp2BuildDefaultTrueRecursively,
- "hardware/interfaces/health/2.1": Bp2BuildDefaultTrue,
- "hardware/interfaces/health/aidl": Bp2BuildDefaultTrue,
- "hardware/interfaces/health/utils": Bp2BuildDefaultTrueRecursively,
- "hardware/interfaces/media": Bp2BuildDefaultTrueRecursively,
- "hardware/interfaces/media/bufferpool/aidl/default/tests": Bp2BuildDefaultFalseRecursively,
- "hardware/interfaces/media/omx/1.0/vts": Bp2BuildDefaultFalseRecursively,
- "hardware/interfaces/neuralnetworks": Bp2BuildDefaultTrueRecursively,
- "hardware/interfaces/neuralnetworks/aidl/vts": Bp2BuildDefaultFalseRecursively,
- "hardware/interfaces/neuralnetworks/1.0/vts": Bp2BuildDefaultFalseRecursively,
- "hardware/interfaces/neuralnetworks/1.1/vts": Bp2BuildDefaultFalseRecursively,
- "hardware/interfaces/neuralnetworks/1.2/vts": Bp2BuildDefaultFalseRecursively,
- "hardware/interfaces/neuralnetworks/1.3/vts": Bp2BuildDefaultFalseRecursively,
- "hardware/interfaces/neuralnetworks/1.4/vts": Bp2BuildDefaultFalseRecursively,
- "hardware/interfaces/tests": Bp2BuildDefaultTrueRecursively,
- "hardware/interfaces/tests/extension": Bp2BuildDefaultFalseRecursively, // missing deps
- "hardware/interfaces/tests/msgq": Bp2BuildDefaultFalseRecursively, // missing deps
-
- "libnativehelper": Bp2BuildDefaultTrueRecursively,
-
- "packages/apps/DevCamera": Bp2BuildDefaultTrue,
- "packages/apps/HTMLViewer": Bp2BuildDefaultTrue,
- "packages/apps/Protips": Bp2BuildDefaultTrue,
- "packages/apps/SafetyRegulatoryInfo": Bp2BuildDefaultTrue,
- "packages/apps/WallpaperPicker": Bp2BuildDefaultTrue,
- "packages/modules/Connectivity/bpf_progs": Bp2BuildDefaultTrueRecursively,
- "packages/modules/Connectivity/service-t": Bp2BuildDefaultTrueRecursively,
- "packages/modules/Connectivity/service/native": Bp2BuildDefaultTrueRecursively,
- "packages/modules/Connectivity/staticlibs/native": Bp2BuildDefaultTrueRecursively,
- "packages/modules/Connectivity/staticlibs/netd": Bp2BuildDefaultTrueRecursively,
- "packages/modules/Connectivity/staticlibs/netd/libnetdutils": Bp2BuildDefaultTrueRecursively,
- "packages/modules/Connectivity/tests/unit/jni": Bp2BuildDefaultTrueRecursively,
- "packages/modules/Gki/libkver": Bp2BuildDefaultTrue,
- "packages/modules/NetworkStack/common/captiveportal": Bp2BuildDefaultTrue,
- "packages/modules/NeuralNetworks/apex": Bp2BuildDefaultTrue,
- "packages/modules/NeuralNetworks/apex/testing": Bp2BuildDefaultTrue,
- "packages/modules/NeuralNetworks/driver/cache": Bp2BuildDefaultTrueRecursively,
- "packages/modules/SdkExtensions/gen_sdk": Bp2BuildDefaultTrue,
- "packages/modules/StatsD/lib/libstatssocket": Bp2BuildDefaultTrueRecursively,
- "packages/modules/adb": Bp2BuildDefaultTrue,
- "packages/modules/adb/apex": Bp2BuildDefaultTrue,
- "packages/modules/adb/crypto": Bp2BuildDefaultTrueRecursively,
- "packages/modules/adb/fastdeploy": Bp2BuildDefaultTrue,
- "packages/modules/adb/libs": Bp2BuildDefaultTrueRecursively,
- "packages/modules/adb/pairing_auth": Bp2BuildDefaultTrueRecursively,
- "packages/modules/adb/pairing_connection": Bp2BuildDefaultTrueRecursively,
- "packages/modules/adb/proto": Bp2BuildDefaultTrueRecursively,
- "packages/modules/adb/tls": Bp2BuildDefaultTrueRecursively,
- "packages/modules/common/proto": Bp2BuildDefaultTrue,
- "packages/providers/MediaProvider/tools/dialogs": Bp2BuildDefaultFalse, // TODO(b/242834374)
- "packages/screensavers/Basic": Bp2BuildDefaultTrue,
- "packages/services/Car/tests/SampleRearViewCamera": Bp2BuildDefaultFalse, // TODO(b/242834321)
-
- "platform_testing/libraries/annotations": Bp2BuildDefaultTrueRecursively,
- "platform_testing/libraries/flag-helpers/libflagtest": Bp2BuildDefaultTrueRecursively,
- "platform_testing/tests/example": Bp2BuildDefaultTrueRecursively,
-
- "prebuilts/clang/host/linux-x86": Bp2BuildDefaultTrueRecursively,
- "prebuilts/gradle-plugin": Bp2BuildDefaultTrueRecursively,
- "prebuilts/module_sdk": Bp2BuildDefaultTrueRecursively,
- "prebuilts/runtime/mainline/platform/sdk": Bp2BuildDefaultTrueRecursively,
- "prebuilts/sdk": Bp2BuildDefaultTrue,
- "prebuilts/sdk/current/androidx": Bp2BuildDefaultTrue,
- "prebuilts/sdk/current/androidx-legacy": Bp2BuildDefaultTrue,
- "prebuilts/sdk/current/extras/app-toolkit": Bp2BuildDefaultTrue,
- "prebuilts/sdk/current/extras/constraint-layout-x": Bp2BuildDefaultTrue,
- "prebuilts/sdk/current/extras/material-design-x": Bp2BuildDefaultTrue,
- "prebuilts/sdk/current/support": Bp2BuildDefaultTrue,
- "prebuilts/tools": Bp2BuildDefaultTrue,
- "prebuilts/tools/common/m2": Bp2BuildDefaultTrue,
- "prebuilts/r8": Bp2BuildDefaultTrueRecursively,
-
- "sdk/annotations": Bp2BuildDefaultTrueRecursively,
- "sdk/dumpeventlog": Bp2BuildDefaultTrue,
- "sdk/eventanalyzer": Bp2BuildDefaultTrue,
-
- "system/apex": Bp2BuildDefaultFalse, // TODO(b/207466993): flaky failures
- "system/apex/apexer": Bp2BuildDefaultTrue,
- "system/apex/libs": Bp2BuildDefaultTrueRecursively,
- "system/apex/libs/libapexsupport": Bp2BuildDefaultFalseRecursively, // TODO(b/267572288): depends on rust
- "system/apex/proto": Bp2BuildDefaultTrueRecursively,
- "system/apex/tools": Bp2BuildDefaultTrueRecursively,
- "system/core/debuggerd": Bp2BuildDefaultTrueRecursively,
- "system/core/diagnose_usb": Bp2BuildDefaultTrueRecursively,
- "system/core/fs_mgr": Bp2BuildDefaultTrueRecursively,
- "system/core/healthd": Bp2BuildDefaultTrue,
- "system/core/healthd/testdata": Bp2BuildDefaultTrue,
- "system/core/libasyncio": Bp2BuildDefaultTrue,
- "system/core/libcrypto_utils": Bp2BuildDefaultTrueRecursively,
- "system/core/libcutils": Bp2BuildDefaultTrueRecursively,
- "system/core/libpackagelistparser": Bp2BuildDefaultTrueRecursively,
- "system/core/libprocessgroup": Bp2BuildDefaultTrue,
- "system/core/libprocessgroup/cgrouprc": Bp2BuildDefaultTrue,
- "system/core/libprocessgroup/cgrouprc_format": Bp2BuildDefaultTrue,
- "system/core/libsparse": Bp2BuildDefaultTrueRecursively,
- "system/core/libstats/expresslog": Bp2BuildDefaultTrueRecursively,
- "system/core/libsuspend": Bp2BuildDefaultTrue,
- "system/core/libsystem": Bp2BuildDefaultTrueRecursively,
- "system/core/libsysutils": Bp2BuildDefaultTrueRecursively,
- "system/core/libutils": Bp2BuildDefaultTrueRecursively,
- "system/core/libvndksupport": Bp2BuildDefaultTrueRecursively,
- "system/core/mkbootfs": Bp2BuildDefaultTrueRecursively,
- "system/core/property_service/libpropertyinfoparser": Bp2BuildDefaultTrueRecursively,
- "system/core/property_service/libpropertyinfoserializer": Bp2BuildDefaultTrueRecursively,
- "system/core/trusty/libtrusty": Bp2BuildDefaultTrue,
- "system/extras/f2fs_utils": Bp2BuildDefaultTrueRecursively,
- "system/extras/toolchain-extras": Bp2BuildDefaultTrue,
- "system/extras/verity": Bp2BuildDefaultTrueRecursively,
- "system/hardware/interfaces/media": Bp2BuildDefaultTrueRecursively,
- "system/incremental_delivery/incfs": Bp2BuildDefaultTrue,
- "system/libartpalette": Bp2BuildDefaultTrueRecursively,
- "system/libbase": Bp2BuildDefaultTrueRecursively,
- "system/libfmq": Bp2BuildDefaultTrue,
- "system/libhidl": Bp2BuildDefaultTrue,
- "system/libhidl/libhidlmemory": Bp2BuildDefaultTrue,
- "system/libhidl/transport": Bp2BuildDefaultTrue,
- "system/libhidl/transport/allocator/1.0": Bp2BuildDefaultTrue,
- "system/libhidl/transport/base/1.0": Bp2BuildDefaultTrue,
- "system/libhidl/transport/manager/1.0": Bp2BuildDefaultTrue,
- "system/libhidl/transport/manager/1.1": Bp2BuildDefaultTrue,
- "system/libhidl/transport/manager/1.2": Bp2BuildDefaultTrue,
- "system/libhidl/transport/memory": Bp2BuildDefaultTrueRecursively,
- "system/libhidl/transport/safe_union/1.0": Bp2BuildDefaultTrue,
- "system/libhidl/transport/token/1.0": Bp2BuildDefaultTrue,
- "system/libhidl/transport/token/1.0/utils": Bp2BuildDefaultTrue,
- "system/libhwbinder": Bp2BuildDefaultTrueRecursively,
- "system/libprocinfo": Bp2BuildDefaultTrue,
- "system/libvintf": Bp2BuildDefaultTrue,
- "system/libziparchive": Bp2BuildDefaultTrueRecursively,
- "system/linkerconfig": Bp2BuildDefaultTrueRecursively,
- "system/logging": Bp2BuildDefaultTrueRecursively,
- "system/media": Bp2BuildDefaultTrue,
- "system/media/alsa_utils": Bp2BuildDefaultTrueRecursively,
- "system/media/audio": Bp2BuildDefaultTrueRecursively,
- "system/media/audio_utils": Bp2BuildDefaultTrueRecursively,
- "system/media/camera": Bp2BuildDefaultTrueRecursively,
- "system/memory/libion": Bp2BuildDefaultTrueRecursively,
- "system/memory/libmemunreachable": Bp2BuildDefaultTrueRecursively,
- "system/netd": Bp2BuildDefaultTrue,
- "system/security/fsverity": Bp2BuildDefaultTrueRecursively,
- "system/sepolicy/apex": Bp2BuildDefaultTrueRecursively,
- "system/testing/gtest_extras": Bp2BuildDefaultTrueRecursively,
- "system/timezone/apex": Bp2BuildDefaultTrueRecursively,
- "system/timezone/output_data": Bp2BuildDefaultTrueRecursively,
- "system/timezone/testdata": Bp2BuildDefaultTrueRecursively,
- "system/timezone/testing": Bp2BuildDefaultTrueRecursively,
- "system/tools/aidl/build/tests_bp2build": Bp2BuildDefaultTrue,
- "system/tools/aidl/metadata": Bp2BuildDefaultTrue,
- "system/tools/hidl": Bp2BuildDefaultTrueRecursively,
- "system/tools/mkbootimg": Bp2BuildDefaultTrueRecursively,
- "system/tools/sysprop": Bp2BuildDefaultTrue,
- "system/tools/xsdc/utils": Bp2BuildDefaultTrueRecursively,
- "system/unwinding/libunwindstack": Bp2BuildDefaultTrueRecursively,
-
- "test/vts/vts_hal_hidl_target": Bp2BuildDefaultTrueRecursively,
-
- "toolchain/pgo-profiles": Bp2BuildDefaultTrueRecursively,
- "tools/apifinder": Bp2BuildDefaultTrue,
- "tools/apksig": Bp2BuildDefaultTrue,
- "tools/dexter/slicer": Bp2BuildDefaultTrueRecursively,
- "tools/external_updater": Bp2BuildDefaultTrueRecursively,
- "tools/metalava": Bp2BuildDefaultTrueRecursively,
- "tools/platform-compat/java/android/compat": Bp2BuildDefaultTrueRecursively,
- "tools/platform-compat/java/androidprocessor": Bp2BuildDefaultTrueRecursively,
- "tools/tradefederation/core/util_apps": Bp2BuildDefaultTrueRecursively,
- "tools/tradefederation/prebuilts/filegroups": Bp2BuildDefaultTrueRecursively,
- }
-
- Bp2buildKeepExistingBuildFile = map[string]bool{
- // This is actually build/bazel/build.BAZEL symlinked to ./BUILD
- ".":/*recursive = */ false,
-
- "build/bazel":/* recursive = */ true,
- "build/make/core":/* recursive = */ false,
- "build/bazel_common_rules":/* recursive = */ true,
- "build/make/target/product/security":/* recursive = */ false,
- // build/make/tools/signapk BUILD file is generated, so build/make/tools is not recursive.
- "build/make/tools":/* recursive = */ false,
- "build/pesto":/* recursive = */ true,
- "build/soong":/* recursive = */ true,
-
- // external/bazelbuild-rules_android/... is needed by mixed builds, otherwise mixed builds analysis fails
- // e.g. ERROR: Analysis of target '@soong_injection//mixed_builds:buildroot' failed
- "external/bazelbuild-rules_android":/* recursive = */ true,
- "external/bazelbuild-rules_cc":/* recursive = */ true,
- "external/bazelbuild-rules_java":/* recursive = */ true,
- "external/bazelbuild-rules_license":/* recursive = */ true,
- "external/bazelbuild-rules_go":/* recursive = */ true,
- "external/bazelbuild-rules_python":/* recursive = */ true,
- "external/bazelbuild-rules_rust":/* recursive = */ true,
- "external/bazelbuild-rules_testing":/* recursive = */ true,
- "external/bazelbuild-kotlin-rules":/* recursive = */ true,
- "external/bazel-skylib":/* recursive = */ true,
- "external/protobuf":/* recursive = */ false,
- "external/python/absl-py":/* recursive = */ true,
-
- "external/compiler-rt/lib/cfi":/* recursive = */ false,
-
- // this BUILD file is globbed by //external/icu/icu4c/source:icu4c_test_data's "data/**/*".
- "external/icu/icu4c/source/data/unidata/norm2":/* recursive = */ false,
-
- // Building manually due to b/179889880: resource files cross package boundary
- "packages/apps/Music":/* recursive = */ true,
-
- "prebuilts/abi-dumps/platform":/* recursive = */ true,
- "prebuilts/abi-dumps/ndk":/* recursive = */ true,
- "prebuilts/bazel":/* recursive = */ true,
- "prebuilts/bundletool":/* recursive = */ true,
- "prebuilts/clang/host/linux-x86":/* recursive = */ false,
- "prebuilts/clang-tools":/* recursive = */ true,
- "prebuilts/gcc":/* recursive = */ true,
- "prebuilts/build-tools":/* recursive = */ true,
- "prebuilts/jdk/jdk8":/* recursive = */ true,
- "prebuilts/jdk/jdk17":/* recursive = */ true,
- "prebuilts/misc":/* recursive = */ false, // not recursive because we need bp2build converted build files in prebuilts/misc/common/asm
- "prebuilts/sdk":/* recursive = */ false,
- "prebuilts/sdk/tools":/* recursive = */ false,
- "prebuilts/r8":/* recursive = */ false,
- "prebuilts/runtime":/* recursive = */ false,
- "prebuilts/rust":/* recursive = */ true,
-
- // not recursive due to conflicting workspace paths in tools/atest/bazel/rules
- "tools/asuite/atest":/* recursive = */ false,
- "tools/asuite/atest/bazel/reporter":/* recursive = */ true,
-
- // Used for testing purposes only. Should not actually exist in the real source tree.
- "testpkg/keep_build_file":/* recursive = */ false,
- }
-
- Bp2buildModuleAlwaysConvertList = []string{
- "aconfig.test.cpp",
- "AconfigJavaHostTest",
- // aconfig
- "libonce_cell",
- "libanyhow",
- "libunicode_segmentation",
- "libmemchr",
- "libbitflags-1.3.2",
- "libryu",
- "libitoa",
- "libos_str_bytes",
- "libheck",
- "libclap_lex",
- "libsyn",
- "libquote",
- "libunicode_ident",
- "libproc_macro2",
- "libthiserror_impl",
- "libserde_derive",
- "libclap_derive",
- "libthiserror",
- "libserde",
- "libclap",
- "libbytes",
- "libprotobuf_support",
- "libtinytemplate",
- "libserde_json",
- "libprotobuf",
-
- "protoc-gen-rust",
- "libprotobuf_codegen",
- "libprotobuf_parse",
- "libregex",
- "libtempfile",
- "libwhich",
- "libregex_syntax",
- "libfastrand",
- "libeither",
- "libaho_corasick",
- "liblibc",
- "libcfg_if",
- "liblog_rust",
- "libgetrandom",
- "libremove_dir_all",
- "libahash",
- "libhashbrown",
- "libindexmap",
- "libaconfig_protos",
- "libpaste",
- "aconfig",
-
- // ext
- "tagsoup",
-
- // framework-minus-apex
- "AndroidFrameworkLintChecker",
- "ImmutabilityAnnotationProcessor",
- "debian.mime.types.minimized",
- "framework-javastream-protos",
- "libview-inspector-annotation-processor",
-
- // services
- "apache-commons-math",
- "cbor-java",
- "icu4j_calendar_astronomer",
- "statslog-art-java-gen",
-
- "AndroidCommonLint",
- "ImmutabilityAnnotation",
- "ImmutabilityAnnotationProcessorHostLibrary",
-
- "libidmap2_policies",
- "libSurfaceFlingerProp",
- "toolbox_input_labels",
-
- // cc mainline modules
-
- // com.android.media.swcodec
- "com.android.media.swcodec",
- "com.android.media.swcodec-androidManifest",
- "com.android.media.swcodec-ld.config.txt",
- "com.android.media.swcodec-mediaswcodec.32rc",
- "com.android.media.swcodec-mediaswcodec.rc",
- "com.android.media.swcodec.certificate",
- "com.android.media.swcodec.key",
- "test_com.android.media.swcodec",
-
- // deps
- "code_coverage.policy",
- "code_coverage.policy.other",
- "codec2_soft_exports",
- "compatibility_matrix_schema",
- "framework-connectivity-protos",
- "framework-connectivity-javastream-protos",
- "gemmlowp_headers",
- "gl_headers",
- "libandroid_runtime_lazy",
- "libandroid_runtime_vm_headers",
- "libaudioclient_aidl_conversion_util",
- "libbinder_headers_platform_shared",
- "libbinderthreadstateutils",
- "libbluetooth-types-header",
- "libcodec2",
- "libcodec2_headers",
- "libcodec2_internal",
- "libdmabufheap",
- "libgsm",
- "libgrallocusage",
- "libgralloctypes",
- "libnativewindow",
- "libneuralnetworks",
- "libneuralnetworks_static",
- "libgraphicsenv",
- "libhardware_headers",
- "libnativeloader-headers",
- "libnativewindow_headers",
- "libneuralnetworks_headers",
- "libneuralnetworks_packageinfo",
- "libopus",
- "libprocpartition",
- "libruy_static",
- "libandroidio",
- "libandroidio_srcs",
- "libserviceutils",
- "libsurfaceflinger_headers",
- "libsync",
- "libtextclassifier_hash_headers",
- "libtextclassifier_hash_static",
- "libtflite_kernel_utils",
- "libtinyxml2",
- "libvorbisidec",
- "media_ndk_headers",
- "media_plugin_headers",
- "mediaswcodec.policy",
- "mediaswcodec.xml",
- "neuralnetworks_types",
- "libneuralnetworks_common",
- "philox_random",
- "philox_random_headers",
- "server_configurable_flags",
- "service-permission-streaming-proto-sources",
- "statslog_neuralnetworks.cpp",
- "statslog_neuralnetworks.h",
- "tensorflow_headers",
-
- "libstagefright_bufferpool@2.0",
- "libstagefright_bufferpool@2.0.1",
- "libSurfaceFlingerProp",
-
- // prebuilts
- "prebuilt_stats-log-api-gen",
- "prebuilt_aapt2",
-
- // fastboot
- "fastboot",
- "libfastboot",
-
- "PluginCoreLib",
- "dagger2",
- "dagger2-android-annotation-stubs",
- "dagger2-bootstrap-compiler",
- "dagger2-producers",
- "okio-lib",
- "setupdesign-strings",
-
- //external/avb
- "avbtool",
- "libavb",
- "avb_headers",
-
- //external/libxml2
- "xmllint",
- "libxml2",
-
- //external/fec
- "libfec_rs",
-
- //system/extras/ext4_utils
- "libext4_utils",
- "mke2fs_conf",
- "mkuserimg_mke2fs",
- "blk_alloc_to_base_fs",
-
- //system/extras/libfec
- "libfec",
-
- //system/extras/squashfs_utils
- "libsquashfs_utils",
-
- //packages/apps/Car/libs/car-ui-lib/car-ui-androidx
- // genrule dependencies for java_imports
- "car-ui-androidx-annotation-nodeps",
- "car-ui-androidx-collection-nodeps",
- "car-ui-androidx-core-common-nodeps",
- "car-ui-androidx-lifecycle-common-nodeps",
- "car-ui-androidx-constraintlayout-solver-nodeps",
-
- //frameworks/native/libs/input
- "inputconstants_aidl",
-
- // needed for aidl_interface's ndk backend
- "libbinder_ndk",
-
- "libusb",
-
- //frameworks/native/cmds/cmd
- "libcmd",
-
- //system/chre
- "chre_api",
-
- //system/gsid
- "libgsi",
- "libgsi_headers",
-
- //system/core/libkeyutils
- "libkeyutils",
-
- //bootable/recovery/otautil
- "libotautil",
-
- //system/vold
- "libvold_headers",
-
- //system/extras/libfscrypt
- "libfscrypt",
-
- //bootable/recovery/fuse_sideload
- "libfusesideload",
-
- "libcodec2_aidl",
- "libcodec2_hidl@1.0",
- "libcodec2_hidl@1.1",
- "libcodec2_hidl@1.2",
- "libcodec2_hidl_plugin_stub",
- "libcodec2_hidl_plugin",
- "libcodec2_hal_common",
- "libstagefright_bufferqueue_helper_novndk",
- "libGLESv2",
- "libEGL",
- "libcodec2_vndk",
- "libnativeloader_lazy",
- "libnativeloader",
- "libEGL_getProcAddress",
- "libEGL_blobCache",
-
- "mediaswcodec",
- "libmedia_headers",
- "libmedia_codecserviceregistrant",
- "libsfplugin_ccodec_utils",
- "libcodec2_soft_aacenc",
- "libcodec2_soft_amrnbdec",
- "libcodec2_soft_amrnbenc",
- "libcodec2_soft_amrwbdec",
- "libcodec2_soft_amrwbenc",
- "libcodec2_soft_hevcdec",
- "libcodec2_soft_hevcenc",
- "libcodec2_soft_g711alawdec",
- "libcodec2_soft_g711mlawdec",
- "libcodec2_soft_mpeg2dec",
- "libcodec2_soft_h263dec",
- "libcodec2_soft_h263enc",
- "libcodec2_soft_mpeg4dec",
- "libcodec2_soft_mpeg4enc",
- "libcodec2_soft_mp3dec",
- "libcodec2_soft_vorbisdec",
- "libcodec2_soft_opusdec",
- "libcodec2_soft_opusenc",
- "libcodec2_soft_vp8dec",
- "libcodec2_soft_vp9dec",
- "libcodec2_soft_av1dec_gav1",
- "libcodec2_soft_av1dec_dav1d",
- "libcodec2_soft_vp8enc",
- "libcodec2_soft_vp9enc",
- "libcodec2_soft_rawdec",
- "libcodec2_soft_flacdec",
- "libcodec2_soft_flacenc",
- "libcodec2_soft_gsmdec",
- "libcodec2_soft_avcdec",
- "libcodec2_soft_avcenc",
- "libcodec2_soft_aacdec",
- "libcodec2_soft_common",
-
- // kotlin srcs in java libs
- "kotlinx_atomicfu",
-
- // kotlin srcs in java binary
- "AnalyzerKt",
- "trebuchet-core",
-
- // kotlin srcs in android_library
- "renderscript_toolkit",
-
- //kotlin srcs in android_binary
- "MusicKotlin",
-
- // java_library with prebuilt sdk_version
- "android-common",
-
- // checked in current.txt for merged_txts
- "non-updatable-current.txt",
- "non-updatable-system-current.txt",
- "non-updatable-module-lib-current.txt",
- "non-updatable-system-server-current.txt",
-
- // for api_fingerprint.txt generation
- "api_fingerprint",
-
- // for building com.android.neuralnetworks
- "libimapper_stablec",
- "libimapper_providerutils",
-
- // min_sdk_version in android_app
- "CtsShimUpgrade",
-
- "art_cmdlineparser_headers",
-
- // Mainline Module Apps
- "CaptivePortalLogin",
- "ModuleMetadata",
-
- "libstagefright_headers",
-
- // Apps with JNI libs
- "SimpleJNI",
- "libsimplejni",
-
- // aidl
- "aidl",
- "libaidl-common",
-
- // Used by xsd_config
- "xsdc",
-
- // cc_test that can be run by b test
- "binderRpcWireProtocolTest",
- "binderUnitTest",
- "cpu_features-bit_utils_test",
- "android.hardware.audio.common.test.utility_tests",
- "HalAudioStreamWorkerTest",
- "libjavacore-unit-tests",
- "NeuralNetworksTest_utils",
- "NeuralNetworksTest_logtag",
- "NeuralNetworksTest_operations",
- "nanoapp_chqts_shared_tests",
- "fakeservicemanager_test",
- "tristate_test",
- "binderUtilsHostTest",
- "run_dex2oat_test",
- "bluetooth-address-unit-tests",
-
- // for platform_compat_config
- "process-compat-config",
-
- // cc_* modules with rscript srcs
- "rstest-latency",
- "libRScpp_static",
- "rs-headers",
- "rs_script_api",
- "libRSDispatch",
-
- // hal_unit_tests and deps
- "chre_flatbuffers",
- "event_logger",
- "hal_unit_tests",
-
- "merge_annotation_zips_test",
-
- // java_resources with multiple resource_dirs
- "emma",
-
- // NDK STL
- "ndk_libc++abi",
- "ndk_libunwind",
- "ndk_libc++_static",
- "ndk_libc++_shared",
- "ndk_system",
-
- // allowlist //prebuilts/common/misc/androidx-test/...
- "androidx.test.runner",
- "androidx.test.runner-nodeps",
- "androidx.test.services.storage",
- "androidx.test.services.storage-nodeps",
- "androidx.test.monitor",
- "androidx.test.monitor-nodeps",
- "androidx.test.annotation",
- "androidx.test.annotation-nodeps",
-
- // jni deps of an internal android_test (b/297405812)
- "libopenjdkjvmti_headers",
-
- // tradefed deps
- "apache-commons-compress",
- "tradefed-protos",
- "grpc-java",
- "grpc-java-api",
- "grpc-java-auth",
- "grpc-java-context",
- "grpc-java-core",
- "grpc-java-core-inprocess",
- "grpc-java-core-internal",
- "grpc-java-core-util",
- "grpc-java-protobuf",
- "grpc-java-protobuf-lite",
- "grpc-java-stub",
- "grpc-java-annotation-stubs",
- "grpc-java-annotation-stubs-srcjar",
- "gen_annotations",
- "opencensus-java-contrib-grpc-metrics",
- "opencensus-java-api",
- "gson",
- "GsonBuildConfig.java",
- "gson_version_generator",
- "lab-resource-grpc",
- "blueprint-deptools",
- "protoc-gen-grpc-java-plugin",
- "tf-remote-client",
- "tradefed-lite",
- "tradefed-isolation-protos",
- "snakeyaml_patched_src_files",
- "asuite_proto_java",
- "tradefed-service-grpc-lib",
- "tradefed-invocation-grpc",
- "tradefed-external-dependencies",
- "tradefed-dynamic-sharding-grpc",
- "tradefed-device-manager-grpc",
- "statsd_internal_protos",
- "snakeyaml",
- "loganalysis",
- "junit-params",
- "grpc-java-testing",
- "grpc-java-netty-shaded",
- "aoa-helper",
- "test-services.apk",
- "test-composers",
- "py3-stdlib-prebuilt-srcs",
- "platformprotos",
- "test-services-normalized.apk",
- "tradefed-common-util",
- "tradefed-clearcut-client",
- "tradefed-result-interfaces",
- "tradefed-device-build-interfaces",
- "tradefed-invocation-interfaces",
- "tradefed-lib-core",
-
- "libandroid_net_connectivity_com_android_net_module_util_jni",
- "libservice-connectivity",
-
- "mainline_modules_sdks_test",
-
- "fake_device_config",
- }
-
- Bp2buildModuleTypeAlwaysConvertList = []string{
- // go/keep-sorted start
- "aconfig_declarations",
- "aconfig_value_set",
- "aconfig_values",
- "aidl_interface_headers",
- "bpf",
- "cc_aconfig_library",
- "cc_prebuilt_library",
- "cc_prebuilt_library_headers",
- "cc_prebuilt_library_shared",
- "cc_prebuilt_library_static",
- "combined_apis",
- "droiddoc_exported_dir",
- "java_aconfig_library",
- "java_import",
- "java_import_host",
- "java_sdk_library",
- "java_sdk_library_import",
- "license",
- "linker_config",
- "ndk_headers",
- "ndk_library",
- "sysprop_library",
- "versioned_ndk_headers",
- "xsd_config",
- // go/keep-sorted end
- }
-
- // Add the names of modules that bp2build should never convert, if it is
- // in the package allowlist. An error will be thrown if a module must
- // not be here and in the alwaysConvert lists.
- //
- // For prebuilt modules (e.g. android_library_import), remember to add
- // the "prebuilt_" prefix to the name, so that it's differentiable from
- // the source versions within Soong's module graph.
- Bp2buildModuleDoNotConvertList = []string{
-
- // rust modules that have cc deps
- "liblogger",
- "libbssl_ffi",
- "libbssl_ffi_nostd",
- "pull_rust",
- "libstatslog_rust",
- "libstatslog_rust_header",
- "libflatbuffers",
- "liblog_event_list",
- "libminijail_rust",
- "libminijail_sys",
- "libfsverity_rs",
- "libtombstoned_client_rust",
-
- // TODO(b/263326760): Failed already.
- "minijail_compiler_unittest",
- "minijail_parser_unittest",
-
- // cc bugs
-
- // TODO(b/198619163) module has same name as source
- "logtagd.rc",
-
- "libgtest_ndk_c++", "libgtest_main_ndk_c++", // TODO(b/201816222): Requires sdk_version support.
-
- // TODO(b/202876379): has arch-variant static_executable
- "linkerconfig",
- "mdnsd",
- "libcutils_test_static",
- "KernelLibcutilsTest",
-
- "linker", // TODO(b/228316882): cc_binary uses link_crt
- "versioner", // TODO(b/228313961): depends on prebuilt shared library libclang-cpp_host as a shared library, which does not supply expected providers for a shared library
-
- // requires host tools for apexer
- "apexer_test", "apexer_test_host_tools", "host_apex_verifier", "host-apex-verifier",
-
- // java bugs
- "libbase_ndk", // TODO(b/186826477): fails to link libctscamera2_jni for device (required for CtsCameraTestCases)
- "bouncycastle", // TODO(b/274474005): Need support for custom system_modules.
- "bouncycastle-test-lib", // TODO(b/274474005): Reverse dependency of bouncycastle
-
- // genrule incompatibilities
- "brotli-fuzzer-corpus", // TODO(b/202015218): outputs are in location incompatible with bazel genrule handling.
- "platform_tools_properties", "build_tools_source_properties", // TODO(b/203369847): multiple genrules in the same package creating the same file
-
- // aar support
- "prebuilt_car-ui-androidx-core-common", // TODO(b/224773339), genrule dependency creates an .aar, not a .jar
- // ERROR: The dependencies for the following 1 jar(s) are not complete.
- // 1.bazel-out/android_target-fastbuild/bin/prebuilts/tools/common/m2/_aar/robolectric-monitor-1.0.2-alpha1/classes_and_libs_merged.jar
- "prebuilt_robolectric-monitor-1.0.2-alpha1",
-
- // path property for filegroups
- "conscrypt", // TODO(b/210751803), we don't handle path property for filegroups
- "conscrypt-for-host", // TODO(b/210751803), we don't handle path property for filegroups
- "host-libprotobuf-java-full", // TODO(b/210751803), we don't handle path property for filegroups
- "libprotobuf-internal-python-srcs", // TODO(b/210751803), we don't handle path property for filegroups
-
- // go deps.
- // TODO: b/305091740 - Rely on bp2build_deps to remove these dependencies.
- "analyze_bcpf", // depends on bpmodify a blueprint_go_binary.
- "analyze_bcpf_test", // depends on bpmodify a blueprint_go_binary.
- "host_bionic_linker_asm", // depends on extract_linker, a go binary.
- "host_bionic_linker_script", // depends on extract_linker, a go binary.
-
- // rust support
- "libtombstoned_client_rust_bridge_code", "libtombstoned_client_wrapper", // rust conversions are not supported
-
- // TODO: b/303474748 - aidl rules for java are incompatible with parcelable declarations
- "modules-utils-list-slice",
- "modules-utils-os",
- "modules-utils-synchronous-result-receiver",
-
- // aidl files not created
- "overlayable_policy_aidl_interface",
-
- // cc_test related.
- // b/274164834 "Could not open Configuration file test.cfg"
- "svcenc", "svcdec",
-
- // Failing host cc_tests
- "gtest_isolated_tests",
- "libunwindstack_unit_test",
- "power_tests", // failing test on server, but not on host
-
- // reflect: call of reflect.Value.NumField on interface Value
- // affects all cc_tests that depend on art_defaults
- "libnativebridge-tests",
- "libnativeloader_test",
- "art_libnativebridge_cts_tests",
- "art_standalone_libdexfile_external_tests",
- "art_standalone_libdexfile_support_tests",
- "libnativebridge-lazy-tests",
- "libnativebridge-test-case",
- "libnativebridge2-test-case",
- "libnativebridge3-test-case",
- "libnativebridge6-test-case",
- "libnativebridge6prezygotefork",
-
- "libandroidfw_tests", // failing due to data path issues
-
- // error: overriding commands for target
- // `out/host/linux-x86/nativetest64/gmock_tests/gmock_tests__cc_runner_test',
- // previously defined at out/soong/installs-aosp_arm.mk:64919`
- "gmock_tests",
-
- // cc_test with unconverted deps, or are device-only (and not verified to pass yet)
- "AMRWBEncTest",
- "avcdec",
- "avcenc",
- "boringssl_test_support", //b/244431896
- "cfi_test_helper",
- "cintltst32",
- "cintltst64",
- "compare",
- "cpuid",
- "elftls_dlopen_ie_error_helper",
- "fdtrack_test",
- "google-benchmark-test",
- "gtest-typed-test_test",
- "gtest_tests",
- "gtest_tests_no_main",
- "gwp_asan_unittest",
- "half_test",
- "hashcombine_test",
- "hevcdec",
- "hevcenc",
- "i444tonv12_eg",
- "icu4c_sample_break",
- "intltest32",
- "intltest64",
- "ion-unit-tests",
- "jemalloc5_integrationtests",
- "jemalloc5_unittests",
- "jemalloc5_stresstests", // run by run_jemalloc_tests.sh and will be deleted after V
- "libcutils_sockets_test",
- "libhwbinder_latency",
- "liblog-host-test", // failing tests
- "libminijail_test",
- "libminijail_unittest_gtest",
- "libpackagelistparser_test",
- "libprotobuf_vendor_suffix_test",
- "libstagefright_amrnbenc_test",
- "libstagefright_amrwbdec_test", // error: did not report any run
- "libstagefright_m4vh263enc_test",
- "libvndksupport-tests",
- "libyuv_unittest",
- "linker-unit-tests",
- "malloc_debug_system_tests",
- "malloc_debug_unit_tests",
- "malloc_hooks_system_tests",
- "mat_test",
- "mathtest",
- "memunreachable_test",
- "metadata_tests",
- "mpeg2dec",
- "mvcdec",
- "pngtest",
- "preinit_getauxval_test_helper",
- "preinit_syscall_test_helper",
- "psnr",
- "quat_test",
- "scudo_unit_tests",
- "thread_exit_cb_helper",
- "ulp",
- "vec_test",
- "yuvconstants",
- "yuvconvert",
-
- // cc_test_library
- "clang_diagnostic_tests",
- "exec_linker_helper_lib",
- "fortify_disabled_for_tidy",
- "ld_config_test_helper_lib1",
- "ld_config_test_helper_lib2",
- "ld_config_test_helper_lib3",
- "ld_preload_test_helper_lib1",
- "ld_preload_test_helper_lib2",
- "libBionicElfTlsLoaderTests",
- "libBionicElfTlsTests",
- "libBionicElfTlsTests",
- "libBionicFramePointerTests",
- "libBionicFramePointerTests",
- "libBionicStandardTests",
- "libBionicStandardTests",
- "libBionicTests",
- "libart-broken",
- "libatest_simple_zip",
- "libcfi-test",
- "libcfi-test-bad",
- "libcrash_test",
- "libcrypto_fuzz_unsafe",
- "libdl_preempt_test_1",
- "libdl_preempt_test_2",
- "libdl_test_df_1_global",
- "libdlext_test",
- "libdlext_test_different_soname",
- "libdlext_test_fd",
- "libdlext_test_norelro",
- "libdlext_test_recursive",
- "libdlext_test_zip",
- "libdvrcommon_test",
- "libfortify1-new-tests-clang",
- "libfortify1-new-tests-clang",
- "libfortify1-tests-clang",
- "libfortify1-tests-clang",
- "libfortify2-new-tests-clang",
- "libfortify2-new-tests-clang",
- "libfortify2-tests-clang",
- "libfortify2-tests-clang",
- "libgnu-hash-table-library",
- "libicutest_static",
- "liblinker_reloc_bench_000",
- "liblinker_reloc_bench_001",
- "liblinker_reloc_bench_002",
- "liblinker_reloc_bench_003",
- "liblinker_reloc_bench_004",
- "liblinker_reloc_bench_005",
- "liblinker_reloc_bench_006",
- "liblinker_reloc_bench_007",
- "liblinker_reloc_bench_008",
- "liblinker_reloc_bench_009",
- "liblinker_reloc_bench_010",
- "liblinker_reloc_bench_011",
- "liblinker_reloc_bench_012",
- "liblinker_reloc_bench_013",
- "liblinker_reloc_bench_014",
- "liblinker_reloc_bench_015",
- "liblinker_reloc_bench_016",
- "liblinker_reloc_bench_017",
- "liblinker_reloc_bench_018",
- "liblinker_reloc_bench_019",
- "liblinker_reloc_bench_020",
- "liblinker_reloc_bench_021",
- "liblinker_reloc_bench_022",
- "liblinker_reloc_bench_023",
- "liblinker_reloc_bench_024",
- "liblinker_reloc_bench_025",
- "liblinker_reloc_bench_026",
- "liblinker_reloc_bench_027",
- "liblinker_reloc_bench_028",
- "liblinker_reloc_bench_029",
- "liblinker_reloc_bench_030",
- "liblinker_reloc_bench_031",
- "liblinker_reloc_bench_032",
- "liblinker_reloc_bench_033",
- "liblinker_reloc_bench_034",
- "liblinker_reloc_bench_035",
- "liblinker_reloc_bench_036",
- "liblinker_reloc_bench_037",
- "liblinker_reloc_bench_038",
- "liblinker_reloc_bench_039",
- "liblinker_reloc_bench_040",
- "liblinker_reloc_bench_041",
- "liblinker_reloc_bench_042",
- "liblinker_reloc_bench_043",
- "liblinker_reloc_bench_044",
- "liblinker_reloc_bench_045",
- "liblinker_reloc_bench_046",
- "liblinker_reloc_bench_047",
- "liblinker_reloc_bench_048",
- "liblinker_reloc_bench_049",
- "liblinker_reloc_bench_050",
- "liblinker_reloc_bench_051",
- "liblinker_reloc_bench_052",
- "liblinker_reloc_bench_053",
- "liblinker_reloc_bench_054",
- "liblinker_reloc_bench_055",
- "liblinker_reloc_bench_056",
- "liblinker_reloc_bench_057",
- "liblinker_reloc_bench_058",
- "liblinker_reloc_bench_059",
- "liblinker_reloc_bench_060",
- "liblinker_reloc_bench_061",
- "liblinker_reloc_bench_062",
- "liblinker_reloc_bench_063",
- "liblinker_reloc_bench_064",
- "liblinker_reloc_bench_065",
- "liblinker_reloc_bench_066",
- "liblinker_reloc_bench_067",
- "liblinker_reloc_bench_068",
- "liblinker_reloc_bench_069",
- "liblinker_reloc_bench_070",
- "liblinker_reloc_bench_071",
- "liblinker_reloc_bench_072",
- "liblinker_reloc_bench_073",
- "liblinker_reloc_bench_074",
- "liblinker_reloc_bench_075",
- "liblinker_reloc_bench_076",
- "liblinker_reloc_bench_077",
- "liblinker_reloc_bench_078",
- "liblinker_reloc_bench_079",
- "liblinker_reloc_bench_080",
- "liblinker_reloc_bench_081",
- "liblinker_reloc_bench_082",
- "liblinker_reloc_bench_083",
- "liblinker_reloc_bench_084",
- "liblinker_reloc_bench_085",
- "liblinker_reloc_bench_086",
- "liblinker_reloc_bench_087",
- "liblinker_reloc_bench_088",
- "liblinker_reloc_bench_089",
- "liblinker_reloc_bench_090",
- "liblinker_reloc_bench_091",
- "liblinker_reloc_bench_092",
- "liblinker_reloc_bench_093",
- "liblinker_reloc_bench_094",
- "liblinker_reloc_bench_095",
- "liblinker_reloc_bench_096",
- "liblinker_reloc_bench_097",
- "liblinker_reloc_bench_098",
- "liblinker_reloc_bench_099",
- "liblinker_reloc_bench_100",
- "liblinker_reloc_bench_101",
- "liblinker_reloc_bench_102",
- "liblinker_reloc_bench_103",
- "liblinker_reloc_bench_104",
- "liblinker_reloc_bench_105",
- "liblinker_reloc_bench_106",
- "liblinker_reloc_bench_107",
- "liblinker_reloc_bench_108",
- "liblinker_reloc_bench_109",
- "liblinker_reloc_bench_110",
- "liblinker_reloc_bench_111",
- "liblinker_reloc_bench_112",
- "liblinker_reloc_bench_113",
- "liblinker_reloc_bench_114",
- "liblinker_reloc_bench_115",
- "liblinker_reloc_bench_116",
- "liblinker_reloc_bench_117",
- "liblinker_reloc_bench_118",
- "liblinker_reloc_bench_119",
- "liblinker_reloc_bench_120",
- "liblinker_reloc_bench_121",
- "liblinker_reloc_bench_122",
- "liblinker_reloc_bench_123",
- "liblinker_reloc_bench_124",
- "liblinker_reloc_bench_125",
- "liblinker_reloc_bench_126",
- "liblinker_reloc_bench_127",
- "liblinker_reloc_bench_128",
- "liblinker_reloc_bench_129",
- "liblinker_reloc_bench_130",
- "liblinker_reloc_bench_131",
- "liblinker_reloc_bench_132",
- "liblinker_reloc_bench_133",
- "liblinker_reloc_bench_134",
- "liblinker_reloc_bench_135",
- "liblinker_reloc_bench_136",
- "liblinker_reloc_bench_137",
- "liblinker_reloc_bench_138",
- "liblinker_reloc_bench_139",
- "liblinker_reloc_bench_140",
- "liblinker_reloc_bench_141",
- "liblinker_reloc_bench_142",
- "liblinker_reloc_bench_143",
- "liblinker_reloc_bench_144",
- "liblinker_reloc_bench_145",
- "liblinker_reloc_bench_146",
- "liblinker_reloc_bench_147",
- "liblinker_reloc_bench_148",
- "liblinker_reloc_bench_149",
- "liblinker_reloc_bench_150",
- "liblinker_reloc_bench_151",
- "liblinker_reloc_bench_152",
- "liblinker_reloc_bench_153",
- "liblinker_reloc_bench_154",
- "liblinker_reloc_bench_155",
- "liblinker_reloc_bench_156",
- "liblinker_reloc_bench_157",
- "liblinker_reloc_bench_158",
- "liblinker_reloc_bench_159",
- "liblinker_reloc_bench_160",
- "liblinker_reloc_bench_161",
- "liblinker_reloc_bench_162",
- "liblinker_reloc_bench_163",
- "liblinker_reloc_bench_164",
- "liblinker_reloc_bench_165",
- "liblinker_reloc_bench_166",
- "liblinker_reloc_bench_167",
- "liblinker_reloc_bench_168",
- "libns_hidden_child_app",
- "libns_hidden_child_global",
- "libns_hidden_child_internal",
- "libns_hidden_child_public",
- "libnstest_dlopened",
- "libnstest_ns_a_public1",
- "libnstest_ns_a_public1_internal",
- "libnstest_ns_b_public2",
- "libnstest_ns_b_public3",
- "libnstest_private",
- "libnstest_private_external",
- "libnstest_public",
- "libnstest_public_internal",
- "libnstest_root",
- "libnstest_root_not_isolated",
- "librelocations-ANDROID_REL",
- "librelocations-ANDROID_RELR",
- "librelocations-RELR",
- "librelocations-fat",
- "libsegment_gap_inner",
- "libsegment_gap_outer",
- "libssl_fuzz_unsafe",
- "libstatssocket_private",
- "libsysv-hash-table-library",
- "libtest_atexit",
- "libtest_check_order_dlsym",
- "libtest_check_order_dlsym_1_left",
- "libtest_check_order_dlsym_2_right",
- "libtest_check_order_dlsym_3_c",
- "libtest_check_order_dlsym_a",
- "libtest_check_order_dlsym_b",
- "libtest_check_order_dlsym_d",
- "libtest_check_order_reloc_root",
- "libtest_check_order_reloc_root_1",
- "libtest_check_order_reloc_root_2",
- "libtest_check_order_reloc_siblings",
- "libtest_check_order_reloc_siblings_1",
- "libtest_check_order_reloc_siblings_2",
- "libtest_check_order_reloc_siblings_3",
- "libtest_check_order_reloc_siblings_a",
- "libtest_check_order_reloc_siblings_b",
- "libtest_check_order_reloc_siblings_c",
- "libtest_check_order_reloc_siblings_c_1",
- "libtest_check_order_reloc_siblings_c_2",
- "libtest_check_order_reloc_siblings_d",
- "libtest_check_order_reloc_siblings_e",
- "libtest_check_order_reloc_siblings_f",
- "libtest_check_rtld_next_from_library",
- "libtest_dlopen_df_1_global",
- "libtest_dlopen_from_ctor",
- "libtest_dlopen_from_ctor_main",
- "libtest_dlopen_weak_undefined_func",
- "libtest_dlsym_df_1_global",
- "libtest_dlsym_from_this",
- "libtest_dlsym_from_this_child",
- "libtest_dlsym_from_this_grandchild",
- "libtest_dlsym_weak_func",
- "libtest_dt_runpath_a",
- "libtest_dt_runpath_b",
- "libtest_dt_runpath_c",
- "libtest_dt_runpath_d",
- "libtest_dt_runpath_d_zip",
- "libtest_dt_runpath_x",
- "libtest_dt_runpath_y",
- "libtest_elftls_dynamic",
- "libtest_elftls_dynamic_filler_1",
- "libtest_elftls_dynamic_filler_2",
- "libtest_elftls_dynamic_filler_3",
- "libtest_elftls_shared_var",
- "libtest_elftls_shared_var_ie",
- "libtest_elftls_tprel",
- "libtest_empty",
- "libtest_ifunc",
- "libtest_ifunc_variable",
- "libtest_ifunc_variable_impl",
- "libtest_indirect_thread_local_dtor",
- "libtest_init_fini_order_child",
- "libtest_init_fini_order_grand_child",
- "libtest_init_fini_order_root",
- "libtest_init_fini_order_root2",
- "libtest_missing_symbol",
- "libtest_missing_symbol_child_private",
- "libtest_missing_symbol_child_public",
- "libtest_missing_symbol_root",
- "libtest_nodelete_1",
- "libtest_nodelete_2",
- "libtest_nodelete_dt_flags_1",
- "libtest_pthread_atfork",
- "libtest_relo_check_dt_needed_order",
- "libtest_relo_check_dt_needed_order_1",
- "libtest_relo_check_dt_needed_order_2",
- "libtest_simple",
- "libtest_thread_local_dtor",
- "libtest_thread_local_dtor2",
- "libtest_two_parents_child",
- "libtest_two_parents_parent1",
- "libtest_two_parents_parent2",
- "libtest_versioned_lib",
- "libtest_versioned_libv1",
- "libtest_versioned_libv2",
- "libtest_versioned_otherlib",
- "libtest_versioned_otherlib_empty",
- "libtest_versioned_uselibv1",
- "libtest_versioned_uselibv2",
- "libtest_versioned_uselibv2_other",
- "libtest_versioned_uselibv3_other",
- "libtest_with_dependency",
- "libtest_with_dependency_loop",
- "libtest_with_dependency_loop_a",
- "libtest_with_dependency_loop_b",
- "libtest_with_dependency_loop_b_tmp",
- "libtest_with_dependency_loop_c",
- "libtestshared",
-
- // releasetools
- "verity_utils",
- "check_ota_package_signature",
- "check_target_files_vintf",
- "releasetools_check_target_files_vintf",
- "ota_from_target_files",
- "releasetools_ota_from_target_files",
- "add_img_to_target_files",
- "releasetools_add_img_to_target_files",
- "fsverity_metadata_generator",
- "sign_target_files_apks",
-
- // depends on the support of yacc file
- "libapplypatch",
- "libapplypatch_modes",
- "applypatch",
-
- // TODO(b/254476335): disable the following due to this bug
- "libapexinfo",
- "libapexinfo_tests",
-
- // uses glob in $(locations)
- "libc_musl_sysroot",
-
- // TODO(b/266459895): depends on libunwindstack
- "libutils_test",
-
- // Has dependencies on other tools like ziptool, bp2build'd data properties don't work with these tests atm
- "ziparchive_tests_large",
- "mkbootimg_test",
- "certify_bootimg_test",
-
- // Despite being _host module types, these require devices to run
- "logd_integration_test",
- "mobly-hello-world-test",
- "mobly-multidevice-test",
-
- // TODO(b/274805756): Support core_platform and current java APIs
- "fake-framework",
-
- // TODO(b/277616982): These modules depend on private java APIs, but maybe they don't need to.
- "StreamingProtoTest",
- "textclassifierprotoslite",
- "styleprotoslite",
- "CtsPkgInstallerConstants",
- "guava-android-testlib",
-
- // python_test_host with test data
- "sbom_writers_test",
- "hidl_test",
-
- // TODO(B/283193845): Remove tradefed from this list.
- "tradefed",
-
- "libprotobuf-full-test", // TODO(b/246997908): cannot convert proto_libraries which implicitly include other srcs in the same directory
- "libprotobuf-lite-test", // TODO(b/246997908): cannot convert proto_libraries which implicitly include other srcs in the same directory
-
- "logcat", // TODO(b/246997908): cannot convert proto_libraries which implicitly include other srcs in the same directory
-
- "expresscatalogvalidator", // TODO(b/246997908): cannot convert proto_libraries which implicitly include other srcs in the same directory
-
- // r8 is a java_binary, which creates an implicit "r8.jar" target, but the
- // same package contains a "r8.jar" file which gets overshadowed by the implicit target.
- // We don't need this target as we're not using the Soong wrapper for now
- "r8",
-
- // TODO(b/299924782): Fix linking error
- "libbinder_on_trusty_mock",
-
- // TODO(b/299943581): Depends on aidl filegroups with implicit headers
- "libdataloader_aidl-cpp",
- "libincremental_manager_aidl-cpp",
-
- // TODO(b/299974637) Fix linking error
- "libbinder_rpc_unstable",
-
- // TODO(b/297356704) sdk_version is unset.
- "VendorAtomCodeGenJavaTest",
-
- // TODO: b/305223367 - Missing dep on android.test.base-neverlink
- "ObjenesisTck",
-
- // TODO - b/306197073: Sets different STL for host and device variants
- "trace_processor_shell",
-
- // TODO - b/303713102: duplicate deps added by cc_lite_proto_library
- "perfetto_unittests",
- "perfetto_integrationtests",
-
- // TODO - b/306194966: Depends on an empty filegroup
- "libperfetto_c",
- }
-
- // Bazel prod-mode allowlist. Modules in this list are built by Bazel
- // in either prod mode or staging mode.
- ProdMixedBuildsEnabledList = []string{
- // M5: tzdata launch
- "com.android.tzdata",
- "test1_com.android.tzdata",
- "test3_com.android.tzdata",
- // M7: adbd launch
- "com.android.adbd",
- "test_com.android.adbd",
- "adbd_test",
- "adb_crypto_test",
- "adb_pairing_auth_test",
- "adb_pairing_connection_test",
- "adb_tls_connection_test",
- // M9: mixed builds for mainline trains launch
- "api_fingerprint",
- // M11: neuralnetworks launch
- "com.android.neuralnetworks",
- "test_com.android.neuralnetworks",
- "libneuralnetworks",
- "libneuralnetworks_static",
- // M13: media.swcodec launch
- // TODO(b/307389608) Relaunch swcodec after fixing rust dependencies
- // "com.android.media.swcodec",
- // "test_com.android.media.swcodec",
- // "libstagefright_foundation",
- // "libcodec2_hidl@1.0",
- }
-
- // Staging-mode allowlist. Modules in this list are only built
- // by Bazel with --bazel-mode-staging. This list should contain modules
- // which will soon be added to the prod allowlist.
- // It is implicit that all modules in ProdMixedBuildsEnabledList will
- // also be built - do not add them to this list.
- StagingMixedBuildsEnabledList = []string{}
-
- // These should be the libs that are included by the apexes in the ProdMixedBuildsEnabledList
- ProdDclaMixedBuildsEnabledList = []string{
- "libbase",
- "libc++",
- "libcrypto",
- "libcutils",
- "libstagefright_flacdec",
- "libutils",
- }
-
- // These should be the libs that are included by the apexes in the StagingMixedBuildsEnabledList
- StagingDclaMixedBuildsEnabledList = []string{}
-
- // TODO(b/269342245): Enable the rest of the DCLA libs
- // "libssl",
-
// The list of module types which are expected to spend lots of build time.
// With `--ninja_weight_source=soong`, ninja builds these module types and deps first.
HugeModuleTypePrefixMap = map[string]int{
diff --git a/android/androidmk.go b/android/androidmk.go
index a0ed1e4..235d7c0 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -30,6 +30,7 @@
"reflect"
"runtime"
"sort"
+ "strconv"
"strings"
"github.com/google/blueprint"
@@ -275,14 +276,17 @@
}
// AddCompatibilityTestSuites adds the supplied test suites to the EntryMap, with special handling
-// for partial MTS test suites.
+// for partial MTS and MCTS test suites.
func (a *AndroidMkEntries) AddCompatibilityTestSuites(suites ...string) {
- // MTS supports a full test suite and partial per-module MTS test suites, with naming mts-${MODULE}.
- // To reduce repetition, if we find a partial MTS test suite without an full MTS test suite,
+ // M(C)TS supports a full test suite and partial per-module MTS test suites, with naming mts-${MODULE}.
+ // To reduce repetition, if we find a partial M(C)TS test suite without an full M(C)TS test suite,
// we add the full test suite to our list.
if PrefixInList(suites, "mts-") && !InList("mts", suites) {
suites = append(suites, "mts")
}
+ if PrefixInList(suites, "mcts-") && !InList("mcts", suites) {
+ suites = append(suites, "mcts")
+ }
a.AddStrings("LOCAL_COMPATIBILITY_SUITE", suites...)
}
@@ -626,6 +630,10 @@
a.SetPath("LOCAL_SOONG_LICENSE_METADATA", licenseMetadata.LicenseMetadataPath)
}
+ if _, ok := SingletonModuleProvider(ctx, mod, ModuleInfoJSONProvider); ok {
+ a.SetBool("LOCAL_SOONG_MODULE_INFO_JSON", true)
+ }
+
extraCtx := &androidMkExtraEntriesContext{
ctx: ctx,
mod: mod,
@@ -643,14 +651,14 @@
}
}
+func (a *AndroidMkEntries) disabled() bool {
+ return a.Disabled || !a.OutputFile.Valid()
+}
+
// write flushes the AndroidMkEntries's in-struct data populated by AndroidMkEntries into the
// given Writer object.
func (a *AndroidMkEntries) write(w io.Writer) {
- if a.Disabled {
- return
- }
-
- if !a.OutputFile.Valid() {
+ if a.disabled() {
return
}
@@ -696,7 +704,9 @@
return
}
- err := translateAndroidMk(ctx, absolutePath(transMk.String()), androidMkModulesList)
+ moduleInfoJSON := PathForOutput(ctx, "module-info"+String(ctx.Config().productVariables.Make_suffix)+".json")
+
+ err := translateAndroidMk(ctx, absolutePath(transMk.String()), moduleInfoJSON, androidMkModulesList)
if err != nil {
ctx.Errorf(err.Error())
}
@@ -707,14 +717,16 @@
})
}
-func translateAndroidMk(ctx SingletonContext, absMkFile string, mods []blueprint.Module) error {
+func translateAndroidMk(ctx SingletonContext, absMkFile string, moduleInfoJSONPath WritablePath, mods []blueprint.Module) error {
buf := &bytes.Buffer{}
+ var moduleInfoJSONs []*ModuleInfoJSON
+
fmt.Fprintln(buf, "LOCAL_MODULE_MAKEFILE := $(lastword $(MAKEFILE_LIST))")
typeStats := make(map[string]int)
for _, mod := range mods {
- err := translateAndroidMkModule(ctx, buf, mod)
+ err := translateAndroidMkModule(ctx, buf, &moduleInfoJSONs, mod)
if err != nil {
os.Remove(absMkFile)
return err
@@ -736,10 +748,36 @@
fmt.Fprintf(buf, "STATS.SOONG_MODULE_TYPE.%s := %d\n", mod_type, typeStats[mod_type])
}
- return pathtools.WriteFileIfChanged(absMkFile, buf.Bytes(), 0666)
+ err := pathtools.WriteFileIfChanged(absMkFile, buf.Bytes(), 0666)
+ if err != nil {
+ return err
+ }
+
+ return writeModuleInfoJSON(ctx, moduleInfoJSONs, moduleInfoJSONPath)
}
-func translateAndroidMkModule(ctx SingletonContext, w io.Writer, mod blueprint.Module) error {
+func writeModuleInfoJSON(ctx SingletonContext, moduleInfoJSONs []*ModuleInfoJSON, moduleInfoJSONPath WritablePath) error {
+ moduleInfoJSONBuf := &strings.Builder{}
+ moduleInfoJSONBuf.WriteString("[")
+ for i, moduleInfoJSON := range moduleInfoJSONs {
+ if i != 0 {
+ moduleInfoJSONBuf.WriteString(",\n")
+ }
+ moduleInfoJSONBuf.WriteString("{")
+ moduleInfoJSONBuf.WriteString(strconv.Quote(moduleInfoJSON.core.RegisterName))
+ moduleInfoJSONBuf.WriteString(":")
+ err := encodeModuleInfoJSON(moduleInfoJSONBuf, moduleInfoJSON)
+ moduleInfoJSONBuf.WriteString("}")
+ if err != nil {
+ return err
+ }
+ }
+ moduleInfoJSONBuf.WriteString("]")
+ WriteFileRule(ctx, moduleInfoJSONPath, moduleInfoJSONBuf.String())
+ return nil
+}
+
+func translateAndroidMkModule(ctx SingletonContext, w io.Writer, moduleInfoJSONs *[]*ModuleInfoJSON, mod blueprint.Module) error {
defer func() {
if r := recover(); r != nil {
panic(fmt.Errorf("%s in translateAndroidMkModule for module %s variant %s",
@@ -748,17 +786,23 @@
}()
// Additional cases here require review for correct license propagation to make.
+ var err error
switch x := mod.(type) {
case AndroidMkDataProvider:
- return translateAndroidModule(ctx, w, mod, x)
+ err = translateAndroidModule(ctx, w, moduleInfoJSONs, mod, x)
case bootstrap.GoBinaryTool:
- return translateGoBinaryModule(ctx, w, mod, x)
+ err = translateGoBinaryModule(ctx, w, mod, x)
case AndroidMkEntriesProvider:
- return translateAndroidMkEntriesModule(ctx, w, mod, x)
+ err = translateAndroidMkEntriesModule(ctx, w, moduleInfoJSONs, mod, x)
default:
// Not exported to make so no make variables to set.
- return nil
}
+
+ if err != nil {
+ return err
+ }
+
+ return err
}
// A simple, special Android.mk entry output func to make it possible to build blueprint tools using
@@ -801,8 +845,8 @@
// A support func for the deprecated AndroidMkDataProvider interface. Use AndroidMkEntryProvider
// instead.
-func translateAndroidModule(ctx SingletonContext, w io.Writer, mod blueprint.Module,
- provider AndroidMkDataProvider) error {
+func translateAndroidModule(ctx SingletonContext, w io.Writer, moduleInfoJSONs *[]*ModuleInfoJSON,
+ mod blueprint.Module, provider AndroidMkDataProvider) error {
amod := mod.(Module).base()
if shouldSkipAndroidMkProcessing(amod) {
@@ -852,6 +896,7 @@
case "*java.SystemModules": // doesn't go through base_rules
case "*java.systemModulesImport": // doesn't go through base_rules
case "*phony.phony": // license properties written
+ case "*phony.PhonyRule": // writes phony deps and acts like `.PHONY`
case "*selinux.selinuxContextsModule": // license properties written
case "*sysprop.syspropLibrary": // license properties written
default:
@@ -864,17 +909,19 @@
WriteAndroidMkData(w, data)
}
+ if !data.Entries.disabled() {
+ if moduleInfoJSON, ok := SingletonModuleProvider(ctx, mod, ModuleInfoJSONProvider); ok {
+ *moduleInfoJSONs = append(*moduleInfoJSONs, moduleInfoJSON)
+ }
+ }
+
return nil
}
// A support func for the deprecated AndroidMkDataProvider interface. Use AndroidMkEntryProvider
// instead.
func WriteAndroidMkData(w io.Writer, data AndroidMkData) {
- if data.Disabled {
- return
- }
-
- if !data.OutputFile.Valid() {
+ if data.Entries.disabled() {
return
}
@@ -889,18 +936,26 @@
fmt.Fprintln(w, "include "+data.Include)
}
-func translateAndroidMkEntriesModule(ctx SingletonContext, w io.Writer, mod blueprint.Module,
- provider AndroidMkEntriesProvider) error {
+func translateAndroidMkEntriesModule(ctx SingletonContext, w io.Writer, moduleInfoJSONs *[]*ModuleInfoJSON,
+ mod blueprint.Module, provider AndroidMkEntriesProvider) error {
if shouldSkipAndroidMkProcessing(mod.(Module).base()) {
return nil
}
+ entriesList := provider.AndroidMkEntries()
+
// Any new or special cases here need review to verify correct propagation of license information.
- for _, entries := range provider.AndroidMkEntries() {
+ for _, entries := range entriesList {
entries.fillInEntries(ctx, mod)
entries.write(w)
}
+ if len(entriesList) > 0 && !entriesList[0].disabled() {
+ if moduleInfoJSON, ok := SingletonModuleProvider(ctx, mod, ModuleInfoJSONProvider); ok {
+ *moduleInfoJSONs = append(*moduleInfoJSONs, moduleInfoJSON)
+ }
+ }
+
return nil
}
diff --git a/android/arch_list.go b/android/arch_list.go
index ab644a4..801ac49 100644
--- a/android/arch_list.go
+++ b/android/arch_list.go
@@ -34,6 +34,11 @@
"broadwell",
"goldmont",
"goldmont-plus",
+ // Target arch is goldmont, but without xsaves support.
+ // This ensures efficient execution on a broad range of Intel/AMD CPUs used
+ // in Chromebooks, including those lacking xsaves support.
+ // (e.g. Kaby Lake, Gemini Lake, Alder Lake and AMD Zen series)
+ "goldmont-without-xsaves",
"haswell",
"icelake",
"ivybridge",
@@ -52,6 +57,7 @@
"broadwell",
"goldmont",
"goldmont-plus",
+ "goldmont-without-xsaves",
"haswell",
"icelake",
"ivybridge",
@@ -197,6 +203,15 @@
"popcnt",
"movbe",
},
+ "goldmont-without-xsaves": {
+ "ssse3",
+ "sse4",
+ "sse4_1",
+ "sse4_2",
+ "aes_ni",
+ "popcnt",
+ "movbe",
+ },
"haswell": {
"ssse3",
"sse4",
@@ -358,6 +373,14 @@
"aes_ni",
"popcnt",
},
+ "goldmont-without-xsaves": {
+ "ssse3",
+ "sse4",
+ "sse4_1",
+ "sse4_2",
+ "aes_ni",
+ "popcnt",
+ },
"haswell": {
"ssse3",
"sse4",
diff --git a/android/config.go b/android/config.go
index 312a5da..1ea0d94 100644
--- a/android/config.go
+++ b/android/config.go
@@ -18,6 +18,7 @@
// product variables necessary for soong_build's operation.
import (
+ "android/soong/shared"
"encoding/json"
"fmt"
"os"
@@ -118,6 +119,11 @@
return c.soongOutDir
}
+// tempDir returns the path to out/soong/.temp, which is cleared at the beginning of every build.
+func (c Config) tempDir() string {
+ return shared.TempDirForOutDir(c.soongOutDir)
+}
+
func (c Config) OutDir() string {
return c.outDir
}
@@ -1843,6 +1849,10 @@
return InList(name, c.config.productVariables.BuildBrokenInputDirModules)
}
+func (c *deviceConfig) BuildBrokenDontCheckSystemSdk() bool {
+ return c.config.productVariables.BuildBrokenDontCheckSystemSdk
+}
+
func (c *config) BuildWarningBadOptionalUsesLibsAllowlist() []string {
return c.productVariables.BuildWarningBadOptionalUsesLibsAllowlist
}
diff --git a/android/config_bp2build.go b/android/config_bp2build.go
index b632e33..4c2fb5e 100644
--- a/android/config_bp2build.go
+++ b/android/config_bp2build.go
@@ -15,24 +15,11 @@
package android
import (
- "fmt"
- "reflect"
- "regexp"
- "sort"
"strings"
- "android/soong/bazel"
- "android/soong/starlark_fmt"
-
"github.com/google/blueprint"
)
-// BazelVarExporter is a collection of configuration variables that can be exported for use in Bazel rules
-type BazelVarExporter interface {
- // asBazel expands strings of configuration variables into their concrete values
- asBazel(Config, ExportedStringVariables, ExportedStringListVariables, ExportedConfigDependingVariables) []bazelConstant
-}
-
// ExportedVariables is a collection of interdependent configuration variables
type ExportedVariables struct {
// Maps containing toolchain variables that are independent of the
@@ -61,18 +48,6 @@
}
}
-func (ev ExportedVariables) asBazel(config Config,
- stringVars ExportedStringVariables, stringListVars ExportedStringListVariables, cfgDepVars ExportedConfigDependingVariables) []bazelConstant {
- ret := []bazelConstant{}
- ret = append(ret, ev.exportedStringVars.asBazel(config, stringVars, stringListVars, cfgDepVars)...)
- ret = append(ret, ev.exportedStringListVars.asBazel(config, stringVars, stringListVars, cfgDepVars)...)
- ret = append(ret, ev.exportedStringListDictVars.asBazel(config, stringVars, stringListVars, cfgDepVars)...)
- // Note: ExportedVariableReferenceDictVars collections can only contain references to other variables and must be printed last
- ret = append(ret, ev.exportedVariableReferenceDictVars.asBazel(config, stringVars, stringListVars, cfgDepVars)...)
- ret = append(ret, ev.exportedConfigDependingVars.asBazel(config, stringVars, stringListVars, cfgDepVars)...)
- return ret
-}
-
// ExportStringStaticVariable declares a static string variable and exports it to
// Bazel's toolchain.
func (ev ExportedVariables) ExportStringStaticVariable(name string, value string) {
@@ -142,49 +117,6 @@
m[k] = v
}
-func (m ExportedConfigDependingVariables) asBazel(config Config,
- stringVars ExportedStringVariables, stringListVars ExportedStringListVariables, cfgDepVars ExportedConfigDependingVariables) []bazelConstant {
- ret := make([]bazelConstant, 0, len(m))
- for variable, unevaluatedVar := range m {
- evalFunc := reflect.ValueOf(unevaluatedVar)
- validateVariableMethod(variable, evalFunc)
- evaluatedResult := evalFunc.Call([]reflect.Value{reflect.ValueOf(config)})
- evaluatedValue := evaluatedResult[0].Interface().(string)
- expandedVars, err := expandVar(config, evaluatedValue, stringVars, stringListVars, cfgDepVars)
- if err != nil {
- panic(fmt.Errorf("error expanding config variable %s: %s", variable, err))
- }
- if len(expandedVars) > 1 {
- ret = append(ret, bazelConstant{
- variableName: variable,
- internalDefinition: starlark_fmt.PrintStringList(expandedVars, 0),
- })
- } else {
- ret = append(ret, bazelConstant{
- variableName: variable,
- internalDefinition: fmt.Sprintf(`"%s"`, validateCharacters(expandedVars[0])),
- })
- }
- }
- return ret
-}
-
-// Ensure that string s has no invalid characters to be generated into the bzl file.
-func validateCharacters(s string) string {
- for _, c := range []string{`\n`, `"`, `\`} {
- if strings.Contains(s, c) {
- panic(fmt.Errorf("%s contains illegal character %s", s, c))
- }
- }
- return s
-}
-
-type bazelConstant struct {
- variableName string
- internalDefinition string
- sortLast bool
-}
-
// ExportedStringVariables is a mapping of variable names to string values
type ExportedStringVariables map[string]string
@@ -192,25 +124,6 @@
m[k] = v
}
-func (m ExportedStringVariables) asBazel(config Config,
- stringVars ExportedStringVariables, stringListVars ExportedStringListVariables, cfgDepVars ExportedConfigDependingVariables) []bazelConstant {
- ret := make([]bazelConstant, 0, len(m))
- for k, variableValue := range m {
- expandedVar, err := expandVar(config, variableValue, stringVars, stringListVars, cfgDepVars)
- if err != nil {
- panic(fmt.Errorf("error expanding config variable %s: %s", k, err))
- }
- if len(expandedVar) > 1 {
- panic(fmt.Errorf("%q expands to more than one string value: %q", variableValue, expandedVar))
- }
- ret = append(ret, bazelConstant{
- variableName: k,
- internalDefinition: fmt.Sprintf(`"%s"`, validateCharacters(expandedVar[0])),
- })
- }
- return ret
-}
-
// ExportedStringListVariables is a mapping of variable names to a list of strings
type ExportedStringListVariables map[string][]string
@@ -218,32 +131,6 @@
m[k] = v
}
-func (m ExportedStringListVariables) asBazel(config Config,
- stringScope ExportedStringVariables, stringListScope ExportedStringListVariables,
- exportedVars ExportedConfigDependingVariables) []bazelConstant {
- ret := make([]bazelConstant, 0, len(m))
- // For each exported variable, recursively expand elements in the variableValue
- // list to ensure that interpolated variables are expanded according to their values
- // in the variable scope.
- for k, variableValue := range m {
- var expandedVars []string
- for _, v := range variableValue {
- expandedVar, err := expandVar(config, v, stringScope, stringListScope, exportedVars)
- if err != nil {
- panic(fmt.Errorf("Error expanding config variable %s=%s: %s", k, v, err))
- }
- expandedVars = append(expandedVars, expandedVar...)
- }
- // Assign the list as a bzl-private variable; this variable will be exported
- // out through a constants struct later.
- ret = append(ret, bazelConstant{
- variableName: k,
- internalDefinition: starlark_fmt.PrintStringList(expandedVars, 0),
- })
- }
- return ret
-}
-
// ExportedStringListDictVariables is a mapping from variable names to a
// dictionary which maps keys to lists of strings
type ExportedStringListDictVariables map[string]map[string][]string
@@ -252,19 +139,6 @@
m[k] = v
}
-// Since dictionaries are not supported in Ninja, we do not expand variables for dictionaries
-func (m ExportedStringListDictVariables) asBazel(_ Config, _ ExportedStringVariables,
- _ ExportedStringListVariables, _ ExportedConfigDependingVariables) []bazelConstant {
- ret := make([]bazelConstant, 0, len(m))
- for k, dict := range m {
- ret = append(ret, bazelConstant{
- variableName: k,
- internalDefinition: starlark_fmt.PrintStringListDict(dict, 0),
- })
- }
- return ret
-}
-
// ExportedVariableReferenceDictVariables is a mapping from variable names to a
// dictionary which references previously defined variables. This is used to
// create a Starlark output such as:
@@ -281,237 +155,3 @@
func (m ExportedVariableReferenceDictVariables) set(k string, v map[string]string) {
m[k] = v
}
-
-func (m ExportedVariableReferenceDictVariables) asBazel(_ Config, _ ExportedStringVariables,
- _ ExportedStringListVariables, _ ExportedConfigDependingVariables) []bazelConstant {
- ret := make([]bazelConstant, 0, len(m))
- for n, dict := range m {
- for k, v := range dict {
- matches, err := variableReference(v)
- if err != nil {
- panic(err)
- } else if !matches.matches {
- panic(fmt.Errorf("Expected a variable reference, got %q", v))
- } else if len(matches.fullVariableReference) != len(v) {
- panic(fmt.Errorf("Expected only a variable reference, got %q", v))
- }
- dict[k] = "_" + matches.variable
- }
- ret = append(ret, bazelConstant{
- variableName: n,
- internalDefinition: starlark_fmt.PrintDict(dict, 0),
- sortLast: true,
- })
- }
- return ret
-}
-
-// BazelToolchainVars expands an ExportedVariables collection and returns a string
-// of formatted Starlark variable definitions
-func BazelToolchainVars(config Config, exportedVars ExportedVariables) string {
- results := exportedVars.asBazel(
- config,
- exportedVars.exportedStringVars,
- exportedVars.exportedStringListVars,
- exportedVars.exportedConfigDependingVars,
- )
-
- sort.Slice(results, func(i, j int) bool {
- if results[i].sortLast != results[j].sortLast {
- return !results[i].sortLast
- }
- return results[i].variableName < results[j].variableName
- })
-
- definitions := make([]string, 0, len(results))
- constants := make([]string, 0, len(results))
- for _, b := range results {
- definitions = append(definitions,
- fmt.Sprintf("_%s = %s", b.variableName, b.internalDefinition))
- constants = append(constants,
- fmt.Sprintf("%[1]s%[2]s = _%[2]s,", starlark_fmt.Indention(1), b.variableName))
- }
-
- // Build the exported constants struct.
- ret := bazel.GeneratedBazelFileWarning
- ret += "\n\n"
- ret += strings.Join(definitions, "\n\n")
- ret += "\n\n"
- ret += "constants = struct(\n"
- ret += strings.Join(constants, "\n")
- ret += "\n)"
-
- return ret
-}
-
-type match struct {
- matches bool
- fullVariableReference string
- variable string
-}
-
-func variableReference(input string) (match, error) {
- // e.g. "${ExternalCflags}"
- r := regexp.MustCompile(`\${(?:config\.)?([a-zA-Z0-9_]+)}`)
-
- matches := r.FindStringSubmatch(input)
- if len(matches) == 0 {
- return match{}, nil
- }
- if len(matches) != 2 {
- return match{}, fmt.Errorf("Expected to only match 1 subexpression in %s, got %d", input, len(matches)-1)
- }
- return match{
- matches: true,
- fullVariableReference: matches[0],
- // Index 1 of FindStringSubmatch contains the subexpression match
- // (variable name) of the capture group.
- variable: matches[1],
- }, nil
-}
-
-// expandVar recursively expand interpolated variables in the exportedVars scope.
-//
-// We're using a string slice to track the seen variables to avoid
-// stackoverflow errors with infinite recursion. it's simpler to use a
-// string slice than to handle a pass-by-referenced map, which would make it
-// quite complex to track depth-first interpolations. It's also unlikely the
-// interpolation stacks are deep (n > 1).
-func expandVar(config Config, toExpand string, stringScope ExportedStringVariables,
- stringListScope ExportedStringListVariables, exportedVars ExportedConfigDependingVariables) ([]string, error) {
-
- // Internal recursive function.
- var expandVarInternal func(string, map[string]bool) (string, error)
- expandVarInternal = func(toExpand string, seenVars map[string]bool) (string, error) {
- var ret string
- remainingString := toExpand
- for len(remainingString) > 0 {
- matches, err := variableReference(remainingString)
- if err != nil {
- panic(err)
- }
- if !matches.matches {
- return ret + remainingString, nil
- }
- matchIndex := strings.Index(remainingString, matches.fullVariableReference)
- ret += remainingString[:matchIndex]
- remainingString = remainingString[matchIndex+len(matches.fullVariableReference):]
-
- variable := matches.variable
- // toExpand contains a variable.
- if _, ok := seenVars[variable]; ok {
- return ret, fmt.Errorf(
- "Unbounded recursive interpolation of variable: %s", variable)
- }
- // A map is passed-by-reference. Create a new map for
- // this scope to prevent variables seen in one depth-first expansion
- // to be also treated as "seen" in other depth-first traversals.
- newSeenVars := map[string]bool{}
- for k := range seenVars {
- newSeenVars[k] = true
- }
- newSeenVars[variable] = true
- if unexpandedVars, ok := stringListScope[variable]; ok {
- expandedVars := []string{}
- for _, unexpandedVar := range unexpandedVars {
- expandedVar, err := expandVarInternal(unexpandedVar, newSeenVars)
- if err != nil {
- return ret, err
- }
- expandedVars = append(expandedVars, expandedVar)
- }
- ret += strings.Join(expandedVars, " ")
- } else if unexpandedVar, ok := stringScope[variable]; ok {
- expandedVar, err := expandVarInternal(unexpandedVar, newSeenVars)
- if err != nil {
- return ret, err
- }
- ret += expandedVar
- } else if unevaluatedVar, ok := exportedVars[variable]; ok {
- evalFunc := reflect.ValueOf(unevaluatedVar)
- validateVariableMethod(variable, evalFunc)
- evaluatedResult := evalFunc.Call([]reflect.Value{reflect.ValueOf(config)})
- evaluatedValue := evaluatedResult[0].Interface().(string)
- expandedVar, err := expandVarInternal(evaluatedValue, newSeenVars)
- if err != nil {
- return ret, err
- }
- ret += expandedVar
- } else {
- return "", fmt.Errorf("Unbound config variable %s", variable)
- }
- }
- return ret, nil
- }
- var ret []string
- stringFields := splitStringKeepingQuotedSubstring(toExpand, ' ')
- for _, v := range stringFields {
- val, err := expandVarInternal(v, map[string]bool{})
- if err != nil {
- return ret, err
- }
- ret = append(ret, val)
- }
-
- return ret, nil
-}
-
-// splitStringKeepingQuotedSubstring splits a string on a provided separator,
-// but it will not split substrings inside unescaped double quotes. If the double
-// quotes are escaped, then the returned string will only include the quote, and
-// not the escape.
-func splitStringKeepingQuotedSubstring(s string, delimiter byte) []string {
- var ret []string
- quote := byte('"')
-
- var substring []byte
- quoted := false
- escaped := false
-
- for i := range s {
- if !quoted && s[i] == delimiter {
- ret = append(ret, string(substring))
- substring = []byte{}
- continue
- }
-
- characterIsEscape := i < len(s)-1 && s[i] == '\\' && s[i+1] == quote
- if characterIsEscape {
- escaped = true
- continue
- }
-
- if s[i] == quote {
- if !escaped {
- quoted = !quoted
- }
- escaped = false
- }
-
- substring = append(substring, s[i])
- }
-
- ret = append(ret, string(substring))
-
- return ret
-}
-
-func validateVariableMethod(name string, methodValue reflect.Value) {
- methodType := methodValue.Type()
- if methodType.Kind() != reflect.Func {
- panic(fmt.Errorf("method given for variable %s is not a function",
- name))
- }
- if n := methodType.NumIn(); n != 1 {
- panic(fmt.Errorf("method for variable %s has %d inputs (should be 1)",
- name, n))
- }
- if n := methodType.NumOut(); n != 1 {
- panic(fmt.Errorf("method for variable %s has %d outputs (should be 1)",
- name, n))
- }
- if kind := methodType.Out(0).Kind(); kind != reflect.String {
- panic(fmt.Errorf("method for variable %s does not return a string",
- name))
- }
-}
diff --git a/android/config_bp2build_test.go b/android/config_bp2build_test.go
deleted file mode 100644
index 1a0ba7b..0000000
--- a/android/config_bp2build_test.go
+++ /dev/null
@@ -1,454 +0,0 @@
-// Copyright 2021 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 android
-
-import (
- "android/soong/bazel"
- "testing"
-)
-
-func TestExpandVars(t *testing.T) {
- android_arm64_config := TestConfig("out", nil, "", nil)
- android_arm64_config.BuildOS = Android
- android_arm64_config.BuildArch = Arm64
-
- testCases := []struct {
- description string
- config Config
- stringScope ExportedStringVariables
- stringListScope ExportedStringListVariables
- configVars ExportedConfigDependingVariables
- toExpand string
- expectedValues []string
- }{
- {
- description: "no expansion for non-interpolated value",
- toExpand: "foo",
- expectedValues: []string{"foo"},
- },
- {
- description: "single level expansion for string var",
- stringScope: ExportedStringVariables{
- "foo": "bar",
- },
- toExpand: "${foo}",
- expectedValues: []string{"bar"},
- },
- {
- description: "single level expansion with short-name for string var",
- stringScope: ExportedStringVariables{
- "foo": "bar",
- },
- toExpand: "${config.foo}",
- expectedValues: []string{"bar"},
- },
- {
- description: "single level expansion string list var",
- stringListScope: ExportedStringListVariables{
- "foo": []string{"bar"},
- },
- toExpand: "${foo}",
- expectedValues: []string{"bar"},
- },
- {
- description: "mixed level expansion for string list var",
- stringScope: ExportedStringVariables{
- "foo": "${bar}",
- "qux": "hello",
- },
- stringListScope: ExportedStringListVariables{
- "bar": []string{"baz", "${qux}"},
- },
- toExpand: "${foo}",
- expectedValues: []string{"baz hello"},
- },
- {
- description: "double level expansion",
- stringListScope: ExportedStringListVariables{
- "foo": []string{"${bar}"},
- "bar": []string{"baz"},
- },
- toExpand: "${foo}",
- expectedValues: []string{"baz"},
- },
- {
- description: "double level expansion with a literal",
- stringListScope: ExportedStringListVariables{
- "a": []string{"${b}", "c"},
- "b": []string{"d"},
- },
- toExpand: "${a}",
- expectedValues: []string{"d c"},
- },
- {
- description: "double level expansion, with two variables in a string",
- stringListScope: ExportedStringListVariables{
- "a": []string{"${b} ${c}"},
- "b": []string{"d"},
- "c": []string{"e"},
- },
- toExpand: "${a}",
- expectedValues: []string{"d e"},
- },
- {
- description: "triple level expansion with two variables in a string",
- stringListScope: ExportedStringListVariables{
- "a": []string{"${b} ${c}"},
- "b": []string{"${c}", "${d}"},
- "c": []string{"${d}"},
- "d": []string{"foo"},
- },
- toExpand: "${a}",
- expectedValues: []string{"foo foo foo"},
- },
- {
- description: "expansion with config depending vars",
- configVars: ExportedConfigDependingVariables{
- "a": func(c Config) string { return c.BuildOS.String() },
- "b": func(c Config) string { return c.BuildArch.String() },
- },
- config: android_arm64_config,
- toExpand: "${a}-${b}",
- expectedValues: []string{"android-arm64"},
- },
- {
- description: "double level multi type expansion",
- stringListScope: ExportedStringListVariables{
- "platform": []string{"${os}-${arch}"},
- "const": []string{"const"},
- },
- configVars: ExportedConfigDependingVariables{
- "os": func(c Config) string { return c.BuildOS.String() },
- "arch": func(c Config) string { return c.BuildArch.String() },
- "foo": func(c Config) string { return "foo" },
- },
- config: android_arm64_config,
- toExpand: "${const}/${platform}/${foo}",
- expectedValues: []string{"const/android-arm64/foo"},
- },
- }
-
- for _, testCase := range testCases {
- t.Run(testCase.description, func(t *testing.T) {
- output, _ := expandVar(testCase.config, testCase.toExpand, testCase.stringScope, testCase.stringListScope, testCase.configVars)
- if len(output) != len(testCase.expectedValues) {
- t.Errorf("Expected %d values, got %d", len(testCase.expectedValues), len(output))
- }
- for i, actual := range output {
- expectedValue := testCase.expectedValues[i]
- if actual != expectedValue {
- t.Errorf("Actual value '%s' doesn't match expected value '%s'", actual, expectedValue)
- }
- }
- })
- }
-}
-
-func TestBazelToolchainVars(t *testing.T) {
- testCases := []struct {
- name string
- config Config
- vars ExportedVariables
- expectedOut string
- }{
- {
- name: "exports strings",
- vars: ExportedVariables{
- exportedStringVars: ExportedStringVariables{
- "a": "b",
- "c": "d",
- },
- },
- expectedOut: bazel.GeneratedBazelFileWarning + `
-
-_a = "b"
-
-_c = "d"
-
-constants = struct(
- a = _a,
- c = _c,
-)`,
- },
- {
- name: "exports string lists",
- vars: ExportedVariables{
- exportedStringListVars: ExportedStringListVariables{
- "a": []string{"b1", "b2"},
- "c": []string{"d1", "d2"},
- },
- },
- expectedOut: bazel.GeneratedBazelFileWarning + `
-
-_a = [
- "b1",
- "b2",
-]
-
-_c = [
- "d1",
- "d2",
-]
-
-constants = struct(
- a = _a,
- c = _c,
-)`,
- },
- {
- name: "exports string lists dicts",
- vars: ExportedVariables{
- exportedStringListDictVars: ExportedStringListDictVariables{
- "a": map[string][]string{"b1": {"b2"}},
- "c": map[string][]string{"d1": {"d2"}},
- },
- },
- expectedOut: bazel.GeneratedBazelFileWarning + `
-
-_a = {
- "b1": ["b2"],
-}
-
-_c = {
- "d1": ["d2"],
-}
-
-constants = struct(
- a = _a,
- c = _c,
-)`,
- },
- {
- name: "exports dict with var refs",
- vars: ExportedVariables{
- exportedVariableReferenceDictVars: ExportedVariableReferenceDictVariables{
- "a": map[string]string{"b1": "${b2}"},
- "c": map[string]string{"d1": "${config.d2}"},
- },
- },
- expectedOut: bazel.GeneratedBazelFileWarning + `
-
-_a = {
- "b1": _b2,
-}
-
-_c = {
- "d1": _d2,
-}
-
-constants = struct(
- a = _a,
- c = _c,
-)`,
- },
- {
- name: "sorts across types with variable references last",
- vars: ExportedVariables{
- exportedStringVars: ExportedStringVariables{
- "b": "b-val",
- "d": "d-val",
- },
- exportedStringListVars: ExportedStringListVariables{
- "c": []string{"c-val"},
- "e": []string{"e-val"},
- },
- exportedStringListDictVars: ExportedStringListDictVariables{
- "a": map[string][]string{"a1": {"a2"}},
- "f": map[string][]string{"f1": {"f2"}},
- },
- exportedVariableReferenceDictVars: ExportedVariableReferenceDictVariables{
- "aa": map[string]string{"b1": "${b}"},
- "cc": map[string]string{"d1": "${config.d}"},
- },
- },
- expectedOut: bazel.GeneratedBazelFileWarning + `
-
-_a = {
- "a1": ["a2"],
-}
-
-_b = "b-val"
-
-_c = ["c-val"]
-
-_d = "d-val"
-
-_e = ["e-val"]
-
-_f = {
- "f1": ["f2"],
-}
-
-_aa = {
- "b1": _b,
-}
-
-_cc = {
- "d1": _d,
-}
-
-constants = struct(
- a = _a,
- b = _b,
- c = _c,
- d = _d,
- e = _e,
- f = _f,
- aa = _aa,
- cc = _cc,
-)`,
- },
- }
-
- for _, tc := range testCases {
- t.Run(tc.name, func(t *testing.T) {
- out := BazelToolchainVars(tc.config, tc.vars)
- if out != tc.expectedOut {
- t.Errorf("Expected \n%s, got \n%s", tc.expectedOut, out)
- }
- })
- }
-}
-
-func TestSplitStringKeepingQuotedSubstring(t *testing.T) {
- testCases := []struct {
- description string
- s string
- delimiter byte
- split []string
- }{
- {
- description: "empty string returns single empty string",
- s: "",
- delimiter: ' ',
- split: []string{
- "",
- },
- },
- {
- description: "string with single space returns two empty strings",
- s: " ",
- delimiter: ' ',
- split: []string{
- "",
- "",
- },
- },
- {
- description: "string with two spaces returns three empty strings",
- s: " ",
- delimiter: ' ',
- split: []string{
- "",
- "",
- "",
- },
- },
- {
- description: "string with four words returns four word string",
- s: "hello world with words",
- delimiter: ' ',
- split: []string{
- "hello",
- "world",
- "with",
- "words",
- },
- },
- {
- description: "string with words and nested quote returns word strings and quote string",
- s: `hello "world with" words`,
- delimiter: ' ',
- split: []string{
- "hello",
- `"world with"`,
- "words",
- },
- },
- {
- description: "string with escaped quote inside real quotes",
- s: `hello \"world "with\" words"`,
- delimiter: ' ',
- split: []string{
- "hello",
- `"world`,
- `"with" words"`,
- },
- },
- {
- description: "string with words and escaped quotes returns word strings",
- s: `hello \"world with\" words`,
- delimiter: ' ',
- split: []string{
- "hello",
- `"world`,
- `with"`,
- "words",
- },
- },
- {
- description: "string which is single quoted substring returns only substring",
- s: `"hello world with words"`,
- delimiter: ' ',
- split: []string{
- `"hello world with words"`,
- },
- },
- {
- description: "string starting with quote returns quoted string",
- s: `"hello world with" words`,
- delimiter: ' ',
- split: []string{
- `"hello world with"`,
- "words",
- },
- },
- {
- description: "string with starting quote and no ending quote returns quote to end of string",
- s: `hello "world with words`,
- delimiter: ' ',
- split: []string{
- "hello",
- `"world with words`,
- },
- },
- {
- description: "quoted string is treated as a single \"word\" unless separated by delimiter",
- s: `hello "world"with words`,
- delimiter: ' ',
- split: []string{
- "hello",
- `"world"with`,
- "words",
- },
- },
- }
-
- for _, tc := range testCases {
- t.Run(tc.description, func(t *testing.T) {
- split := splitStringKeepingQuotedSubstring(tc.s, tc.delimiter)
- if len(split) != len(tc.split) {
- t.Fatalf("number of split string elements (%d) differs from expected (%d): split string (%v), expected (%v)",
- len(split), len(tc.split), split, tc.split,
- )
- }
- for i := range split {
- if split[i] != tc.split[i] {
- t.Errorf("split string element (%d), %v, differs from expected, %v", i, split[i], tc.split[i])
- }
- }
- })
- }
-}
diff --git a/android/defs.go b/android/defs.go
index 03968c1..fe52936 100644
--- a/android/defs.go
+++ b/android/defs.go
@@ -15,13 +15,8 @@
package android
import (
- "fmt"
- "strings"
- "testing"
-
"github.com/google/blueprint"
"github.com/google/blueprint/bootstrap"
- "github.com/google/blueprint/proptools"
)
var (
@@ -72,8 +67,7 @@
Command: "if ! cmp -s $in $out; then cp $in $out; fi",
Description: "cp if changed $out",
Restat: true,
- },
- "cpFlags")
+ })
CpExecutable = pctx.AndroidStaticRule("CpExecutable",
blueprint.RuleParams{
@@ -142,110 +136,6 @@
exportedVars.ExportStringList("NeverAllowNoUseIncludeDir", neverallowNoUseIncludeDir)
}
-func BazelCcToolchainVars(config Config) string {
- return BazelToolchainVars(config, exportedVars)
-}
-
-var (
- // echoEscaper escapes a string such that passing it to "echo -e" will produce the input value.
- echoEscaper = strings.NewReplacer(
- `\`, `\\`, // First escape existing backslashes so they aren't interpreted by `echo -e`.
- "\n", `\n`, // Then replace newlines with \n
- )
-
- // echoEscaper reverses echoEscaper.
- echoUnescaper = strings.NewReplacer(
- `\n`, "\n",
- `\\`, `\`,
- )
-
- // shellUnescaper reverses the replacer in proptools.ShellEscape
- shellUnescaper = strings.NewReplacer(`'\''`, `'`)
-)
-
-func buildWriteFileRule(ctx BuilderContext, outputFile WritablePath, content string) {
- content = echoEscaper.Replace(content)
- content = proptools.NinjaEscape(proptools.ShellEscapeIncludingSpaces(content))
- if content == "" {
- content = "''"
- }
- ctx.Build(pctx, BuildParams{
- Rule: writeFile,
- Output: outputFile,
- Description: "write " + outputFile.Base(),
- Args: map[string]string{
- "content": content,
- },
- })
-}
-
-// WriteFileRule creates a ninja rule to write contents to a file. The contents will be escaped
-// so that the file contains exactly the contents passed to the function, plus a trailing newline.
-func WriteFileRule(ctx BuilderContext, outputFile WritablePath, content string) {
- WriteFileRuleVerbatim(ctx, outputFile, content+"\n")
-}
-
-// WriteFileRuleVerbatim creates a ninja rule to write contents to a file. The contents will be
-// escaped so that the file contains exactly the contents passed to the function.
-func WriteFileRuleVerbatim(ctx BuilderContext, outputFile WritablePath, content string) {
- // This is MAX_ARG_STRLEN subtracted with some safety to account for shell escapes
- const SHARD_SIZE = 131072 - 10000
-
- if len(content) > SHARD_SIZE {
- var chunks WritablePaths
- for i, c := range ShardString(content, SHARD_SIZE) {
- tempPath := outputFile.ReplaceExtension(ctx, fmt.Sprintf("%s.%d", outputFile.Ext(), i))
- buildWriteFileRule(ctx, tempPath, c)
- chunks = append(chunks, tempPath)
- }
- ctx.Build(pctx, BuildParams{
- Rule: Cat,
- Inputs: chunks.Paths(),
- Output: outputFile,
- Description: "Merging to " + outputFile.Base(),
- })
- return
- }
- buildWriteFileRule(ctx, outputFile, content)
-}
-
-// WriteExecutableFileRuleVerbatim is the same as WriteFileRuleVerbatim, but runs chmod +x on the result
-func WriteExecutableFileRuleVerbatim(ctx BuilderContext, outputFile WritablePath, content string) {
- intermediate := PathForIntermediates(ctx, "write_executable_file_intermediates").Join(ctx, outputFile.String())
- WriteFileRuleVerbatim(ctx, intermediate, content)
- ctx.Build(pctx, BuildParams{
- Rule: CpExecutable,
- Output: outputFile,
- Input: intermediate,
- })
-}
-
-// shellUnescape reverses proptools.ShellEscape
-func shellUnescape(s string) string {
- // Remove leading and trailing quotes if present
- if len(s) >= 2 && s[0] == '\'' {
- s = s[1 : len(s)-1]
- }
- s = shellUnescaper.Replace(s)
- return s
-}
-
-// ContentFromFileRuleForTests returns the content that was passed to a WriteFileRule for use
-// in tests.
-func ContentFromFileRuleForTests(t *testing.T, ctx *TestContext, params TestingBuildParams) string {
- t.Helper()
- if g, w := params.Rule, writeFile; g != w {
- t.Errorf("expected params.Rule to be %q, was %q", w, g)
- return ""
- }
-
- content := params.Args["content"]
- content = shellUnescape(content)
- content = echoUnescaper.Replace(content)
-
- return content
-}
-
// GlobToListFileRule creates a rule that writes a list of files matching a pattern to a file.
func GlobToListFileRule(ctx ModuleContext, pattern string, excludes []string, file WritablePath) {
bootstrap.GlobFile(ctx.blueprintModuleContext(), pattern, excludes, file.String())
diff --git a/android/makevars.go b/android/makevars.go
index d4cfd29..4039e7e 100644
--- a/android/makevars.go
+++ b/android/makevars.go
@@ -16,9 +16,11 @@
import (
"bytes"
+ "cmp"
"fmt"
"path/filepath"
"runtime"
+ "slices"
"sort"
"strings"
@@ -242,6 +244,8 @@
var dists []dist
var phonies []phony
var katiInstalls []katiInstall
+ var katiInitRcInstalls []katiInstall
+ var katiVintfManifestInstalls []katiInstall
var katiSymlinks []katiInstall
providers := append([]makeVarsProvider(nil), makeVarsInitProviders...)
@@ -275,10 +279,33 @@
if m.ExportedToMake() {
katiInstalls = append(katiInstalls, m.base().katiInstalls...)
+ katiInitRcInstalls = append(katiInitRcInstalls, m.base().katiInitRcInstalls...)
+ katiVintfManifestInstalls = append(katiVintfManifestInstalls, m.base().katiVintfInstalls...)
katiSymlinks = append(katiSymlinks, m.base().katiSymlinks...)
}
})
+ compareKatiInstalls := func(a, b katiInstall) int {
+ aTo, bTo := a.to.String(), b.to.String()
+ if cmpTo := cmp.Compare(aTo, bTo); cmpTo != 0 {
+ return cmpTo
+ }
+
+ aFrom, bFrom := a.from.String(), b.from.String()
+ return cmp.Compare(aFrom, bFrom)
+ }
+
+ slices.SortFunc(katiInitRcInstalls, compareKatiInstalls)
+ katiInitRcInstalls = slices.CompactFunc(katiInitRcInstalls, func(a, b katiInstall) bool {
+ return compareKatiInstalls(a, b) == 0
+ })
+ katiInstalls = append(katiInstalls, katiInitRcInstalls...)
+
+ slices.SortFunc(katiVintfManifestInstalls, compareKatiInstalls)
+ katiVintfManifestInstalls = slices.CompactFunc(katiVintfManifestInstalls, func(a, b katiInstall) bool {
+ return compareKatiInstalls(a, b) == 0
+ })
+
if ctx.Failed() {
return
}
@@ -316,7 +343,7 @@
ctx.Errorf(err.Error())
}
- installsBytes := s.writeInstalls(katiInstalls, katiSymlinks)
+ installsBytes := s.writeInstalls(katiInstalls, katiSymlinks, katiVintfManifestInstalls)
if err := pathtools.WriteFileIfChanged(installsFile, installsBytes, 0666); err != nil {
ctx.Errorf(err.Error())
}
@@ -438,7 +465,7 @@
// writeInstalls writes the list of install rules generated by Soong to a makefile. The rules
// are exported to Make instead of written directly to the ninja file so that main.mk can add
// the dependencies from the `required` property that are hard to resolve in Soong.
-func (s *makeVarsSingleton) writeInstalls(installs, symlinks []katiInstall) []byte {
+func (s *makeVarsSingleton) writeInstalls(installs, symlinks, katiVintfManifestInstalls []katiInstall) []byte {
buf := &bytes.Buffer{}
fmt.Fprint(buf, `# Autogenerated file
@@ -486,9 +513,9 @@
for _, symlink := range symlinks {
fmt.Fprintf(buf, "%s:", symlink.to.String())
if symlink.from != nil {
- // The symlink doesn't need updating when the target is modified, but we sometimes
- // have a dependency on a symlink to a binary instead of to the binary directly, and
- // the mtime of the symlink must be updated when the binary is modified, so use a
+ // The katiVintfManifestInstall doesn't need updating when the target is modified, but we sometimes
+ // have a dependency on a katiVintfManifestInstall to a binary instead of to the binary directly, and
+ // the mtime of the katiVintfManifestInstall must be updated when the binary is modified, so use a
// normal dependency here instead of an order-only dependency.
fmt.Fprintf(buf, " %s", symlink.from.String())
}
@@ -507,7 +534,7 @@
if symlink.from != nil {
rel, err := filepath.Rel(filepath.Dir(symlink.to.String()), symlink.from.String())
if err != nil {
- panic(fmt.Errorf("failed to find relative path for symlink from %q to %q: %w",
+ panic(fmt.Errorf("failed to find relative path for katiVintfManifestInstall from %q to %q: %w",
symlink.from.String(), symlink.to.String(), err))
}
fromStr = rel
@@ -521,6 +548,19 @@
fmt.Fprintln(buf)
}
+ for _, install := range katiVintfManifestInstalls {
+ // Write a rule for each vintf install request that calls the copy-vintf-manifest-chedk make function.
+ fmt.Fprintf(buf, "$(eval $(call copy-vintf-manifest-checked, %s, %s))\n", install.from.String(), install.to.String())
+
+ if len(install.implicitDeps) > 0 {
+ panic(fmt.Errorf("unsupported implicitDeps %q in vintf install rule %q", install.implicitDeps, install.to))
+ }
+ if len(install.orderOnlyDeps) > 0 {
+ panic(fmt.Errorf("unsupported orderOnlyDeps %q in vintf install rule %q", install.orderOnlyDeps, install.to))
+ }
+
+ fmt.Fprintln(buf)
+ }
return buf.Bytes()
}
diff --git a/android/module.go b/android/module.go
index 1100fee..1a428e5 100644
--- a/android/module.go
+++ b/android/module.go
@@ -23,6 +23,7 @@
"net/url"
"path/filepath"
"reflect"
+ "slices"
"sort"
"strings"
@@ -839,8 +840,12 @@
// katiInstalls tracks the install rules that were created by Soong but are being exported
// to Make to convert to ninja rules so that Make can add additional dependencies.
katiInstalls katiInstalls
- katiSymlinks katiInstalls
- testData []DataPath
+ // katiInitRcInstalls and katiVintfInstalls track the install rules created by Soong that are
+ // allowed to have duplicates across modules and variants.
+ katiInitRcInstalls katiInstalls
+ katiVintfInstalls katiInstalls
+ katiSymlinks katiInstalls
+ testData []DataPath
// The files to copy to the dist as explicitly specified in the .bp file.
distFiles TaggedDistFiles
@@ -863,12 +868,19 @@
initRcPaths Paths
vintfFragmentsPaths Paths
+ installedInitRcPaths InstallPaths
+ installedVintfFragmentsPaths InstallPaths
+
// set of dependency module:location mappings used to populate the license metadata for
// apex containers.
licenseInstallMap []string
// The path to the generated license metadata file for the module.
licenseMetadataFile WritablePath
+
+ // moduleInfoJSON can be filled out by GenerateAndroidBuildActions to write a JSON file that will
+ // be included in the final module-info.json produced by Make.
+ moduleInfoJSON *ModuleInfoJSON
}
func (m *ModuleBase) AddJSONData(d *map[string]interface{}) {
@@ -1684,6 +1696,41 @@
}
})
+ if m.Device() {
+ // Handle any init.rc and vintf fragment files requested by the module. All files installed by this
+ // module will automatically have a dependency on the installed init.rc or vintf fragment file.
+ // The same init.rc or vintf fragment file may be requested by multiple modules or variants,
+ // so instead of installing them now just compute the install path and store it for later.
+ // The full list of all init.rc and vintf fragment install rules will be deduplicated later
+ // so only a single rule is created for each init.rc or vintf fragment file.
+
+ if !m.InVendorRamdisk() {
+ m.initRcPaths = PathsForModuleSrc(ctx, m.commonProperties.Init_rc)
+ rcDir := PathForModuleInstall(ctx, "etc", "init")
+ for _, src := range m.initRcPaths {
+ installedInitRc := rcDir.Join(ctx, src.Base())
+ m.katiInitRcInstalls = append(m.katiInitRcInstalls, katiInstall{
+ from: src,
+ to: installedInitRc,
+ })
+ ctx.PackageFile(rcDir, src.Base(), src)
+ m.installedInitRcPaths = append(m.installedInitRcPaths, installedInitRc)
+ }
+ }
+
+ m.vintfFragmentsPaths = PathsForModuleSrc(ctx, m.commonProperties.Vintf_fragments)
+ vintfDir := PathForModuleInstall(ctx, "etc", "vintf", "manifest")
+ for _, src := range m.vintfFragmentsPaths {
+ installedVintfFragment := vintfDir.Join(ctx, src.Base())
+ m.katiVintfInstalls = append(m.katiVintfInstalls, katiInstall{
+ from: src,
+ to: installedVintfFragment,
+ })
+ ctx.PackageFile(vintfDir, src.Base(), src)
+ m.installedVintfFragmentsPaths = append(m.installedVintfFragmentsPaths, installedVintfFragment)
+ }
+ }
+
licensesPropertyFlattener(ctx)
if ctx.Failed() {
return
@@ -1694,18 +1741,6 @@
return
}
- m.initRcPaths = PathsForModuleSrc(ctx, m.commonProperties.Init_rc)
- rcDir := PathForModuleInstall(ctx, "etc", "init")
- for _, src := range m.initRcPaths {
- ctx.PackageFile(rcDir, filepath.Base(src.String()), src)
- }
-
- m.vintfFragmentsPaths = PathsForModuleSrc(ctx, m.commonProperties.Vintf_fragments)
- vintfDir := PathForModuleInstall(ctx, "etc", "vintf", "manifest")
- for _, src := range m.vintfFragmentsPaths {
- ctx.PackageFile(vintfDir, filepath.Base(src.String()), src)
- }
-
// Create the set of tagged dist files after calling GenerateAndroidBuildActions
// as GenerateTaggedDistFiles() calls OutputFiles(tag) and so relies on the
// output paths being set which must be done before or during
@@ -1741,11 +1776,90 @@
buildLicenseMetadata(ctx, m.licenseMetadataFile)
+ if m.moduleInfoJSON != nil {
+ var installed InstallPaths
+ installed = append(installed, m.katiInstalls.InstallPaths()...)
+ installed = append(installed, m.katiSymlinks.InstallPaths()...)
+ installed = append(installed, m.katiInitRcInstalls.InstallPaths()...)
+ installed = append(installed, m.katiVintfInstalls.InstallPaths()...)
+ installedStrings := installed.Strings()
+
+ var targetRequired, hostRequired []string
+ if ctx.Host() {
+ targetRequired = m.commonProperties.Target_required
+ } else {
+ hostRequired = m.commonProperties.Host_required
+ }
+
+ var data []string
+ for _, d := range m.testData {
+ data = append(data, d.ToRelativeInstallPath())
+ }
+
+ if m.moduleInfoJSON.Uninstallable {
+ installedStrings = nil
+ if len(m.moduleInfoJSON.CompatibilitySuites) == 1 && m.moduleInfoJSON.CompatibilitySuites[0] == "null-suite" {
+ m.moduleInfoJSON.CompatibilitySuites = nil
+ m.moduleInfoJSON.TestConfig = nil
+ m.moduleInfoJSON.AutoTestConfig = nil
+ data = nil
+ }
+ }
+
+ m.moduleInfoJSON.core = CoreModuleInfoJSON{
+ RegisterName: m.moduleInfoRegisterName(ctx, m.moduleInfoJSON.SubName),
+ Path: []string{ctx.ModuleDir()},
+ Installed: installedStrings,
+ ModuleName: m.BaseModuleName() + m.moduleInfoJSON.SubName,
+ SupportedVariants: []string{m.moduleInfoVariant(ctx)},
+ TargetDependencies: targetRequired,
+ HostDependencies: hostRequired,
+ Data: data,
+ }
+ SetProvider(ctx, ModuleInfoJSONProvider, m.moduleInfoJSON)
+ }
+
m.buildParams = ctx.buildParams
m.ruleParams = ctx.ruleParams
m.variables = ctx.variables
}
+func (m *ModuleBase) moduleInfoRegisterName(ctx ModuleContext, subName string) string {
+ name := m.BaseModuleName()
+
+ prefix := ""
+ if ctx.Host() {
+ if ctx.Os() != ctx.Config().BuildOS {
+ prefix = "host_cross_"
+ }
+ }
+ suffix := ""
+ arches := slices.Clone(ctx.Config().Targets[ctx.Os()])
+ arches = slices.DeleteFunc(arches, func(target Target) bool {
+ return target.NativeBridge != ctx.Target().NativeBridge
+ })
+ if len(arches) > 0 && ctx.Arch().ArchType != arches[0].Arch.ArchType {
+ if ctx.Arch().ArchType.Multilib == "lib32" {
+ suffix = "_32"
+ } else {
+ suffix = "_64"
+ }
+ }
+ return prefix + name + subName + suffix
+}
+
+func (m *ModuleBase) moduleInfoVariant(ctx ModuleContext) string {
+ variant := "DEVICE"
+ if ctx.Host() {
+ if ctx.Os() != ctx.Config().BuildOS {
+ variant = "HOST_CROSS"
+ } else {
+ variant = "HOST"
+ }
+ }
+ return variant
+}
+
// Check the supplied dist structure to make sure that it is valid.
//
// property - the base property, e.g. dist or dists[1], which is combined with the
diff --git a/android/module_context.go b/android/module_context.go
index 81692d5..e772f8b 100644
--- a/android/module_context.go
+++ b/android/module_context.go
@@ -210,6 +210,11 @@
// LicenseMetadataFile returns the path where the license metadata for this module will be
// generated.
LicenseMetadataFile() Path
+
+ // ModuleInfoJSON returns a pointer to the ModuleInfoJSON struct that can be filled out by
+ // GenerateAndroidBuildActions. If it is called then the struct will be written out and included in
+ // the module-info.json generated by Make, and Make will not generate its own data for this module.
+ ModuleInfoJSON() *ModuleInfoJSON
}
type moduleContext struct {
@@ -518,6 +523,8 @@
if !m.skipInstall() {
deps = append(deps, InstallPaths(m.module.base().installFilesDepSet.ToList())...)
+ deps = append(deps, m.module.base().installedInitRcPaths...)
+ deps = append(deps, m.module.base().installedVintfFragmentsPaths...)
var implicitDeps, orderOnlyDeps Paths
@@ -695,6 +702,15 @@
return m.module.base().licenseMetadataFile
}
+func (m *moduleContext) ModuleInfoJSON() *ModuleInfoJSON {
+ if moduleInfoJSON := m.module.base().moduleInfoJSON; moduleInfoJSON != nil {
+ return moduleInfoJSON
+ }
+ moduleInfoJSON := &ModuleInfoJSON{}
+ m.module.base().moduleInfoJSON = moduleInfoJSON
+ return moduleInfoJSON
+}
+
// Returns a list of paths expanded from globs and modules referenced using ":module" syntax. The property must
// be tagged with `android:"path" to support automatic source module dependency resolution.
//
diff --git a/android/module_info_json.go b/android/module_info_json.go
new file mode 100644
index 0000000..1c0a38e
--- /dev/null
+++ b/android/module_info_json.go
@@ -0,0 +1,103 @@
+package android
+
+import (
+ "encoding/json"
+ "io"
+ "slices"
+
+ "github.com/google/blueprint"
+)
+
+type CoreModuleInfoJSON struct {
+ RegisterName string `json:"-"`
+ Path []string `json:"path,omitempty"` // $(sort $(ALL_MODULES.$(m).PATH))
+ Installed []string `json:"installed,omitempty"` // $(sort $(ALL_MODULES.$(m).INSTALLED))
+ ModuleName string `json:"module_name,omitempty"` // $(ALL_MODULES.$(m).MODULE_NAME)
+ SupportedVariants []string `json:"supported_variants,omitempty"` // $(sort $(ALL_MODULES.$(m).SUPPORTED_VARIANTS))
+ HostDependencies []string `json:"host_dependencies,omitempty"` // $(sort $(ALL_MODULES.$(m).HOST_REQUIRED_FROM_TARGET))
+ TargetDependencies []string `json:"target_dependencies,omitempty"` // $(sort $(ALL_MODULES.$(m).TARGET_REQUIRED_FROM_HOST))
+ Data []string `json:"data,omitempty"` // $(sort $(ALL_MODULES.$(m).TEST_DATA))
+}
+
+type ModuleInfoJSON struct {
+ core CoreModuleInfoJSON
+ SubName string `json:"-"`
+ Uninstallable bool `json:"-"`
+ Class []string `json:"class,omitempty"` // $(sort $(ALL_MODULES.$(m).CLASS))
+ Tags []string `json:"tags,omitempty"` // $(sort $(ALL_MODULES.$(m).TAGS))
+ Dependencies []string `json:"dependencies,omitempty"` // $(sort $(ALL_DEPS.$(m).ALL_DEPS))
+ SharedLibs []string `json:"shared_libs,omitempty"` // $(sort $(ALL_MODULES.$(m).SHARED_LIBS))
+ StaticLibs []string `json:"static_libs,omitempty"` // $(sort $(ALL_MODULES.$(m).STATIC_LIBS))
+ SystemSharedLibs []string `json:"system_shared_libs,omitempty"` // $(sort $(ALL_MODULES.$(m).SYSTEM_SHARED_LIBS))
+ Srcs []string `json:"srcs,omitempty"` // $(sort $(ALL_MODULES.$(m).SRCS))
+ SrcJars []string `json:"srcjars,omitempty"` // $(sort $(ALL_MODULES.$(m).SRCJARS))
+ ClassesJar []string `json:"classes_jar,omitempty"` // $(sort $(ALL_MODULES.$(m).CLASSES_JAR))
+ TestMainlineModules []string `json:"test_mainline_modules,omitempty"` // $(sort $(ALL_MODULES.$(m).TEST_MAINLINE_MODULES))
+ IsUnitTest bool `json:"is_unit_test,omitempty"` // $(ALL_MODULES.$(m).IS_UNIT_TEST)
+ TestOptionsTags []string `json:"test_options_tags,omitempty"` // $(sort $(ALL_MODULES.$(m).TEST_OPTIONS_TAGS))
+ RuntimeDependencies []string `json:"runtime_dependencies,omitempty"` // $(sort $(ALL_MODULES.$(m).LOCAL_RUNTIME_LIBRARIES))
+ StaticDependencies []string `json:"static_dependencies,omitempty"` // $(sort $(ALL_MODULES.$(m).LOCAL_STATIC_LIBRARIES))
+ DataDependencies []string `json:"data_dependencies,omitempty"` // $(sort $(ALL_MODULES.$(m).TEST_DATA_BINS))
+
+ CompatibilitySuites []string `json:"compatibility_suites,omitempty"` // $(sort $(ALL_MODULES.$(m).COMPATIBILITY_SUITES))
+ AutoTestConfig []string `json:"auto_test_config,omitempty"` // $(ALL_MODULES.$(m).auto_test_config)
+ TestConfig []string `json:"test_config,omitempty"` // $(strip $(ALL_MODULES.$(m).TEST_CONFIG) $(ALL_MODULES.$(m).EXTRA_TEST_CONFIGS)
+}
+
+//ALL_DEPS.$(LOCAL_MODULE).ALL_DEPS := $(sort \
+//$(ALL_DEPS.$(LOCAL_MODULE).ALL_DEPS) \
+//$(LOCAL_STATIC_LIBRARIES) \
+//$(LOCAL_WHOLE_STATIC_LIBRARIES) \
+//$(LOCAL_SHARED_LIBRARIES) \
+//$(LOCAL_DYLIB_LIBRARIES) \
+//$(LOCAL_RLIB_LIBRARIES) \
+//$(LOCAL_PROC_MACRO_LIBRARIES) \
+//$(LOCAL_HEADER_LIBRARIES) \
+//$(LOCAL_STATIC_JAVA_LIBRARIES) \
+//$(LOCAL_JAVA_LIBRARIES) \
+//$(LOCAL_JNI_SHARED_LIBRARIES))
+
+type combinedModuleInfoJSON struct {
+ *CoreModuleInfoJSON
+ *ModuleInfoJSON
+}
+
+func encodeModuleInfoJSON(w io.Writer, moduleInfoJSON *ModuleInfoJSON) error {
+ moduleInfoJSONCopy := *moduleInfoJSON
+
+ sortAndUnique := func(s *[]string) {
+ *s = slices.Clone(*s)
+ slices.Sort(*s)
+ *s = slices.Compact(*s)
+ }
+
+ sortAndUnique(&moduleInfoJSONCopy.core.Path)
+ sortAndUnique(&moduleInfoJSONCopy.core.Installed)
+ sortAndUnique(&moduleInfoJSONCopy.core.SupportedVariants)
+ sortAndUnique(&moduleInfoJSONCopy.core.HostDependencies)
+ sortAndUnique(&moduleInfoJSONCopy.core.TargetDependencies)
+ sortAndUnique(&moduleInfoJSONCopy.core.Data)
+
+ sortAndUnique(&moduleInfoJSONCopy.Class)
+ sortAndUnique(&moduleInfoJSONCopy.Tags)
+ sortAndUnique(&moduleInfoJSONCopy.Dependencies)
+ sortAndUnique(&moduleInfoJSONCopy.SharedLibs)
+ sortAndUnique(&moduleInfoJSONCopy.StaticLibs)
+ sortAndUnique(&moduleInfoJSONCopy.SystemSharedLibs)
+ sortAndUnique(&moduleInfoJSONCopy.Srcs)
+ sortAndUnique(&moduleInfoJSONCopy.SrcJars)
+ sortAndUnique(&moduleInfoJSONCopy.ClassesJar)
+ sortAndUnique(&moduleInfoJSONCopy.TestMainlineModules)
+ sortAndUnique(&moduleInfoJSONCopy.TestOptionsTags)
+ sortAndUnique(&moduleInfoJSONCopy.RuntimeDependencies)
+ sortAndUnique(&moduleInfoJSONCopy.StaticDependencies)
+ sortAndUnique(&moduleInfoJSONCopy.DataDependencies)
+ sortAndUnique(&moduleInfoJSONCopy.CompatibilitySuites)
+ sortAndUnique(&moduleInfoJSONCopy.AutoTestConfig)
+ sortAndUnique(&moduleInfoJSONCopy.TestConfig)
+
+ encoder := json.NewEncoder(w)
+ return encoder.Encode(combinedModuleInfoJSON{&moduleInfoJSONCopy.core, &moduleInfoJSONCopy})
+}
+
+var ModuleInfoJSONProvider = blueprint.NewProvider[*ModuleInfoJSON]()
diff --git a/android/neverallow.go b/android/neverallow.go
index f721b94..62c5e59 100644
--- a/android/neverallow.go
+++ b/android/neverallow.go
@@ -57,7 +57,6 @@
AddNeverAllowRules(createUncompressDexRules()...)
AddNeverAllowRules(createInitFirstStageRules()...)
AddNeverAllowRules(createProhibitFrameworkAccessRules()...)
- AddNeverAllowRules(createBp2BuildRule())
AddNeverAllowRules(createCcStubsRule())
AddNeverAllowRules(createJavaExcludeStaticLibsRule())
AddNeverAllowRules(createProhibitHeaderOnlyRule())
@@ -68,14 +67,6 @@
neverallows = append(neverallows, rules...)
}
-func createBp2BuildRule() Rule {
- return NeverAllow().
- With("bazel_module.bp2build_available", "true").
- NotIn("soong_tests"). // only used in tests
- Because("setting bp2build_available in Android.bp is not " +
- "supported for custom conversion, use allowlists.go instead.")
-}
-
var (
neverallowNotInIncludeDir = []string{
"art",
diff --git a/android/packaging.go b/android/packaging.go
index 503bb97..8873540 100644
--- a/android/packaging.go
+++ b/android/packaging.go
@@ -17,6 +17,7 @@
import (
"fmt"
"path/filepath"
+ "strings"
"github.com/google/blueprint"
)
@@ -239,7 +240,14 @@
// CopySpecsToDir is a helper that will add commands to the rule builder to copy the PackagingSpec
// entries into the specified directory.
func (p *PackagingBase) CopySpecsToDir(ctx ModuleContext, builder *RuleBuilder, specs map[string]PackagingSpec, dir WritablePath) (entries []string) {
+ if len(specs) == 0 {
+ return entries
+ }
seenDir := make(map[string]bool)
+ preparerPath := PathForModuleOut(ctx, "preparer.sh")
+ cmd := builder.Command().Tool(preparerPath)
+ var sb strings.Builder
+ sb.WriteString("set -e\n")
for _, k := range SortedKeys(specs) {
ps := specs[k]
destPath := filepath.Join(dir.String(), ps.relPathInPackage)
@@ -247,18 +255,21 @@
entries = append(entries, ps.relPathInPackage)
if _, ok := seenDir[destDir]; !ok {
seenDir[destDir] = true
- builder.Command().Text("mkdir").Flag("-p").Text(destDir)
+ sb.WriteString(fmt.Sprintf("mkdir -p %s\n", destDir))
}
if ps.symlinkTarget == "" {
- builder.Command().Text("cp").Input(ps.srcPath).Text(destPath)
+ cmd.Implicit(ps.srcPath)
+ sb.WriteString(fmt.Sprintf("cp %s %s\n", ps.srcPath, destPath))
} else {
- builder.Command().Text("ln").Flag("-sf").Text(ps.symlinkTarget).Text(destPath)
+ sb.WriteString(fmt.Sprintf("ln -sf %s %s\n", ps.symlinkTarget, destPath))
}
if ps.executable {
- builder.Command().Text("chmod").Flag("a+x").Text(destPath)
+ sb.WriteString(fmt.Sprintf("chmod a+x %s\n", destPath))
}
}
+ WriteExecutableFileRuleVerbatim(ctx, preparerPath, sb.String())
+
return entries
}
diff --git a/android/raw_files.go b/android/raw_files.go
new file mode 100644
index 0000000..9d7f5e8
--- /dev/null
+++ b/android/raw_files.go
@@ -0,0 +1,279 @@
+// Copyright 2023 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 android
+
+import (
+ "crypto/sha1"
+ "encoding/hex"
+ "fmt"
+ "github.com/google/blueprint"
+ "io"
+ "io/fs"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+
+ "github.com/google/blueprint/proptools"
+)
+
+// WriteFileRule creates a ninja rule to write contents to a file by immediately writing the
+// contents, plus a trailing newline, to a file in out/soong/raw-${TARGET_PRODUCT}, and then creating
+// a ninja rule to copy the file into place.
+func WriteFileRule(ctx BuilderContext, outputFile WritablePath, content string) {
+ writeFileRule(ctx, outputFile, content, true, false)
+}
+
+// WriteFileRuleVerbatim creates a ninja rule to write contents to a file by immediately writing the
+// contents to a file in out/soong/raw-${TARGET_PRODUCT}, and then creating a ninja rule to copy the file into place.
+func WriteFileRuleVerbatim(ctx BuilderContext, outputFile WritablePath, content string) {
+ writeFileRule(ctx, outputFile, content, false, false)
+}
+
+// WriteExecutableFileRuleVerbatim is the same as WriteFileRuleVerbatim, but runs chmod +x on the result
+func WriteExecutableFileRuleVerbatim(ctx BuilderContext, outputFile WritablePath, content string) {
+ writeFileRule(ctx, outputFile, content, false, true)
+}
+
+// tempFile provides a testable wrapper around a file in out/soong/.temp. It writes to a temporary file when
+// not in tests, but writes to a buffer in memory when used in tests.
+type tempFile struct {
+ // tempFile contains wraps an io.Writer, which will be file if testMode is false, or testBuf if it is true.
+ io.Writer
+
+ file *os.File
+ testBuf *strings.Builder
+}
+
+func newTempFile(ctx BuilderContext, pattern string, testMode bool) *tempFile {
+ if testMode {
+ testBuf := &strings.Builder{}
+ return &tempFile{
+ Writer: testBuf,
+ testBuf: testBuf,
+ }
+ } else {
+ f, err := os.CreateTemp(absolutePath(ctx.Config().tempDir()), pattern)
+ if err != nil {
+ panic(fmt.Errorf("failed to open temporary raw file: %w", err))
+ }
+ return &tempFile{
+ Writer: f,
+ file: f,
+ }
+ }
+}
+
+func (t *tempFile) close() error {
+ if t.file != nil {
+ return t.file.Close()
+ }
+ return nil
+}
+
+func (t *tempFile) name() string {
+ if t.file != nil {
+ return t.file.Name()
+ }
+ return "temp_file_in_test"
+}
+
+func (t *tempFile) rename(to string) {
+ if t.file != nil {
+ os.MkdirAll(filepath.Dir(to), 0777)
+ err := os.Rename(t.file.Name(), to)
+ if err != nil {
+ panic(fmt.Errorf("failed to rename %s to %s: %w", t.file.Name(), to, err))
+ }
+ }
+}
+
+func (t *tempFile) remove() error {
+ if t.file != nil {
+ return os.Remove(t.file.Name())
+ }
+ return nil
+}
+
+func writeContentToTempFileAndHash(ctx BuilderContext, content string, newline bool) (*tempFile, string) {
+ tempFile := newTempFile(ctx, "raw", ctx.Config().captureBuild)
+ defer tempFile.close()
+
+ hash := sha1.New()
+ w := io.MultiWriter(tempFile, hash)
+
+ _, err := io.WriteString(w, content)
+ if err == nil && newline {
+ _, err = io.WriteString(w, "\n")
+ }
+ if err != nil {
+ panic(fmt.Errorf("failed to write to temporary raw file %s: %w", tempFile.name(), err))
+ }
+ return tempFile, hex.EncodeToString(hash.Sum(nil))
+}
+
+func writeFileRule(ctx BuilderContext, outputFile WritablePath, content string, newline bool, executable bool) {
+ // Write the contents to a temporary file while computing its hash.
+ tempFile, hash := writeContentToTempFileAndHash(ctx, content, newline)
+
+ // Shard the final location of the raw file into a subdirectory based on the first two characters of the
+ // hash to avoid making the raw directory too large and slowing down accesses.
+ relPath := filepath.Join(hash[0:2], hash)
+
+ // These files are written during soong_build. If something outside the build deleted them there would be no
+ // trigger to rerun soong_build, and the build would break with dependencies on missing files. Writing them
+ // to their final locations would risk having them deleted when cleaning a module, and would also pollute the
+ // output directory with files for modules that have never been built.
+ // Instead, the files are written to a separate "raw" directory next to the build.ninja file, and a ninja
+ // rule is created to copy the files into their final location as needed.
+ // Obsolete files written by previous runs of soong_build must be cleaned up to avoid continually growing
+ // disk usage as the hashes of the files change over time. The cleanup must not remove files that were
+ // created by previous runs of soong_build for other products, as the build.ninja files for those products
+ // may still exist and still reference those files. The raw files from different products are kept
+ // separate by appending the Make_suffix to the directory name.
+ rawPath := PathForOutput(ctx, "raw"+proptools.String(ctx.Config().productVariables.Make_suffix), relPath)
+
+ rawFileInfo := rawFileInfo{
+ relPath: relPath,
+ }
+
+ if ctx.Config().captureBuild {
+ // When running tests tempFile won't write to disk, instead store the contents for later retrieval by
+ // ContentFromFileRuleForTests.
+ rawFileInfo.contentForTests = tempFile.testBuf.String()
+ }
+
+ rawFileSet := getRawFileSet(ctx.Config())
+ if _, exists := rawFileSet.LoadOrStore(hash, rawFileInfo); exists {
+ // If a raw file with this hash has already been created delete the temporary file.
+ tempFile.remove()
+ } else {
+ // If this is the first time this hash has been seen then move it from the temporary directory
+ // to the raw directory. If the file already exists in the raw directory assume it has the correct
+ // contents.
+ absRawPath := absolutePath(rawPath.String())
+ _, err := os.Stat(absRawPath)
+ if os.IsNotExist(err) {
+ tempFile.rename(absRawPath)
+ } else if err != nil {
+ panic(fmt.Errorf("failed to stat %q: %w", absRawPath, err))
+ } else {
+ tempFile.remove()
+ }
+ }
+
+ // Emit a rule to copy the file from raw directory to the final requested location in the output tree.
+ // Restat is used to ensure that two different products that produce identical files copied from their
+ // own raw directories they don't cause everything downstream to rebuild.
+ rule := rawFileCopy
+ if executable {
+ rule = rawFileCopyExecutable
+ }
+ ctx.Build(pctx, BuildParams{
+ Rule: rule,
+ Input: rawPath,
+ Output: outputFile,
+ Description: "raw " + outputFile.Base(),
+ })
+}
+
+var (
+ rawFileCopy = pctx.AndroidStaticRule("rawFileCopy",
+ blueprint.RuleParams{
+ Command: "if ! cmp -s $in $out; then cp $in $out; fi",
+ Description: "copy raw file $out",
+ Restat: true,
+ })
+ rawFileCopyExecutable = pctx.AndroidStaticRule("rawFileCopyExecutable",
+ blueprint.RuleParams{
+ Command: "if ! cmp -s $in $out; then cp $in $out; fi && chmod +x $out",
+ Description: "copy raw exectuable file $out",
+ Restat: true,
+ })
+)
+
+type rawFileInfo struct {
+ relPath string
+ contentForTests string
+}
+
+var rawFileSetKey OnceKey = NewOnceKey("raw file set")
+
+func getRawFileSet(config Config) *SyncMap[string, rawFileInfo] {
+ return config.Once(rawFileSetKey, func() any {
+ return &SyncMap[string, rawFileInfo]{}
+ }).(*SyncMap[string, rawFileInfo])
+}
+
+// ContentFromFileRuleForTests returns the content that was passed to a WriteFileRule for use
+// in tests.
+func ContentFromFileRuleForTests(t *testing.T, ctx *TestContext, params TestingBuildParams) string {
+ t.Helper()
+ if params.Rule != rawFileCopy && params.Rule != rawFileCopyExecutable {
+ t.Errorf("expected params.Rule to be rawFileCopy or rawFileCopyExecutable, was %q", params.Rule)
+ return ""
+ }
+
+ key := filepath.Base(params.Input.String())
+ rawFileSet := getRawFileSet(ctx.Config())
+ rawFileInfo, _ := rawFileSet.Load(key)
+
+ return rawFileInfo.contentForTests
+}
+
+func rawFilesSingletonFactory() Singleton {
+ return &rawFilesSingleton{}
+}
+
+type rawFilesSingleton struct{}
+
+func (rawFilesSingleton) GenerateBuildActions(ctx SingletonContext) {
+ if ctx.Config().captureBuild {
+ // Nothing to do when running in tests, no temporary files were created.
+ return
+ }
+ rawFileSet := getRawFileSet(ctx.Config())
+ rawFilesDir := PathForOutput(ctx, "raw"+proptools.String(ctx.Config().productVariables.Make_suffix)).String()
+ absRawFilesDir := absolutePath(rawFilesDir)
+ err := filepath.WalkDir(absRawFilesDir, func(path string, d fs.DirEntry, err error) error {
+ if err != nil {
+ return err
+ }
+ if d.IsDir() {
+ // Ignore obsolete directories for now.
+ return nil
+ }
+
+ // Assume the basename of the file is a hash
+ key := filepath.Base(path)
+ relPath, err := filepath.Rel(absRawFilesDir, path)
+ if err != nil {
+ return err
+ }
+
+ // Check if a file with the same hash was written by this run of soong_build. If the file was not written,
+ // or if a file with the same hash was written but to a different path in the raw directory, then delete it.
+ // Checking that the path matches allows changing the structure of the raw directory, for example to increase
+ // the sharding.
+ rawFileInfo, written := rawFileSet.Load(key)
+ if !written || rawFileInfo.relPath != relPath {
+ os.Remove(path)
+ }
+ return nil
+ })
+ if err != nil {
+ panic(fmt.Errorf("failed to clean %q: %w", rawFilesDir, err))
+ }
+}
diff --git a/android/register.go b/android/register.go
index cd968cd..d00c15f 100644
--- a/android/register.go
+++ b/android/register.go
@@ -191,8 +191,9 @@
// Register makevars after other singletons so they can export values through makevars
singleton{parallel: false, name: "makevars", factory: makeVarsSingletonFunc},
- // Register env and ninjadeps last so that they can track all used environment variables and
+ // Register rawfiles and ninjadeps last so that they can track all used environment variables and
// Ninja file dependencies stored in the config.
+ singleton{parallel: false, name: "rawfiles", factory: rawFilesSingletonFactory},
singleton{parallel: false, name: "ninjadeps", factory: ninjaDepsSingletonFactory},
)
diff --git a/android/rule_builder_test.go b/android/rule_builder_test.go
index d659dcc..9e5f12d 100644
--- a/android/rule_builder_test.go
+++ b/android/rule_builder_test.go
@@ -816,13 +816,13 @@
func TestRuleBuilderWithNinjaVarEscaping(t *testing.T) {
bp := `
rule_builder_test {
- name: "foo_sbox_escaped_ninja",
+ name: "foo_sbox_escaped",
flags: ["${cmdFlags}"],
sbox: true,
sbox_inputs: true,
}
rule_builder_test {
- name: "foo_sbox",
+ name: "foo_sbox_unescaped",
flags: ["${cmdFlags}"],
sbox: true,
sbox_inputs: true,
@@ -834,15 +834,16 @@
FixtureWithRootAndroidBp(bp),
).RunTest(t)
- escapedNinjaMod := result.ModuleForTests("foo_sbox_escaped_ninja", "").Rule("writeFile")
+ escapedNinjaMod := result.ModuleForTests("foo_sbox_escaped", "").Output("sbox.textproto")
+ AssertStringEquals(t, "expected rule", "android/soong/android.rawFileCopy", escapedNinjaMod.Rule.String())
AssertStringDoesContain(
t,
"",
- escapedNinjaMod.BuildParams.Args["content"],
- "$${cmdFlags}",
+ ContentFromFileRuleForTests(t, result.TestContext, escapedNinjaMod),
+ "${cmdFlags}",
)
- unescapedNinjaMod := result.ModuleForTests("foo_sbox", "").Rule("unescapedWriteFile")
+ unescapedNinjaMod := result.ModuleForTests("foo_sbox_unescaped", "").Rule("unescapedWriteFile")
AssertStringDoesContain(
t,
"",
diff --git a/android/sdk_version.go b/android/sdk_version.go
index aafcee7..73568af 100644
--- a/android/sdk_version.go
+++ b/android/sdk_version.go
@@ -16,6 +16,7 @@
import (
"fmt"
+ "reflect"
"strconv"
"strings"
)
@@ -162,6 +163,17 @@
// If BOARD_CURRENT_API_LEVEL_FOR_VENDOR_MODULES has a numeric value,
// use it instead of "current" for the vendor partition.
currentSdkVersion := ctx.DeviceConfig().CurrentApiLevelForVendorModules()
+ // b/314011075: special case for Java modules in vendor partition. They can no longer use
+ // SDK 35 or later. Their maximum API level is limited to 34 (Android U). This is to
+ // discourage the use of Java APIs in the vendor partition which hasn't been officially
+ // supported since the Project Treble back in Android 10. We would like to eventually
+ // evacuate all Java modules from the partition, but that shall be done progressively.
+ // Note that the check for the availability of SDK 34 is to not break existing tests where
+ // any of the frozen SDK version is unavailable.
+ if isJava(ctx.Module()) && isSdkVersion34AvailableIn(ctx.Config()) {
+ currentSdkVersion = "34"
+ }
+
if currentSdkVersion == "current" {
return s
}
@@ -290,28 +302,79 @@
}
}
+// Checks if the use of this SDK `s` is valid for the given module context `ctx`.
func (s SdkSpec) ValidateSystemSdk(ctx EarlyModuleContext) bool {
- // Ensures that the specified system SDK version is one of BOARD_SYSTEMSDK_VERSIONS (for vendor/product Java module)
- // Assuming that BOARD_SYSTEMSDK_VERSIONS := 28 29,
- // sdk_version of the modules in vendor/product that use system sdk must be either system_28, system_29 or system_current
- if s.Kind != SdkSystem || s.ApiLevel.IsPreview() {
+ // Do some early checks. This check is currently only for Java modules. And our only concern
+ // is the use of "system" SDKs.
+ if !isJava(ctx.Module()) || s.Kind != SdkSystem || ctx.DeviceConfig().BuildBrokenDontCheckSystemSdk() {
return true
}
- allowedVersions := ctx.DeviceConfig().PlatformSystemSdkVersions()
- if ctx.DeviceSpecific() || ctx.SocSpecific() || (ctx.ProductSpecific() && ctx.Config().EnforceProductPartitionInterface()) {
- systemSdkVersions := ctx.DeviceConfig().SystemSdkVersions()
- if len(systemSdkVersions) > 0 {
- allowedVersions = systemSdkVersions
+
+ inVendor := ctx.DeviceSpecific() || ctx.SocSpecific()
+ inProduct := ctx.ProductSpecific()
+ isProductUnbundled := ctx.Config().EnforceProductPartitionInterface()
+ inApex := false
+ if am, ok := ctx.Module().(ApexModule); ok {
+ inApex = am.InAnyApex()
+ }
+ isUnbundled := inVendor || (inProduct && isProductUnbundled) || inApex
+
+ // Bundled modules can use any SDK
+ if !isUnbundled {
+ return true
+ }
+
+ // Unbundled modules are allowed to use BOARD_SYSTEMSDK_VERSIONS
+ supportedVersions := ctx.DeviceConfig().SystemSdkVersions()
+
+ // b/314011075: special case for vendor modules. Java modules in the vendor partition can
+ // not use SDK 35 or later. This is to discourage the use of Java APIs in the vendor
+ // partition which hasn't been officially supported since the Project Treble back in Android
+ // 10. We would like to eventually evacuate all Java modules from the partition, but that
+ // shall be done progressively.
+ if inVendor {
+ // 28 was the API when BOARD_SYSTEMSDK_VERSIONS was introduced, so that's the oldest
+ // we should allow.
+ supportedVersions = []string{}
+ for v := 28; v <= 34; v++ {
+ supportedVersions = append(supportedVersions, strconv.Itoa(v))
}
}
- if len(allowedVersions) > 0 && !InList(s.ApiLevel.String(), allowedVersions) {
+
+ // APEXes in the system partition are still considered as part of the platform, thus can use
+ // more SDKs from PLATFORM_SYSTEMSDK_VERSIONS
+ if inApex && !inVendor {
+ supportedVersions = ctx.DeviceConfig().PlatformSystemSdkVersions()
+ }
+
+ thisVer, err := s.EffectiveVersion(ctx)
+ if err != nil {
+ ctx.PropertyErrorf("sdk_version", "invalid sdk version %q", s.Raw)
+ return false
+ }
+
+ thisVerString := strconv.Itoa(thisVer.FinalOrPreviewInt())
+ if thisVer.IsPreview() {
+ thisVerString = *ctx.Config().productVariables.Platform_sdk_version_or_codename
+ }
+
+ if !InList(thisVerString, supportedVersions) {
ctx.PropertyErrorf("sdk_version", "incompatible sdk version %q. System SDK version should be one of %q",
- s.Raw, allowedVersions)
+ s.Raw, supportedVersions)
return false
}
return true
}
+func isJava(m Module) bool {
+ moduleType := reflect.TypeOf(m).String()
+ return strings.HasPrefix(moduleType, "*java.")
+}
+
+func isSdkVersion34AvailableIn(c Config) bool {
+ return c.PlatformSdkVersion().FinalInt() >= 34
+}
+
func init() {
RegisterMakeVarsProvider(pctx, javaSdkMakeVars)
}
diff --git a/android/soong_config_modules_test.go b/android/soong_config_modules_test.go
index 79bdeb8..a6b2c51 100644
--- a/android/soong_config_modules_test.go
+++ b/android/soong_config_modules_test.go
@@ -376,8 +376,7 @@
prepareForSoongConfigTestModule,
FixtureWithRootAndroidBp(bp),
).ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern([]string{
- // TODO(b/171232169): improve the error message for non-existent properties
- `unrecognized property "soong_config_variables`,
+ `unrecognized property "soong_config_variables.feature1.made_up_property`,
})).RunTest(t)
}
diff --git a/android/soongconfig/modules.go b/android/soongconfig/modules.go
index 23c8afa..f6b4938 100644
--- a/android/soongconfig/modules.go
+++ b/android/soongconfig/modules.go
@@ -16,16 +16,12 @@
import (
"fmt"
+ "github.com/google/blueprint/parser"
+ "github.com/google/blueprint/proptools"
"io"
"reflect"
"sort"
"strings"
- "sync"
-
- "github.com/google/blueprint/parser"
- "github.com/google/blueprint/proptools"
-
- "android/soong/starlark_fmt"
)
const conditionsDefault = "conditions_default"
@@ -236,110 +232,6 @@
variables map[string]soongConfigVariable
}
-// Bp2BuildSoongConfigDefinition keeps a global record of all soong config
-// string vars, bool vars and value vars created by every
-// soong_config_module_type in this build.
-type Bp2BuildSoongConfigDefinitions struct {
- StringVars map[string]map[string]bool
- BoolVars map[string]bool
- ValueVars map[string]bool
-}
-
-var bp2buildSoongConfigVarsLock sync.Mutex
-
-// SoongConfigVariablesForBp2build extracts information from a
-// SoongConfigDefinition that bp2build needs to generate constraint settings and
-// values for, in order to migrate soong_config_module_type usages to Bazel.
-func (defs *Bp2BuildSoongConfigDefinitions) AddVars(mtDef *SoongConfigDefinition) {
- // In bp2build mode, this method is called concurrently in goroutines from
- // loadhooks while parsing soong_config_module_type, so add a mutex to
- // prevent concurrent map writes. See b/207572723
- bp2buildSoongConfigVarsLock.Lock()
- defer bp2buildSoongConfigVarsLock.Unlock()
-
- if defs.StringVars == nil {
- defs.StringVars = make(map[string]map[string]bool)
- }
- if defs.BoolVars == nil {
- defs.BoolVars = make(map[string]bool)
- }
- if defs.ValueVars == nil {
- defs.ValueVars = make(map[string]bool)
- }
- // varCache contains a cache of string variables namespace + property
- // The same variable may be used in multiple module types (for example, if need support
- // for cc_default and java_default), only need to process once
- varCache := map[string]bool{}
-
- for _, moduleType := range mtDef.ModuleTypes {
- for _, v := range moduleType.Variables {
- key := strings.Join([]string{moduleType.ConfigNamespace, v.variableProperty()}, "__")
-
- // The same variable may be used in multiple module types (for example, if need support
- // for cc_default and java_default), only need to process once
- if _, keyInCache := varCache[key]; keyInCache {
- continue
- } else {
- varCache[key] = true
- }
-
- if strVar, ok := v.(*stringVariable); ok {
- if _, ok := defs.StringVars[key]; !ok {
- defs.StringVars[key] = make(map[string]bool, len(strVar.values))
- }
- for _, value := range strVar.values {
- defs.StringVars[key][value] = true
- }
- } else if _, ok := v.(*boolVariable); ok {
- defs.BoolVars[key] = true
- } else if _, ok := v.(*valueVariable); ok {
- defs.ValueVars[key] = true
- } else {
- panic(fmt.Errorf("Unsupported variable type: %+v", v))
- }
- }
- }
-}
-
-// This is a copy of the one available in soong/android/util.go, but depending
-// on the android package causes a cyclic dependency. A refactoring here is to
-// extract common utils out from android/utils.go for other packages like this.
-func sortedStringKeys(m interface{}) []string {
- v := reflect.ValueOf(m)
- if v.Kind() != reflect.Map {
- panic(fmt.Sprintf("%#v is not a map", m))
- }
- keys := v.MapKeys()
- s := make([]string, 0, len(keys))
- for _, key := range keys {
- s = append(s, key.String())
- }
- sort.Strings(s)
- return s
-}
-
-// String emits the Soong config variable definitions as Starlark dictionaries.
-func (defs Bp2BuildSoongConfigDefinitions) String() string {
- ret := ""
- ret += "soong_config_bool_variables = "
- ret += starlark_fmt.PrintBoolDict(defs.BoolVars, 0)
- ret += "\n\n"
-
- ret += "soong_config_value_variables = "
- ret += starlark_fmt.PrintBoolDict(defs.ValueVars, 0)
- ret += "\n\n"
-
- stringVars := make(map[string][]string, len(defs.StringVars))
- for k, v := range defs.StringVars {
- stringVars[k] = sortedStringKeys(v)
- }
-
- ret += "soong_config_string_variables = "
- ret += starlark_fmt.PrintStringListDict(stringVars, 0)
-
- return ret
-}
-
// CreateProperties returns a reflect.Value of a newly constructed type that contains the desired
// property layout for the Soong config variables, with each possible value an interface{} that
// contains a nil pointer to another newly constructed type that contains the affectable properties.
diff --git a/android/soongconfig/modules_test.go b/android/soongconfig/modules_test.go
index a5fa349..00e8b78 100644
--- a/android/soongconfig/modules_test.go
+++ b/android/soongconfig/modules_test.go
@@ -413,220 +413,3 @@
t.Fatalf("Error message was not correct, expected %q, got %q", expected, err.Error())
}
}
-
-func Test_Bp2BuildSoongConfigDefinitionsAddVars(t *testing.T) {
- testCases := []struct {
- desc string
- defs []*SoongConfigDefinition
- expected Bp2BuildSoongConfigDefinitions
- }{
- {
- desc: "non-overlapping",
- defs: []*SoongConfigDefinition{
- &SoongConfigDefinition{
- ModuleTypes: map[string]*ModuleType{
- "a": &ModuleType{
- ConfigNamespace: "foo",
- Variables: []soongConfigVariable{
- &stringVariable{
- baseVariable: baseVariable{"string_var"},
- values: []string{"a", "b", "c"},
- },
- },
- },
- },
- },
- &SoongConfigDefinition{
- ModuleTypes: map[string]*ModuleType{
- "b": &ModuleType{
- ConfigNamespace: "foo",
- Variables: []soongConfigVariable{
- &stringVariable{
- baseVariable: baseVariable{"string_var"},
- values: []string{"a", "b", "c"},
- },
- &boolVariable{baseVariable: baseVariable{"bool_var"}},
- &valueVariable{baseVariable: baseVariable{"variable_var"}},
- },
- },
- },
- },
- },
- expected: Bp2BuildSoongConfigDefinitions{
- StringVars: map[string]map[string]bool{
- "foo__string_var": map[string]bool{"a": true, "b": true, "c": true},
- },
- BoolVars: map[string]bool{"foo__bool_var": true},
- ValueVars: map[string]bool{"foo__variable_var": true},
- },
- },
- {
- desc: "overlapping",
- defs: []*SoongConfigDefinition{
- &SoongConfigDefinition{
- ModuleTypes: map[string]*ModuleType{
- "a": &ModuleType{
- ConfigNamespace: "foo",
- Variables: []soongConfigVariable{
- &stringVariable{
- baseVariable: baseVariable{"string_var"},
- values: []string{"a", "b", "c"},
- },
- },
- },
- },
- },
- &SoongConfigDefinition{
- ModuleTypes: map[string]*ModuleType{
- "b": &ModuleType{
- ConfigNamespace: "foo",
- Variables: []soongConfigVariable{
- &stringVariable{
- baseVariable: baseVariable{"string_var"},
- values: []string{"b", "c", "d"},
- },
- &boolVariable{baseVariable: baseVariable{"bool_var"}},
- &valueVariable{baseVariable: baseVariable{"variable_var"}},
- },
- },
- },
- },
- },
- expected: Bp2BuildSoongConfigDefinitions{
- StringVars: map[string]map[string]bool{
- "foo__string_var": map[string]bool{"a": true, "b": true, "c": true, "d": true},
- },
- BoolVars: map[string]bool{"foo__bool_var": true},
- ValueVars: map[string]bool{"foo__variable_var": true},
- },
- },
- }
-
- for _, tc := range testCases {
- t.Run(tc.desc, func(t *testing.T) {
- actual := &Bp2BuildSoongConfigDefinitions{}
- for _, d := range tc.defs {
- func(def *SoongConfigDefinition) {
- actual.AddVars(def)
- }(d)
- }
- if !reflect.DeepEqual(*actual, tc.expected) {
- t.Errorf("Expected %#v, got %#v", tc.expected, *actual)
- }
- })
- }
-
-}
-
-func Test_Bp2BuildSoongConfigDefinitions(t *testing.T) {
- testCases := []struct {
- desc string
- defs Bp2BuildSoongConfigDefinitions
- expected string
- }{
- {
- desc: "all empty",
- defs: Bp2BuildSoongConfigDefinitions{},
- expected: `soong_config_bool_variables = {}
-
-soong_config_value_variables = {}
-
-soong_config_string_variables = {}`}, {
- desc: "only bool",
- defs: Bp2BuildSoongConfigDefinitions{
- BoolVars: map[string]bool{
- "bool_var": true,
- },
- },
- expected: `soong_config_bool_variables = {
- "bool_var": True,
-}
-
-soong_config_value_variables = {}
-
-soong_config_string_variables = {}`}, {
- desc: "only value vars",
- defs: Bp2BuildSoongConfigDefinitions{
- ValueVars: map[string]bool{
- "value_var": true,
- },
- },
- expected: `soong_config_bool_variables = {}
-
-soong_config_value_variables = {
- "value_var": True,
-}
-
-soong_config_string_variables = {}`}, {
- desc: "only string vars",
- defs: Bp2BuildSoongConfigDefinitions{
- StringVars: map[string]map[string]bool{
- "string_var": map[string]bool{
- "choice1": true,
- "choice2": true,
- "choice3": true,
- },
- },
- },
- expected: `soong_config_bool_variables = {}
-
-soong_config_value_variables = {}
-
-soong_config_string_variables = {
- "string_var": [
- "choice1",
- "choice2",
- "choice3",
- ],
-}`}, {
- desc: "all vars",
- defs: Bp2BuildSoongConfigDefinitions{
- BoolVars: map[string]bool{
- "bool_var_one": true,
- },
- ValueVars: map[string]bool{
- "value_var_one": true,
- "value_var_two": true,
- },
- StringVars: map[string]map[string]bool{
- "string_var_one": map[string]bool{
- "choice1": true,
- "choice2": true,
- "choice3": true,
- },
- "string_var_two": map[string]bool{
- "foo": true,
- "bar": true,
- },
- },
- },
- expected: `soong_config_bool_variables = {
- "bool_var_one": True,
-}
-
-soong_config_value_variables = {
- "value_var_one": True,
- "value_var_two": True,
-}
-
-soong_config_string_variables = {
- "string_var_one": [
- "choice1",
- "choice2",
- "choice3",
- ],
- "string_var_two": [
- "bar",
- "foo",
- ],
-}`},
- }
- for _, test := range testCases {
- t.Run(test.desc, func(t *testing.T) {
- actual := test.defs.String()
- if actual != test.expected {
- t.Errorf("Expected:\n%s\nbut got:\n%s", test.expected, actual)
- }
- })
- }
-}
diff --git a/android/test_config.go b/android/test_config.go
index 9e1ac70..a15343a 100644
--- a/android/test_config.go
+++ b/android/test_config.go
@@ -39,11 +39,12 @@
DeviceName: stringPtr("test_device"),
DeviceProduct: stringPtr("test_product"),
Platform_sdk_version: intPtr(30),
+ Platform_sdk_version_or_codename: stringPtr("S"),
Platform_sdk_codename: stringPtr("S"),
Platform_base_sdk_extension_version: intPtr(1),
Platform_version_active_codenames: []string{"S", "Tiramisu"},
- DeviceSystemSdkVersions: []string{"14", "15"},
- Platform_systemsdk_versions: []string{"29", "30"},
+ DeviceSystemSdkVersions: []string{"29", "30", "S"},
+ Platform_systemsdk_versions: []string{"29", "30", "S", "Tiramisu"},
AAPTConfig: []string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"},
AAPTPreferredConfig: stringPtr("xhdpi"),
AAPTCharacteristics: stringPtr("nosdcard"),
diff --git a/android/testing.go b/android/testing.go
index 3d0300a..78afaa5 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -183,7 +183,6 @@
type TestContext struct {
*Context
preArch, preDeps, postDeps, finalDeps []RegisterMutatorFunc
- bp2buildPreArch, bp2buildMutators []RegisterMutatorFunc
NameResolver *NameResolver
// The list of singletons registered for the test.
@@ -219,12 +218,6 @@
ctx.finalDeps = append(ctx.finalDeps, f)
}
-// PreArchBp2BuildMutators adds mutators to be register for converting Android Blueprint modules
-// into Bazel BUILD targets that should run prior to deps and conversion.
-func (ctx *TestContext) PreArchBp2BuildMutators(f RegisterMutatorFunc) {
- ctx.bp2buildPreArch = append(ctx.bp2buildPreArch, f)
-}
-
func (ctx *TestContext) OtherModuleProviderAdaptor() OtherModuleProviderContext {
return NewOtherModuleProviderAdaptor(func(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool) {
return ctx.moduleProvider(module, provider)
diff --git a/android/util.go b/android/util.go
index ae1c657..51313ce 100644
--- a/android/util.go
+++ b/android/util.go
@@ -22,6 +22,7 @@
"runtime"
"sort"
"strings"
+ "sync"
)
// CopyOf returns a new slice that has the same contents as s.
@@ -597,3 +598,32 @@
set[item] = true
}
}
+
+// SyncMap is a wrapper around sync.Map that provides type safety via generics.
+type SyncMap[K comparable, V any] struct {
+ sync.Map
+}
+
+// Load returns the value stored in the map for a key, or the zero value if no
+// value is present.
+// The ok result indicates whether value was found in the map.
+func (m *SyncMap[K, V]) Load(key K) (value V, ok bool) {
+ v, ok := m.Map.Load(key)
+ if !ok {
+ return *new(V), false
+ }
+ return v.(V), true
+}
+
+// Store sets the value for a key.
+func (m *SyncMap[K, V]) Store(key K, value V) {
+ m.Map.Store(key, value)
+}
+
+// LoadOrStore returns the existing value for the key if present.
+// Otherwise, it stores and returns the given value.
+// The loaded result is true if the value was loaded, false if stored.
+func (m *SyncMap[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool) {
+ v, loaded := m.Map.LoadOrStore(key, value)
+ return v.(V), loaded
+}
diff --git a/android/variable.go b/android/variable.go
index fa4cfc1..9844080 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -448,6 +448,7 @@
BuildBrokenVendorPropertyNamespace bool `json:",omitempty"`
BuildBrokenIncorrectPartitionImages bool `json:",omitempty"`
BuildBrokenInputDirModules []string `json:",omitempty"`
+ BuildBrokenDontCheckSystemSdk bool `json:",omitempty"`
BuildWarningBadOptionalUsesLibsAllowlist []string `json:",omitempty"`
diff --git a/apex/apex.go b/apex/apex.go
index 45abbba..42a7d73 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -719,7 +719,7 @@
// getImageVariationPair returns a pair for the image variation name as its
// prefix and suffix. The prefix indicates whether it's core/vendor/product and the
-// suffix indicates the vndk version when it's vendor or product.
+// suffix indicates the vndk version for vendor/product if vndk is enabled.
// getImageVariation can simply join the result of this function to get the
// image variation name.
func (a *apexBundle) getImageVariationPair(deviceConfig android.DeviceConfig) (string, string) {
@@ -727,8 +727,8 @@
return cc.VendorVariationPrefix, a.vndkVersion(deviceConfig)
}
- var prefix string
- var vndkVersion string
+ prefix := android.CoreVariation
+ vndkVersion := ""
if deviceConfig.VndkVersion() != "" {
if a.SocSpecific() || a.DeviceSpecific() {
prefix = cc.VendorVariationPrefix
@@ -737,15 +737,18 @@
prefix = cc.ProductVariationPrefix
vndkVersion = deviceConfig.PlatformVndkVersion()
}
+ } else {
+ if a.SocSpecific() || a.DeviceSpecific() {
+ prefix = cc.VendorVariation
+ } else if a.ProductSpecific() {
+ prefix = cc.ProductVariation
+ }
}
if vndkVersion == "current" {
vndkVersion = deviceConfig.PlatformVndkVersion()
}
- if vndkVersion != "" {
- return prefix, vndkVersion
- }
- return android.CoreVariation, "" // The usual case
+ return prefix, vndkVersion
}
// getImageVariation returns the image variant name for this apexBundle. In most cases, it's simply
@@ -2853,17 +2856,6 @@
//
// Module separator
//
- m["com.android.mediaprovider"] = []string{
- "MediaProvider",
- "MediaProviderGoogle",
- "fmtlib_ndk",
- "libbase_ndk",
- "libfuse",
- "libfuse_jni",
- }
- //
- // Module separator
- //
m["com.android.runtime"] = []string{
"libdebuggerd",
"libdebuggerd_common_headers",
@@ -2885,14 +2877,6 @@
//
// Module separator
//
- m["com.android.tethering"] = []string{
- "android.hardware.tetheroffload.config-V1.0-java",
- "android.hardware.tetheroffload.control-V1.0-java",
- "net-utils-framework-common",
- }
- //
- // Module separator
- //
m["com.android.wifi"] = []string{
"PlatformProperties",
"android.hardware.wifi-V1.0-java",
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 616421a..1b9fa19 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -11436,6 +11436,20 @@
}
}
+ // Check that the boot jars of the selected apex are run through boot_jars_package_check
+ // This validates that the jars on the bootclasspath do not contain packages outside an allowlist
+ checkBootJarsPackageCheck := func(t *testing.T, ctx *android.TestContext, expectedBootJar string) {
+ platformBcp := ctx.ModuleForTests("platform-bootclasspath", "android_common")
+ bootJarsCheckRule := platformBcp.Rule("boot_jars_package_check")
+ android.AssertStringMatches(t, "Could not find the correct boot dex jar in package check rule", bootJarsCheckRule.RuleParams.Command, "build/soong/scripts/check_boot_jars/package_allowed_list.txt.*"+expectedBootJar)
+ }
+
+ // Check that the boot jars used to generate the monolithic hiddenapi flags come from the selected apex
+ checkBootJarsForMonolithicHiddenapi := func(t *testing.T, ctx *android.TestContext, expectedBootJar string) {
+ monolithicHiddenapiFlagsCmd := ctx.ModuleForTests("platform-bootclasspath", "android_common").Output("out/soong/hiddenapi/hiddenapi-stub-flags.txt").RuleParams.Command
+ android.AssertStringMatches(t, "Could not find the correct boot dex jar in monolithic hiddenapi flags generation command", monolithicHiddenapiFlagsCmd, "--boot-dex="+expectedBootJar)
+ }
+
bp := `
// Source APEX.
@@ -11575,5 +11589,7 @@
)
ctx := testDexpreoptWithApexes(t, bp, "", preparer, fragment)
checkBootDexJarPath(t, ctx, "framework-foo", tc.expectedBootJar)
+ checkBootJarsPackageCheck(t, ctx, tc.expectedBootJar)
+ checkBootJarsForMonolithicHiddenapi(t, ctx, tc.expectedBootJar)
}
}
diff --git a/apex/platform_bootclasspath_test.go b/apex/platform_bootclasspath_test.go
index b741963..01b616b 100644
--- a/apex/platform_bootclasspath_test.go
+++ b/apex/platform_bootclasspath_test.go
@@ -382,6 +382,9 @@
// Make sure that the myplatform-bootclasspath has the correct dependencies.
CheckModuleDependencies(t, result.TestContext, "myplatform-bootclasspath", "android_common", []string{
+ // source vs prebuilt selection metadata module
+ `platform:all_apex_contributions`,
+
// The following are stubs.
`platform:android_stubs_current`,
`platform:android_system_stubs_current`,
@@ -534,6 +537,9 @@
// Make sure that the myplatform-bootclasspath has the correct dependencies.
CheckModuleDependencies(t, result.TestContext, "myplatform-bootclasspath", "android_common", []string{
+ // source vs prebuilt selection metadata module
+ `platform:all_apex_contributions`,
+
// The following are stubs.
"platform:prebuilt_sdk_public_current_android",
"platform:prebuilt_sdk_system_current_android",
diff --git a/cc/androidmk.go b/cc/androidmk.go
index 54c7f97..bde096b 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -101,15 +101,6 @@
if len(c.Properties.AndroidMkSharedLibs) > 0 {
entries.AddStrings("LOCAL_SHARED_LIBRARIES", c.Properties.AndroidMkSharedLibs...)
}
- if len(c.Properties.AndroidMkStaticLibs) > 0 {
- entries.AddStrings("LOCAL_STATIC_LIBRARIES", c.Properties.AndroidMkStaticLibs...)
- }
- if len(c.Properties.AndroidMkWholeStaticLibs) > 0 {
- entries.AddStrings("LOCAL_WHOLE_STATIC_LIBRARIES", c.Properties.AndroidMkWholeStaticLibs...)
- }
- if len(c.Properties.AndroidMkHeaderLibs) > 0 {
- entries.AddStrings("LOCAL_HEADER_LIBRARIES", c.Properties.AndroidMkHeaderLibs...)
- }
if len(c.Properties.AndroidMkRuntimeLibs) > 0 {
entries.AddStrings("LOCAL_RUNTIME_LIBRARIES", c.Properties.AndroidMkRuntimeLibs...)
}
diff --git a/cc/binary.go b/cc/binary.go
index 61541ad..7aa8e20 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -541,6 +541,11 @@
return binary.Properties.Overrides
}
+func (binary *binaryDecorator) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ moduleInfoJSON.Class = []string{"EXECUTABLES"}
+ binary.baseLinker.moduleInfoJSON(ctx, moduleInfoJSON)
+}
+
var _ overridable = (*binaryDecorator)(nil)
func init() {
diff --git a/cc/cc.go b/cc/cc.go
index 9f32c44..c6e21c2 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -25,6 +25,7 @@
"strings"
"android/soong/testing"
+
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -300,8 +301,8 @@
// Set by DepsMutator.
AndroidMkSystemSharedLibs []string `blueprint:"mutated"`
- // The name of the image this module is built for, suffixed with a '.'
- ImageVariationPrefix string `blueprint:"mutated"`
+ // The name of the image this module is built for
+ ImageVariation string `blueprint:"mutated"`
// The VNDK version this module is built against. If empty, the module is not
// build against the VNDK.
@@ -543,6 +544,7 @@
isPreventInstall() bool
isCfiAssemblySupportEnabled() bool
getSharedFlags() *SharedFlags
+ notInPlatform() bool
}
type SharedFlags struct {
@@ -623,6 +625,8 @@
// Get the deps that have been explicitly specified in the properties.
linkerSpecifiedDeps(specifiedDeps specifiedDeps) specifiedDeps
+
+ moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON)
}
// specifiedDeps is a tuple struct representing dependencies of a linked binary owned by the linker.
@@ -1785,6 +1789,10 @@
return ctx.mod.isCfiAssemblySupportEnabled()
}
+func (ctx *moduleContextImpl) notInPlatform() bool {
+ return ctx.mod.NotInPlatform()
+}
+
func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
return &Module{
hod: hod,
@@ -1941,6 +1949,7 @@
"libdl_android": true,
"libm": true,
"libdl": true,
+ "libz": true,
// art apex
"libandroidio": true,
"libdexfile": true,
@@ -2139,6 +2148,39 @@
android.CollectDependencyAconfigFiles(ctx, &c.mergedAconfigFiles)
c.maybeInstall(ctx, apexInfo)
+
+ if c.linker != nil {
+ moduleInfoJSON := ctx.ModuleInfoJSON()
+ c.linker.moduleInfoJSON(ctx, moduleInfoJSON)
+ moduleInfoJSON.SharedLibs = c.Properties.AndroidMkSharedLibs
+ moduleInfoJSON.StaticLibs = c.Properties.AndroidMkStaticLibs
+ moduleInfoJSON.SystemSharedLibs = c.Properties.AndroidMkSystemSharedLibs
+ moduleInfoJSON.RuntimeDependencies = c.Properties.AndroidMkRuntimeLibs
+
+ moduleInfoJSON.Dependencies = append(moduleInfoJSON.Dependencies, c.Properties.AndroidMkSharedLibs...)
+ moduleInfoJSON.Dependencies = append(moduleInfoJSON.Dependencies, c.Properties.AndroidMkStaticLibs...)
+ moduleInfoJSON.Dependencies = append(moduleInfoJSON.Dependencies, c.Properties.AndroidMkHeaderLibs...)
+ moduleInfoJSON.Dependencies = append(moduleInfoJSON.Dependencies, c.Properties.AndroidMkWholeStaticLibs...)
+
+ if c.sanitize != nil && len(moduleInfoJSON.Class) > 0 &&
+ (moduleInfoJSON.Class[0] == "STATIC_LIBRARIES" || moduleInfoJSON.Class[0] == "HEADER_LIBRARIES") {
+ if Bool(c.sanitize.Properties.SanitizeMutated.Cfi) {
+ moduleInfoJSON.SubName += ".cfi"
+ }
+ if Bool(c.sanitize.Properties.SanitizeMutated.Hwaddress) {
+ moduleInfoJSON.SubName += ".hwasan"
+ }
+ if Bool(c.sanitize.Properties.SanitizeMutated.Scs) {
+ moduleInfoJSON.SubName += ".scs"
+ }
+ }
+ moduleInfoJSON.SubName += c.Properties.SubName
+
+ if c.Properties.IsSdkVariant && c.Properties.SdkAndPlatformVariantVisibleToMake {
+ moduleInfoJSON.Uninstallable = true
+ }
+
+ }
}
func (c *Module) maybeUnhideFromMake() {
@@ -2386,9 +2428,9 @@
// Only retrieve the snapshot on demand in order to avoid circular dependencies
// between the modules in the snapshot and the snapshot itself.
var snapshotModule []blueprint.Module
- if c.InVendor() && c.VndkVersion() == actx.DeviceConfig().VndkVersion() {
+ if c.InVendor() && c.VndkVersion() == actx.DeviceConfig().VndkVersion() && actx.OtherModuleExists("vendor_snapshot") {
snapshotModule = actx.AddVariationDependencies(nil, nil, "vendor_snapshot")
- } else if recoverySnapshotVersion := actx.DeviceConfig().RecoverySnapshotVersion(); recoverySnapshotVersion != "current" && recoverySnapshotVersion != "" && c.InRecovery() {
+ } else if recoverySnapshotVersion := actx.DeviceConfig().RecoverySnapshotVersion(); recoverySnapshotVersion != "current" && recoverySnapshotVersion != "" && c.InRecovery() && actx.OtherModuleExists("recovery_snapshot") {
snapshotModule = actx.AddVariationDependencies(nil, nil, "recovery_snapshot")
}
if len(snapshotModule) > 0 && snapshotModule[0] != nil {
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 5c5275e..321bd38 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -26,6 +26,8 @@
"android/soong/aidl_library"
"android/soong/android"
+
+ "github.com/google/blueprint"
)
func init() {
@@ -45,6 +47,14 @@
}),
)
+// TODO(b/316829758) Update prepareForCcTest with this configuration and remove prepareForCcTestWithoutVndk
+var prepareForCcTestWithoutVndk = android.GroupFixturePreparers(
+ PrepareForIntegrationTestWithCc,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.VendorApiLevel = StringPtr("202404")
+ }),
+)
+
var apexVariationName = "apex28"
var apexVersion = "28"
@@ -2640,6 +2650,7 @@
name: "libexternal_headers",
export_include_dirs: ["include"],
vendor_available: true,
+ product_available: true,
}
cc_library_headers {
name: "libexternal_llndk_headers",
@@ -4784,3 +4795,51 @@
return
}
}
+
+// TODO(b/316829758) Remove this test and do not set VNDK version from other tests
+func TestImageVariantsWithoutVndk(t *testing.T) {
+ t.Parallel()
+
+ bp := `
+ cc_binary {
+ name: "binfoo",
+ srcs: ["binfoo.cc"],
+ vendor_available: true,
+ product_available: true,
+ shared_libs: ["libbar"]
+ }
+ cc_library {
+ name: "libbar",
+ srcs: ["libbar.cc"],
+ vendor_available: true,
+ product_available: true,
+ }
+ `
+
+ ctx := prepareForCcTestWithoutVndk.RunTestWithBp(t, bp)
+
+ hasDep := func(m android.Module, wantDep android.Module) bool {
+ t.Helper()
+ var found bool
+ ctx.VisitDirectDeps(m, func(dep blueprint.Module) {
+ if dep == wantDep {
+ found = true
+ }
+ })
+ return found
+ }
+
+ testDepWithVariant := func(imageVariant string) {
+ imageVariantStr := ""
+ if imageVariant != "core" {
+ imageVariantStr = "_" + imageVariant
+ }
+ binFooModule := ctx.ModuleForTests("binfoo", "android"+imageVariantStr+"_arm64_armv8-a").Module()
+ libBarModule := ctx.ModuleForTests("libbar", "android"+imageVariantStr+"_arm64_armv8-a_shared").Module()
+ android.AssertBoolEquals(t, "binfoo should have dependency on libbar with image variant "+imageVariant, true, hasDep(binFooModule, libBarModule))
+ }
+
+ testDepWithVariant("core")
+ testDepWithVariant("vendor")
+ testDepWithVariant("product")
+}
diff --git a/cc/config/x86_64_device.go b/cc/config/x86_64_device.go
index e43848c..ff0a3b7 100644
--- a/cc/config/x86_64_device.go
+++ b/cc/config/x86_64_device.go
@@ -49,6 +49,10 @@
"goldmont-plus": []string{
"-march=goldmont-plus",
},
+ "goldmont-without-xsaves": []string{
+ "-march=goldmont",
+ "-mno-xsaves",
+ },
"haswell": []string{
"-march=core-avx2",
},
diff --git a/cc/config/x86_device.go b/cc/config/x86_device.go
index c826d3c..08be869 100644
--- a/cc/config/x86_device.go
+++ b/cc/config/x86_device.go
@@ -56,6 +56,10 @@
"goldmont-plus": []string{
"-march=goldmont-plus",
},
+ "goldmont-without-xsaves": []string{
+ "-march=goldmont",
+ "-mno-xsaves",
+ },
"haswell": []string{
"-march=core-avx2",
},
diff --git a/cc/fuzz.go b/cc/fuzz.go
index f5642d6..2436f33 100644
--- a/cc/fuzz.go
+++ b/cc/fuzz.go
@@ -144,25 +144,35 @@
}
func (fuzz *fuzzBinary) linkerFlags(ctx ModuleContext, flags Flags) Flags {
+ subdir := "lib"
+ if ctx.inVendor() {
+ subdir = "lib/vendor"
+ }
+
flags = fuzz.binaryDecorator.linkerFlags(ctx, flags)
// RunPaths on devices isn't instantiated by the base linker. `../lib` for
// installed fuzz targets (both host and device), and `./lib` for fuzz
// target packages.
- flags.Local.LdFlags = append(flags.Local.LdFlags, `-Wl,-rpath,\$$ORIGIN/lib`)
+ flags.Local.LdFlags = append(flags.Local.LdFlags, `-Wl,-rpath,\$$ORIGIN/`+subdir)
// When running on device, fuzz targets with vendor: true set will be in
// fuzzer_name/vendor/fuzzer_name (note the extra 'vendor' and thus need to
// link with libraries in ../../lib/. Non-vendor binaries only need to look
// one level up, in ../lib/.
if ctx.inVendor() {
- flags.Local.LdFlags = append(flags.Local.LdFlags, `-Wl,-rpath,\$$ORIGIN/../../lib`)
+ flags.Local.LdFlags = append(flags.Local.LdFlags, `-Wl,-rpath,\$$ORIGIN/../../`+subdir)
} else {
- flags.Local.LdFlags = append(flags.Local.LdFlags, `-Wl,-rpath,\$$ORIGIN/../lib`)
+ flags.Local.LdFlags = append(flags.Local.LdFlags, `-Wl,-rpath,\$$ORIGIN/../`+subdir)
}
return flags
}
+func (fuzz *fuzzBinary) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ fuzz.binaryDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
+ moduleInfoJSON.Class = []string{"EXECUTABLES"}
+}
+
// IsValidSharedDependency takes a module and determines if it is a unique shared library
// that should be installed in the fuzz target output directories. This function
// returns true, unless:
@@ -216,19 +226,27 @@
}
func SharedLibraryInstallLocation(
- libraryBase string, isHost bool, fuzzDir string, archString string) string {
+ libraryBase string, isHost bool, isVendor bool, fuzzDir string, archString string) string {
installLocation := "$(PRODUCT_OUT)/data"
if isHost {
installLocation = "$(HOST_OUT)"
}
+ subdir := "lib"
+ if isVendor {
+ subdir = "lib/vendor"
+ }
installLocation = filepath.Join(
- installLocation, fuzzDir, archString, "lib", libraryBase)
+ installLocation, fuzzDir, archString, subdir, libraryBase)
return installLocation
}
// Get the device-only shared library symbols install directory.
-func SharedLibrarySymbolsInstallLocation(libraryBase string, fuzzDir string, archString string) string {
- return filepath.Join("$(PRODUCT_OUT)/symbols/data/", fuzzDir, archString, "/lib/", libraryBase)
+func SharedLibrarySymbolsInstallLocation(libraryBase string, isVendor bool, fuzzDir string, archString string) string {
+ subdir := "lib"
+ if isVendor {
+ subdir = "lib/vendor"
+ }
+ return filepath.Join("$(PRODUCT_OUT)/symbols/data/", fuzzDir, archString, subdir, libraryBase)
}
func (fuzzBin *fuzzBinary) install(ctx ModuleContext, file android.Path) {
@@ -239,16 +257,29 @@
// Grab the list of required shared libraries.
fuzzBin.sharedLibraries, _ = CollectAllSharedDependencies(ctx)
+ // TODO: does not mirror Android linkernamespaces
+ // the logic here has special cases for vendor, but it would need more work to
+ // work in arbitrary partitions, so just surface errors early for a few cases
+ //
+ // Even without these, there are certain situations across linkernamespaces
+ // that this won't support. For instance, you might have:
+ //
+ // my_fuzzer (vendor) -> libbinder_ndk (core) -> libbinder (vendor)
+ //
+ // This dependency chain wouldn't be possible to express in the current
+ // logic because all the deps currently match the variant of the source
+ // module.
+
for _, ruleBuilderInstall := range fuzzBin.sharedLibraries {
install := ruleBuilderInstall.To
fuzzBin.installedSharedDeps = append(fuzzBin.installedSharedDeps,
SharedLibraryInstallLocation(
- install, ctx.Host(), installBase, ctx.Arch().ArchType.String()))
+ install, ctx.Host(), ctx.inVendor(), installBase, ctx.Arch().ArchType.String()))
// Also add the dependency on the shared library symbols dir.
if !ctx.Host() {
fuzzBin.installedSharedDeps = append(fuzzBin.installedSharedDeps,
- SharedLibrarySymbolsInstallLocation(install, installBase, ctx.Arch().ArchType.String()))
+ SharedLibrarySymbolsInstallLocation(install, ctx.inVendor(), installBase, ctx.Arch().ArchType.String()))
}
}
@@ -407,6 +438,10 @@
}
sharedLibsInstallDirPrefix := "lib"
+ if ccModule.InVendor() {
+ sharedLibsInstallDirPrefix = "lib/vendor"
+ }
+
if !ccModule.IsFuzzModule() {
return
}
@@ -499,7 +534,7 @@
// install it to the output directory. Setup the install destination here,
// which will be used by $(copy-many-files) in the Make backend.
installDestination := SharedLibraryInstallLocation(
- install, module.Host(), fuzzDir, archString)
+ install, module.Host(), module.InVendor(), fuzzDir, archString)
if (*sharedLibraryInstalled)[installDestination] {
continue
}
@@ -517,7 +552,7 @@
// we want symbolization tools (like `stack`) to be able to find the symbols
// in $ANDROID_PRODUCT_OUT/symbols automagically.
if !module.Host() {
- symbolsInstallDestination := SharedLibrarySymbolsInstallLocation(install, fuzzDir, archString)
+ symbolsInstallDestination := SharedLibrarySymbolsInstallLocation(install, module.InVendor(), fuzzDir, archString)
symbolsInstallDestination = strings.ReplaceAll(symbolsInstallDestination, "$", "$$")
s.SharedLibInstallStrings = append(s.SharedLibInstallStrings,
library.String()+":"+symbolsInstallDestination)
diff --git a/cc/image.go b/cc/image.go
index 4c0c722..9eec255 100644
--- a/cc/image.go
+++ b/cc/image.go
@@ -42,10 +42,18 @@
)
const (
+ // VendorVariation is the variant name used for /vendor code that does not
+ // compile against the VNDK.
+ VendorVariation = "vendor"
+
// VendorVariationPrefix is the variant prefix used for /vendor code that compiles
// against the VNDK.
VendorVariationPrefix = "vendor."
+ // ProductVariation is the variant name used for /product code that does not
+ // compile against the VNDK.
+ ProductVariation = "product"
+
// ProductVariationPrefix is the variant prefix used for /product code that compiles
// against the VNDK.
ProductVariationPrefix = "product."
@@ -112,12 +120,12 @@
// Returns true if the module is "product" variant. Usually these modules are installed in /product
func (c *Module) InProduct() bool {
- return c.Properties.ImageVariationPrefix == ProductVariationPrefix
+ return c.Properties.ImageVariation == ProductVariation
}
// Returns true if the module is "vendor" variant. Usually these modules are installed in /vendor
func (c *Module) InVendor() bool {
- return c.Properties.ImageVariationPrefix == VendorVariationPrefix
+ return c.Properties.ImageVariation == VendorVariation
}
func (c *Module) InRamdisk() bool {
@@ -439,10 +447,8 @@
// and vendor and product variants will be created with LLNDK stubs.
// The LLNDK libraries need vendor variants even if there is no VNDK.
coreVariantNeeded = true
- if platformVndkVersion != "" {
- vendorVariants = append(vendorVariants, platformVndkVersion)
- productVariants = append(productVariants, platformVndkVersion)
- }
+ vendorVariants = append(vendorVariants, platformVndkVersion)
+ productVariants = append(productVariants, platformVndkVersion)
// Generate vendor variants for boardVndkVersion only if the VNDK snapshot does not
// provide the LLNDK stub libraries.
if needVndkVersionVendorVariantForLlndk {
@@ -453,13 +459,7 @@
// for system and product.
coreVariantNeeded = true
vendorVariants = append(vendorVariants, boardVndkVersion)
- if platformVndkVersion != "" {
- productVariants = append(productVariants, platformVndkVersion)
- }
- } else if boardVndkVersion == "" {
- // If the device isn't compiling against the VNDK, we always
- // use the core mode.
- coreVariantNeeded = true
+ productVariants = append(productVariants, platformVndkVersion)
} else if m.IsSnapshotPrebuilt() {
// Make vendor variants only for the versions in BOARD_VNDK_VERSION and
// PRODUCT_EXTRA_VNDK_VERSIONS.
@@ -557,11 +557,19 @@
}
for _, variant := range android.FirstUniqueStrings(vendorVariants) {
- m.AppendExtraVariant(VendorVariationPrefix + variant)
+ if variant == "" {
+ m.AppendExtraVariant(VendorVariation)
+ } else {
+ m.AppendExtraVariant(VendorVariationPrefix + variant)
+ }
}
for _, variant := range android.FirstUniqueStrings(productVariants) {
- m.AppendExtraVariant(ProductVariationPrefix + variant)
+ if variant == "" {
+ m.AppendExtraVariant(ProductVariation)
+ } else {
+ m.AppendExtraVariant(ProductVariationPrefix + variant)
+ }
}
m.SetRamdiskVariantNeeded(ramdiskVariantNeeded)
@@ -672,9 +680,12 @@
} else if variant == android.RecoveryVariation {
m.MakeAsPlatform()
squashRecoverySrcs(m)
- } else if strings.HasPrefix(variant, VendorVariationPrefix) {
- m.Properties.ImageVariationPrefix = VendorVariationPrefix
- m.Properties.VndkVersion = strings.TrimPrefix(variant, VendorVariationPrefix)
+ } else if strings.HasPrefix(variant, VendorVariation) {
+ m.Properties.ImageVariation = VendorVariation
+
+ if strings.HasPrefix(variant, VendorVariationPrefix) {
+ m.Properties.VndkVersion = strings.TrimPrefix(variant, VendorVariationPrefix)
+ }
squashVendorSrcs(m)
// Makefile shouldn't know vendor modules other than BOARD_VNDK_VERSION.
@@ -684,9 +695,11 @@
m.Properties.HideFromMake = true
m.HideFromMake()
}
- } else if strings.HasPrefix(variant, ProductVariationPrefix) {
- m.Properties.ImageVariationPrefix = ProductVariationPrefix
- m.Properties.VndkVersion = strings.TrimPrefix(variant, ProductVariationPrefix)
+ } else if strings.HasPrefix(variant, ProductVariation) {
+ m.Properties.ImageVariation = ProductVariation
+ if strings.HasPrefix(variant, ProductVariationPrefix) {
+ m.Properties.VndkVersion = strings.TrimPrefix(variant, ProductVariationPrefix)
+ }
squashProductSrcs(m)
}
diff --git a/cc/library.go b/cc/library.go
index 4c8deef..592f70f 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -1041,6 +1041,40 @@
return specifiedDeps
}
+func (library *libraryDecorator) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ if library.static() {
+ moduleInfoJSON.Class = []string{"STATIC_LIBRARIES"}
+ moduleInfoJSON.Uninstallable = true
+ } else if library.shared() {
+ moduleInfoJSON.Class = []string{"SHARED_LIBRARIES"}
+ } else if library.header() {
+ moduleInfoJSON.Class = []string{"HEADER_LIBRARIES"}
+ moduleInfoJSON.Uninstallable = true
+ }
+
+ if library.buildStubs() && library.stubsVersion() != "" {
+ moduleInfoJSON.SubName += "." + library.stubsVersion()
+ }
+
+ // If a library providing a stub is included in an APEX, the private APIs of the library
+ // is accessible only inside the APEX. From outside of the APEX, clients can only use the
+ // public APIs via the stub. To enforce this, the (latest version of the) stub gets the
+ // name of the library. The impl library instead gets the `.bootstrap` suffix to so that
+ // they can be exceptionally used directly when APEXes are not available (e.g. during the
+ // very early stage in the boot process).
+ if len(library.Properties.Stubs.Versions) > 0 && !ctx.Host() && ctx.notInPlatform() &&
+ !ctx.inRamdisk() && !ctx.inVendorRamdisk() && !ctx.inRecovery() && !ctx.useVndk() && !ctx.static() {
+ if library.buildStubs() && library.isLatestStubVersion() {
+ moduleInfoJSON.SubName = ""
+ }
+ if !library.buildStubs() {
+ moduleInfoJSON.SubName = ".bootstrap"
+ }
+ }
+
+ library.baseLinker.moduleInfoJSON(ctx, moduleInfoJSON)
+}
+
func (library *libraryDecorator) linkStatic(ctx ModuleContext,
flags Flags, deps PathDeps, objs Objects) android.Path {
diff --git a/cc/linker.go b/cc/linker.go
index 357d1ce..85c128e 100644
--- a/cc/linker.go
+++ b/cc/linker.go
@@ -648,6 +648,9 @@
return specifiedDeps
}
+func (linker *baseLinker) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+}
+
// Injecting version symbols
// Some host modules want a version number, but we don't want to rebuild it every time. Optionally add a step
// after linking that injects a constant placeholder with the current version number.
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index 98fb334..183e818 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -486,6 +486,12 @@
}
}
+func (linker *stubDecorator) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ linker.libraryDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
+ // Overwrites the SubName computed by libraryDecorator
+ moduleInfoJSON.SubName = ndkLibrarySuffix + "." + linker.apiLevel.String()
+}
+
func (linker *stubDecorator) Name(name string) string {
return name + ndkLibrarySuffix
}
diff --git a/cc/object.go b/cc/object.go
index 0dba99f..6c0391f 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -238,3 +238,8 @@
func (object *objectLinker) isCrt() bool {
return Bool(object.Properties.Crt)
}
+
+func (object *objectLinker) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ object.baseLinker.moduleInfoJSON(ctx, moduleInfoJSON)
+ moduleInfoJSON.Class = []string{"STATIC_LIBRARIES"}
+}
diff --git a/cc/symbolfile/__init__.py b/cc/symbolfile/__init__.py
index 94c8567..345e9f9 100644
--- a/cc/symbolfile/__init__.py
+++ b/cc/symbolfile/__init__.py
@@ -46,6 +46,15 @@
Arch('x86_64'),
)
+# TODO: it would be nice to dedupe with 'has_*_tag' property methods
+SUPPORTED_TAGS = ALL_ARCHITECTURES + (
+ Tag('apex'),
+ Tag('llndk'),
+ Tag('platform-only'),
+ Tag('systemapi'),
+ Tag('var'),
+ Tag('weak'),
+)
# Arbitrary magic number. We use the same one in api-level.h for this purpose.
FUTURE_API_LEVEL = 10000
@@ -136,6 +145,8 @@
def is_api_level_tag(tag: Tag) -> bool:
"""Returns true if this tag has an API level that may need decoding."""
+ if tag.startswith('llndk-deprecated='):
+ return True
if tag.startswith('introduced='):
return True
if tag.startswith('introduced-'):
@@ -170,6 +181,9 @@
ParseError: An unknown version name was found in a tag.
"""
if not is_api_level_tag(tag):
+ if tag not in SUPPORTED_TAGS:
+ raise ParseError(f'Unsupported tag: {tag}')
+
return tag
name, value = split_tag(tag)
diff --git a/cc/symbolfile/test_symbolfile.py b/cc/symbolfile/test_symbolfile.py
index 856b9d7..83becc2 100644
--- a/cc/symbolfile/test_symbolfile.py
+++ b/cc/symbolfile/test_symbolfile.py
@@ -40,10 +40,20 @@
self.assertEqual(Tags(), symbolfile.get_tags('foo bar baz', {}))
def test_get_tags(self) -> None:
- self.assertEqual(Tags.from_strs(['foo', 'bar']),
- symbolfile.get_tags('# foo bar', {}))
- self.assertEqual(Tags.from_strs(['bar', 'baz']),
- symbolfile.get_tags('foo # bar baz', {}))
+ self.assertEqual(Tags.from_strs(['llndk', 'apex']),
+ symbolfile.get_tags('# llndk apex', {}))
+ self.assertEqual(Tags.from_strs(['llndk', 'apex']),
+ symbolfile.get_tags('foo # llndk apex', {}))
+
+ def test_get_unrecognized_tags(self) -> None:
+ with self.assertRaises(symbolfile.ParseError):
+ symbolfile.get_tags('# bar', {})
+ with self.assertRaises(symbolfile.ParseError):
+ symbolfile.get_tags('foo # bar', {})
+ with self.assertRaises(symbolfile.ParseError):
+ symbolfile.get_tags('# #', {})
+ with self.assertRaises(symbolfile.ParseError):
+ symbolfile.get_tags('# apex # llndk', {})
def test_split_tag(self) -> None:
self.assertTupleEqual(('foo', 'bar'),
@@ -425,13 +435,13 @@
def test_parse_version(self) -> None:
input_file = io.StringIO(textwrap.dedent("""\
- VERSION_1 { # foo bar
+ VERSION_1 { # weak introduced=35
baz;
- qux; # woodly doodly
+ qux; # apex llndk
};
VERSION_2 {
- } VERSION_1; # asdf
+ } VERSION_1; # not-a-tag
"""))
parser = symbolfile.SymbolFileParser(input_file, {}, self.filter)
@@ -439,11 +449,11 @@
version = parser.parse_version()
self.assertEqual('VERSION_1', version.name)
self.assertIsNone(version.base)
- self.assertEqual(Tags.from_strs(['foo', 'bar']), version.tags)
+ self.assertEqual(Tags.from_strs(['weak', 'introduced=35']), version.tags)
expected_symbols = [
Symbol('baz', Tags()),
- Symbol('qux', Tags.from_strs(['woodly', 'doodly'])),
+ Symbol('qux', Tags.from_strs(['apex', 'llndk'])),
]
self.assertEqual(expected_symbols, version.symbols)
@@ -476,7 +486,7 @@
def test_parse_symbol(self) -> None:
input_file = io.StringIO(textwrap.dedent("""\
foo;
- bar; # baz qux
+ bar; # llndk apex
"""))
parser = symbolfile.SymbolFileParser(input_file, {}, self.filter)
@@ -488,7 +498,7 @@
parser.next_line()
symbol = parser.parse_symbol()
self.assertEqual('bar', symbol.name)
- self.assertEqual(Tags.from_strs(['baz', 'qux']), symbol.tags)
+ self.assertEqual(Tags.from_strs(['llndk', 'apex']), symbol.tags)
def test_wildcard_symbol_global(self) -> None:
input_file = io.StringIO(textwrap.dedent("""\
@@ -537,13 +547,13 @@
hidden1;
global:
foo;
- bar; # baz
+ bar; # llndk
};
- VERSION_2 { # wasd
+ VERSION_2 { # weak
# Implicit global scope.
woodly;
- doodly; # asdf
+ doodly; # llndk
local:
qwerty;
} VERSION_1;
@@ -554,12 +564,12 @@
expected = [
symbolfile.Version('VERSION_1', None, Tags(), [
Symbol('foo', Tags()),
- Symbol('bar', Tags.from_strs(['baz'])),
+ Symbol('bar', Tags.from_strs(['llndk'])),
]),
symbolfile.Version(
- 'VERSION_2', 'VERSION_1', Tags.from_strs(['wasd']), [
+ 'VERSION_2', 'VERSION_1', Tags.from_strs(['weak']), [
Symbol('woodly', Tags()),
- Symbol('doodly', Tags.from_strs(['asdf'])),
+ Symbol('doodly', Tags.from_strs(['llndk'])),
]),
]
diff --git a/cc/test.go b/cc/test.go
index d02145b..347d7c9 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -321,6 +321,13 @@
return []interface{}{&test.InstallerProperties}
}
+func (test *testDecorator) moduleInfoJSON(ctx android.ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ if android.PrefixInList(moduleInfoJSON.CompatibilitySuites, "mts-") &&
+ !android.InList("mts", moduleInfoJSON.CompatibilitySuites) {
+ moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, "mts")
+ }
+}
+
func NewTestInstaller() *baseInstaller {
return NewBaseInstaller("nativetest", "nativetest64", InstallInData)
}
@@ -355,6 +362,38 @@
return flags
}
+func (test *testBinary) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ if ctx.Host() && Bool(test.Properties.Test_options.Unit_test) {
+ moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, "host-unit-tests")
+ }
+ moduleInfoJSON.TestOptionsTags = append(moduleInfoJSON.TestOptionsTags, test.Properties.Test_options.Tags...)
+ moduleInfoJSON.TestMainlineModules = append(moduleInfoJSON.TestMainlineModules, test.Properties.Test_mainline_modules...)
+ if test.testConfig != nil {
+ if _, ok := test.testConfig.(android.WritablePath); ok {
+ moduleInfoJSON.AutoTestConfig = []string{"true"}
+ }
+ moduleInfoJSON.TestConfig = append(moduleInfoJSON.TestConfig, test.testConfig.String())
+ }
+ moduleInfoJSON.TestConfig = append(moduleInfoJSON.TestConfig, test.extraTestConfigs.Strings()...)
+
+ if Bool(test.Properties.Test_per_src) {
+ moduleInfoJSON.SubName = "_" + String(test.binaryDecorator.Properties.Stem)
+ }
+
+ moduleInfoJSON.DataDependencies = append(moduleInfoJSON.DataDependencies, test.Properties.Data_bins...)
+
+ if len(test.InstallerProperties.Test_suites) > 0 {
+ moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, test.InstallerProperties.Test_suites...)
+ } else {
+ moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, "null-suite")
+ }
+
+ test.binaryDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
+ test.testDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
+ moduleInfoJSON.Class = []string{"NATIVE_TESTS"}
+
+}
+
func (test *testBinary) installerProps() []interface{} {
return append(test.baseInstaller.installerProps(), test.testDecorator.installerProps()...)
}
@@ -532,6 +571,15 @@
return flags
}
+func (test *testLibrary) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ if len(test.InstallerProperties.Test_suites) > 0 {
+ moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, test.InstallerProperties.Test_suites...)
+ }
+
+ test.libraryDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
+ test.testDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
+}
+
func (test *testLibrary) installerProps() []interface{} {
return append(test.baseInstaller.installerProps(), test.testDecorator.installerProps()...)
}
@@ -626,6 +674,29 @@
benchmark.binaryDecorator.baseInstaller.install(ctx, file)
}
+func (benchmark *benchmarkDecorator) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ benchmark.binaryDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
+
+ moduleInfoJSON.Class = []string{"NATIVE_TESTS"}
+ if len(benchmark.Properties.Test_suites) > 0 {
+ moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, benchmark.Properties.Test_suites...)
+ } else {
+ moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, "null-suite")
+ }
+
+ if android.PrefixInList(moduleInfoJSON.CompatibilitySuites, "mts-") &&
+ !android.InList("mts", moduleInfoJSON.CompatibilitySuites) {
+ moduleInfoJSON.CompatibilitySuites = append(moduleInfoJSON.CompatibilitySuites, "mts")
+ }
+
+ if benchmark.testConfig != nil {
+ if _, ok := benchmark.testConfig.(android.WritablePath); ok {
+ moduleInfoJSON.AutoTestConfig = []string{"true"}
+ }
+ moduleInfoJSON.TestConfig = []string{benchmark.testConfig.String()}
+ }
+}
+
func NewBenchmark(hod android.HostOrDeviceSupported) *Module {
module, binary := newBinary(hod)
module.multilib = android.MultilibBoth
diff --git a/cc/vndk_prebuilt.go b/cc/vndk_prebuilt.go
index 3f3a025..eb1790f 100644
--- a/cc/vndk_prebuilt.go
+++ b/cc/vndk_prebuilt.go
@@ -187,6 +187,11 @@
return nil
}
+func (p *vndkPrebuiltLibraryDecorator) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
+ p.libraryDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
+ moduleInfoJSON.SubName += p.androidMkSuffix
+}
+
func (p *vndkPrebuiltLibraryDecorator) MatchesWithDevice(config android.DeviceConfig) bool {
arches := config.Arches()
if len(arches) == 0 || arches[0].ArchType.String() != p.arch() {
diff --git a/cmd/merge_module_info_json/Android.bp b/cmd/merge_module_info_json/Android.bp
new file mode 100644
index 0000000..1ae6a47
--- /dev/null
+++ b/cmd/merge_module_info_json/Android.bp
@@ -0,0 +1,30 @@
+// Copyright 2021 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 {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+blueprint_go_binary {
+ name: "merge_module_info_json",
+ srcs: [
+ "merge_module_info_json.go",
+ ],
+ deps: [
+ "soong-response",
+ ],
+ testSrcs: [
+ "merge_module_info_json_test.go",
+ ],
+}
diff --git a/cmd/merge_module_info_json/merge_module_info_json.go b/cmd/merge_module_info_json/merge_module_info_json.go
new file mode 100644
index 0000000..0143984
--- /dev/null
+++ b/cmd/merge_module_info_json/merge_module_info_json.go
@@ -0,0 +1,223 @@
+// Copyright 2021 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.
+
+// merge_module_info_json is a utility that merges module_info.json files generated by
+// Soong and Make.
+
+package main
+
+import (
+ "android/soong/response"
+ "cmp"
+ "encoding/json"
+ "flag"
+ "fmt"
+ "os"
+ "slices"
+)
+
+var (
+ out = flag.String("o", "", "output file")
+ listFile = flag.String("l", "", "input file list file")
+)
+
+func usage() {
+ fmt.Fprintf(os.Stderr, "usage: %s -o <output file> <input files>\n", os.Args[0])
+ flag.PrintDefaults()
+ fmt.Fprintln(os.Stderr, "merge_module_info_json reads input files that each contain an array of json objects")
+ fmt.Fprintln(os.Stderr, "and writes them out as a single json array to the output file.")
+
+ os.Exit(2)
+}
+
+func main() {
+ flag.Usage = usage
+ flag.Parse()
+
+ if *out == "" {
+ fmt.Fprintf(os.Stderr, "%s: error: -o is required\n", os.Args[0])
+ usage()
+ }
+
+ inputs := flag.Args()
+ if *listFile != "" {
+ listFileInputs, err := readListFile(*listFile)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "failed to read list file %s: %s", *listFile, err)
+ os.Exit(1)
+ }
+ inputs = append(inputs, listFileInputs...)
+ }
+
+ err := mergeJsonObjects(*out, inputs)
+
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "%s: error: %s\n", os.Args[0], err.Error())
+ os.Exit(1)
+ }
+}
+
+func readListFile(file string) ([]string, error) {
+ f, err := os.Open(*listFile)
+ if err != nil {
+ return nil, err
+ }
+ return response.ReadRspFile(f)
+}
+
+func mergeJsonObjects(output string, inputs []string) error {
+ combined := make(map[string]any)
+ for _, input := range inputs {
+ objects, err := decodeObjectFromJson(input)
+ if err != nil {
+ return err
+ }
+
+ for _, object := range objects {
+ for k, v := range object {
+ if old, exists := combined[k]; exists {
+ v = combine(old, v)
+ }
+ combined[k] = v
+ }
+ }
+ }
+
+ f, err := os.Create(output)
+ if err != nil {
+ return fmt.Errorf("failed to open output file: %w", err)
+ }
+ encoder := json.NewEncoder(f)
+ encoder.SetIndent("", " ")
+ err = encoder.Encode(combined)
+ if err != nil {
+ return fmt.Errorf("failed to encode to output file: %w", err)
+ }
+
+ return nil
+}
+
+func decodeObjectFromJson(input string) ([]map[string]any, error) {
+ f, err := os.Open(input)
+ if err != nil {
+ return nil, fmt.Errorf("failed to open input file: %w", err)
+ }
+
+ decoder := json.NewDecoder(f)
+ var object any
+ err = decoder.Decode(&object)
+ if err != nil {
+ return nil, fmt.Errorf("failed to parse input file %q: %w", input, err)
+ }
+
+ switch o := object.(type) {
+ case []any:
+ var ret []map[string]any
+ for _, arrayElement := range o {
+ if m, ok := arrayElement.(map[string]any); ok {
+ ret = append(ret, m)
+ } else {
+ return nil, fmt.Errorf("unknown JSON type in array %T", arrayElement)
+ }
+ }
+ return ret, nil
+
+ case map[string]any:
+ return []map[string]any{o}, nil
+ }
+
+ return nil, fmt.Errorf("unknown JSON type %T", object)
+}
+
+func combine(old, new any) any {
+ // fmt.Printf("%#v %#v\n", old, new)
+ switch oldTyped := old.(type) {
+ case map[string]any:
+ if newObject, ok := new.(map[string]any); ok {
+ return combineObjects(oldTyped, newObject)
+ } else {
+ panic(fmt.Errorf("expected map[string]any, got %#v", new))
+ }
+ case []any:
+ if newArray, ok := new.([]any); ok {
+ return combineArrays(oldTyped, newArray)
+ } else {
+ panic(fmt.Errorf("expected []any, got %#v", new))
+ }
+ case string:
+ if newString, ok := new.(string); ok {
+ if oldTyped != newString {
+ panic(fmt.Errorf("strings %q and %q don't match", oldTyped, newString))
+ }
+ return oldTyped
+ } else {
+ panic(fmt.Errorf("expected []any, got %#v", new))
+ }
+ default:
+ panic(fmt.Errorf("can't combine type %T", old))
+ }
+}
+
+func combineObjects(old, new map[string]any) map[string]any {
+ for k, newField := range new {
+ // HACK: Don't merge "test_config" field. This matches the behavior in base_rules.mk that overwrites
+ // instead of appending ALL_MODULES.$(my_register_name).TEST_CONFIG, keeping the
+ if k == "test_config" {
+ old[k] = newField
+ continue
+ }
+ if oldField, exists := old[k]; exists {
+ oldField = combine(oldField, newField)
+ old[k] = oldField
+ } else {
+ old[k] = newField
+ }
+ }
+
+ return old
+}
+
+func combineArrays(old, new []any) []any {
+ containsNonStrings := false
+ for _, oldElement := range old {
+ switch oldElement.(type) {
+ case string:
+ default:
+ containsNonStrings = true
+ }
+ }
+ for _, newElement := range new {
+ found := false
+ for _, oldElement := range old {
+ if oldElement == newElement {
+ found = true
+ break
+ }
+ }
+ if !found {
+ switch newElement.(type) {
+ case string:
+ default:
+ containsNonStrings = true
+ }
+ old = append(old, newElement)
+ }
+ }
+ if !containsNonStrings {
+ slices.SortFunc(old, func(a, b any) int {
+ return cmp.Compare(a.(string), b.(string))
+ })
+ }
+ return old
+}
diff --git a/cmd/merge_module_info_json/merge_module_info_json_test.go b/cmd/merge_module_info_json/merge_module_info_json_test.go
new file mode 100644
index 0000000..dbf1aa1
--- /dev/null
+++ b/cmd/merge_module_info_json/merge_module_info_json_test.go
@@ -0,0 +1,58 @@
+// Copyright 2021 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 main
+
+import (
+ "reflect"
+ "testing"
+)
+
+func Test_combine(t *testing.T) {
+ tests := []struct {
+ name string
+ old any
+ new any
+ want any
+ }{
+ {
+ name: "objects",
+ old: map[string]any{
+ "foo": "bar",
+ "baz": []any{"a"},
+ },
+ new: map[string]any{
+ "foo": "bar",
+ "baz": []any{"b"},
+ },
+ want: map[string]any{
+ "foo": "bar",
+ "baz": []any{"a", "b"},
+ },
+ },
+ {
+ name: "arrays",
+ old: []any{"foo", "bar"},
+ new: []any{"foo", "baz"},
+ want: []any{"bar", "baz", "foo"},
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ if got := combine(tt.old, tt.new); !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("combine() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index 7742492..4727566 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -28,6 +28,7 @@
"android/soong/android/allowlists"
"android/soong/bp2build"
"android/soong/shared"
+
"github.com/google/blueprint"
"github.com/google/blueprint/bootstrap"
"github.com/google/blueprint/deptools"
@@ -196,7 +197,7 @@
ctx.Context.PrintJSONGraphAndActions(graphFile, actionsFile)
}
-func writeBuildGlobsNinjaFile(ctx *android.Context) []string {
+func writeBuildGlobsNinjaFile(ctx *android.Context) {
ctx.EventHandler.Begin("globs_ninja_file")
defer ctx.EventHandler.End("globs_ninja_file")
@@ -208,7 +209,6 @@
SrcDir: ctx.SrcDir(),
}, ctx.Config())
maybeQuit(err, "")
- return bootstrap.GlobFileListFiles(globDir)
}
func writeDepFile(outputFile string, eventHandler *metrics.EventHandler, ninjaDeps []string) {
@@ -238,8 +238,7 @@
maybeQuit(err, "")
ninjaDeps = append(ninjaDeps, extraNinjaDeps...)
- globListFiles := writeBuildGlobsNinjaFile(ctx)
- ninjaDeps = append(ninjaDeps, globListFiles...)
+ writeBuildGlobsNinjaFile(ctx)
// Convert the Soong module graph into Bazel BUILD files.
switch ctx.Config().BuildMode {
diff --git a/docs/map_files.md b/docs/map_files.md
index 35e8cbb..37f91ec 100644
--- a/docs/map_files.md
+++ b/docs/map_files.md
@@ -134,6 +134,9 @@
Historically this annotation was spelled `vndk`, but it has always meant LL-NDK.
+When an llndk API is deprecated, the `llndk` tag is dropped and
+`llndk-deprecate=<V>` is added.
+
### platform-only
Indicates that the version or symbol is public in the implementation library but
diff --git a/java/Android.bp b/java/Android.bp
index 79cd3f9..2585cd2 100644
--- a/java/Android.bp
+++ b/java/Android.bp
@@ -108,8 +108,9 @@
"prebuilt_apis_test.go",
"proto_test.go",
"rro_test.go",
- "sdk_test.go",
"sdk_library_test.go",
+ "sdk_test.go",
+ "sdk_version_test.go",
"system_modules_test.go",
"systemserver_classpath_fragment_test.go",
"test_spec_test.go",
diff --git a/java/aar.go b/java/aar.go
index 2ad8fdf..eb07e0f 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -544,7 +544,7 @@
if a.useResourceProcessorBusyBox() {
rJar := android.PathForModuleOut(ctx, "busybox/R.jar")
- resourceProcessorBusyBoxGenerateBinaryR(ctx, rTxt, a.mergedManifestFile, rJar, staticDeps, a.isLibrary)
+ resourceProcessorBusyBoxGenerateBinaryR(ctx, rTxt, a.mergedManifestFile, rJar, staticDeps, a.isLibrary, a.aaptProperties.Aaptflags)
aapt2ExtractExtraPackages(ctx, extraPackages, rJar)
transitiveRJars = append(transitiveRJars, rJar)
a.rJar = rJar
@@ -604,7 +604,7 @@
// using Bazel's ResourceProcessorBusyBox tool, which is faster than compiling the R.java files and
// supports producing classes for static dependencies that only include resources from that dependency.
func resourceProcessorBusyBoxGenerateBinaryR(ctx android.ModuleContext, rTxt, manifest android.Path,
- rJar android.WritablePath, transitiveDeps transitiveAarDeps, isLibrary bool) {
+ rJar android.WritablePath, transitiveDeps transitiveAarDeps, isLibrary bool, aaptFlags []string) {
var args []string
var deps android.Paths
@@ -621,6 +621,17 @@
args = append(args, "--finalFields=false")
}
+ for i, arg := range aaptFlags {
+ const AAPT_CUSTOM_PACKAGE = "--custom-package"
+ if strings.HasPrefix(arg, AAPT_CUSTOM_PACKAGE) {
+ pkg := strings.TrimSpace(strings.TrimPrefix(arg, AAPT_CUSTOM_PACKAGE))
+ if pkg == "" && i+1 < len(aaptFlags) {
+ pkg = aaptFlags[i+1]
+ }
+ args = append(args, "--packageForR "+pkg)
+ }
+ }
+
deps = append(deps, rTxt, manifest)
ctx.Build(pctx, android.BuildParams{
@@ -1194,7 +1205,7 @@
linkFlags, linkDeps, nil, overlayRes, transitiveAssets, nil, nil)
a.rJar = android.PathForModuleOut(ctx, "busybox/R.jar")
- resourceProcessorBusyBoxGenerateBinaryR(ctx, a.rTxt, a.manifest, a.rJar, nil, true)
+ resourceProcessorBusyBoxGenerateBinaryR(ctx, a.rTxt, a.manifest, a.rJar, nil, true, nil)
aapt2ExtractExtraPackages(ctx, a.extraAaptPackagesFile, a.rJar)
diff --git a/java/app_test.go b/java/app_test.go
index 861c047..3ee94d5 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -2109,7 +2109,7 @@
Output("libjni.so").Output.String()
sdkJNI := ctx.ModuleForTests("libjni", "android_arm64_armv8-a_sdk_shared").
Output("libjni.so").Output.String()
- vendorJNI := ctx.ModuleForTests("libvendorjni", "android_arm64_armv8-a_shared").
+ vendorJNI := ctx.ModuleForTests("libvendorjni", "android_vendor_arm64_armv8-a_shared").
Output("libvendorjni.so").Output.String()
for _, test := range testCases {
diff --git a/java/base.go b/java/base.go
index 0d3e4db..51471ea 100644
--- a/java/base.go
+++ b/java/base.go
@@ -1644,30 +1644,11 @@
}
if ctx.Device() {
- lintSDKVersion := func(apiLevel android.ApiLevel) int {
+ lintSDKVersion := func(apiLevel android.ApiLevel) android.ApiLevel {
if !apiLevel.IsPreview() {
- return apiLevel.FinalInt()
+ return apiLevel
} else {
- // When running metalava, we pass --version-codename. When that value
- // is not REL, metalava will add 1 to the --current-version argument.
- // On old branches, PLATFORM_SDK_VERSION is the latest version (for that
- // branch) and the codename is REL, except potentially on the most
- // recent non-master branch. On that branch, it goes through two other
- // phases before it gets to the phase previously described:
- // - PLATFORM_SDK_VERSION has not been updated yet, and the codename
- // is not rel. This happens for most of the internal branch's life
- // while the branch has been cut but is still under active development.
- // - PLATFORM_SDK_VERSION has been set, but the codename is still not
- // REL. This happens briefly during the release process. During this
- // state the code to add --current-version is commented out, and then
- // that commenting out is reverted after the codename is set to REL.
- // On the master branch, the PLATFORM_SDK_VERSION always represents a
- // prior version and the codename is always non-REL.
- //
- // We need to add one here to match metalava adding 1. Technically
- // this means that in the state described in the second bullet point
- // above, this number is 1 higher than it should be.
- return ctx.Config().PlatformSdkVersion().FinalInt() + 1
+ return ctx.Config().DefaultAppTargetSdk(ctx)
}
}
diff --git a/java/builder.go b/java/builder.go
index d03c8e5..6919236 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -274,11 +274,29 @@
` cat $$f; ` +
`done > $out`,
})
+
+ gatherReleasedFlaggedApisRule = pctx.AndroidStaticRule("gatherReleasedFlaggedApisRule",
+ blueprint.RuleParams{
+ Command: `${aconfig} dump --format bool ` +
+ `--out ${out} ` +
+ `${flags_path} ` +
+ `${filter_args} `,
+ CommandDeps: []string{"${aconfig}"},
+ Description: "aconfig_bool",
+ }, "flags_path", "filter_args")
+
+ generateMetalavaRevertAnnotationsRule = pctx.AndroidStaticRule("generateMetalavaRevertAnnotationsRule",
+ blueprint.RuleParams{
+ Command: `${keep-flagged-apis} ${in} > ${out}`,
+ })
)
func init() {
pctx.Import("android/soong/android")
pctx.Import("android/soong/java/config")
+
+ pctx.HostBinToolVariable("aconfig", "aconfig")
+ pctx.HostBinToolVariable("keep-flagged-apis", "keep-flagged-apis")
}
type javaBuilderFlags struct {
diff --git a/java/code_metadata_test.go b/java/code_metadata_test.go
index 509e701..0ef348a 100644
--- a/java/code_metadata_test.go
+++ b/java/code_metadata_test.go
@@ -25,12 +25,10 @@
}`
result := runCodeMetadataTest(t, android.FixtureExpectsNoErrors, bp)
- module := result.ModuleForTests(
- "module-name", "",
- ).Module().(*soongTesting.CodeMetadataModule)
+ module := result.ModuleForTests("module-name", "")
// Check that the provider has the right contents
- data, _ := android.SingletonModuleProvider(result, module, soongTesting.CodeMetadataProviderKey)
+ data, _ := android.SingletonModuleProvider(result, module.Module(), soongTesting.CodeMetadataProviderKey)
if !strings.HasSuffix(
data.IntermediatePath.String(), "/intermediateCodeMetadata.pb",
) {
@@ -40,13 +38,8 @@
)
}
- buildParamsSlice := module.BuildParamsForTests()
- var metadata = ""
- for _, params := range buildParamsSlice {
- if params.Rule.String() == "android/soong/android.writeFile" {
- metadata = params.Args["content"]
- }
- }
+ metadata := android.ContentFromFileRuleForTests(t, result.TestContext,
+ module.Output(data.IntermediatePath.String()))
metadataList := make([]*code_metadata_internal_proto.CodeMetadataInternal_TargetOwnership, 0, 2)
teamId := "12345"
@@ -63,9 +56,7 @@
CodeMetadataMetadata := code_metadata_internal_proto.CodeMetadataInternal{TargetOwnershipList: metadataList}
protoData, _ := proto.Marshal(&CodeMetadataMetadata)
- rawData := string(protoData)
- formattedData := strings.ReplaceAll(rawData, "\n", "\\n")
- expectedMetadata := "'" + formattedData + "\\n'"
+ expectedMetadata := string(protoData)
if metadata != expectedMetadata {
t.Errorf(
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index 73609bf..82cece3 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -699,28 +699,40 @@
// extractEncodedDexJarsFromModulesOrBootclasspathFragments gets the hidden API encoded dex jars for
// the given modules.
func extractEncodedDexJarsFromModulesOrBootclasspathFragments(ctx android.ModuleContext, apexJarModulePairs []apexJarModulePair) bootDexJarByModule {
- apexNameToBcpInfoMap := getApexNameToBcpInfoMap(ctx)
+ apexNameToApexExportInfoMap := getApexNameToApexExportsInfoMap(ctx)
encodedDexJarsByModuleName := bootDexJarByModule{}
for _, pair := range apexJarModulePairs {
- dexJarPath := getDexJarForApex(ctx, pair, apexNameToBcpInfoMap)
+ dexJarPath := getDexJarForApex(ctx, pair, apexNameToApexExportInfoMap)
encodedDexJarsByModuleName.addPath(pair.jarModule, dexJarPath)
}
return encodedDexJarsByModuleName
}
+type apexNameToApexExportsInfoMap map[string]android.ApexExportsInfo
+
+// javaLibraryPathOnHost returns the path to the java library which is exported by the apex for hiddenapi and dexpreopt and a boolean indicating whether the java library exists
+// For prebuilt apexes, this is created by deapexing the prebuilt apex
+func (m *apexNameToApexExportsInfoMap) javaLibraryDexPathOnHost(ctx android.ModuleContext, apex string, javalib string) (android.Path, bool) {
+ if info, exists := (*m)[apex]; exists {
+ if dex, exists := info.LibraryNameToDexJarPathOnHost[javalib]; exists {
+ return dex, true
+ } else {
+ ctx.ModuleErrorf("Apex %s does not provide a dex boot jar for library %s\n", apex, javalib)
+ }
+ }
+ // An apex entry could not be found. Return false.
+ // TODO: b/308174306 - When all the mainline modules have been flagged, make this a hard error
+ return nil, false
+}
+
// Returns the java libraries exported by the apex for hiddenapi and dexpreopt
// This information can come from two mechanisms
// 1. New: Direct deps to _selected_ apexes. The apexes return a ApexExportsInfo
// 2. Legacy: An edge to java_library or java_import (java_sdk_library) module. For prebuilt apexes, this serves as a hook and is populated by deapexers of prebuilt apxes
// TODO: b/308174306 - Once all mainline modules have been flagged, drop (2)
-func getDexJarForApex(ctx android.ModuleContext, pair apexJarModulePair, apexNameToBcpInfoMap map[string]android.ApexExportsInfo) android.Path {
- if info, exists := apexNameToBcpInfoMap[pair.apex]; exists {
- libraryName := android.RemoveOptionalPrebuiltPrefix(pair.jarModule.Name())
- if dex, exists := info.LibraryNameToDexJarPathOnHost[libraryName]; exists {
- return dex
- } else {
- ctx.ModuleErrorf("Apex %s does not provide a dex boot jar for library %s\n", pair.apex, libraryName)
- }
+func getDexJarForApex(ctx android.ModuleContext, pair apexJarModulePair, apexNameToApexExportsInfoMap apexNameToApexExportsInfoMap) android.Path {
+ if dex, found := apexNameToApexExportsInfoMap.javaLibraryDexPathOnHost(ctx, pair.apex, android.RemoveOptionalPrebuiltPrefix(pair.jarModule.Name())); found {
+ return dex
}
// TODO: b/308174306 - Remove the legacy mechanism
if android.IsConfiguredJarForPlatform(pair.apex) || android.IsModulePrebuilt(pair.jarModule) {
@@ -900,14 +912,14 @@
return fragment.(commonBootclasspathFragment).getProfilePath()
}
-func getApexNameToBcpInfoMap(ctx android.ModuleContext) map[string]android.ApexExportsInfo {
- apexNameToBcpInfoMap := map[string]android.ApexExportsInfo{}
+func getApexNameToApexExportsInfoMap(ctx android.ModuleContext) apexNameToApexExportsInfoMap {
+ apexNameToApexExportsInfoMap := apexNameToApexExportsInfoMap{}
ctx.VisitDirectDepsWithTag(dexpreoptBootJarDepTag, func(am android.Module) {
if info, exists := android.OtherModuleProvider(ctx, am, android.ApexExportsInfoProvider); exists {
- apexNameToBcpInfoMap[info.ApexName] = info
+ apexNameToApexExportsInfoMap[info.ApexName] = info
}
})
- return apexNameToBcpInfoMap
+ return apexNameToApexExportsInfoMap
}
// Generate boot image build rules for a specific target.
@@ -952,7 +964,7 @@
invocationPath := outputPath.ReplaceExtension(ctx, "invocation")
- apexNameToBcpInfoMap := getApexNameToBcpInfoMap(ctx)
+ apexNameToApexExportsInfoMap := getApexNameToApexExportsInfoMap(ctx)
cmd.Tool(globalSoong.Dex2oat).
Flag("--avoid-storing-invocation").
@@ -966,7 +978,7 @@
}
for _, apex := range image.profileImports {
- importedProfile := getProfilePathForApex(ctx, apex, apexNameToBcpInfoMap)
+ importedProfile := getProfilePathForApex(ctx, apex, apexNameToApexExportsInfoMap)
if importedProfile == nil {
ctx.ModuleErrorf("Boot image config '%[1]s' imports profile from '%[2]s', but '%[2]s' "+
"doesn't provide a profile",
diff --git a/java/droiddoc.go b/java/droiddoc.go
index 138c9c3..7a61034 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -208,6 +208,8 @@
docZip android.WritablePath
stubsSrcJar android.WritablePath
+
+ exportableStubsSrcJar android.WritablePath
}
func (j *Javadoc) OutputFiles(tag string) (android.Paths, error) {
@@ -397,6 +399,15 @@
sm := module.(SystemModulesProvider)
outputDir, outputDeps := sm.OutputDirAndDeps()
deps.systemModules = &systemModules{outputDir, outputDeps}
+ case aconfigDeclarationTag:
+ if dep, ok := android.OtherModuleProvider(ctx, module, android.AconfigDeclarationsProviderKey); ok {
+ deps.aconfigProtoFiles = append(deps.aconfigProtoFiles, dep.IntermediateCacheOutputPath)
+ } else {
+ ctx.ModuleErrorf("Only aconfig_declarations module type is allowed for "+
+ "flags_packages property, but %s is not aconfig_declarations module type",
+ module.Name(),
+ )
+ }
}
})
// do not pass exclude_srcs directly when expanding srcFiles since exclude_srcs
diff --git a/java/droidstubs.go b/java/droidstubs.go
index e7ccc1b..bdbaf92 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -30,6 +30,28 @@
// The values allowed for Droidstubs' Api_levels_sdk_type
var allowedApiLevelSdkTypes = []string{"public", "system", "module-lib", "system-server"}
+type StubsType int
+
+const (
+ Everything StubsType = iota
+ Runtime
+ Exportable
+ Unavailable
+)
+
+func (s StubsType) String() string {
+ switch s {
+ case Everything:
+ return "everything"
+ case Runtime:
+ return "runtime"
+ case Exportable:
+ return "exportable"
+ default:
+ return ""
+ }
+}
+
func init() {
RegisterStubsBuildComponents(android.InitRegistrationContext)
}
@@ -66,6 +88,14 @@
metadataZip android.WritablePath
metadataDir android.WritablePath
+
+ exportableApiFile android.WritablePath
+ exportableRemovedApiFile android.WritablePath
+ exportableNullabilityWarningsFile android.WritablePath
+ exportableAnnotationsZip android.WritablePath
+ exportableApiVersionsXml android.WritablePath
+ exportableMetadataZip android.WritablePath
+ exportableMetadataDir android.WritablePath
}
type DroidstubsProperties struct {
@@ -151,6 +181,10 @@
// API surface of this module. If set, the module contributes to an API surface.
// For the full list of available API surfaces, refer to soong/android/sdk_version.go
Api_surface *string
+
+ // a list of aconfig_declarations module names that the stubs generated in this module
+ // depend on.
+ Aconfig_declarations []string
}
// Used by xsd_config
@@ -175,6 +209,36 @@
CurrentApiTimestamp() android.Path
}
+type annotationFlagsParams struct {
+ migratingNullability bool
+ validatingNullability bool
+ nullabilityWarningsFile android.WritablePath
+ annotationsZip android.WritablePath
+}
+type stubsCommandParams struct {
+ srcJarDir android.ModuleOutPath
+ stubsDir android.OptionalPath
+ stubsSrcJar android.WritablePath
+ metadataZip android.WritablePath
+ metadataDir android.WritablePath
+ apiVersionsXml android.WritablePath
+ nullabilityWarningsFile android.WritablePath
+ annotationsZip android.WritablePath
+ stubConfig stubsCommandConfigParams
+}
+type stubsCommandConfigParams struct {
+ stubsType StubsType
+ javaVersion javaVersion
+ deps deps
+ checkApi bool
+ generateStubs bool
+ doApiLint bool
+ doCheckReleased bool
+ writeSdkValues bool
+ migratingNullability bool
+ validatingNullability bool
+}
+
// 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.
@@ -207,21 +271,55 @@
return module
}
+func getStubsTypeAndTag(tag string) (StubsType, string, error) {
+ if len(tag) == 0 {
+ return Everything, "", nil
+ }
+ if tag[0] != '.' {
+ return Unavailable, "", fmt.Errorf("tag must begin with \".\"")
+ }
+
+ stubsType := Everything
+ // Check if the tag has a stubs type prefix (e.g. ".exportable")
+ for st := Everything; st <= Exportable; st++ {
+ if strings.HasPrefix(tag, "."+st.String()) {
+ stubsType = st
+ }
+ }
+
+ return stubsType, strings.TrimPrefix(tag, "."+stubsType.String()), nil
+}
+
+// Droidstubs' tag supports specifying with the stubs type.
+// While supporting the pre-existing tags, it also supports tags with
+// the stubs type prefix. Some examples are shown below:
+// {.annotations.zip} - pre-existing behavior. Returns the path to the
+// annotation zip.
+// {.exportable} - Returns the path to the exportable stubs src jar.
+// {.exportable.annotations.zip} - Returns the path to the exportable
+// annotations zip file.
+// {.runtime.api_versions.xml} - Runtime stubs does not generate api versions
+// xml file. For unsupported combinations, the default everything output file
+// is returned.
func (d *Droidstubs) OutputFiles(tag string) (android.Paths, error) {
- switch tag {
+ stubsType, prefixRemovedTag, err := getStubsTypeAndTag(tag)
+ if err != nil {
+ return nil, err
+ }
+ switch prefixRemovedTag {
case "":
- return android.Paths{d.stubsSrcJar}, nil
+ return d.StubsSrcJarWithStubsType(stubsType)
case ".docs.zip":
- return android.Paths{d.docZip}, nil
+ return d.DocZipWithStubsType(stubsType)
case ".api.txt", android.DefaultDistTag:
// This is the default dist path for dist properties that have no tag property.
- return android.Paths{d.apiFile}, nil
+ return d.ApiFilePathWithStubsType(stubsType)
case ".removed-api.txt":
- return android.Paths{d.removedApiFile}, nil
+ return d.RemovedApiFilePathWithStubsType(stubsType)
case ".annotations.zip":
- return android.Paths{d.annotationsZip}, nil
+ return d.AnnotationsZipWithStubsType(stubsType)
case ".api_versions.xml":
- return android.Paths{d.apiVersionsXml}, nil
+ return d.ApiVersionsXmlFilePathWithStubsType(stubsType)
default:
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
}
@@ -231,18 +329,96 @@
return d.annotationsZip
}
+func (d *Droidstubs) ExportableAnnotationsZip() android.Path {
+ return d.exportableAnnotationsZip
+}
+
+func (d *Droidstubs) AnnotationsZipWithStubsType(stubsType StubsType) (android.Paths, error) {
+ switch stubsType {
+ case Everything:
+ return android.Paths{d.AnnotationsZip()}, nil
+ case Exportable:
+ return android.Paths{d.ExportableAnnotationsZip()}, nil
+ default:
+ return nil, fmt.Errorf("annotations zip not supported for the stub type %s", stubsType.String())
+ }
+}
+
func (d *Droidstubs) ApiFilePath() android.Path {
return d.apiFile
}
+func (d *Droidstubs) ExportableApiFilePath() android.Path {
+ return d.exportableApiFile
+}
+
+func (d *Droidstubs) ApiFilePathWithStubsType(stubsType StubsType) (android.Paths, error) {
+ switch stubsType {
+ case Everything:
+ return android.Paths{d.ApiFilePath()}, nil
+ case Exportable:
+ return android.Paths{d.ExportableApiFilePath()}, nil
+ default:
+ return nil, fmt.Errorf("api file path not supported for the stub type %s", stubsType.String())
+ }
+}
+
+func (d *Droidstubs) ApiVersionsXmlFilePathWithStubsType(stubsType StubsType) (android.Paths, error) {
+ switch stubsType {
+ case Everything:
+ return android.Paths{d.apiVersionsXml}, nil
+ default:
+ return nil, fmt.Errorf("api versions xml file path not supported for the stub type %s", stubsType.String())
+ }
+}
+
+func (d *Droidstubs) DocZipWithStubsType(stubsType StubsType) (android.Paths, error) {
+ switch stubsType {
+ case Everything:
+ return android.Paths{d.docZip}, nil
+ default:
+ return nil, fmt.Errorf("docs zip not supported for the stub type %s", stubsType.String())
+ }
+}
+
func (d *Droidstubs) RemovedApiFilePath() android.Path {
return d.removedApiFile
}
+func (d *Droidstubs) ExportableRemovedApiFilePath() android.Path {
+ return d.exportableRemovedApiFile
+}
+
+func (d *Droidstubs) RemovedApiFilePathWithStubsType(stubsType StubsType) (android.Paths, error) {
+ switch stubsType {
+ case Everything:
+ return android.Paths{d.RemovedApiFilePath()}, nil
+ case Exportable:
+ return android.Paths{d.ExportableRemovedApiFilePath()}, nil
+ default:
+ return nil, fmt.Errorf("removed api file path not supported for the stub type %s", stubsType.String())
+ }
+}
+
func (d *Droidstubs) StubsSrcJar() android.Path {
return d.stubsSrcJar
}
+func (d *Droidstubs) ExportableStubsSrcJar() android.Path {
+ return d.exportableStubsSrcJar
+}
+
+func (d *Droidstubs) StubsSrcJarWithStubsType(stubsType StubsType) (android.Paths, error) {
+ switch stubsType {
+ case Everything:
+ return android.Paths{d.StubsSrcJar()}, nil
+ case Exportable:
+ return android.Paths{d.ExportableStubsSrcJar()}, nil
+ default:
+ return nil, fmt.Errorf("stubs srcjar not supported for the stub type %s", stubsType.String())
+ }
+}
+
func (d *Droidstubs) CurrentApiTimestamp() android.Path {
return d.checkCurrentApiTimestamp
}
@@ -274,41 +450,52 @@
}
}
+ if len(d.properties.Aconfig_declarations) != 0 {
+ for _, aconfigDeclarationModuleName := range d.properties.Aconfig_declarations {
+ ctx.AddDependency(ctx.Module(), aconfigDeclarationTag, aconfigDeclarationModuleName)
+ }
+ }
+
if d.properties.Api_levels_module != nil {
ctx.AddDependency(ctx.Module(), metalavaAPILevelsModuleTag, proptools.String(d.properties.Api_levels_module))
}
}
-func (d *Droidstubs) stubsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsDir android.OptionalPath) {
- if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") ||
- apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released") ||
- String(d.properties.Api_filename) != "" {
+func (d *Droidstubs) sdkValuesFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, metadataDir android.WritablePath) {
+ cmd.FlagWithArg("--sdk-values ", metadataDir.String())
+}
+
+func (d *Droidstubs) stubsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsDir android.OptionalPath, stubsType StubsType, checkApi bool) {
+ if checkApi || String(d.properties.Api_filename) != "" {
filename := proptools.StringDefault(d.properties.Api_filename, ctx.ModuleName()+"_api.txt")
- uncheckedApiFile := android.PathForModuleOut(ctx, "metalava", filename)
+ uncheckedApiFile := android.PathForModuleOut(ctx, stubsType.String(), filename)
cmd.FlagWithOutput("--api ", uncheckedApiFile)
- d.apiFile = uncheckedApiFile
+
+ if stubsType == Everything {
+ d.apiFile = uncheckedApiFile
+ } else if stubsType == Exportable {
+ d.exportableApiFile = uncheckedApiFile
+ }
} else if sourceApiFile := proptools.String(d.properties.Check_api.Current.Api_file); sourceApiFile != "" {
// If check api is disabled then make the source file available for export.
d.apiFile = android.PathForModuleSrc(ctx, sourceApiFile)
}
- if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") ||
- apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released") ||
- String(d.properties.Removed_api_filename) != "" {
+ if checkApi || String(d.properties.Removed_api_filename) != "" {
filename := proptools.StringDefault(d.properties.Removed_api_filename, ctx.ModuleName()+"_removed.txt")
- uncheckedRemovedFile := android.PathForModuleOut(ctx, "metalava", filename)
+ uncheckedRemovedFile := android.PathForModuleOut(ctx, stubsType.String(), filename)
cmd.FlagWithOutput("--removed-api ", uncheckedRemovedFile)
- d.removedApiFile = uncheckedRemovedFile
+
+ if stubsType == Everything {
+ d.removedApiFile = uncheckedRemovedFile
+ } else if stubsType == Exportable {
+ d.exportableRemovedApiFile = uncheckedRemovedFile
+ }
} else if sourceRemovedApiFile := proptools.String(d.properties.Check_api.Current.Removed_api_file); sourceRemovedApiFile != "" {
// If check api is disabled then make the source removed api file available for export.
d.removedApiFile = android.PathForModuleSrc(ctx, sourceRemovedApiFile)
}
- if Bool(d.properties.Write_sdk_values) {
- d.metadataDir = android.PathForModuleOut(ctx, "metalava", "metadata")
- cmd.FlagWithArg("--sdk-values ", d.metadataDir.String())
- }
-
if stubsDir.Valid() {
if Bool(d.properties.Create_doc_stubs) {
cmd.FlagWithArg("--doc-stubs ", stubsDir.String())
@@ -321,16 +508,11 @@
}
}
-func (d *Droidstubs) annotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
+func (d *Droidstubs) annotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, params annotationFlagsParams) {
if Bool(d.properties.Annotations_enabled) {
cmd.Flag(config.MetalavaAnnotationsFlags)
- validatingNullability :=
- strings.Contains(String(d.Javadoc.properties.Args), "--validate-nullability-from-merged-stubs") ||
- String(d.properties.Validate_nullability_from_list) != ""
-
- migratingNullability := String(d.properties.Previous_api) != ""
- if migratingNullability {
+ if params.migratingNullability {
previousApi := android.PathForModuleSrc(ctx, String(d.properties.Previous_api))
cmd.FlagWithInput("--migrate-nullness ", previousApi)
}
@@ -339,13 +521,11 @@
cmd.FlagWithInput("--validate-nullability-from-list ", android.PathForModuleSrc(ctx, s))
}
- if validatingNullability {
- d.nullabilityWarningsFile = android.PathForModuleOut(ctx, "metalava", ctx.ModuleName()+"_nullability_warnings.txt")
- cmd.FlagWithOutput("--nullability-warnings-txt ", d.nullabilityWarningsFile)
+ if params.validatingNullability {
+ cmd.FlagWithOutput("--nullability-warnings-txt ", params.nullabilityWarningsFile)
}
- d.annotationsZip = android.PathForModuleOut(ctx, "metalava", ctx.ModuleName()+"_annotations.zip")
- cmd.FlagWithOutput("--extract-annotations ", d.annotationsZip)
+ cmd.FlagWithOutput("--extract-annotations ", params.annotationsZip)
if len(d.properties.Merge_annotations_dirs) != 0 {
d.mergeAnnoDirFlags(ctx, cmd)
@@ -377,10 +557,10 @@
})
}
-func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
+func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsType StubsType, apiVersionsXml android.WritablePath) {
var apiVersions android.Path
if proptools.Bool(d.properties.Api_levels_annotations_enabled) {
- d.apiLevelsGenerationFlags(ctx, cmd)
+ d.apiLevelsGenerationFlags(ctx, cmd, stubsType, apiVersionsXml)
apiVersions = d.apiVersionsXml
} else {
ctx.VisitDirectDepsWithTag(metalavaAPILevelsModuleTag, func(m android.Module) {
@@ -399,14 +579,13 @@
}
}
-func (d *Droidstubs) apiLevelsGenerationFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
+func (d *Droidstubs) apiLevelsGenerationFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsType StubsType, apiVersionsXml android.WritablePath) {
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!")
}
- d.apiVersionsXml = android.PathForModuleOut(ctx, "metalava", "api-versions.xml")
- cmd.FlagWithOutput("--generate-api-levels ", d.apiVersionsXml)
+ cmd.FlagWithOutput("--generate-api-levels ", apiVersionsXml)
filename := proptools.StringDefault(d.properties.Api_levels_jar_filename, "android.jar")
@@ -538,47 +717,91 @@
return cmd
}
-func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- deps := d.Javadoc.collectDeps(ctx)
+// Pass flagged apis related flags to metalava. When aconfig_declarations property is not
+// defined for a module, simply revert all flagged apis annotations. If aconfig_declarations
+// property is defined, apply transformations and only revert the flagged apis that are not
+// enabled via release configurations and are not specified in aconfig_declarations
+func (d *Droidstubs) generateRevertAnnotationArgs(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsType StubsType, aconfigFlagsPaths android.Paths) {
- javaVersion := getJavaVersion(ctx, String(d.Javadoc.properties.Java_version), android.SdkContext(d))
+ if len(aconfigFlagsPaths) == 0 {
+ cmd.Flag("--revert-annotation android.annotation.FlaggedApi")
+ return
+ }
- // Create rule for metalava
+ releasedFlaggedApisFile := android.PathForModuleOut(ctx, fmt.Sprintf("released-flagged-apis-%s.txt", stubsType.String()))
+ revertAnnotationsFile := android.PathForModuleOut(ctx, fmt.Sprintf("revert-annotations-%s.txt", stubsType.String()))
- srcJarDir := android.PathForModuleOut(ctx, "metalava", "srcjars")
+ var filterArgs string
+ switch stubsType {
+ // No flagged apis specific flags need to be passed to metalava when generating
+ // everything stubs
+ case Everything:
+ return
- rule := android.NewRuleBuilder(pctx, ctx)
+ case Runtime:
+ filterArgs = "--filter='state:ENABLED+permission:READ_ONLY' --filter='permission:READ_WRITE'"
- rule.Sbox(android.PathForModuleOut(ctx, "metalava"),
- android.PathForModuleOut(ctx, "metalava.sbox.textproto")).
- SandboxInputs()
+ case Exportable:
+ filterArgs = "--filter='state:ENABLED+permission:READ_ONLY'"
+ }
+
+ ctx.Build(pctx, android.BuildParams{
+ Rule: gatherReleasedFlaggedApisRule,
+ Inputs: aconfigFlagsPaths,
+ Output: releasedFlaggedApisFile,
+ Description: fmt.Sprintf("%s gather aconfig flags", stubsType),
+ Args: map[string]string{
+ "flags_path": android.JoinPathsWithPrefix(aconfigFlagsPaths, "--cache "),
+ "filter_args": filterArgs,
+ },
+ })
+
+ ctx.Build(pctx, android.BuildParams{
+ Rule: generateMetalavaRevertAnnotationsRule,
+ Input: releasedFlaggedApisFile,
+ Output: revertAnnotationsFile,
+ Description: fmt.Sprintf("%s revert annotations", stubsType),
+ })
+
+ cmd.FlagWithInput("@", revertAnnotationsFile)
+}
+
+func (d *Droidstubs) commonMetalavaStubCmd(ctx android.ModuleContext, rule *android.RuleBuilder,
+ params stubsCommandParams) *android.RuleBuilderCommand {
if BoolDefault(d.properties.High_mem, false) {
// This metalava run uses lots of memory, restrict the number of metalava jobs that can run in parallel.
rule.HighMem()
}
- generateStubs := BoolDefault(d.properties.Generate_stubs, true)
- var stubsDir android.OptionalPath
- if generateStubs {
- d.Javadoc.stubsSrcJar = android.PathForModuleOut(ctx, "metalava", ctx.ModuleName()+"-"+"stubs.srcjar")
- stubsDir = android.OptionalPathForPath(android.PathForModuleOut(ctx, "metalava", "stubsDir"))
- rule.Command().Text("rm -rf").Text(stubsDir.String())
- rule.Command().Text("mkdir -p").Text(stubsDir.String())
+ if params.stubConfig.generateStubs {
+ rule.Command().Text("rm -rf").Text(params.stubsDir.String())
+ rule.Command().Text("mkdir -p").Text(params.stubsDir.String())
}
- srcJarList := zipSyncCmd(ctx, rule, srcJarDir, d.Javadoc.srcJars)
+ srcJarList := zipSyncCmd(ctx, rule, params.srcJarDir, d.Javadoc.srcJars)
- homeDir := android.PathForModuleOut(ctx, "metalava", "home")
- cmd := metalavaCmd(ctx, rule, javaVersion, d.Javadoc.srcFiles, srcJarList,
- deps.bootClasspath, deps.classpath, homeDir)
+ homeDir := android.PathForModuleOut(ctx, params.stubConfig.stubsType.String(), "home")
+ cmd := metalavaCmd(ctx, rule, params.stubConfig.javaVersion, d.Javadoc.srcFiles, srcJarList,
+ params.stubConfig.deps.bootClasspath, params.stubConfig.deps.classpath, homeDir)
cmd.Implicits(d.Javadoc.implicits)
- d.stubsFlags(ctx, cmd, stubsDir)
+ d.stubsFlags(ctx, cmd, params.stubsDir, params.stubConfig.stubsType, params.stubConfig.checkApi)
- d.annotationsFlags(ctx, cmd)
+ if params.stubConfig.writeSdkValues {
+ d.sdkValuesFlags(ctx, cmd, params.metadataDir)
+ }
+
+ annotationParams := annotationFlagsParams{
+ migratingNullability: params.stubConfig.migratingNullability,
+ validatingNullability: params.stubConfig.validatingNullability,
+ nullabilityWarningsFile: params.nullabilityWarningsFile,
+ annotationsZip: params.annotationsZip,
+ }
+
+ d.annotationsFlags(ctx, cmd, annotationParams)
d.inclusionAnnotationsFlags(ctx, cmd)
- d.apiLevelsAnnotationsFlags(ctx, cmd)
+ d.apiLevelsAnnotationsFlags(ctx, cmd, params.stubConfig.stubsType, params.apiVersionsXml)
d.expandArgs(ctx, cmd)
@@ -586,24 +809,105 @@
cmd.ImplicitOutput(android.PathForModuleGen(ctx, o))
}
- // Add options for the other optional tasks: API-lint and check-released.
- // We generate separate timestamp files for them.
+ return cmd
+}
- doApiLint := false
- doCheckReleased := false
+// Sandbox rule for generating the everything stubs and other artifacts
+func (d *Droidstubs) everythingStubCmd(ctx android.ModuleContext, params stubsCommandConfigParams) {
+ srcJarDir := android.PathForModuleOut(ctx, Everything.String(), "srcjars")
+ rule := android.NewRuleBuilder(pctx, ctx)
+ rule.Sbox(android.PathForModuleOut(ctx, Everything.String()),
+ android.PathForModuleOut(ctx, "metalava.sbox.textproto")).
+ SandboxInputs()
+
+ var stubsDir android.OptionalPath
+ if params.generateStubs {
+ stubsDir = android.OptionalPathForPath(android.PathForModuleOut(ctx, Everything.String(), "stubsDir"))
+ d.Javadoc.stubsSrcJar = android.PathForModuleOut(ctx, Everything.String(), ctx.ModuleName()+"-"+"stubs.srcjar")
+ }
+
+ if params.writeSdkValues {
+ d.metadataDir = android.PathForModuleOut(ctx, Everything.String(), "metadata")
+ d.metadataZip = android.PathForModuleOut(ctx, Everything.String(), ctx.ModuleName()+"-metadata.zip")
+ }
+
+ if Bool(d.properties.Annotations_enabled) {
+ if params.validatingNullability {
+ d.nullabilityWarningsFile = android.PathForModuleOut(ctx, Everything.String(), ctx.ModuleName()+"_nullability_warnings.txt")
+ }
+ d.annotationsZip = android.PathForModuleOut(ctx, Everything.String(), ctx.ModuleName()+"_annotations.zip")
+ }
+ if Bool(d.properties.Api_levels_annotations_enabled) {
+ d.apiVersionsXml = android.PathForModuleOut(ctx, Everything.String(), "api-versions.xml")
+ }
+
+ commonCmdParams := stubsCommandParams{
+ srcJarDir: srcJarDir,
+ stubsDir: stubsDir,
+ stubsSrcJar: d.Javadoc.stubsSrcJar,
+ metadataDir: d.metadataDir,
+ apiVersionsXml: d.apiVersionsXml,
+ nullabilityWarningsFile: d.nullabilityWarningsFile,
+ annotationsZip: d.annotationsZip,
+ stubConfig: params,
+ }
+
+ cmd := d.commonMetalavaStubCmd(ctx, rule, commonCmdParams)
+
+ d.everythingOptionalCmd(ctx, cmd, params.doApiLint, params.doCheckReleased)
+
+ if params.generateStubs {
+ rule.Command().
+ BuiltTool("soong_zip").
+ Flag("-write_if_changed").
+ Flag("-jar").
+ FlagWithOutput("-o ", d.Javadoc.stubsSrcJar).
+ FlagWithArg("-C ", stubsDir.String()).
+ FlagWithArg("-D ", stubsDir.String())
+ }
+
+ if params.writeSdkValues {
+ rule.Command().
+ BuiltTool("soong_zip").
+ Flag("-write_if_changed").
+ Flag("-d").
+ FlagWithOutput("-o ", d.metadataZip).
+ FlagWithArg("-C ", d.metadataDir.String()).
+ FlagWithArg("-D ", d.metadataDir.String())
+ }
+
+ // 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 params.doApiLint {
+ rule.Command().Text("touch").Output(d.apiLintTimestamp)
+ }
+ if params.doCheckReleased {
+ rule.Command().Text("touch").Output(d.checkLastReleasedApiTimestamp)
+ }
+
+ // TODO(b/183630617): rewrapper doesn't support restat rules
+ if !metalavaUseRbe(ctx) {
+ rule.Restat()
+ }
+
+ zipSyncCleanupCmd(rule, srcJarDir)
+
+ rule.Build("metalava", "metalava merged")
+}
+
+// Sandbox rule for generating the everything artifacts that are not run by
+// default but only run based on the module configurations
+func (d *Droidstubs) everythingOptionalCmd(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, doApiLint bool, doCheckReleased bool) {
// Add API lint options.
-
- if BoolDefault(d.properties.Check_api.Api_lint.Enabled, false) {
- doApiLint = true
-
+ if doApiLint {
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")
}
- d.apiLintReport = android.PathForModuleOut(ctx, "metalava", "api_lint_report.txt")
+ d.apiLintReport = android.PathForModuleOut(ctx, Everything.String(), "api_lint_report.txt")
cmd.FlagWithOutput("--report-even-if-suppressed ", d.apiLintReport) // TODO: Change to ":api-lint"
// TODO(b/154317059): Clean up this allowlist by baselining and/or checking in last-released.
@@ -614,8 +918,8 @@
}
baselineFile := android.OptionalPathForModuleSrc(ctx, d.properties.Check_api.Api_lint.Baseline_file)
- updatedBaselineOutput := android.PathForModuleOut(ctx, "metalava", "api_lint_baseline.txt")
- d.apiLintTimestamp = android.PathForModuleOut(ctx, "metalava", "api_lint.timestamp")
+ updatedBaselineOutput := android.PathForModuleOut(ctx, Everything.String(), "api_lint_baseline.txt")
+ d.apiLintTimestamp = android.PathForModuleOut(ctx, Everything.String(), "api_lint.timestamp")
// Note this string includes a special shell quote $' ... ', which decodes the "\n"s.
//
@@ -656,10 +960,7 @@
}
// Add "check released" options. (Detect incompatible API changes from the last public release)
-
- if apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released") {
- doCheckReleased = true
-
+ if doCheckReleased {
if len(d.Javadoc.properties.Out) > 0 {
ctx.PropertyErrorf("out", "out property may not be combined with check_api")
}
@@ -667,9 +968,9 @@
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, "metalava", "last_released_baseline.txt")
+ updatedBaselineOutput := android.PathForModuleOut(ctx, Everything.String(), "last_released_baseline.txt")
- d.checkLastReleasedApiTimestamp = android.PathForModuleOut(ctx, "metalava", "check_last_released_api.timestamp")
+ d.checkLastReleasedApiTimestamp = android.PathForModuleOut(ctx, Everything.String(), "check_last_released_api.timestamp")
cmd.FlagWithInput("--check-compatibility:api:released ", apiFile)
cmd.FlagWithInput("--check-compatibility:removed:released ", removedApiFile)
@@ -694,35 +995,93 @@
currentApiFile := android.PathForModuleSrc(ctx, String(d.properties.Check_api.Current.Api_file))
cmd.FlagWithInput("--use-same-format-as ", currentApiFile)
}
+}
- if generateStubs {
+// Sandbox rule for generating exportable stubs and other artifacts
+func (d *Droidstubs) exportableStubCmd(ctx android.ModuleContext, params stubsCommandConfigParams) {
+ optionalCmdParams := stubsCommandParams{
+ stubConfig: params,
+ }
+
+ d.Javadoc.exportableStubsSrcJar = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"-"+"stubs.srcjar")
+ optionalCmdParams.stubsSrcJar = d.Javadoc.exportableStubsSrcJar
+ if params.writeSdkValues {
+ d.exportableMetadataZip = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"-metadata.zip")
+ d.exportableMetadataDir = android.PathForModuleOut(ctx, params.stubsType.String(), "metadata")
+ optionalCmdParams.metadataZip = d.exportableMetadataZip
+ optionalCmdParams.metadataDir = d.exportableMetadataDir
+ }
+
+ if Bool(d.properties.Annotations_enabled) {
+ if params.validatingNullability {
+ d.exportableNullabilityWarningsFile = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"_nullability_warnings.txt")
+ optionalCmdParams.nullabilityWarningsFile = d.exportableNullabilityWarningsFile
+ }
+ d.exportableAnnotationsZip = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"_annotations.zip")
+ optionalCmdParams.annotationsZip = d.exportableAnnotationsZip
+ }
+ if Bool(d.properties.Api_levels_annotations_enabled) {
+ d.exportableApiVersionsXml = android.PathForModuleOut(ctx, params.stubsType.String(), "api-versions.xml")
+ optionalCmdParams.apiVersionsXml = d.exportableApiVersionsXml
+ }
+
+ if params.checkApi || String(d.properties.Api_filename) != "" {
+ filename := proptools.StringDefault(d.properties.Api_filename, ctx.ModuleName()+"_api.txt")
+ d.exportableApiFile = android.PathForModuleOut(ctx, params.stubsType.String(), filename)
+ }
+
+ if params.checkApi || String(d.properties.Removed_api_filename) != "" {
+ filename := proptools.StringDefault(d.properties.Removed_api_filename, ctx.ModuleName()+"_api.txt")
+ d.exportableRemovedApiFile = android.PathForModuleOut(ctx, params.stubsType.String(), filename)
+ }
+
+ d.optionalStubCmd(ctx, optionalCmdParams)
+}
+
+func (d *Droidstubs) optionalStubCmd(ctx android.ModuleContext, params stubsCommandParams) {
+
+ params.srcJarDir = android.PathForModuleOut(ctx, params.stubConfig.stubsType.String(), "srcjars")
+ rule := android.NewRuleBuilder(pctx, ctx)
+ rule.Sbox(android.PathForModuleOut(ctx, params.stubConfig.stubsType.String()),
+ android.PathForModuleOut(ctx, fmt.Sprintf("metalava_%s.sbox.textproto", params.stubConfig.stubsType.String()))).
+ SandboxInputs()
+
+ if params.stubConfig.generateStubs {
+ params.stubsDir = android.OptionalPathForPath(android.PathForModuleOut(ctx, params.stubConfig.stubsType.String(), "stubsDir"))
+ }
+
+ cmd := d.commonMetalavaStubCmd(ctx, rule, params)
+
+ d.generateRevertAnnotationArgs(ctx, cmd, params.stubConfig.stubsType, params.stubConfig.deps.aconfigProtoFiles)
+
+ if params.stubConfig.doApiLint {
+ // Pass the lint baseline file as an input to resolve the lint errors.
+ // The exportable stubs generation does not update the lint baseline file.
+ // Lint baseline file update is handled by the everything stubs
+ baselineFile := android.OptionalPathForModuleSrc(ctx, d.properties.Check_api.Api_lint.Baseline_file)
+ if baselineFile.Valid() {
+ cmd.FlagWithInput("--baseline:api-lint ", baselineFile.Path())
+ }
+ }
+
+ if params.stubConfig.generateStubs {
rule.Command().
BuiltTool("soong_zip").
Flag("-write_if_changed").
Flag("-jar").
- FlagWithOutput("-o ", d.Javadoc.stubsSrcJar).
- FlagWithArg("-C ", stubsDir.String()).
- FlagWithArg("-D ", stubsDir.String())
+ FlagWithOutput("-o ", params.stubsSrcJar).
+ FlagWithArg("-C ", params.stubsDir.String()).
+ FlagWithArg("-D ", params.stubsDir.String())
}
- if Bool(d.properties.Write_sdk_values) {
- d.metadataZip = android.PathForModuleOut(ctx, "metalava", ctx.ModuleName()+"-metadata.zip")
+ if params.stubConfig.writeSdkValues {
rule.Command().
BuiltTool("soong_zip").
Flag("-write_if_changed").
Flag("-d").
- FlagWithOutput("-o ", d.metadataZip).
- FlagWithArg("-C ", d.metadataDir.String()).
- FlagWithArg("-D ", d.metadataDir.String())
- }
-
- // 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)
+ FlagWithOutput("-o ", params.metadataZip).
+ FlagWithArg("-C ", params.metadataDir.String()).
+ FlagWithArg("-D ", params.metadataDir.String())
}
// TODO(b/183630617): rewrapper doesn't support restat rules
@@ -730,9 +1089,53 @@
rule.Restat()
}
- zipSyncCleanupCmd(rule, srcJarDir)
+ zipSyncCleanupCmd(rule, params.srcJarDir)
- rule.Build("metalava", "metalava merged")
+ rule.Build(fmt.Sprintf("metalava_%s", params.stubConfig.stubsType.String()), "metalava merged")
+}
+
+func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ deps := d.Javadoc.collectDeps(ctx)
+
+ javaVersion := getJavaVersion(ctx, String(d.Javadoc.properties.Java_version), android.SdkContext(d))
+ generateStubs := BoolDefault(d.properties.Generate_stubs, true)
+
+ // Add options for the other optional tasks: API-lint and check-released.
+ // We generate separate timestamp files for them.
+ doApiLint := BoolDefault(d.properties.Check_api.Api_lint.Enabled, false)
+ doCheckReleased := apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released")
+
+ writeSdkValues := Bool(d.properties.Write_sdk_values)
+
+ annotationsEnabled := Bool(d.properties.Annotations_enabled)
+
+ migratingNullability := annotationsEnabled && String(d.properties.Previous_api) != ""
+ validatingNullability := annotationsEnabled && (strings.Contains(String(d.Javadoc.properties.Args), "--validate-nullability-from-merged-stubs") ||
+ String(d.properties.Validate_nullability_from_list) != "")
+
+ checkApi := apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") ||
+ apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released")
+
+ stubCmdParams := stubsCommandConfigParams{
+ javaVersion: javaVersion,
+ deps: deps,
+ checkApi: checkApi,
+ generateStubs: generateStubs,
+ doApiLint: doApiLint,
+ doCheckReleased: doCheckReleased,
+ writeSdkValues: writeSdkValues,
+ migratingNullability: migratingNullability,
+ validatingNullability: validatingNullability,
+ }
+ stubCmdParams.stubsType = Everything
+ // Create default (i.e. "everything" stubs) rule for metalava
+ d.everythingStubCmd(ctx, stubCmdParams)
+
+ // The module generates "exportable" (and "runtime" eventually) stubs regardless of whether
+ // aconfig_declarations property is defined or not. If the property is not defined, the module simply
+ // strips all flagged apis to generate the "exportable" stubs
+ stubCmdParams.stubsType = Exportable
+ d.exportableStubCmd(ctx, stubCmdParams)
if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") {
@@ -748,7 +1151,7 @@
ctx.PropertyErrorf("baseline_file", "current API check can't have a baseline file. (module %s)", ctx.ModuleName())
}
- d.checkCurrentApiTimestamp = android.PathForModuleOut(ctx, "metalava", "check_current_api.timestamp")
+ d.checkCurrentApiTimestamp = android.PathForModuleOut(ctx, Everything.String(), "check_current_api.timestamp")
rule := android.NewRuleBuilder(pctx, ctx)
@@ -791,7 +1194,7 @@
rule.Build("metalavaCurrentApiCheck", "check current API")
- d.updateCurrentApiTimestamp = android.PathForModuleOut(ctx, "metalava", "update_current_api.timestamp")
+ d.updateCurrentApiTimestamp = android.PathForModuleOut(ctx, Everything.String(), "update_current_api.timestamp")
// update API rule
rule = android.NewRuleBuilder(pctx, ctx)
@@ -826,7 +1229,7 @@
checkNullabilityWarnings := android.PathForModuleSrc(ctx, String(d.properties.Check_nullability_warnings))
- d.checkNullabilityWarningsTimestamp = android.PathForModuleOut(ctx, "metalava", "check_nullability_warnings.timestamp")
+ d.checkNullabilityWarningsTimestamp = android.PathForModuleOut(ctx, Everything.String(), "check_nullability_warnings.timestamp")
msg := fmt.Sprintf(`\n******************************\n`+
`The warnings encountered during nullability annotation validation did\n`+
@@ -926,7 +1329,9 @@
func (p *PrebuiltStubsSources) OutputFiles(tag string) (android.Paths, error) {
switch tag {
- case "":
+ // prebuilt droidstubs does not output "exportable" stubs.
+ // Output the "everything" stubs srcjar file if the tag is ".exportable".
+ case "", ".exportable":
return android.Paths{p.stubsSrcJar}, nil
default:
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go
index 7bcaca1..379e240 100644
--- a/java/droidstubs_test.go
+++ b/java/droidstubs_test.go
@@ -395,3 +395,54 @@
cmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, manifest).Commands[0].Command)
android.AssertStringDoesContain(t, "flagged api hide command not included", cmdline, "--revert-annotation android.annotation.FlaggedApi")
}
+
+func TestAconfigDeclarations(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ }),
+ android.FixtureMergeMockFs(map[string][]byte{
+ "a/A.java": nil,
+ "a/current.txt": nil,
+ "a/removed.txt": nil,
+ }),
+ ).RunTestWithBp(t, `
+ aconfig_declarations {
+ name: "bar",
+ package: "com.example.package",
+ srcs: [
+ "bar.aconfig",
+ ],
+ }
+ droidstubs {
+ name: "foo",
+ srcs: ["a/A.java"],
+ api_surface: "public",
+ check_api: {
+ current: {
+ api_file: "a/current.txt",
+ removed_api_file: "a/removed.txt",
+ }
+ },
+ aconfig_declarations: [
+ "bar",
+ ],
+ }
+ `)
+
+ // Check that droidstubs depend on aconfig_declarations
+ android.AssertBoolEquals(t, "foo expected to depend on bar",
+ CheckModuleHasDependency(t, result.TestContext, "foo", "android_common", "bar"), true)
+
+ m := result.ModuleForTests("foo", "android_common")
+ android.AssertStringDoesContain(t, "foo generates revert annotations file",
+ strings.Join(m.AllOutputs(), ""), "revert-annotations-exportable.txt")
+
+ // revert-annotations.txt passed to exportable stubs generation metalava command
+ manifest := m.Output("metalava_exportable.sbox.textproto")
+ cmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, manifest).Commands[0].Command)
+ android.AssertStringDoesContain(t, "flagged api hide command not included", cmdline, "revert-annotations-exportable.txt")
+
+ android.AssertStringDoesContain(t, "foo generates exportable stubs jar",
+ strings.Join(m.AllOutputs(), ""), "exportable/foo-stubs.srcjar")
+}
diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go
index bf99757..c3caa08 100644
--- a/java/hiddenapi_modular.go
+++ b/java/hiddenapi_modular.go
@@ -19,6 +19,7 @@
"strings"
"android/soong/android"
+ "android/soong/dexpreopt"
"github.com/google/blueprint"
)
@@ -1250,9 +1251,27 @@
}
// extractBootDexJarsFromModules extracts the boot dex jars from the supplied modules.
+// This information can come from two mechanisms
+// 1. New: Direct deps to _selected_ apexes. The apexes contain a ApexExportsInfo
+// 2. Legacy: An edge to java_sdk_library(_import) module. For prebuilt apexes, this serves as a hook and is populated by deapexers of prebuilt apxes
+// TODO: b/308174306 - Once all mainline modules have been flagged, drop (2)
func extractBootDexJarsFromModules(ctx android.ModuleContext, contents []android.Module) bootDexJarByModule {
bootDexJars := bootDexJarByModule{}
+
+ apexNameToApexExportsInfoMap := getApexNameToApexExportsInfoMap(ctx)
+ // For ART and mainline module jars, query apexNameToApexExportsInfoMap to get the dex file
+ apexJars := dexpreopt.GetGlobalConfig(ctx).ArtApexJars.AppendList(&dexpreopt.GetGlobalConfig(ctx).ApexBootJars)
+ for i := 0; i < apexJars.Len(); i++ {
+ if dex, found := apexNameToApexExportsInfoMap.javaLibraryDexPathOnHost(ctx, apexJars.Apex(i), apexJars.Jar(i)); found {
+ bootDexJars[apexJars.Jar(i)] = dex
+ }
+ }
+
+ // TODO - b/308174306: Drop the legacy mechanism
for _, module := range contents {
+ if _, exists := bootDexJars[android.RemoveOptionalPrebuiltPrefix(module.Name())]; exists {
+ continue
+ }
hiddenAPIModule := hiddenAPIModuleFromModule(ctx, module)
if hiddenAPIModule == nil {
continue
diff --git a/java/java.go b/java/java.go
index 2a4fafa..4227d36 100644
--- a/java/java.go
+++ b/java/java.go
@@ -26,6 +26,7 @@
"android/soong/remoteexec"
"android/soong/testing"
+
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -519,6 +520,7 @@
kotlinStdlib android.Paths
kotlinAnnotations android.Paths
kotlinPlugins android.Paths
+ aconfigProtoFiles android.Paths
disableTurbine bool
}
diff --git a/java/java_test.go b/java/java_test.go
index b9dc453..8d96184 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -2465,7 +2465,7 @@
}
`)
- currentApiTimestampPath := "api-stubs-docs-non-updatable/android_common/metalava/check_current_api.timestamp"
+ currentApiTimestampPath := "api-stubs-docs-non-updatable/android_common/everything/check_current_api.timestamp"
foo := result.ModuleForTests("foo", "android_common").Module().(*ApiLibrary)
fooValidationPathsString := strings.Join(foo.validationPaths.Strings(), " ")
bar := result.ModuleForTests("bar", "android_common").Module().(*ApiLibrary)
diff --git a/java/lint.go b/java/lint.go
index 5a684a8..c3d723b 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -17,7 +17,6 @@
import (
"fmt"
"sort"
- "strconv"
"strings"
"github.com/google/blueprint/proptools"
@@ -56,7 +55,8 @@
// Modules that provide extra lint checks
Extra_check_modules []string
- // Name of the file that lint uses as the baseline. Defaults to "lint-baseline.xml".
+ // The lint baseline file to use. If specified, lint warnings listed in this file will be
+ // suppressed during lint checks.
Baseline_filename *string
// If true, baselining updatability lint checks (e.g. NewApi) is prohibited. Defaults to false.
@@ -84,9 +84,9 @@
classes android.Path
extraLintCheckJars android.Paths
library bool
- minSdkVersion int
- targetSdkVersion int
- compileSdkVersion int
+ minSdkVersion android.ApiLevel
+ targetSdkVersion android.ApiLevel
+ compileSdkVersion android.ApiLevel
compileSdkKind android.SdkKind
javaLanguageLevel string
kotlinLanguageLevel string
@@ -357,33 +357,20 @@
Text(`echo "<?xml version='1.0' encoding='utf-8'?>" &&`).
Text(`echo "<manifest xmlns:android='http://schemas.android.com/apk/res/android'" &&`).
Text(`echo " android:versionCode='1' android:versionName='1' >" &&`).
- Textf(`echo " <uses-sdk android:minSdkVersion='%d' android:targetSdkVersion='%d'/>" &&`,
- l.minSdkVersion, l.targetSdkVersion).
+ Textf(`echo " <uses-sdk android:minSdkVersion='%s' android:targetSdkVersion='%s'/>" &&`,
+ l.minSdkVersion.String(), l.targetSdkVersion.String()).
Text(`echo "</manifest>"`).
Text(") >").Output(manifestPath)
return manifestPath
}
-func (l *linter) getBaselineFilepath(ctx android.ModuleContext) android.OptionalPath {
- var lintBaseline android.OptionalPath
- if lintFilename := proptools.StringDefault(l.properties.Lint.Baseline_filename, "lint-baseline.xml"); lintFilename != "" {
- if String(l.properties.Lint.Baseline_filename) != "" {
- // if manually specified, we require the file to exist
- lintBaseline = android.OptionalPathForPath(android.PathForModuleSrc(ctx, lintFilename))
- } else {
- lintBaseline = android.ExistentPathForSource(ctx, ctx.ModuleDir(), lintFilename)
- }
- }
- return lintBaseline
-}
-
func (l *linter) lint(ctx android.ModuleContext) {
if !l.enabled() {
return
}
- if l.minSdkVersion != l.compileSdkVersion {
+ if l.minSdkVersion.CompareTo(l.compileSdkVersion) == -1 {
l.extraMainlineLintErrors = append(l.extraMainlineLintErrors, updatabilityChecks...)
// Skip lint warning checks for NewApi warnings for libcore where they come from source
// files that reference the API they are adding (b/208656169).
@@ -497,7 +484,7 @@
FlagWithOutput("--html ", html).
FlagWithOutput("--text ", text).
FlagWithOutput("--xml ", xml).
- FlagWithArg("--compile-sdk-version ", strconv.Itoa(l.compileSdkVersion)).
+ FlagWithArg("--compile-sdk-version ", l.compileSdkVersion.String()).
FlagWithArg("--java-language-level ", l.javaLanguageLevel).
FlagWithArg("--kotlin-language-level ", l.kotlinLanguageLevel).
FlagWithArg("--url ", fmt.Sprintf(".=.,%s=out", android.PathForOutput(ctx).String())).
@@ -518,9 +505,8 @@
cmd.FlagWithArg("--check ", checkOnly)
}
- lintBaseline := l.getBaselineFilepath(ctx)
- if lintBaseline.Valid() {
- cmd.FlagWithInput("--baseline ", lintBaseline.Path())
+ if l.properties.Lint.Baseline_filename != nil {
+ cmd.FlagWithInput("--baseline ", android.PathForModuleSrc(ctx, *l.properties.Lint.Baseline_filename))
}
cmd.FlagWithOutput("--write-reference-baseline ", referenceBaseline)
@@ -556,6 +542,10 @@
if l.buildModuleReportZip {
l.reports = BuildModuleLintReportZips(ctx, l.LintDepSets())
}
+
+ // Create a per-module phony target to run the lint check.
+ phonyName := ctx.ModuleName() + "-lint"
+ ctx.Phony(phonyName, xml)
}
func BuildModuleLintReportZips(ctx android.ModuleContext, depSets LintDepSets) android.Paths {
diff --git a/java/lint_test.go b/java/lint_test.go
index 5e6b8bc..b7e6aad 100644
--- a/java/lint_test.go
+++ b/java/lint_test.go
@@ -21,7 +21,7 @@
"android/soong/android"
)
-func TestJavaLint(t *testing.T) {
+func TestJavaLintDoesntUseBaselineImplicitly(t *testing.T) {
ctx, _ := testJavaWithFS(t, `
java_library {
name: "foo",
@@ -40,30 +40,8 @@
foo := ctx.ModuleForTests("foo", "android_common")
sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx, foo.Output("lint.sbox.textproto"))
- if !strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml") {
- t.Error("did not pass --baseline flag")
- }
-}
-
-func TestJavaLintWithoutBaseline(t *testing.T) {
- ctx, _ := testJavaWithFS(t, `
- java_library {
- name: "foo",
- srcs: [
- "a.java",
- "b.java",
- "c.java",
- ],
- min_sdk_version: "29",
- sdk_version: "system_current",
- }
- `, map[string][]byte{})
-
- foo := ctx.ModuleForTests("foo", "android_common")
-
- sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx, foo.Output("lint.sbox.textproto"))
- if strings.Contains(*sboxProto.Commands[0].Command, "--baseline") {
- t.Error("passed --baseline flag for non existent file")
+ if strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml") {
+ t.Error("Passed --baseline flag when baseline_filename was not set")
}
}
diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go
index 88d1ae8..4db426e 100644
--- a/java/platform_bootclasspath.go
+++ b/java/platform_bootclasspath.go
@@ -106,6 +106,9 @@
}
func (b *platformBootclasspathModule) DepsMutator(ctx android.BottomUpMutatorContext) {
+ // Create a dependency on all_apex_contributions to determine the selected mainline module
+ ctx.AddDependency(ctx.Module(), apexContributionsMetadataDepTag, "all_apex_contributions")
+
b.hiddenAPIDepsMutator(ctx)
if !dexpreopt.IsDex2oatNeeded(ctx) {
@@ -130,6 +133,8 @@
func (b *platformBootclasspathModule) BootclasspathDepsMutator(ctx android.BottomUpMutatorContext) {
// Add dependencies on all the ART jars.
global := dexpreopt.GetGlobalConfig(ctx)
+ addDependenciesOntoSelectedBootImageApexes(ctx, "com.android.art")
+ // TODO: b/308174306 - Remove the mechanism of depending on the java_sdk_library(_import) directly
addDependenciesOntoBootImageModules(ctx, global.ArtApexJars, platformBootclasspathArtBootJarDepTag)
// Add dependencies on all the non-updatable jars, which are on the platform or in non-updatable
@@ -138,6 +143,12 @@
// Add dependencies on all the updatable jars, except the ART jars.
apexJars := dexpreopt.GetGlobalConfig(ctx).ApexBootJars
+ apexes := []string{}
+ for i := 0; i < apexJars.Len(); i++ {
+ apexes = append(apexes, apexJars.Apex(i))
+ }
+ addDependenciesOntoSelectedBootImageApexes(ctx, android.FirstUniqueStrings(apexes)...)
+ // TODO: b/308174306 - Remove the mechanism of depending on the java_sdk_library(_import) directly
addDependenciesOntoBootImageModules(ctx, apexJars, platformBootclasspathApexBootJarDepTag)
// Add dependencies on all the fragments.
diff --git a/java/sdk_library.go b/java/sdk_library.go
index ef34fb6..0df869e 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -231,6 +231,10 @@
return ".stubs" + scope.moduleSuffix
}
+func (scope *apiScope) exportableStubsLibraryModuleNameSuffix() string {
+ return ".stubs.exportable" + scope.moduleSuffix
+}
+
func (scope *apiScope) apiLibraryModuleName(baseName string) string {
return scope.stubsLibraryModuleName(baseName) + ".from-text"
}
@@ -239,10 +243,18 @@
return scope.stubsLibraryModuleName(baseName) + ".from-source"
}
+func (scope *apiScope) exportableSourceStubsLibraryModuleName(baseName string) string {
+ return scope.exportableStubsLibraryModuleName(baseName) + ".from-source"
+}
+
func (scope *apiScope) stubsLibraryModuleName(baseName string) string {
return baseName + scope.stubsLibraryModuleNameSuffix()
}
+func (scope *apiScope) exportableStubsLibraryModuleName(baseName string) string {
+ return baseName + scope.exportableStubsLibraryModuleNameSuffix()
+}
+
func (scope *apiScope) stubsSourceModuleName(baseName string) string {
return baseName + ".stubs.source" + scope.moduleSuffix
}
@@ -628,6 +640,10 @@
// Defaults to false.
Contribute_to_android_api *bool
+ // a list of aconfig_declarations module names that the stubs generated in this module
+ // depend on.
+ Aconfig_declarations []string
+
// TODO: determines whether to create HTML doc or not
// Html_doc *bool
}
@@ -891,6 +907,12 @@
return c.namingScheme.stubsLibraryModuleName(apiScope, baseName)
}
+// Name of the java_library module that compiles the exportable stubs source.
+func (c *commonToSdkLibraryAndImport) exportableStubsLibraryModuleName(apiScope *apiScope) string {
+ baseName := c.module.BaseModuleName()
+ return c.namingScheme.exportableStubsLibraryModuleName(apiScope, baseName)
+}
+
// Name of the droidstubs module that generates the stubs source and may also
// generate/check the API.
func (c *commonToSdkLibraryAndImport) stubsSourceModuleName(apiScope *apiScope) string {
@@ -907,9 +929,16 @@
// Name of the java_library module that compiles the stubs
// generated from source Java files.
-func (c *commonToSdkLibraryAndImport) sourceStubLibraryModuleName(apiScope *apiScope) string {
+func (c *commonToSdkLibraryAndImport) sourceStubsLibraryModuleName(apiScope *apiScope) string {
baseName := c.module.BaseModuleName()
- return c.namingScheme.sourceStubLibraryModuleName(apiScope, baseName)
+ return c.namingScheme.sourceStubsLibraryModuleName(apiScope, baseName)
+}
+
+// Name of the java_library module that compiles the exportable stubs
+// generated from source Java files.
+func (c *commonToSdkLibraryAndImport) exportableSourceStubsLibraryModuleName(apiScope *apiScope) string {
+ baseName := c.module.BaseModuleName()
+ return c.namingScheme.exportableSourceStubsLibraryModuleName(apiScope, baseName)
}
// The component names for different outputs of the java_sdk_library.
@@ -1625,36 +1654,34 @@
mctx.CreateModule(LibraryFactory, properties...)
}
-// Creates a static java library that has API stubs
-func (module *SdkLibrary) createStubsLibrary(mctx android.DefaultableHookContext, apiScope *apiScope) {
- props := struct {
- Name *string
- Visibility []string
- Srcs []string
- Installable *bool
- Sdk_version *string
- System_modules *string
- Patch_module *string
- Libs []string
- Static_libs []string
- Compile_dex *bool
- Java_version *string
- Openjdk9 struct {
- Srcs []string
- Javacflags []string
- }
- Dist struct {
- Targets []string
- Dest *string
- Dir *string
- Tag *string
- }
- }{}
+type libraryProperties struct {
+ Name *string
+ Visibility []string
+ Srcs []string
+ Installable *bool
+ Sdk_version *string
+ System_modules *string
+ Patch_module *string
+ Libs []string
+ Static_libs []string
+ Compile_dex *bool
+ Java_version *string
+ Openjdk9 struct {
+ Srcs []string
+ Javacflags []string
+ }
+ Dist struct {
+ Targets []string
+ Dest *string
+ Dir *string
+ Tag *string
+ }
+}
- props.Name = proptools.StringPtr(module.sourceStubLibraryModuleName(apiScope))
+func (module *SdkLibrary) stubsLibraryProps(mctx android.DefaultableHookContext, apiScope *apiScope) libraryProperties {
+ props := libraryProperties{}
props.Visibility = []string{"//visibility:override", "//visibility:private"}
// sources are generated from the droiddoc
- props.Srcs = []string{":" + module.stubsSourceModuleName(apiScope)}
sdkVersion := module.sdkVersionForStubsLibrary(mctx, apiScope)
props.Sdk_version = proptools.StringPtr(sdkVersion)
props.System_modules = module.deviceProperties.System_modules
@@ -1674,6 +1701,25 @@
// interop with older developer tools that don't support 1.9.
props.Java_version = proptools.StringPtr("1.8")
+ return props
+}
+
+// Creates a static java library that has API stubs
+func (module *SdkLibrary) createStubsLibrary(mctx android.DefaultableHookContext, apiScope *apiScope) {
+
+ props := module.stubsLibraryProps(mctx, apiScope)
+ props.Name = proptools.StringPtr(module.sourceStubsLibraryModuleName(apiScope))
+ props.Srcs = []string{":" + module.stubsSourceModuleName(apiScope)}
+
+ mctx.CreateModule(LibraryFactory, &props, module.sdkComponentPropertiesForChildLibrary())
+}
+
+// Create a static java library that compiles the "exportable" stubs
+func (module *SdkLibrary) createExportableStubsLibrary(mctx android.DefaultableHookContext, apiScope *apiScope) {
+ props := module.stubsLibraryProps(mctx, apiScope)
+ props.Name = proptools.StringPtr(module.exportableSourceStubsLibraryModuleName(apiScope))
+ props.Srcs = []string{":" + module.stubsSourceModuleName(apiScope) + "{.exportable}"}
+
mctx.CreateModule(LibraryFactory, &props, module.sdkComponentPropertiesForChildLibrary())
}
@@ -1698,6 +1744,7 @@
Merge_inclusion_annotations_dirs []string
Generate_stubs *bool
Previous_api *string
+ Aconfig_declarations []string
Check_api struct {
Current ApiToCheck
Last_released ApiToCheck
@@ -1742,6 +1789,7 @@
props.Annotations_enabled = module.sdkLibraryProperties.Annotations_enabled
props.Merge_annotations_dirs = module.sdkLibraryProperties.Merge_annotations_dirs
props.Merge_inclusion_annotations_dirs = module.sdkLibraryProperties.Merge_inclusion_annotations_dirs
+ props.Aconfig_declarations = module.sdkLibraryProperties.Aconfig_declarations
droidstubsArgs := []string{}
if len(module.sdkLibraryProperties.Api_packages) != 0 {
@@ -1902,43 +1950,15 @@
mctx.CreateModule(ApiLibraryFactory, &props, module.sdkComponentPropertiesForChildLibrary())
}
-func (module *SdkLibrary) createTopLevelStubsLibrary(
- mctx android.DefaultableHookContext, apiScope *apiScope, contributesToApiSurface bool) {
- props := struct {
- Name *string
- Visibility []string
- Sdk_version *string
- Static_libs []string
- System_modules *string
- Dist struct {
- Targets []string
- Dest *string
- Dir *string
- Tag *string
- }
- Compile_dex *bool
- }{}
- props.Name = proptools.StringPtr(module.stubsLibraryModuleName(apiScope))
+func (module *SdkLibrary) topLevelStubsLibraryProps(mctx android.DefaultableHookContext, apiScope *apiScope) libraryProperties {
+ props := libraryProperties{}
+
props.Visibility = childModuleVisibility(module.sdkLibraryProperties.Stubs_library_visibility)
sdkVersion := module.sdkVersionForStubsLibrary(mctx, apiScope)
props.Sdk_version = proptools.StringPtr(sdkVersion)
- // Add the stub compiling java_library/java_api_library as static lib based on build config
- staticLib := module.sourceStubLibraryModuleName(apiScope)
- if mctx.Config().BuildFromTextStub() && contributesToApiSurface {
- staticLib = module.apiLibraryModuleName(apiScope)
- }
- props.Static_libs = append(props.Static_libs, staticLib)
props.System_modules = module.deviceProperties.System_modules
- // Dist the class jar artifact for sdk builds.
- if !Bool(module.sdkLibraryProperties.No_dist) {
- props.Dist.Targets = []string{"sdk", "win_sdk"}
- props.Dist.Dest = proptools.StringPtr(fmt.Sprintf("%v.jar", module.distStem()))
- props.Dist.Dir = proptools.StringPtr(module.apiDistPath(apiScope))
- props.Dist.Tag = proptools.StringPtr(".jar")
- }
-
// The imports need to be compiled to dex if the java_sdk_library requests it.
compileDex := module.dexProperties.Compile_dex
if module.stubLibrariesCompiledForDex() {
@@ -1946,6 +1966,43 @@
}
props.Compile_dex = compileDex
+ return props
+}
+
+func (module *SdkLibrary) createTopLevelStubsLibrary(
+ mctx android.DefaultableHookContext, apiScope *apiScope, contributesToApiSurface bool) {
+
+ props := module.topLevelStubsLibraryProps(mctx, apiScope)
+ props.Name = proptools.StringPtr(module.stubsLibraryModuleName(apiScope))
+
+ // Add the stub compiling java_library/java_api_library as static lib based on build config
+ staticLib := module.sourceStubsLibraryModuleName(apiScope)
+ if mctx.Config().BuildFromTextStub() && contributesToApiSurface {
+ staticLib = module.apiLibraryModuleName(apiScope)
+ }
+ props.Static_libs = append(props.Static_libs, staticLib)
+
+ mctx.CreateModule(LibraryFactory, &props, module.sdkComponentPropertiesForChildLibrary())
+}
+
+func (module *SdkLibrary) createTopLevelExportableStubsLibrary(
+ mctx android.DefaultableHookContext, apiScope *apiScope) {
+
+ props := module.topLevelStubsLibraryProps(mctx, apiScope)
+ props.Name = proptools.StringPtr(module.exportableStubsLibraryModuleName(apiScope))
+
+ // Dist the class jar artifact for sdk builds.
+ // "exportable" stubs are copied to dist for sdk builds instead of the "everything" stubs.
+ if !Bool(module.sdkLibraryProperties.No_dist) {
+ props.Dist.Targets = []string{"sdk", "win_sdk"}
+ props.Dist.Dest = proptools.StringPtr(fmt.Sprintf("%v.jar", module.distStem()))
+ props.Dist.Dir = proptools.StringPtr(module.apiDistPath(apiScope))
+ props.Dist.Tag = proptools.StringPtr(".jar")
+ }
+
+ staticLib := module.exportableSourceStubsLibraryModuleName(apiScope)
+ props.Static_libs = append(props.Static_libs, staticLib)
+
mctx.CreateModule(LibraryFactory, &props, module.sdkComponentPropertiesForChildLibrary())
}
@@ -2151,6 +2208,7 @@
module.createStubsSourcesAndApi(mctx, scope, module.stubsSourceModuleName(scope), scope.droidstubsArgs)
module.createStubsLibrary(mctx, scope)
+ module.createExportableStubsLibrary(mctx, scope)
alternativeFullApiSurfaceStubLib := ""
if scope == apiScopePublic {
@@ -2162,6 +2220,7 @@
}
module.createTopLevelStubsLibrary(mctx, scope, contributesToApiSurface)
+ module.createTopLevelExportableStubsLibrary(mctx, scope)
}
if module.requiresRuntimeImplementationLibrary() {
@@ -2217,7 +2276,11 @@
apiLibraryModuleName(scope *apiScope, baseName string) string
- sourceStubLibraryModuleName(scope *apiScope, baseName string) string
+ sourceStubsLibraryModuleName(scope *apiScope, baseName string) string
+
+ exportableStubsLibraryModuleName(scope *apiScope, baseName string) string
+
+ exportableSourceStubsLibraryModuleName(scope *apiScope, baseName string) string
}
type defaultNamingScheme struct {
@@ -2235,34 +2298,47 @@
return scope.apiLibraryModuleName(baseName)
}
-func (s *defaultNamingScheme) sourceStubLibraryModuleName(scope *apiScope, baseName string) string {
+func (s *defaultNamingScheme) sourceStubsLibraryModuleName(scope *apiScope, baseName string) string {
return scope.sourceStubLibraryModuleName(baseName)
}
+func (s *defaultNamingScheme) exportableStubsLibraryModuleName(scope *apiScope, baseName string) string {
+ return scope.exportableStubsLibraryModuleName(baseName)
+}
+
+func (s *defaultNamingScheme) exportableSourceStubsLibraryModuleName(scope *apiScope, baseName string) string {
+ return scope.exportableSourceStubsLibraryModuleName(baseName)
+}
+
var _ sdkLibraryComponentNamingScheme = (*defaultNamingScheme)(nil)
+func hasStubsLibrarySuffix(name string, apiScope *apiScope) bool {
+ return strings.HasSuffix(name, apiScope.stubsLibraryModuleNameSuffix()) ||
+ strings.HasSuffix(name, apiScope.exportableStubsLibraryModuleNameSuffix())
+}
+
func moduleStubLinkType(name string) (stub bool, ret sdkLinkType) {
name = strings.TrimSuffix(name, ".from-source")
// This suffix-based approach is fragile and could potentially mis-trigger.
// TODO(b/155164730): Clean this up when modules no longer reference sdk_lib stubs directly.
- if strings.HasSuffix(name, apiScopePublic.stubsLibraryModuleNameSuffix()) {
+ if hasStubsLibrarySuffix(name, apiScopePublic) {
if name == "hwbinder.stubs" || name == "libcore_private.stubs" {
// Due to a previous bug, these modules were not considered stubs, so we retain that.
return false, javaPlatform
}
return true, javaSdk
}
- if strings.HasSuffix(name, apiScopeSystem.stubsLibraryModuleNameSuffix()) {
+ if hasStubsLibrarySuffix(name, apiScopeSystem) {
return true, javaSystem
}
- if strings.HasSuffix(name, apiScopeModuleLib.stubsLibraryModuleNameSuffix()) {
+ if hasStubsLibrarySuffix(name, apiScopeModuleLib) {
return true, javaModule
}
- if strings.HasSuffix(name, apiScopeTest.stubsLibraryModuleNameSuffix()) {
+ if hasStubsLibrarySuffix(name, apiScopeTest) {
return true, javaSystem
}
- if strings.HasSuffix(name, apiScopeSystemServer.stubsLibraryModuleNameSuffix()) {
+ if hasStubsLibrarySuffix(name, apiScopeSystemServer) {
return true, javaSystemServer
}
return false, javaPlatform
diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go
index 63419d6..c14f3e6 100644
--- a/java/sdk_library_test.go
+++ b/java/sdk_library_test.go
@@ -1423,7 +1423,7 @@
for _, tt := range testCases {
t.Run(tt.module, func(t *testing.T) {
- m := result.ModuleForTests(tt.module+".stubs", "android_common").Module().(*Library)
+ m := result.ModuleForTests(apiScopePublic.exportableStubsLibraryModuleName(tt.module), "android_common").Module().(*Library)
dists := m.Dists()
if len(dists) != 1 {
t.Fatalf("expected exactly 1 dist entry, got %d", len(dists))
@@ -1693,3 +1693,56 @@
android.AssertStringDoesContain(t, "bar.xml java_sdk_xml command", barPermissions.RuleParams.Command, `dependency=\"foo\"`)
}
+
+func TestSdkLibraryExportableStubsLibrary(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
+ PrepareForTestWithJavaSdkLibraryFiles,
+ FixtureWithLastReleaseApis("foo"),
+ android.FixtureModifyConfig(func(config android.Config) {
+ config.SetApiLibraries([]string{"foo"})
+ }),
+ ).RunTestWithBp(t, `
+ aconfig_declarations {
+ name: "bar",
+ package: "com.example.package",
+ srcs: [
+ "bar.aconfig",
+ ],
+ }
+ java_sdk_library {
+ name: "foo",
+ srcs: ["a.java", "b.java"],
+ api_packages: ["foo"],
+ system: {
+ enabled: true,
+ },
+ module_lib: {
+ enabled: true,
+ },
+ test: {
+ enabled: true,
+ },
+ aconfig_declarations: [
+ "bar",
+ ],
+ }
+ `)
+
+ exportableStubsLibraryModuleName := apiScopePublic.exportableStubsLibraryModuleName("foo")
+ exportableSourceStubsLibraryModuleName := apiScopePublic.exportableSourceStubsLibraryModuleName("foo")
+
+ // Check modules generation
+ topLevelModule := result.ModuleForTests(exportableStubsLibraryModuleName, "android_common")
+ result.ModuleForTests(exportableSourceStubsLibraryModuleName, "android_common")
+
+ // Check static lib dependency
+ android.AssertBoolEquals(t, "exportable top level stubs library module depends on the"+
+ "exportable source stubs library module", true,
+ CheckModuleHasDependency(t, result.TestContext, exportableStubsLibraryModuleName,
+ "android_common", exportableSourceStubsLibraryModuleName),
+ )
+ android.AssertArrayString(t, "exportable source stub library is a static lib of the"+
+ "top level exportable stubs library", []string{exportableSourceStubsLibraryModuleName},
+ topLevelModule.Module().(*Library).properties.Static_libs)
+}
diff --git a/java/sdk_version_test.go b/java/sdk_version_test.go
new file mode 100644
index 0000000..88351d2
--- /dev/null
+++ b/java/sdk_version_test.go
@@ -0,0 +1,66 @@
+// Copyright 2024 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 (
+ "testing"
+
+ "android/soong/android"
+)
+
+func stringPtr(v string) *string {
+ return &v
+}
+
+func TestSystemSdkFromVendor(t *testing.T) {
+ fixtures := android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModules,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.Platform_sdk_version = intPtr(34)
+ variables.Platform_sdk_codename = stringPtr("VanillaIceCream")
+ variables.Platform_version_active_codenames = []string{"VanillaIceCream"}
+ variables.Platform_systemsdk_versions = []string{"33", "34", "VanillaIceCream"}
+ variables.DeviceSystemSdkVersions = []string{"VanillaIceCream"}
+ }),
+ FixtureWithPrebuiltApis(map[string][]string{
+ "33": {},
+ "34": {},
+ "35": {},
+ }),
+ )
+
+ fixtures.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern("incompatible sdk version")).
+ RunTestWithBp(t, `
+ android_app {
+ name: "foo",
+ srcs: ["a.java"],
+ vendor: true,
+ sdk_version: "system_35",
+ }`)
+
+ result := fixtures.RunTestWithBp(t, `
+ android_app {
+ name: "foo",
+ srcs: ["a.java"],
+ vendor: true,
+ sdk_version: "system_current",
+ }`)
+ fooModule := result.ModuleForTests("foo", "android_common")
+ fooClasspath := fooModule.Rule("javac").Args["classpath"]
+
+ android.AssertStringDoesContain(t, "foo classpath", fooClasspath, "prebuilts/sdk/34/system/android.jar")
+ android.AssertStringDoesNotContain(t, "foo classpath", fooClasspath, "prebuilts/sdk/35/system/android.jar")
+ android.AssertStringDoesNotContain(t, "foo classpath", fooClasspath, "prebuilts/sdk/current/system/android.jar")
+}
diff --git a/java/test_spec_test.go b/java/test_spec_test.go
index f628b4b..4144dad 100644
--- a/java/test_spec_test.go
+++ b/java/test_spec_test.go
@@ -29,12 +29,10 @@
}`
result := runTestSpecTest(t, android.FixtureExpectsNoErrors, bp)
- module := result.ModuleForTests(
- "module-name", "",
- ).Module().(*soongTesting.TestSpecModule)
+ module := result.ModuleForTests("module-name", "")
// Check that the provider has the right contents
- data, _ := android.SingletonModuleProvider(result, module, soongTesting.TestSpecProviderKey)
+ data, _ := android.SingletonModuleProvider(result, module.Module(), soongTesting.TestSpecProviderKey)
if !strings.HasSuffix(
data.IntermediatePath.String(), "/intermediateTestSpecMetadata.pb",
) {
@@ -44,13 +42,8 @@
)
}
- buildParamsSlice := module.BuildParamsForTests()
- var metadata = ""
- for _, params := range buildParamsSlice {
- if params.Rule.String() == "android/soong/android.writeFile" {
- metadata = params.Args["content"]
- }
- }
+ metadata := android.ContentFromFileRuleForTests(t, result.TestContext,
+ module.Output(data.IntermediatePath.String()))
metadataList := make([]*test_spec_proto.TestSpec_OwnershipMetadata, 0, 2)
teamId := "12345"
@@ -70,9 +63,7 @@
}
testSpecMetadata := test_spec_proto.TestSpec{OwnershipMetadataList: metadataList}
protoData, _ := proto.Marshal(&testSpecMetadata)
- rawData := string(protoData)
- formattedData := strings.ReplaceAll(rawData, "\n", "\\n")
- expectedMetadata := "'" + formattedData + "\\n'"
+ expectedMetadata := string(protoData)
if metadata != expectedMetadata {
t.Errorf(
diff --git a/phony/phony.go b/phony/phony.go
index a8b651a..bb48788 100644
--- a/phony/phony.go
+++ b/phony/phony.go
@@ -24,6 +24,7 @@
func init() {
android.RegisterModuleType("phony", PhonyFactory)
+ android.RegisterModuleType("phony_rule", PhonyRuleFactory)
}
type phony struct {
@@ -71,3 +72,40 @@
},
}
}
+
+type PhonyRule struct {
+ android.ModuleBase
+
+ properties PhonyProperties
+}
+
+type PhonyProperties struct {
+ // The Phony_deps is the set of all dependencies for this target,
+ // and it can function similarly to .PHONY in a makefile.
+ // Additionally, dependencies within it can even include genrule.
+ Phony_deps []string
+}
+
+// The phony_rule provides functionality similar to the .PHONY in a makefile.
+// It can create a phony target and include relevant dependencies associated with it.
+func PhonyRuleFactory() android.Module {
+ module := &PhonyRule{}
+ android.InitAndroidModule(module)
+ module.AddProperties(&module.properties)
+ return module
+}
+
+func (p *PhonyRule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+}
+
+func (p *PhonyRule) AndroidMk() android.AndroidMkData {
+ return android.AndroidMkData{
+ Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
+ if len(p.properties.Phony_deps) > 0 {
+ depModulesStr := strings.Join(p.properties.Phony_deps, " ")
+ fmt.Fprintln(w, ".PHONY:", name)
+ fmt.Fprintln(w, name, ":", depModulesStr)
+ }
+ },
+ }
+}
diff --git a/rust/config/x86_64_device.go b/rust/config/x86_64_device.go
index c797eef..cc16704 100644
--- a/rust/config/x86_64_device.go
+++ b/rust/config/x86_64_device.go
@@ -28,15 +28,16 @@
x86_64LinkFlags = []string{}
x86_64ArchVariantRustFlags = map[string][]string{
- "": []string{},
- "broadwell": []string{"-C target-cpu=broadwell"},
- "goldmont": []string{"-C target-cpu=goldmont"},
- "goldmont-plus": []string{"-C target-cpu=goldmont-plus"},
- "haswell": []string{"-C target-cpu=haswell"},
- "ivybridge": []string{"-C target-cpu=ivybridge"},
- "sandybridge": []string{"-C target-cpu=sandybridge"},
- "silvermont": []string{"-C target-cpu=silvermont"},
- "skylake": []string{"-C target-cpu=skylake"},
+ "": []string{},
+ "broadwell": []string{"-C target-cpu=broadwell"},
+ "goldmont": []string{"-C target-cpu=goldmont"},
+ "goldmont-plus": []string{"-C target-cpu=goldmont-plus"},
+ "goldmont-without-xsaves": []string{"-C target-cpu=goldmont", "-C target-feature=-xsaves"},
+ "haswell": []string{"-C target-cpu=haswell"},
+ "ivybridge": []string{"-C target-cpu=ivybridge"},
+ "sandybridge": []string{"-C target-cpu=sandybridge"},
+ "silvermont": []string{"-C target-cpu=silvermont"},
+ "skylake": []string{"-C target-cpu=skylake"},
//TODO: Add target-cpu=stoneyridge when rustc supports it.
"stoneyridge": []string{""},
"tremont": []string{"-C target-cpu=tremont"},
diff --git a/rust/config/x86_device.go b/rust/config/x86_device.go
index 822f281..e7b575c 100644
--- a/rust/config/x86_device.go
+++ b/rust/config/x86_device.go
@@ -26,16 +26,17 @@
x86LinkFlags = []string{}
x86ArchVariantRustFlags = map[string][]string{
- "": []string{},
- "atom": []string{"-C target-cpu=atom"},
- "broadwell": []string{"-C target-cpu=broadwell"},
- "goldmont": []string{"-C target-cpu=goldmont"},
- "goldmont-plus": []string{"-C target-cpu=goldmont-plus"},
- "haswell": []string{"-C target-cpu=haswell"},
- "ivybridge": []string{"-C target-cpu=ivybridge"},
- "sandybridge": []string{"-C target-cpu=sandybridge"},
- "silvermont": []string{"-C target-cpu=silvermont"},
- "skylake": []string{"-C target-cpu=skylake"},
+ "": []string{},
+ "atom": []string{"-C target-cpu=atom"},
+ "broadwell": []string{"-C target-cpu=broadwell"},
+ "goldmont": []string{"-C target-cpu=goldmont"},
+ "goldmont-plus": []string{"-C target-cpu=goldmont-plus"},
+ "goldmont-without-xsaves": []string{"-C target-cpu=goldmont", "-C target-feature=-xsaves"},
+ "haswell": []string{"-C target-cpu=haswell"},
+ "ivybridge": []string{"-C target-cpu=ivybridge"},
+ "sandybridge": []string{"-C target-cpu=sandybridge"},
+ "silvermont": []string{"-C target-cpu=silvermont"},
+ "skylake": []string{"-C target-cpu=skylake"},
//TODO: Add target-cpu=stoneyridge when rustc supports it.
"stoneyridge": []string{""},
"tremont": []string{"-C target-cpu=tremont"},
diff --git a/rust/fuzz.go b/rust/fuzz.go
index bacfa2d..1770d2e 100644
--- a/rust/fuzz.go
+++ b/rust/fuzz.go
@@ -142,12 +142,12 @@
fuzz.installedSharedDeps = append(fuzz.installedSharedDeps,
cc.SharedLibraryInstallLocation(
- install, ctx.Host(), installBase, ctx.Arch().ArchType.String()))
+ install, ctx.Host(), ctx.InstallInVendor(), installBase, ctx.Arch().ArchType.String()))
// Also add the dependency on the shared library symbols dir.
if !ctx.Host() {
fuzz.installedSharedDeps = append(fuzz.installedSharedDeps,
- cc.SharedLibrarySymbolsInstallLocation(install, installBase, ctx.Arch().ArchType.String()))
+ cc.SharedLibrarySymbolsInstallLocation(install, ctx.InstallInVendor(), installBase, ctx.Arch().ArchType.String()))
}
}
diff --git a/rust/image.go b/rust/image.go
index d0218f0..7adf234 100644
--- a/rust/image.go
+++ b/rust/image.go
@@ -184,12 +184,12 @@
}
func (mod *Module) InProduct() bool {
- return mod.Properties.ImageVariationPrefix == cc.ProductVariationPrefix
+ return mod.Properties.ImageVariation == cc.ProductVariation
}
// Returns true if the module is "vendor" variant. Usually these modules are installed in /vendor
func (mod *Module) InVendor() bool {
- return mod.Properties.ImageVariationPrefix == cc.VendorVariationPrefix
+ return mod.Properties.ImageVariation == cc.VendorVariation
}
func (mod *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
@@ -198,9 +198,11 @@
m.MakeAsPlatform()
} else if variant == android.RecoveryVariation {
m.MakeAsPlatform()
- } else if strings.HasPrefix(variant, cc.VendorVariationPrefix) {
- m.Properties.ImageVariationPrefix = cc.VendorVariationPrefix
- m.Properties.VndkVersion = strings.TrimPrefix(variant, cc.VendorVariationPrefix)
+ } else if strings.HasPrefix(variant, cc.VendorVariation) {
+ m.Properties.ImageVariation = cc.VendorVariation
+ if strings.HasPrefix(variant, cc.VendorVariationPrefix) {
+ m.Properties.VndkVersion = strings.TrimPrefix(variant, cc.VendorVariationPrefix)
+ }
// Makefile shouldn't know vendor modules other than BOARD_VNDK_VERSION.
// Hide other vendor variants to avoid collision.
@@ -209,9 +211,11 @@
m.Properties.HideFromMake = true
m.HideFromMake()
}
- } else if strings.HasPrefix(variant, cc.ProductVariationPrefix) {
- m.Properties.ImageVariationPrefix = cc.ProductVariationPrefix
- m.Properties.VndkVersion = strings.TrimPrefix(variant, cc.ProductVariationPrefix)
+ } else if strings.HasPrefix(variant, cc.ProductVariation) {
+ m.Properties.ImageVariation = cc.ProductVariation
+ if strings.HasPrefix(variant, cc.ProductVariationPrefix) {
+ m.Properties.VndkVersion = strings.TrimPrefix(variant, cc.ProductVariationPrefix)
+ }
}
}
diff --git a/rust/rust.go b/rust/rust.go
index 6f4631d..34ce4c5 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -20,6 +20,7 @@
"android/soong/bloaty"
"android/soong/testing"
+
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -69,9 +70,9 @@
AndroidMkProcMacroLibs []string `blueprint:"mutated"`
AndroidMkStaticLibs []string `blueprint:"mutated"`
- ImageVariationPrefix string `blueprint:"mutated"`
- VndkVersion string `blueprint:"mutated"`
- SubName string `blueprint:"mutated"`
+ ImageVariation string `blueprint:"mutated"`
+ VndkVersion string `blueprint:"mutated"`
+ SubName string `blueprint:"mutated"`
// SubName is used by CC for tracking image variants / SDK versions. RustSubName is used for Rust-specific
// subnaming which shouldn't be visible to CC modules (such as the rlib stdlinkage subname). This should be
diff --git a/scripts/Android.bp b/scripts/Android.bp
index 97f6ab4..7baaadb 100644
--- a/scripts/Android.bp
+++ b/scripts/Android.bp
@@ -254,3 +254,8 @@
"modify_permissions_allowlist.py",
],
}
+
+sh_binary_host {
+ name: "keep-flagged-apis",
+ src: "keep-flagged-apis.sh",
+}
diff --git a/scripts/keep-flagged-apis.sh b/scripts/keep-flagged-apis.sh
new file mode 100755
index 0000000..9c48fdb
--- /dev/null
+++ b/scripts/keep-flagged-apis.sh
@@ -0,0 +1,46 @@
+#!/bin/bash -e
+#
+# Copyright 2023 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.
+
+# Convert a list of flags in the input file to a list of metalava options
+# that will keep the APIs for those flags will hiding all other flagged
+# APIs.
+
+FLAGS="$1"
+
+FLAGGED="android.annotation.FlaggedApi"
+
+# Convert the list of feature flags in the input file to Metalava options
+# of the form `--revert-annotation !android.annotation.FlaggedApi("<flag>")`
+# to prevent the annotated APIs from being hidden, i.e. include the annotated
+# APIs in the SDK snapshots. This also preserves the line comments, they will
+# be ignored by Metalava but might be useful when debugging.
+while read -r line; do
+ key=$(echo "$line" | cut -d= -f1)
+ value=$(echo "$line" | cut -d= -f2)
+
+ # Skip if value is not true and line does not start with '#'
+ if [[ ( $value != "true" ) && ( $line =~ ^[^#] )]]; then
+ continue
+ fi
+
+ # Escape and quote the key for sed
+ escaped_key=$(echo "$key" | sed "s/'/\\\'/g; s/ /\\ /g")
+
+ echo $line | sed "s|^[^#].*$|--revert-annotation '!$FLAGGED(\"$escaped_key\")'|"
+done < "$FLAGS"
+
+# Revert all flagged APIs, unless listed above.
+echo "--revert-annotation $FLAGGED"
diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go
index ee1b5db..a89e28e 100644
--- a/sdk/bootclasspath_fragment_sdk_test.go
+++ b/sdk/bootclasspath_fragment_sdk_test.go
@@ -490,14 +490,14 @@
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar
.intermediates/myothersdklibrary.stubs/android_common/combined/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar
-.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt
-.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt
+.intermediates/myothersdklibrary.stubs.source/android_common/everything/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt
+.intermediates/myothersdklibrary.stubs.source/android_common/everything/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt
.intermediates/mysdklibrary.stubs/android_common/combined/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
.intermediates/mycoreplatform.stubs/android_common/combined/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar
-.intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt
-.intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt
+.intermediates/mycoreplatform.stubs.source/android_common/everything/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt
+.intermediates/mycoreplatform.stubs.source/android_common/everything/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt
`)
})
@@ -510,14 +510,14 @@
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar
.intermediates/myothersdklibrary.stubs/android_common/combined/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar
-.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt
-.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt
+.intermediates/myothersdklibrary.stubs.source/android_common/everything/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt
+.intermediates/myothersdklibrary.stubs.source/android_common/everything/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt
.intermediates/mysdklibrary.stubs/android_common/combined/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
.intermediates/mycoreplatform.stubs/android_common/combined/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar
-.intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt
-.intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt
+.intermediates/mycoreplatform.stubs.source/android_common/everything/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt
+.intermediates/mycoreplatform.stubs.source/android_common/everything/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt
`
t.Run("added-via-apex", func(t *testing.T) {
testSnapshotWithBootClasspathFragment_Contents(t, `
@@ -964,11 +964,11 @@
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar
.intermediates/mynewlibrary.stubs/android_common/combined/mynewlibrary.stubs.jar -> sdk_library/public/mynewlibrary-stubs.jar
-.intermediates/mynewlibrary.stubs.source/android_common/metalava/mynewlibrary.stubs.source_api.txt -> sdk_library/public/mynewlibrary.txt
-.intermediates/mynewlibrary.stubs.source/android_common/metalava/mynewlibrary.stubs.source_removed.txt -> sdk_library/public/mynewlibrary-removed.txt
+.intermediates/mynewlibrary.stubs.source/android_common/everything/mynewlibrary.stubs.source_api.txt -> sdk_library/public/mynewlibrary.txt
+.intermediates/mynewlibrary.stubs.source/android_common/everything/mynewlibrary.stubs.source_removed.txt -> sdk_library/public/mynewlibrary-removed.txt
.intermediates/mysdklibrary.stubs/android_common/combined/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
`),
snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot),
snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot),
@@ -1096,8 +1096,8 @@
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/stub-flags.csv -> hiddenapi/stub-flags.csv
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/all-flags.csv -> hiddenapi/all-flags.csv
.intermediates/mysdklibrary.stubs/android_common/combined/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
`
// On S the stub flags should only be generated from mysdklibrary as mynewsdklibrary is not part
@@ -1174,11 +1174,11 @@
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
.intermediates/mysdklibrary.stubs/android_common/combined/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
.intermediates/mynewsdklibrary.stubs/android_common/combined/mynewsdklibrary.stubs.jar -> sdk_library/public/mynewsdklibrary-stubs.jar
-.intermediates/mynewsdklibrary.stubs.source/android_common/metalava/mynewsdklibrary.stubs.source_api.txt -> sdk_library/public/mynewsdklibrary.txt
-.intermediates/mynewsdklibrary.stubs.source/android_common/metalava/mynewsdklibrary.stubs.source_removed.txt -> sdk_library/public/mynewsdklibrary-removed.txt
+.intermediates/mynewsdklibrary.stubs.source/android_common/everything/mynewsdklibrary.stubs.source_api.txt -> sdk_library/public/mynewsdklibrary.txt
+.intermediates/mynewsdklibrary.stubs.source/android_common/everything/mynewsdklibrary.stubs.source_removed.txt -> sdk_library/public/mynewsdklibrary-removed.txt
`
// On tiramisu the stub flags should be generated from both mynewsdklibrary and mysdklibrary as
diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go
index 680494f..592c005 100644
--- a/sdk/java_sdk_test.go
+++ b/sdk/java_sdk_test.go
@@ -697,8 +697,8 @@
.intermediates/exported-system-module/android_common/turbine-combined/exported-system-module.jar -> java/exported-system-module.jar
.intermediates/system-module/android_common/turbine-combined/system-module.jar -> java/system-module.jar
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
`),
checkInfoContents(result.Config, `
[
@@ -942,14 +942,14 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
.intermediates/myjavalib.stubs.system/android_common/combined/myjavalib.stubs.system.jar -> sdk_library/system/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source.system/android_common/metalava/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt
-.intermediates/myjavalib.stubs.source.system/android_common/metalava/myjavalib.stubs.source.system_removed.txt -> sdk_library/system/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source.system/android_common/everything/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt
+.intermediates/myjavalib.stubs.source.system/android_common/everything/myjavalib.stubs.source.system_removed.txt -> sdk_library/system/myjavalib-removed.txt
.intermediates/myjavalib.stubs.test/android_common/combined/myjavalib.stubs.test.jar -> sdk_library/test/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source.test/android_common/metalava/myjavalib.stubs.source.test_api.txt -> sdk_library/test/myjavalib.txt
-.intermediates/myjavalib.stubs.source.test/android_common/metalava/myjavalib.stubs.source.test_removed.txt -> sdk_library/test/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source.test/android_common/everything/myjavalib.stubs.source.test_api.txt -> sdk_library/test/myjavalib.txt
+.intermediates/myjavalib.stubs.source.test/android_common/everything/myjavalib.stubs.source.test_removed.txt -> sdk_library/test/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
@@ -1000,8 +1000,8 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib-foo.stubs/android_common/combined/myjavalib-foo.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib-foo.stubs.source/android_common/metalava/myjavalib-foo.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib-foo.stubs.source/android_common/metalava/myjavalib-foo.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib-foo.stubs.source/android_common/everything/myjavalib-foo.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib-foo.stubs.source/android_common/everything/myjavalib-foo.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
@@ -1053,9 +1053,9 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source-stubs.srcjar -> sdk_library/public/myjavalib.srcjar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source-stubs.srcjar -> sdk_library/public/myjavalib.srcjar
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
`),
)
}
@@ -1101,9 +1101,9 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_annotations.zip -> sdk_library/public/myjavalib_annotations.zip
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_annotations.zip -> sdk_library/public/myjavalib_annotations.zip
`),
checkMergeZips(".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip"),
)
@@ -1154,8 +1154,8 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
`),
checkMergeZips(".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip"),
)
@@ -1271,8 +1271,8 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
@@ -1319,8 +1319,8 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
@@ -1377,11 +1377,11 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
.intermediates/myjavalib.stubs.system/android_common/combined/myjavalib.stubs.system.jar -> sdk_library/system/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source.system/android_common/metalava/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt
-.intermediates/myjavalib.stubs.source.system/android_common/metalava/myjavalib.stubs.source.system_removed.txt -> sdk_library/system/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source.system/android_common/everything/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt
+.intermediates/myjavalib.stubs.source.system/android_common/everything/myjavalib.stubs.source.system_removed.txt -> sdk_library/system/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
@@ -1449,14 +1449,14 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
.intermediates/myjavalib.stubs.system/android_common/combined/myjavalib.stubs.system.jar -> sdk_library/system/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source.system/android_common/metalava/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt
-.intermediates/myjavalib.stubs.source.system/android_common/metalava/myjavalib.stubs.source.system_removed.txt -> sdk_library/system/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source.system/android_common/everything/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt
+.intermediates/myjavalib.stubs.source.system/android_common/everything/myjavalib.stubs.source.system_removed.txt -> sdk_library/system/myjavalib-removed.txt
.intermediates/myjavalib.stubs.module_lib/android_common/combined/myjavalib.stubs.module_lib.jar -> sdk_library/module-lib/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source.module_lib/android_common/metalava/myjavalib.stubs.source.module_lib_api.txt -> sdk_library/module-lib/myjavalib.txt
-.intermediates/myjavalib.stubs.source.module_lib/android_common/metalava/myjavalib.stubs.source.module_lib_removed.txt -> sdk_library/module-lib/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source.module_lib/android_common/everything/myjavalib.stubs.source.module_lib_api.txt -> sdk_library/module-lib/myjavalib.txt
+.intermediates/myjavalib.stubs.source.module_lib/android_common/everything/myjavalib.stubs.source.module_lib_removed.txt -> sdk_library/module-lib/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/module-lib/myjavalib_stub_sources.zip",
@@ -1515,11 +1515,11 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
.intermediates/myjavalib.stubs.system_server/android_common/combined/myjavalib.stubs.system_server.jar -> sdk_library/system-server/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source.system_server/android_common/metalava/myjavalib.stubs.source.system_server_api.txt -> sdk_library/system-server/myjavalib.txt
-.intermediates/myjavalib.stubs.source.system_server/android_common/metalava/myjavalib.stubs.source.system_server_removed.txt -> sdk_library/system-server/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source.system_server/android_common/everything/myjavalib.stubs.source.system_server_api.txt -> sdk_library/system-server/myjavalib.txt
+.intermediates/myjavalib.stubs.source.system_server/android_common/everything/myjavalib.stubs.source.system_server_removed.txt -> sdk_library/system-server/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
@@ -1569,8 +1569,8 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
@@ -1626,8 +1626,8 @@
`),
checkAllCopyRules(`
.intermediates/myjavalib.stubs/android_common/combined/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/everything/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
docs/known_doctags -> doctags/docs/known_doctags
`),
)
diff --git a/sdk/sdk_test.go b/sdk/sdk_test.go
index 5a25146..d14c2ba 100644
--- a/sdk/sdk_test.go
+++ b/sdk/sdk_test.go
@@ -488,8 +488,8 @@
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/stub-flags.csv -> hiddenapi/stub-flags.csv
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/all-flags.csv -> hiddenapi/all-flags.csv
.intermediates/mysdklibrary.stubs/android_common/combined/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
+.intermediates/mysdklibrary.stubs.source/android_common/everything/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
`),
)
})
diff --git a/sysprop/sysprop_test.go b/sysprop/sysprop_test.go
index e51fe39..e5b3dea 100644
--- a/sysprop/sysprop_test.go
+++ b/sysprop/sysprop_test.go
@@ -125,6 +125,12 @@
variables.DeviceSystemSdkVersions = []string{"28"}
variables.DeviceVndkVersion = proptools.StringPtr("current")
variables.Platform_vndk_version = proptools.StringPtr("29")
+ variables.DeviceCurrentApiLevelForVendorModules = proptools.StringPtr("28")
+ }),
+ java.FixtureWithPrebuiltApis(map[string][]string{
+ "28": {},
+ "29": {},
+ "30": {},
}),
mockFS.AddToFixture(),
android.FixtureWithRootAndroidBp(bp),
diff --git a/testing/code_metadata.go b/testing/code_metadata.go
index 3cf7c59..11ba430 100644
--- a/testing/code_metadata.go
+++ b/testing/code_metadata.go
@@ -128,7 +128,7 @@
intermediatePath := android.PathForModuleOut(
ctx, "intermediateCodeMetadata.pb",
)
- android.WriteFileRule(ctx, intermediatePath, string(protoData))
+ android.WriteFileRuleVerbatim(ctx, intermediatePath, string(protoData))
android.SetProvider(ctx,
CodeMetadataProviderKey,
diff --git a/testing/test_spec.go b/testing/test_spec.go
index d259612..4d885c6 100644
--- a/testing/test_spec.go
+++ b/testing/test_spec.go
@@ -117,7 +117,7 @@
if err != nil {
ctx.ModuleErrorf("Error: %s", err.Error())
}
- android.WriteFileRule(ctx, intermediatePath, string(protoData))
+ android.WriteFileRuleVerbatim(ctx, intermediatePath, string(protoData))
android.SetProvider(ctx,
TestSpecProviderKey, TestSpecProviderData{
diff --git a/ui/build/Android.bp b/ui/build/Android.bp
index 21453ba..ee286f6 100644
--- a/ui/build/Android.bp
+++ b/ui/build/Android.bp
@@ -35,6 +35,7 @@
"blueprint",
"blueprint-bootstrap",
"blueprint-microfactory",
+ "soong-android",
"soong-finder",
"soong-remoteexec",
"soong-shared",
@@ -46,6 +47,7 @@
"soong-ui-tracer",
],
srcs: [
+ "androidmk_denylist.go",
"build.go",
"cleanbuild.go",
"config.go",
diff --git a/ui/build/androidmk_denylist.go b/ui/build/androidmk_denylist.go
new file mode 100644
index 0000000..b2266b2
--- /dev/null
+++ b/ui/build/androidmk_denylist.go
@@ -0,0 +1,44 @@
+// Copyright 2024 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 build
+
+import (
+ "strings"
+
+ "android/soong/android"
+)
+
+var androidmk_denylist []string = []string{
+ "chained_build_config/",
+ "cts/",
+ "dalvik/",
+ "developers/",
+ "kernel/",
+ "libcore/",
+ "libnativehelper/",
+ "pdk/",
+ "toolchain/",
+}
+
+func blockAndroidMks(androidMks []string) []string {
+ return android.FilterListPred(androidMks, func(s string) bool {
+ for _, d := range androidmk_denylist {
+ if strings.HasPrefix(s, d) {
+ return false
+ }
+ }
+ return true
+ })
+}
diff --git a/ui/build/finder.go b/ui/build/finder.go
index d0bcf40..a114079 100644
--- a/ui/build/finder.go
+++ b/ui/build/finder.go
@@ -128,6 +128,7 @@
// Stop searching a subdirectory recursively after finding an Android.mk.
androidMks := f.FindFirstNamedAt(".", "Android.mk")
+ androidMks = blockAndroidMks(androidMks)
err := dumpListToFile(ctx, config, androidMks, filepath.Join(dumpDir, "Android.mk.list"))
if err != nil {
ctx.Fatalf("Could not export module list: %v", err)
diff --git a/ui/build/soong.go b/ui/build/soong.go
index 0bf8862..90c3bfc 100644
--- a/ui/build/soong.go
+++ b/ui/build/soong.go
@@ -36,6 +36,7 @@
"github.com/google/blueprint"
"github.com/google/blueprint/bootstrap"
"github.com/google/blueprint/microfactory"
+ "github.com/google/blueprint/pathtools"
"google.golang.org/protobuf/proto"
)
@@ -181,7 +182,15 @@
return globPathName
}
-func (pb PrimaryBuilderFactory) primaryBuilderInvocation() bootstrap.PrimaryBuilderInvocation {
+func getGlobPathNameFromPrimaryBuilderFactory(config Config, pb PrimaryBuilderFactory) string {
+ if pb.name == soongBuildTag {
+ // Glob path for soong build would be separated per product target
+ return getGlobPathName(config)
+ }
+ return pb.name
+}
+
+func (pb PrimaryBuilderFactory) primaryBuilderInvocation(config Config) bootstrap.PrimaryBuilderInvocation {
commonArgs := make([]string, 0, 0)
if !pb.config.skipSoongTests {
@@ -215,11 +224,7 @@
var allArgs []string
allArgs = append(allArgs, pb.specificArgs...)
- globPathName := pb.name
- // Glob path for soong build would be separated per product target
- if pb.name == soongBuildTag {
- globPathName = getGlobPathName(pb.config)
- }
+ globPathName := getGlobPathNameFromPrimaryBuilderFactory(config, pb)
allArgs = append(allArgs,
"--globListDir", globPathName,
"--globFile", pb.config.NamedGlobFile(globPathName))
@@ -234,8 +239,11 @@
}
allArgs = append(allArgs, "Android.bp")
+ globfiles := bootstrap.GlobFileListFiles(bootstrap.GlobDirectory(config.SoongOutDir(), globPathName))
+
return bootstrap.PrimaryBuilderInvocation{
Inputs: []string{"Android.bp"},
+ Implicits: globfiles,
Outputs: []string{pb.output},
Args: allArgs,
Description: pb.description,
@@ -376,17 +384,10 @@
if debuggedInvocations[pbf.name] {
pbf.debugPort = delvePort
}
- pbi := pbf.primaryBuilderInvocation()
+ pbi := pbf.primaryBuilderInvocation(config)
invocations = append(invocations, pbi)
}
- // The glob .ninja files are subninja'd. However, they are generated during
- // the build itself so we write an empty file if the file does not exist yet
- // so that the subninja doesn't fail on clean builds
- for _, globFile := range bootstrapGlobFileList(config) {
- writeEmptyFile(ctx, globFile)
- }
-
blueprintArgs := bootstrap.Args{
ModuleListFile: filepath.Join(config.FileListDir(), "Android.bp.list"),
OutFile: shared.JoinPath(config.SoongOutDir(), "bootstrap.ninja"),
@@ -408,6 +409,28 @@
primaryBuilderInvocations: invocations,
}
+ // The glob ninja files are generated during the main build phase. However, the
+ // primary buildifer invocation depends on all of its glob files, even before
+ // it's been run. Generate a "empty" glob ninja file on the first run,
+ // so that the files can be there to satisfy the dependency.
+ for _, pb := range pbfs {
+ globPathName := getGlobPathNameFromPrimaryBuilderFactory(config, pb)
+ globNinjaFile := config.NamedGlobFile(globPathName)
+ if _, err := os.Stat(globNinjaFile); os.IsNotExist(err) {
+ err := bootstrap.WriteBuildGlobsNinjaFile(&bootstrap.GlobSingleton{
+ GlobLister: func() pathtools.MultipleGlobResults { return nil },
+ GlobFile: globNinjaFile,
+ GlobDir: bootstrap.GlobDirectory(config.SoongOutDir(), globPathName),
+ SrcDir: ".",
+ }, blueprintConfig)
+ if err != nil {
+ ctx.Fatal(err)
+ }
+ } else if err != nil {
+ ctx.Fatal(err)
+ }
+ }
+
// since `bootstrap.ninja` is regenerated unconditionally, we ignore the deps, i.e. little
// reason to write a `bootstrap.ninja.d` file
_, err := bootstrap.RunBlueprint(blueprintArgs, bootstrap.DoEverything, blueprintCtx, blueprintConfig)
diff --git a/ui/build/test_build.go b/ui/build/test_build.go
index c5dc4c5..3095139 100644
--- a/ui/build/test_build.go
+++ b/ui/build/test_build.go
@@ -63,6 +63,7 @@
outDir := config.OutDir()
modulePathsDir := filepath.Join(outDir, ".module_paths")
+ rawFilesDir := filepath.Join(outDir, "soong", "raw")
variablesFilePath := filepath.Join(outDir, "soong", "soong.variables")
// dexpreopt.config is an input to the soong_docs action, which runs the
@@ -88,6 +89,7 @@
continue
}
if strings.HasPrefix(line, modulePathsDir) ||
+ strings.HasPrefix(line, rawFilesDir) ||
line == variablesFilePath ||
line == dexpreoptConfigFilePath ||
line == buildDatetimeFilePath ||