kokoro: Use 'data' disk for build directory

Fixes spurious out-of-disk failures

Change-Id: I31c5f7f5c07c0f75826909de6444b8ef9cc8818e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/81100
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
diff --git a/kokoro/linux/build.sh b/kokoro/linux/build.sh
index 1fcb77b..430f6c5 100755
--- a/kokoro/linux/build.sh
+++ b/kokoro/linux/build.sh
@@ -35,10 +35,11 @@
 docker run --rm -i \
   --privileged \
   --volume "${ROOT_DIR}:${ROOT_DIR}" \
-  --volume "${TMP_DIR}:/src" \
+  --volume "${TMP_DIR}/kokoro/tint:/tint" \
   --volume "${KOKORO_ARTIFACTS_DIR}:/mnt/artifacts" \
   --workdir "${ROOT_DIR}" \
-  --env SRC_DIR="/src/tint" \
+  --env SRC_DIR="/tint/src" \
+  --env BUILD_DIR="/tint/build" \
   --env BUILD_TYPE=$BUILD_TYPE \
   --env BUILD_SYSTEM=$BUILD_SYSTEM \
   --env BUILD_SANITIZER=$BUILD_SANITIZER \
diff --git a/kokoro/linux/docker.sh b/kokoro/linux/docker.sh
index 9818060..22a15ac 100755
--- a/kokoro/linux/docker.sh
+++ b/kokoro/linux/docker.sh
@@ -14,6 +14,22 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+# This is the bash script invoked inside a docker container.
+# The script expects that the CWD points to a clean checkout of Tint.
+# As `gclient sync` will litter the tint checkout with fetched tools and
+# projects, this script will first clone the pristine tint checkout to
+# ${SRC_DIR}. This allows developers to locally run this script without having
+# to worry about their local tint copy being touched.
+#
+# This script expects the following environment variables to be set on entry:
+#
+# SRC_DIR         - Path to where the local Tint copy will be made. See above.
+# BUILD_DIR       - Path to where Tint will be built.
+# BUILD_TYPE      - Either: 'Debug' or 'Release'
+# BUILD_SYSTEM    - Must be 'cmake'
+# BUILD_SANITIZER - Either: '', 'asan', or 'ubstan'
+# BUILD_TOOLCHAIN - Either: 'clang' or 'gcc'
+
 set -e # Fail on any error.
 
 function show_cmds { set -x; }
@@ -62,9 +78,11 @@
 using go-1.14.4      # Speeds up ./tools/lint
 using doxygen-1.8.18
 
-status "Cloning to clean source directory at '${SRC_DIR}'"
-
+status "Creating source directory '${SRC_DIR}' and build directory '${BUILD_DIR}'"
 mkdir -p ${SRC_DIR}
+mkdir -p ${BUILD_DIR}
+
+status "Cloning to source directory '${SRC_DIR}'"
 cd ${SRC_DIR}
 git clone ${CLONE_SRC_DIR} .
 
@@ -79,9 +97,6 @@
 if [ "$BUILD_SYSTEM" == "cmake" ]; then
     using cmake-3.17.2
 
-    BUILD_DIR=/tmp/tint-build
-    mkdir -p ${BUILD_DIR}
-
     COMMON_CMAKE_FLAGS=""
     COMMON_CMAKE_FLAGS+=" -DCMAKE_BUILD_TYPE=${BUILD_TYPE}"
     COMMON_CMAKE_FLAGS+=" -DTINT_DOCS_WARN_AS_ERROR=1"
@@ -117,7 +132,7 @@
         cmake --build . --target tint-docs
     hide_cmds
 
-    status "Building tint"
+    status "Building tint in '${BUILD_DIR}'"
     show_cmds
         cmake ${SRC_DIR} ${CMAKE_FLAGS} ${COMMON_CMAKE_FLAGS}
         cmake --build . -- --jobs=$(nproc)