Skip to content

Commit

Permalink
Do even less work when not importing Index Build indexstores (#3078)
Browse files Browse the repository at this point in the history
Signed-off-by: Brentley Jones <github@brentleyjones.com>
  • Loading branch information
brentleyjones authored Aug 20, 2024
1 parent 1588079 commit 4a02abb
Showing 1 changed file with 26 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,43 @@ cd "$SRCROOT"
readonly config="${BAZEL_CONFIG}_indexbuild"

# Compiled outputs (i.e. swiftmodules) and generated inputs
readonly output_groups=(
"index_import"
output_groups=(
# Compile params
"bc $BAZEL_TARGET_ID"
# Products (i.e. bundles) and index store data. The products themselves aren't
# used, they cause transitive files to be created. We use
# `--experimental_remote_download_regex` below to collect the files we care
# about.
"bp $BAZEL_TARGET_ID"
# TODO: Remove `bi` once we remove support for legacy generation mode
"bi $BAZEL_TARGET_ID"
)

readonly targetid_regex='@{0,2}(.*)//(.*):(.*) ([^\ ]+)$'

indexstores_filelists=()
if [[ "$IMPORT_INDEX_BUILD_INDEXSTORES" == "YES" && \
"$BAZEL_TARGET_ID" =~ $targetid_regex ]]; then
repo="${BASH_REMATCH[1]}"
if [[ "$repo" == "@" ]]; then
repo=""
fi
if [[ "$IMPORT_INDEX_BUILD_INDEXSTORES" == "YES" ]]; then
output_groups+=(
"index_import"
# TODO: Remove `bi` once we remove support for legacy generation mode
"bi $BAZEL_TARGET_ID"
)

readonly targetid_regex='@{0,2}(.*)//(.*):(.*) ([^\ ]+)$'

package="${BASH_REMATCH[2]}"
target="${BASH_REMATCH[3]}"
configuration="${BASH_REMATCH[4]}"
filelist="$configuration/bin/${repo:+"external/$repo/"}$package/$target-bi.filelist"
if [[ "$BAZEL_TARGET_ID" =~ $targetid_regex ]]; then
repo="${BASH_REMATCH[1]}"
if [[ "$repo" == "@" ]]; then
repo=""
fi

package="${BASH_REMATCH[2]}"
target="${BASH_REMATCH[3]}"
configuration="${BASH_REMATCH[4]}"
filelist="$configuration/bin/${repo:+"external/$repo/"}$package/$target-bi.filelist"

indexstores_filelists+=("$filelist")
fi

indexstores_filelists+=("$filelist")
readonly indexstores_regex='.*\.indexstore/.*|'
else
readonly indexstores_regex=''
fi

readonly build_pre_config_flags=(
Expand All @@ -64,7 +72,7 @@ readonly build_pre_config_flags=(
# This is brittle. If different file extensions are used for compilation
# inputs, they will need to be added to this list. Ideally we can stop doing
# this once Bazel adds support for a Remote Output Service.
"--experimental_remote_download_regex=.*\.indexstore/.*|.*\.(cfg|c|C|cc|cl|cpp|cu|cxx|c++|def|h|H|hh|hpp|hxx|h++|hmap|ilc|inc|inl|ipp|tcc|tlh|tli|tpp|m|modulemap|mm|pch|swift|swiftdoc|swiftmodule|swiftsourceinfo|yaml)$"
"--experimental_remote_download_regex=${indexstores_regex}.*|.*\.(cfg|c|C|cc|cl|cpp|cu|cxx|c++|def|h|H|hh|hpp|hxx|h++|hmap|ilc|inc|inl|ipp|tcc|tlh|tli|tpp|m|modulemap|mm|pch|swift|swiftdoc|swiftmodule|swiftsourceinfo|yaml)$"
)

source "$BAZEL_INTEGRATION_DIR/bazel_build.sh"
Expand Down

0 comments on commit 4a02abb

Please sign in to comment.