Rollback of commit b9f401b97590cb95e76efb0ba8bf5319cfe93108.

*** Reason for rollback ***

Broke tests on Mac: https://google.com/url?sa=D&q=http%3A%2F%2Fci.bazel.io%2Fjob%2FBazel%2FJAVA_VERSION%3D1.8%2CPLATFORM_NAME%3Ddarwin-x86_64%2F269%2Fconsole

*** Original change description ***

Speed-up bootstrap on OS X by removing tool compilation.

--
MOS_MIGRATED_REVID=110785493
diff --git a/.gitignore b/.gitignore
index 8fbc80a..06f4d0f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,5 +11,25 @@
 /.classpath
 /.factorypath
 /.idea/
-/base_workspace/*
+/base_workspace/bazel-bin
+/base_workspace/bazel-genfiles
+/base_workspace/bazel-out
+/base_workspace/bazel-base_workspace
+/base_workspace/bazel-testlogs
+/base_workspace/examples
+/base_workspace/tools
+/base_workspace/third_party
+/base_workspace/src
 /bazel.iml
+/tools/jdk/jdk
+/tools/objc/*.jar
+/tools/objc/actoolwrapper.sh
+/tools/objc/environment_plist.sh
+/tools/objc/ibtoolwrapper.sh
+/tools/objc/momctoolwrapper.sh
+/tools/objc/momcwrapper.sh
+/tools/objc/realpath
+/tools/objc/StdRedirect.dylib
+/tools/objc/swiftstdlibtoolwrapper.sh
+/tools/objc/swiftstdlibtoolzip.sh
+/tools/objc/xcrunwrapper.sh
diff --git a/compile.sh b/compile.sh
index 2b23064..5810348 100755
--- a/compile.sh
+++ b/compile.sh
@@ -32,6 +32,7 @@
   echo "  General purpose commands:" >&2
   echo "     build       = compile,tools,init (default)" >&2
   echo "     compile     = compile a Bazel binary for usage" >&2
+  echo "     tools       = compile and install tooling for Bazel" >&2
   echo "     init        = initialize the base workspace" >&2
   echo "  Commands for developers:" >&2
   echo "     all         = build,determinism,test" >&2
@@ -41,15 +42,17 @@
 }
 
 function parse_options() {
-  local keywords="(build|compile|init|all|determinism|bootstrap|test)"
+  local keywords="(build|compile|tools|init|all|determinism|bootstrap|test)"
   COMMANDS="${1:-build}"
   [[ "${COMMANDS}" =~ ^$keywords(,$keywords)*$ ]] || usage "$@"
   DO_COMPILE=
+  DO_TOOLS_COMPILATION=
   DO_CHECKSUM=
   DO_FULL_CHECKSUM=1
   DO_TESTS=
   DO_BASE_WORKSPACE_INIT=
   [[ "${COMMANDS}" =~ (compile|build|all) ]] && DO_COMPILE=1
+  [[ "${COMMANDS}" =~ (tools|build|all) ]] && DO_TOOLS_COMPILATION=1
   [[ "${COMMANDS}" =~ (init|build|all) ]] && DO_BASE_WORKSPACE_INIT=1
   [[ "${COMMANDS}" =~ (bootstrap|determinism|all) ]] && DO_CHECKSUM=1
   [[ "${COMMANDS}" =~ (bootstrap) ]] && DO_FULL_CHECKSUM=
@@ -85,11 +88,29 @@
   EMBED_LABEL="head (@${git_sha1:-non-git})"
 fi
 
-if [[ $PLATFORM == "darwin" ]] && \
-    xcodebuild -showsdks 2> /dev/null | grep -q '\-sdk iphonesimulator'; then
-  EXTRA_BAZEL_ARGS="${EXTRA_BAZEL_ARGS-} --define IPHONE_SDK=1"
-fi
 source scripts/bootstrap/bootstrap.sh
+if [ $DO_TOOLS_COMPILATION ]; then
+  if [[ $PLATFORM == "darwin" ]]; then
+    bazel_bootstrap //src/tools/xcode/actoolwrapper:actoolwrapper tools/objc/actoolwrapper.sh 0755
+    bazel_bootstrap //src/tools/xcode/ibtoolwrapper:ibtoolwrapper tools/objc/ibtoolwrapper.sh 0755
+    bazel_bootstrap //src/tools/xcode/momcwrapper:momcwrapper tools/objc/momcwrapper.sh 0755
+    bazel_bootstrap //src/tools/xcode/swiftstdlibtoolwrapper:swiftstdlibtoolwrapper tools/objc/swiftstdlibtoolzip.sh 0755
+    bazel_bootstrap //src/tools/xcode/xcrunwrapper:xcrunwrapper tools/objc/xcrunwrapper.sh 0755
+    bazel_bootstrap //src/objc_tools/bundlemerge:bundlemerge_deploy.jar \
+        tools/objc/precomp_bundlemerge_deploy.jar
+    bazel_bootstrap //src/objc_tools/plmerge:plmerge_deploy.jar \
+        tools/objc/precomp_plmerge_deploy.jar
+    bazel_bootstrap //src/objc_tools/xcodegen:xcodegen_deploy.jar \
+        tools/objc/precomp_xcodegen_deploy.jar
+    if xcodebuild -showsdks 2> /dev/null | grep -q '\-sdk iphonesimulator'; then
+        bazel_bootstrap //src/tools/xcode/stdredirect:StdRedirect.dylib \
+            tools/objc/StdRedirect.dylib 0755
+    fi
+    bazel_bootstrap //src/tools/xcode/realpath:realpath tools/objc/realpath 0755
+    bazel_bootstrap //src/tools/xcode/environment:environment_plist \
+        tools/objc/environment_plist.sh 0755
+  fi
+fi
 
 if [ $DO_COMPILE ]; then
   new_step 'Building Bazel with Bazel'
diff --git a/scripts/bootstrap/bootstrap.sh b/scripts/bootstrap/bootstrap.sh
index 94f0bff..2ffae0d 100755
--- a/scripts/bootstrap/bootstrap.sh
+++ b/scripts/bootstrap/bootstrap.sh
@@ -34,8 +34,7 @@
       --javabuilder_top=//src/java_tools/buildjar:bootstrap_deploy.jar \
       --genclass_top=//src/java_tools/buildjar:bootstrap_genclass_deploy.jar \
       --ijar_top=//third_party/ijar \
-      --strategy=Javac=worker --worker_quit_after_build \
-      ${EXTRA_BAZEL_ARGS-}"}
+      --strategy=Javac=worker --worker_quit_after_build"}
 
 function bazel_bootstrap() {
   local mode=${3:-"0644"}
diff --git a/src/BUILD b/src/BUILD
index da36181..1904986 100644
--- a/src/BUILD
+++ b/src/BUILD
@@ -66,25 +66,6 @@
           """,
 )
 
-filegroup(
-    name = "darwin_tools",
-    srcs = [
-        "//src/tools/xcode/actoolwrapper:actoolwrapper",
-        "//src/tools/xcode/ibtoolwrapper:ibtoolwrapper",
-        "//src/tools/xcode/momcwrapper:momcwrapper",
-        "//src/tools/xcode/swiftstdlibtoolwrapper:swiftstdlibtoolwrapper",
-        "//src/tools/xcode/environment:environment_plist",
-        "//src/tools/xcode/xcrunwrapper:xcrunwrapper",
-        "//src/objc_tools/bundlemerge:bundlemerge_deploy.jar",
-        "//src/objc_tools/plmerge:plmerge_deploy.jar",
-        "//src/objc_tools/xcodegen:xcodegen_deploy.jar",
-        "//src/tools/xcode/realpath:realpath",
-    ] + select({
-        ":iphonesdk": ["//src/tools/xcode/stdredirect:StdRedirect.dylib"],
-        "//conditions:default": [],
-    }),
-)
-
 genrule(
     name = "embedded_tools",
     srcs = [
@@ -102,11 +83,7 @@
         "//src/java_tools/singlejar:SingleJar_deploy.jar",
         "//src/java_tools/buildjar/java/com/google/devtools/build/buildjar/genclass:GenClass_deploy.jar",
         "//third_party/ijar",
-    ] + select({
-        ":darwin": [":darwin_tools"],
-        ":darwin_x86_64": [":darwin_tools"],
-        "//conditions:default": [],
-    }),
+    ],
     outs = ["embedded_tools.zip"],
     cmd = "$(location :create_embedded_tools.sh) $@ $(SRCS)",
 )
@@ -169,12 +146,6 @@
 )
 
 config_setting(
-    name = "iphonesdk",
-    values = {"define": "IPHONE_SDK=1"},
-    visibility = ["//visibility:public"],
-)
-
-config_setting(
     name = "freebsd",
     values = {"cpu": "freebsd"},
     visibility = ["//visibility:public"],
diff --git a/src/create_embedded_tools.sh b/src/create_embedded_tools.sh
index e0faa3a..742b2ec 100755
--- a/src/create_embedded_tools.sh
+++ b/src/create_embedded_tools.sh
@@ -32,10 +32,6 @@
     *SingleJar_deploy.jar) OUTPUT_PATH=tools/jdk/SingleJar_deploy.jar ;;
     *GenClass_deploy.jar) OUTPUT_PATH=tools/jdk/GenClass_deploy.jar ;;
     *ijar) OUTPUT_PATH=tools/jdk/ijar ;;
-    *src/objc_tools/*) OUTPUT_PATH=tools/objc/precomp_${i##*/} ;;
-    *xcode*StdRedirect.dylib) OUTPUT_PATH=tools/objc/StdRedirect.dylib ;;
-    *xcode*realpath) OUTPUT_PATH=tools/objc/realpath ;;
-    *src/tools/xcode/*) OUTPUT_PATH=tools/objc/${i##*/}.sh ;;
     *) OUTPUT_PATH=$(echo $i | sed 's_^.*bazel-out/[^/]*/bin/__') ;;
   esac
 
diff --git a/src/tools/xcode/actoolwrapper/BUILD b/src/tools/xcode/actoolwrapper/BUILD
index 76c7532..79bfdd6 100644
--- a/src/tools/xcode/actoolwrapper/BUILD
+++ b/src/tools/xcode/actoolwrapper/BUILD
@@ -1,4 +1,4 @@
-package(default_visibility = ["//src:__subpackages__"])
+package(default_visibility = ["//src/test:__subpackages__"])
 
 filegroup(
     name = "srcs",
diff --git a/src/tools/xcode/ibtoolwrapper/BUILD b/src/tools/xcode/ibtoolwrapper/BUILD
index bb00f72..434132b 100644
--- a/src/tools/xcode/ibtoolwrapper/BUILD
+++ b/src/tools/xcode/ibtoolwrapper/BUILD
@@ -1,4 +1,4 @@
-package(default_visibility = ["//src:__subpackages__"])
+package(default_visibility = ["//src/test:__subpackages__"])
 
 filegroup(
     name = "srcs",
diff --git a/src/tools/xcode/momcwrapper/BUILD b/src/tools/xcode/momcwrapper/BUILD
index dd959d1..61acf80 100644
--- a/src/tools/xcode/momcwrapper/BUILD
+++ b/src/tools/xcode/momcwrapper/BUILD
@@ -1,4 +1,4 @@
-package(default_visibility = ["//src:__subpackages__"])
+package(default_visibility = ["//src/test:__subpackages__"])
 
 filegroup(
     name = "srcs",
diff --git a/src/tools/xcode/swiftstdlibtoolwrapper/BUILD b/src/tools/xcode/swiftstdlibtoolwrapper/BUILD
index ecbe656..1a98848 100644
--- a/src/tools/xcode/swiftstdlibtoolwrapper/BUILD
+++ b/src/tools/xcode/swiftstdlibtoolwrapper/BUILD
@@ -1,4 +1,4 @@
-package(default_visibility = ["//src:__subpackages__"])
+package(default_visibility = ["//src/test:__subpackages__"])
 
 filegroup(
     name = "srcs",
diff --git a/src/tools/xcode/xcrunwrapper/BUILD b/src/tools/xcode/xcrunwrapper/BUILD
index e3dbf20..e8ea859 100644
--- a/src/tools/xcode/xcrunwrapper/BUILD
+++ b/src/tools/xcode/xcrunwrapper/BUILD
@@ -1,4 +1,4 @@
-package(default_visibility = ["//src:__subpackages__"])
+package(default_visibility = ["//src/test:__subpackages__"])
 
 filegroup(
     name = "srcs",