Upgraded to bazel 0.6.1

Enable cpu environments so we can drop the NO_BUILD_* files!!!

Change-Id: I904612c5dcc1a1cd285e160c0836b7249ab5ce72
diff --git a/tools/BUILD b/tools/BUILD
index b8a4f1e..bab0b6e 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -39,3 +39,13 @@
   name = 'has_ubsan',
   values = {'define': 'have_ubsan=true'},
 )
+
+environment(name = "k8")
+environment(name = "armhf-debian")
+environment(name = "roborio")
+environment(name = "cortex-m4f")
+environment_group(
+    name = "cpus",
+    environments = [":k8", ":roborio", ":armhf-debian", ":cortex-m4f"],
+    defaults = [":k8", ":roborio", ":armhf-debian"],
+)
diff --git a/tools/bazel b/tools/bazel
index 25266b8..d58a193 100755
--- a/tools/bazel
+++ b/tools/bazel
@@ -24,7 +24,7 @@
   exec "${BAZEL_OVERRIDE}" "$@"
 fi
 
-readonly VERSION="201701021712+4964f2c"
+readonly VERSION="0.6.1"
 
 readonly DOWNLOAD_DIR="$(dirname "${BASH_SOURCE[0]}")/../bazel-downloads"
 # Directory to unpack bazel into.  This must change whenever bazel changes.
@@ -40,7 +40,7 @@
   exit 1
 fi
 
-readonly INSTALLER_NAME="bazel_${VERSION}_amd64.deb"
+readonly INSTALLER_NAME="bazel_${VERSION}-linux-x86_64.deb"
 readonly DOWNLOAD_URL="http://frc971.org/Build-Dependencies/${INSTALLER_NAME}"
 
 if [[ ! -d "${VERSION_DIR}" ]]; then
diff --git a/tools/bazel.rc b/tools/bazel.rc
index 0e3001f..513bc94 100644
--- a/tools/bazel.rc
+++ b/tools/bazel.rc
@@ -52,5 +52,13 @@
 # Dump the output of the failing test to stdout.
 test --test_output=errors
 
-build --experimental_sandbox_shm
+build --experimental_sandbox_base=/dev/shm/
 build --experimental_multi_threaded_digest
+
+build --sandbox_fake_hostname=true
+build --sandbox_fake_username=true
+
+build --experimental_auto_cpu_environment_group=//tools:cpus
+startup --host_jvm_args=-Dbazel.DigestFunction=SHA1
+
+common --watchfs
diff --git a/tools/build_rules/fortran.bzl b/tools/build_rules/fortran.bzl
index 2d6e4db..e1f2abf 100644
--- a/tools/build_rules/fortran.bzl
+++ b/tools/build_rules/fortran.bzl
@@ -77,6 +77,7 @@
       name = name + '_' + pic_o_file,
       src = src,
       visibility = ['//visibility:private'],
+      restricted_to = ['@//tools:k8'],
     )
     pic_o_files.append(pic_o_file)
 
@@ -88,4 +89,5 @@
       '-lgfortran',
     ],
     visibility = visibility,
+    restricted_to = ['@//tools:k8'],
   )
diff --git a/tools/build_rules/ruby.bzl b/tools/build_rules/ruby.bzl
index 2c93596..cfab2e9 100644
--- a/tools/build_rules/ruby.bzl
+++ b/tools/build_rules/ruby.bzl
@@ -3,7 +3,7 @@
 ruby_file_types = FileType(['.rb'])
 
 def _collect_transitive_sources(ctx):
-  source_files = set(order='compile')
+  source_files = depset(order='postorder')
   for dep in ctx.attr.deps:
     source_files += dep.transitive_ruby_files
 
@@ -34,7 +34,7 @@
   )
 
   return struct(
-    files = set([executable]),
+    files = depset([executable]),
     runfiles = ctx.runfiles(collect_data = True),
   )
 
diff --git a/tools/ci/run-tests.sh b/tools/ci/run-tests.sh
index 4de8e30..98762e7 100755
--- a/tools/ci/run-tests.sh
+++ b/tools/ci/run-tests.sh
@@ -1,5 +1,5 @@
 #!/bin/sh
 set -e
 
-bazel --batch test -c opt --curses=no --color=no --jobs=1 //... -- $(cat NO_BUILD_AMD64)
-bazel --batch build -c opt --curses=no --color=no --jobs=1 //... --cpu=roborio -- $(cat NO_BUILD_ROBORIO)
+bazel --batch test -c opt --curses=no --color=no --jobs=1 //...
+bazel --batch build -c opt --curses=no --color=no --jobs=1 //... --cpu=roborio