Skip to content

Commit

Permalink
Merge pull request #78 from bazel-ios/amber/move-incremental-indexstores
Browse files Browse the repository at this point in the history
Only move indexstores generated by build
  • Loading branch information
amberdixon authored Jun 24, 2020
2 parents 4f96d7b + 9edf402 commit d81b490
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 43 deletions.
1 change: 1 addition & 0 deletions rules/xcodeproj.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ def _xcodeproj_impl(ctx):
set -euxo pipefail
cd $BAZEL_WORKSPACE_ROOT
export BAZEL_BUILD_EVENT_TEXT_FILENAME=$(mktemp -d)/build_event.txt
$BAZEL_BUILD_EXEC {bazel_build_target_name}
$BAZEL_INSTALLER
""".format(bazel_build_target_name = target_info.bazel_build_target_name),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,26 @@ set -euo pipefail

# See `_indexstore.sh` for full details.

# Make sure add these to bazel build target copts for objective-c
find "$BAZEL_WORKSPACE_ROOT/bazel-out"/*/bin/ \
-type d \
-name "*.indexstore" \
-print0 \
| xargs -0 "$BAZEL_INSTALLERS_DIR/_indexstore.sh"

echo "Finish remapping index files"
echo "Start remapping index files at `date`"

FOUND_INDEXSTORES=`pcregrep -o1 'command_line: "(.*\.indexstore)' $BAZEL_BUILD_EVENT_TEXT_FILENAME || true`

declare -a EXISTING_INDEXSTORES=()
for i in $FOUND_INDEXSTORES
do
if [ -d $i ]
then
EXISTING_INDEXSTORES+=($i)
fi
done

echo "Found ${#EXISTING_INDEXSTORES[@]} existing indexstores"

if [ ${#EXISTING_INDEXSTORES[@]} -ne 0 ]
then
"$BAZEL_INSTALLERS_DIR/_indexstore.sh" $EXISTING_INDEXSTORES
else
echo "No indexstores found"
fi

echo "Finish remapping index files at `date`"
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\nset -euxo pipefail\ncd $BAZEL_WORKSPACE_ROOT\n\n$BAZEL_BUILD_EXEC tests/macos/xcodeproj:Single-Application-RunnableTestSuite_iPad-Air-2__12.4\n$BAZEL_INSTALLER\n";
shellScript = "\nset -euxo pipefail\ncd $BAZEL_WORKSPACE_ROOT\n\nexport BAZEL_BUILD_EVENT_TEXT_FILENAME=$(mktemp -d)/build_event.txt\n$BAZEL_BUILD_EXEC tests/macos/xcodeproj:Single-Application-RunnableTestSuite_iPad-Air-2__12.4\n$BAZEL_INSTALLER\n";
};
8C9FD347EEDF21022077C21D /* Build with bazel */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -222,7 +222,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\nset -euxo pipefail\ncd $BAZEL_WORKSPACE_ROOT\n\n$BAZEL_BUILD_EXEC rules/test_host_app:iOS-12.0-AppHost\n$BAZEL_INSTALLER\n";
shellScript = "\nset -euxo pipefail\ncd $BAZEL_WORKSPACE_ROOT\n\nexport BAZEL_BUILD_EVENT_TEXT_FILENAME=$(mktemp -d)/build_event.txt\n$BAZEL_BUILD_EXEC rules/test_host_app:iOS-12.0-AppHost\n$BAZEL_INSTALLER\n";
};
CEFFC66550AFA438E8952334 /* Build with bazel */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -240,7 +240,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\nset -euxo pipefail\ncd $BAZEL_WORKSPACE_ROOT\n\n$BAZEL_BUILD_EXEC tests/macos/xcodeproj:Single-Application-UnitTests\n$BAZEL_INSTALLER\n";
shellScript = "\nset -euxo pipefail\ncd $BAZEL_WORKSPACE_ROOT\n\nexport BAZEL_BUILD_EVENT_TEXT_FILENAME=$(mktemp -d)/build_event.txt\n$BAZEL_BUILD_EXEC tests/macos/xcodeproj:Single-Application-UnitTests\n$BAZEL_INSTALLER\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,26 @@ set -euo pipefail

# See `_indexstore.sh` for full details.

# Make sure add these to bazel build target copts for objective-c
find "$BAZEL_WORKSPACE_ROOT/bazel-out"/*/bin/ \
-type d \
-name "*.indexstore" \
-print0 \
| xargs -0 "$BAZEL_INSTALLERS_DIR/_indexstore.sh"

echo "Finish remapping index files"
echo "Start remapping index files at `date`"

FOUND_INDEXSTORES=`pcregrep -o1 'command_line: "(.*\.indexstore)' $BAZEL_BUILD_EVENT_TEXT_FILENAME || true`

declare -a EXISTING_INDEXSTORES=()
for i in $FOUND_INDEXSTORES
do
if [ -d $i ]
then
EXISTING_INDEXSTORES+=($i)
fi
done

echo "Found ${#EXISTING_INDEXSTORES[@]} existing indexstores"

if [ ${#EXISTING_INDEXSTORES[@]} -ne 0 ]
then
"$BAZEL_INSTALLERS_DIR/_indexstore.sh" $EXISTING_INDEXSTORES
else
echo "No indexstores found"
fi

echo "Finish remapping index files at `date`"
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\nset -euxo pipefail\ncd $BAZEL_WORKSPACE_ROOT\n\n$BAZEL_BUILD_EXEC tests/macos/xcodeproj:Single-Application-RunnableTestSuite_iPad-Air-2__12.4\n$BAZEL_INSTALLER\n";
shellScript = "\nset -euxo pipefail\ncd $BAZEL_WORKSPACE_ROOT\n\nexport BAZEL_BUILD_EVENT_TEXT_FILENAME=$(mktemp -d)/build_event.txt\n$BAZEL_BUILD_EXEC tests/macos/xcodeproj:Single-Application-RunnableTestSuite_iPad-Air-2__12.4\n$BAZEL_INSTALLER\n";
};
B6158A7B27A31249CCAFEC9E /* Build with bazel */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -222,7 +222,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\nset -euxo pipefail\ncd $BAZEL_WORKSPACE_ROOT\n\n$BAZEL_BUILD_EXEC rules/test_host_app:iOS-12.0-AppHost\n$BAZEL_INSTALLER\n";
shellScript = "\nset -euxo pipefail\ncd $BAZEL_WORKSPACE_ROOT\n\nexport BAZEL_BUILD_EVENT_TEXT_FILENAME=$(mktemp -d)/build_event.txt\n$BAZEL_BUILD_EXEC rules/test_host_app:iOS-12.0-AppHost\n$BAZEL_INSTALLER\n";
};
D318F6F09E06731B996B9EF2 /* Build with bazel */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -240,7 +240,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\nset -euxo pipefail\ncd $BAZEL_WORKSPACE_ROOT\n\n$BAZEL_BUILD_EXEC tests/macos/xcodeproj:Single-Application-UnitTests\n$BAZEL_INSTALLER\n";
shellScript = "\nset -euxo pipefail\ncd $BAZEL_WORKSPACE_ROOT\n\nexport BAZEL_BUILD_EVENT_TEXT_FILENAME=$(mktemp -d)/build_event.txt\n$BAZEL_BUILD_EXEC tests/macos/xcodeproj:Single-Application-UnitTests\n$BAZEL_INSTALLER\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,26 @@ set -euo pipefail

# See `_indexstore.sh` for full details.

# Make sure add these to bazel build target copts for objective-c
find "$BAZEL_WORKSPACE_ROOT/bazel-out"/*/bin/ \
-type d \
-name "*.indexstore" \
-print0 \
| xargs -0 "$BAZEL_INSTALLERS_DIR/_indexstore.sh"

echo "Finish remapping index files"
echo "Start remapping index files at `date`"

FOUND_INDEXSTORES=`pcregrep -o1 'command_line: "(.*\.indexstore)' $BAZEL_BUILD_EVENT_TEXT_FILENAME || true`

declare -a EXISTING_INDEXSTORES=()
for i in $FOUND_INDEXSTORES
do
if [ -d $i ]
then
EXISTING_INDEXSTORES+=($i)
fi
done

echo "Found ${#EXISTING_INDEXSTORES[@]} existing indexstores"

if [ ${#EXISTING_INDEXSTORES[@]} -ne 0 ]
then
"$BAZEL_INSTALLERS_DIR/_indexstore.sh" $EXISTING_INDEXSTORES
else
echo "No indexstores found"
fi

echo "Finish remapping index files at `date`"
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\nset -euxo pipefail\ncd $BAZEL_WORKSPACE_ROOT\n\n$BAZEL_BUILD_EXEC tests/ios/unit-test/test-imports-app:TestImports-Unit-Tests\n$BAZEL_INSTALLER\n";
shellScript = "\nset -euxo pipefail\ncd $BAZEL_WORKSPACE_ROOT\n\nexport BAZEL_BUILD_EVENT_TEXT_FILENAME=$(mktemp -d)/build_event.txt\n$BAZEL_BUILD_EXEC tests/ios/unit-test/test-imports-app:TestImports-Unit-Tests\n$BAZEL_INSTALLER\n";
};
2756FB505F15157D82C9069E /* Build with bazel */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -288,7 +288,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\nset -euxo pipefail\ncd $BAZEL_WORKSPACE_ROOT\n\n$BAZEL_BUILD_EXEC rules/test_host_app:iOS-10.0-AppHost\n$BAZEL_INSTALLER\n";
shellScript = "\nset -euxo pipefail\ncd $BAZEL_WORKSPACE_ROOT\n\nexport BAZEL_BUILD_EVENT_TEXT_FILENAME=$(mktemp -d)/build_event.txt\n$BAZEL_BUILD_EXEC rules/test_host_app:iOS-10.0-AppHost\n$BAZEL_INSTALLER\n";
};
3D60A491CE72F7D799EC0383 /* Build with bazel */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -306,7 +306,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\nset -euxo pipefail\ncd $BAZEL_WORKSPACE_ROOT\n\n$BAZEL_BUILD_EXEC tests/ios/unit-test/test-imports-app:TestImports-App\n$BAZEL_INSTALLER\n";
shellScript = "\nset -euxo pipefail\ncd $BAZEL_WORKSPACE_ROOT\n\nexport BAZEL_BUILD_EVENT_TEXT_FILENAME=$(mktemp -d)/build_event.txt\n$BAZEL_BUILD_EXEC tests/ios/unit-test/test-imports-app:TestImports-App\n$BAZEL_INSTALLER\n";
};
6DBC122A6C2C8B5D5805E16D /* Build with bazel */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -324,7 +324,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\nset -euxo pipefail\ncd $BAZEL_WORKSPACE_ROOT\n\n$BAZEL_BUILD_EXEC tests/ios/unit-test:DefaultHosted\n$BAZEL_INSTALLER\n";
shellScript = "\nset -euxo pipefail\ncd $BAZEL_WORKSPACE_ROOT\n\nexport BAZEL_BUILD_EVENT_TEXT_FILENAME=$(mktemp -d)/build_event.txt\n$BAZEL_BUILD_EXEC tests/ios/unit-test:DefaultHosted\n$BAZEL_INSTALLER\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down
2 changes: 1 addition & 1 deletion tools/xcodeproj_shims/build-wrapper.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
set -euxo pipefail

$BAZEL_PATH build $1 2>&1 | $BAZEL_OUTPUT_PROCESSOR
$BAZEL_PATH build --build_event_text_file=$BAZEL_BUILD_EVENT_TEXT_FILENAME --build_event_publish_all_actions $1 2>&1 | $BAZEL_OUTPUT_PROCESSOR
31 changes: 23 additions & 8 deletions tools/xcodeproj_shims/installers/indexstores.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,26 @@ set -euo pipefail

# See `_indexstore.sh` for full details.

# Make sure add these to bazel build target copts for objective-c
find "$BAZEL_WORKSPACE_ROOT/bazel-out"/*/bin/ \
-type d \
-name "*.indexstore" \
-print0 \
| xargs -0 "$BAZEL_INSTALLERS_DIR/_indexstore.sh"

echo "Finish remapping index files"
echo "Start remapping index files at `date`"

FOUND_INDEXSTORES=`pcregrep -o1 'command_line: "(.*\.indexstore)' $BAZEL_BUILD_EVENT_TEXT_FILENAME || true`

declare -a EXISTING_INDEXSTORES=()
for i in $FOUND_INDEXSTORES
do
if [ -d $i ]
then
EXISTING_INDEXSTORES+=($i)
fi
done

echo "Found ${#EXISTING_INDEXSTORES[@]} existing indexstores"

if [ ${#EXISTING_INDEXSTORES[@]} -ne 0 ]
then
"$BAZEL_INSTALLERS_DIR/_indexstore.sh" $EXISTING_INDEXSTORES
else
echo "No indexstores found"
fi

echo "Finish remapping index files at `date`"

0 comments on commit d81b490

Please sign in to comment.