platform_build_soong/cmd
Jingwen Chen 5ba7e479d1 Create a AOSP Bazel overlay workspace with Soong
The Bazel overlay is a directory at out/soong/bazel_overlay that
replicates the layout of the AOSP Soong module tree, but as a Bazel
workspace. Each Soong module variant is represented as a BUILD target
created with the `soong_module` rule.

To create this overlay, run `m bazel_overlay`.

A `soong_module` target can depend on other `soong_module` targets.
These dependencies replicate each module's `directDeps` in the Blueprint
graph, just before `PrepareBuildActions`.

This enables users to use bazel query as a way to introspect the Soong
module graph. For example,

- Direct reverse dependencies of //bionic/libc:generated_android_ids in
//bionic/libc/...:

$ bazel query 'rdeps(//bionic/libc/...,
//bionic/libc:generated_android_ids, 1)'
//bionic/libc:libc_bionic_ndk--android_recovery_arm_armv7-a-neon_static
//bionic/libc:libc_bionic_ndk--android_ramdisk_arm_armv7-a-neon_static
//bionic/libc:libc_bionic_ndk--android_arm_armv7-a-neon_static_com.android.runtime
//bionic/libc:libc_bionic_ndk--android_arm_armv7-a-neon_static
//bionic/libc:generated_android_ids

- Why does com.android.runtime depend on lzma?

$ bazel query
'somepath(//bionic/apex:com.android.runtime--android_common_com.android.runtime_image,
//external/lzma/...)'
//bionic/apex:com.android.runtime--android_common_com.android.runtime_image
//bionic/libc/malloc_debug:libc_malloc_debug--android_arm_armv7-a-neon_shared_com.android.runtime
//system/core/libunwindstack:libunwindstack--android_arm_armv7-a-neon_shared_com.android.runtime
//external/lzma/C:liblzma--android_arm_armv7-a-neon_shared_com.android.runtime

- What does the dep graph of //bionic/libc:crtbegin_so look like?

$ bazel query
'deps(//bionic/libc:crtbegin_so--android_arm_armv7-a-neon)'
--output=graph > graph.in && dot -Tpng < graph.in > graph.png

https://photos.app.goo.gl/DfsdoFRNsRjGwTmy8

Test:  croot && m bazel_overlay && cd out/soong/bazel_overlay && bazel
query //... && bazel query 'rdeps(//bionic/libc/...,
//bionic/libc:generated_android_ids, 1)'

Signed-off-by: Jingwen Chen <jingwen@google.com>
Change-Id: I3bf40309bfb2d963bb8a688706385a57ee304c37#
2020-08-06 10:24:21 +00:00
..
dep_fixer Rewrite depfile from sbox to stay reproducible 2019-08-29 14:47:40 -07:00
diff_target_files Update language to comply with inclusive guidance 2020-07-31 16:50:52 +00:00
extract_apks Output apkcerts file for android_app_set. 2020-07-01 10:03:09 -07:00
extract_jar_packages Fix bpfmt issues and add bpfmt to preupload checks 2020-06-29 09:14:08 +02:00
extract_linker Fix bpfmt issues and add bpfmt to preupload checks 2020-06-29 09:14:08 +02:00
fileslist fileslist: hash the content of symlink, not the file it points to. 2017-03-29 13:43:41 -07:00
host_bionic_inject Explain checkLinker errors a bit more. 2020-05-27 21:31:42 +01:00
javac_wrapper Silence trailing "1 warning" message from javac when warning is silenced 2019-11-11 21:48:33 +00:00
merge_zips Update language to comply with inclusive guidance 2020-07-28 21:22:12 +00:00
multiproduct_kati Take into account RAM usage for multiproduct_kati 2019-12-27 09:54:11 -08:00
path_interposer Remove TEMPORARY_DISABLE_PATH_RESTRICTIONS 2020-05-04 19:54:57 +00:00
pom2bp pom2bp: add apex_available/min_sdk_version 2020-05-27 00:37:45 +09:00
pom2mk Add -jetifier to pom2mk and pom2bp 2019-04-20 21:47:14 -07:00
sbox Fix bpfmt issues and add bpfmt to preupload checks 2020-06-29 09:14:08 +02:00
soong_build Create a AOSP Bazel overlay workspace with Soong 2020-08-06 10:24:21 +00:00
soong_env Fix bpfmt issues and add bpfmt to preupload checks 2020-06-29 09:14:08 +02:00
soong_ui Inclusive fix: renaming dumb terminal to simple terminal. 2020-07-28 20:25:03 +00:00
zip2zip Fix bpfmt issues and add bpfmt to preupload checks 2020-06-29 09:14:08 +02:00
zipsync Fix bpfmt issues and add bpfmt to preupload checks 2020-06-29 09:14:08 +02:00