Merge "Add a dummy jiri_snapshot.xml" into main
diff --git a/.bazelversion b/.bazelversion
new file mode 100644
index 0000000..0569b66
--- /dev/null
+++ b/.bazelversion
@@ -0,0 +1 @@
+5.0.0rc1
diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh
new file mode 100755
index 0000000..7db05e8
--- /dev/null
+++ b/scripts/bootstrap.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+# Copyright 2021 The Fuchsia Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+set -e
+
+# This script is used to fetch the prebuilts that are needed by the sdk-integration build.
+
+REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/..
+readonly REPO_ROOT="${REPO_ROOT}"
+readonly BAZELISK_TOOL="${REPO_ROOT}/tools/bazel"
+
+download_prebuilt() {
+ echo "Downloading prebuilt binaries."
+
+ # If we just run bazelisk it will ensure that bazel is installed
+ echo "Downloading bazel"
+ $BAZELISK_TOOL --version
+
+ echo "Download complete."
+}
+
+main() {
+ download_prebuilt
+}
+
+main "$@"
diff --git a/scripts/build.sh b/scripts/build.sh
new file mode 100755
index 0000000..2ac721c
--- /dev/null
+++ b/scripts/build.sh
@@ -0,0 +1,80 @@
+#!/bin/bash
+
+# Copyright 2021 The Fuchsia Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+set -e
+
+# This script is used by infra to validate the tests can be run
+
+REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/..
+readonly REPO_ROOT="${REPO_ROOT}"
+
+readonly TEST_SUITES=("bazel_rules_fuchsia")
+
+help() {
+ echo
+ echo "Script used to validate the sdk-integration tests"
+ echo
+ echo "Usage:"
+ echo " $(basename "$0") [<options>]"
+ echo
+ echo "Options:"
+ echo
+ echo " -o <output_user_root>"
+ echo " This is a bazel parameter. More about it can be found in"
+ echo " https://docs.bazel.build/versions/main/command-line-reference.html#flag--output_user_root"
+ echo
+}
+
+show_run_test_message() {
+ local test_path=$1
+ echo "Run test in:"
+ echo
+ echo " ${test_path}"
+ echo
+}
+
+show_bazel_build_message() {
+ local target_path=$1
+ echo "Build target in:"
+ echo
+ echo " ${target_path}"
+ echo
+}
+
+run_bazel() {
+ local bazel="${REPO_ROOT}/tools/bazel"
+ if [[ -z "$output_user_root" ]]; then
+ "$bazel" "$@"
+ else
+ "$bazel" --output_user_root "${output_user_root}" "$@"
+ fi
+}
+
+validate_tests_for_tools() {
+ for path in "${TEST_SUITES[@]}"; do
+ (
+ cd "${REPO_ROOT}/${path}"
+ show_run_test_message "$(pwd)"
+ run_bazel test --test_output=all "..."
+ ) || exit 1
+ done
+}
+
+main() {
+ while getopts ":o:h" opt; do
+ case ${opt} in
+ 'o') output_user_root=$OPTARG ;;
+ 'h' | '?')
+ help
+ exit 1
+ ;;
+ esac
+ done
+
+ validate_tests_for_tools
+}
+
+main "$@"
diff --git a/tools/bazel b/tools/bazel
new file mode 100755
index 0000000..a3b40a5
--- /dev/null
+++ b/tools/bazel
@@ -0,0 +1,56 @@
+#!/usr/bin/env bash
+
+# Copyright 2021 The Fuchsia Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+set -e -o pipefail
+
+REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/..
+readonly REPO_ROOT="${REPO_ROOT}"
+
+ARCH=
+OS=
+
+KERNEL_NAME=$(uname -s | tr '[:upper:]' '[:lower:]')
+case "${KERNEL_NAME}" in
+ linux)
+ OS="linux"
+ ;;
+ darwin)
+ OS="darwin"
+ ;;
+ *)
+ >&2 echo "bazelisk not supported on ${KERNEL_NAME}"
+ exit 1
+esac
+
+if [ -z "$ARCH" ]; then
+ MACHINE=$(uname -m | tr '[:upper:]' '[:lower:]')
+ case "${MACHINE}" in
+ x86_64|amd64)
+ ARCH=amd64
+ ;;
+ aarch64)
+ ARCH=arm64
+ ;;
+ arm*)
+ ARCH="${MACHINE}"
+ ;;
+ *86)
+ ARCH=386
+ ;;
+ *)
+ >&2 echo "UNKNOWN Machine architecture: ${MACHINE}"
+ exit 1
+ esac
+fi
+
+
+
+main() {
+ local BAZELISK_BIN="${REPO_ROOT}/vendor/bazelisk/bazelisk-${OS}-${ARCH}"
+ exec "${BAZELISK_BIN}" "${@}"
+}
+
+main "$@"
diff --git a/vendor/bazelisk/bazelisk-darwin-amd64 b/vendor/bazelisk/bazelisk-darwin-amd64
new file mode 100755
index 0000000..5a4bbb4
--- /dev/null
+++ b/vendor/bazelisk/bazelisk-darwin-amd64
Binary files differ
diff --git a/vendor/bazelisk/bazelisk-darwin-arm64 b/vendor/bazelisk/bazelisk-darwin-arm64
new file mode 100755
index 0000000..5519f6c
--- /dev/null
+++ b/vendor/bazelisk/bazelisk-darwin-arm64
Binary files differ
diff --git a/vendor/bazelisk/bazelisk-linux-amd64 b/vendor/bazelisk/bazelisk-linux-amd64
new file mode 100755
index 0000000..f0109f7
--- /dev/null
+++ b/vendor/bazelisk/bazelisk-linux-amd64
Binary files differ
diff --git a/vendor/bazelisk/bazelisk-linux-arm64 b/vendor/bazelisk/bazelisk-linux-arm64
new file mode 100755
index 0000000..9702b6b
--- /dev/null
+++ b/vendor/bazelisk/bazelisk-linux-arm64
Binary files differ