From bab814f33022363ce34987a73992d2870d3e6124 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Wed, 26 Aug 2020 15:34:53 -0700 Subject: [PATCH] Add a showcommands function to envsetup. This is similar to the old `m showcommands`, but operates on specific output paths instead and does not require a build aside from the initial invocation of soong to generate the ninja files. The `--regenerate` option is accepted that causes the ninja file to be regenerated first, but this is not the default because it is slow. Just note that without this flag results may be stale. It unfortunately doesn't work for everything in out. For example, `$OUT/system/lib/libc.so` won't work because it is a symlink that isn't in the build graph, but `$OUT/system/lib/bootstrap/libc.so` works. Test: showcommands out/target/product/walleye/system/lib/libz.so Bug: None Change-Id: I4cfded3db994044870fc71ae4bcf9a69224b1e15 --- envsetup.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/envsetup.sh b/envsetup.sh index e98103497..abe1eabb2 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -1613,6 +1613,41 @@ function source_vendorsetup() { done } +function showcommands() { + local T=$(gettop) + if [[ -z "$TARGET_PRODUCT" ]]; then + >&2 echo "TARGET_PRODUCT not set. Run lunch." + return + fi + case $(uname -s) in + Darwin) + PREBUILT_NAME=darwin-x86 + ;; + Linux) + PREBUILT_NAME=linux-x86 + ;; + *) + >&2 echo Unknown host $(uname -s) + return + ;; + esac + if [[ -z "$OUT_DIR" ]]; then + if [[ -z "$OUT_DIR_COMMON_BASE" ]]; then + OUT_DIR=out + else + OUT_DIR=${OUT_DIR_COMMON_BASE}/${PWD##*/} + fi + fi + if [[ "$1" == "--regenerate" ]]; then + shift 1 + NINJA_ARGS="-t commands $@" m + else + (cd $T && prebuilts/build-tools/$PREBUILT_NAME/bin/ninja \ + -f $OUT_DIR/combined-${TARGET_PRODUCT}.ninja \ + -t commands "$@") + fi +} + validate_current_shell source_vendorsetup addcompletions