Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Bazel build and stub builds in parallel for more performant builds #1177

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ $(BAZEL_INTEGRATION_DIR)/calculate_output_groups.py
name: name,
outputFileListPaths: outputFileListPaths,
shellScript: """
"$BAZEL_INTEGRATION_DIR/bazel_build.sh"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And you could only do this in BwB mode, because in BwX, it needs generated sources. I think there might be other issues as well.

I like the idea though, and I hadn't considered backgrounding it. I was planning on something like this though where the various steps go as soon as they can, and I'll probably use this trick to accomplish it.

"$BAZEL_INTEGRATION_DIR/bazel_build.sh" > "$OBJROOT/bazel_build_output" 2>&1 &

""",
showEnvVarsInLog: false,
Expand Down
2 changes: 2 additions & 0 deletions xcodeproj/internal/bazel_integration_files/bazel_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ touch "$build_marker"
"$GENERATOR_LABEL" \
2>&1

touch "$OBJROOT/bazel_build_finish"

indexstores_filelists=()
for output_group in "${output_groups[@]}"; do
filelist="$GENERATOR_TARGET_NAME-${output_group//\//_}"
Expand Down
29 changes: 29 additions & 0 deletions xcodeproj/internal/bazel_integration_files/copy_outputs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,35 @@ if [[ "$ACTION" == indexbuild ]]; then
# Write to "$SCHEME_TARGET_IDS_FILE" to allow next index to catch up
echo "$BAZEL_LABEL,$BAZEL_TARGET_ID" > "$SCHEME_TARGET_IDS_FILE"
else
# If this is the requesting target, wait for Bazel build to finish
should_wait_for_bazel=false
while IFS= read -r line; do
if [[ "$line" == "$BAZEL_LABEL,$BAZEL_TARGET_ID" ]]; then
should_wait_for_bazel=true
break
fi
done < "$SCHEME_TARGET_IDS_FILE"

if [[ "$should_wait_for_bazel" == true ]]; then
bazel_build_start_marker="$OBJROOT/bazel_build_start"
bazel_build_finish_marker="$OBJROOT/bazel_build_finish"
bazel_build_output="$OBJROOT/bazel_build_output"

while [[ ! -f "$bazel_build_finish_marker" ]] || [[ "$bazel_build_start_marker" -nt "$bazel_build_finish_marker" ]]; do
if [[ -f "$bazel_build_output" ]] && \
[[ "$bazel_build_start_marker" -ot "$bazel_build_output" ]] && \
[[ "$(tail -n 1 "$bazel_build_output")" == *"FAILED: Build did NOT complete successfully" ]]; then
cat "$bazel_build_output"
exit 1
fi

echo "Waiting for Bazel build to finish..."
sleep 5
done

cat "$bazel_build_output"
fi

# Copy product
if [[ -n ${BAZEL_OUTPUTS_PRODUCT:-} ]]; then
if [[ "$BAZEL_OUTPUTS_PRODUCT" = *.ipa ]]; then
Expand Down