diff --git a/rules/xcodeproj.bzl b/rules/xcodeproj.bzl index 03900a8b..2b15cd00 100644 --- a/rules/xcodeproj.bzl +++ b/rules/xcodeproj.bzl @@ -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), diff --git a/tests/macos/xcodeproj/Single-Application-Project-AllTargets.xcodeproj/bazelinstallers/indexstores.sh b/tests/macos/xcodeproj/Single-Application-Project-AllTargets.xcodeproj/bazelinstallers/indexstores.sh index ee2e1871..1f436c7b 100755 --- a/tests/macos/xcodeproj/Single-Application-Project-AllTargets.xcodeproj/bazelinstallers/indexstores.sh +++ b/tests/macos/xcodeproj/Single-Application-Project-AllTargets.xcodeproj/bazelinstallers/indexstores.sh @@ -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" \ No newline at end of file +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`" diff --git a/tests/macos/xcodeproj/Single-Application-Project-AllTargets.xcodeproj/project.pbxproj b/tests/macos/xcodeproj/Single-Application-Project-AllTargets.xcodeproj/project.pbxproj index 82f7a7d7..6c2ed8eb 100755 --- a/tests/macos/xcodeproj/Single-Application-Project-AllTargets.xcodeproj/project.pbxproj +++ b/tests/macos/xcodeproj/Single-Application-Project-AllTargets.xcodeproj/project.pbxproj @@ -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; @@ -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; @@ -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 */ diff --git a/tests/macos/xcodeproj/Single-Application-Project-DirectTargetsOnly.xcodeproj/bazelinstallers/indexstores.sh b/tests/macos/xcodeproj/Single-Application-Project-DirectTargetsOnly.xcodeproj/bazelinstallers/indexstores.sh index ee2e1871..1f436c7b 100755 --- a/tests/macos/xcodeproj/Single-Application-Project-DirectTargetsOnly.xcodeproj/bazelinstallers/indexstores.sh +++ b/tests/macos/xcodeproj/Single-Application-Project-DirectTargetsOnly.xcodeproj/bazelinstallers/indexstores.sh @@ -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" \ No newline at end of file +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`" diff --git a/tests/macos/xcodeproj/Single-Application-Project-DirectTargetsOnly.xcodeproj/project.pbxproj b/tests/macos/xcodeproj/Single-Application-Project-DirectTargetsOnly.xcodeproj/project.pbxproj index 54d0041b..5951034a 100755 --- a/tests/macos/xcodeproj/Single-Application-Project-DirectTargetsOnly.xcodeproj/project.pbxproj +++ b/tests/macos/xcodeproj/Single-Application-Project-DirectTargetsOnly.xcodeproj/project.pbxproj @@ -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; @@ -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; @@ -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 */ diff --git a/tests/macos/xcodeproj/Test-Target-With-Test-Host-Project.xcodeproj/bazelinstallers/indexstores.sh b/tests/macos/xcodeproj/Test-Target-With-Test-Host-Project.xcodeproj/bazelinstallers/indexstores.sh index ee2e1871..1f436c7b 100755 --- a/tests/macos/xcodeproj/Test-Target-With-Test-Host-Project.xcodeproj/bazelinstallers/indexstores.sh +++ b/tests/macos/xcodeproj/Test-Target-With-Test-Host-Project.xcodeproj/bazelinstallers/indexstores.sh @@ -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" \ No newline at end of file +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`" diff --git a/tests/macos/xcodeproj/Test-Target-With-Test-Host-Project.xcodeproj/project.pbxproj b/tests/macos/xcodeproj/Test-Target-With-Test-Host-Project.xcodeproj/project.pbxproj index b1df15bc..5b03b95f 100755 --- a/tests/macos/xcodeproj/Test-Target-With-Test-Host-Project.xcodeproj/project.pbxproj +++ b/tests/macos/xcodeproj/Test-Target-With-Test-Host-Project.xcodeproj/project.pbxproj @@ -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; @@ -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; @@ -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; @@ -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 */ diff --git a/tools/xcodeproj_shims/build-wrapper.sh b/tools/xcodeproj_shims/build-wrapper.sh index 561127f6..f3c4e68b 100755 --- a/tools/xcodeproj_shims/build-wrapper.sh +++ b/tools/xcodeproj_shims/build-wrapper.sh @@ -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 diff --git a/tools/xcodeproj_shims/installers/indexstores.sh b/tools/xcodeproj_shims/installers/indexstores.sh index ee2e1871..1f436c7b 100755 --- a/tools/xcodeproj_shims/installers/indexstores.sh +++ b/tools/xcodeproj_shims/installers/indexstores.sh @@ -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" \ No newline at end of file +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`"