xref: /aosp_15_r20/external/skia/infra/bots/build_task_drivers.sh (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1*c8dee2aaSAndroid Build Coastguard Worker#!/bin/bash
2*c8dee2aaSAndroid Build Coastguard Worker# Copyright 2022 Google LLC
3*c8dee2aaSAndroid Build Coastguard Worker#
4*c8dee2aaSAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be
5*c8dee2aaSAndroid Build Coastguard Worker# found in the LICENSE file.
6*c8dee2aaSAndroid Build Coastguard Worker#
7*c8dee2aaSAndroid Build Coastguard Worker# Takes two arguments.
8*c8dee2aaSAndroid Build Coastguard Worker#   First argument is the output directory where executables are to be placed.
9*c8dee2aaSAndroid Build Coastguard Worker#   Second (optional) argument is the target platform. These are formatted as os_arch
10*c8dee2aaSAndroid Build Coastguard Worker#   https://github.com/bazelbuild/rules_go/blob/e9a7054ff11a520e3b8aceb76a3ba44bb8da4c94/go/toolchain/toolchains.bzl#L22
11*c8dee2aaSAndroid Build Coastguard Worker
12*c8dee2aaSAndroid Build Coastguard Workerset -x -e
13*c8dee2aaSAndroid Build Coastguard Worker
14*c8dee2aaSAndroid Build Coastguard Worker# Navigate to the root of the infra checkout.
15*c8dee2aaSAndroid Build Coastguard Workercd $(dirname ${BASH_SOURCE[0]})
16*c8dee2aaSAndroid Build Coastguard Workercd ../..
17*c8dee2aaSAndroid Build Coastguard Worker
18*c8dee2aaSAndroid Build Coastguard WorkerPLATFORM=${2:-linux_amd64} # use linux_amd64 if not specified
19*c8dee2aaSAndroid Build Coastguard Worker
20*c8dee2aaSAndroid Build Coastguard Worker# Build the executables and extract them to the folder in the first argument.
21*c8dee2aaSAndroid Build Coastguard Worker# We specify the cache directory to be somewhere other than the default (home directory)
22*c8dee2aaSAndroid Build Coastguard Worker# Because the home directory is mounted on / which typically does not have a lot of disk space.
23*c8dee2aaSAndroid Build Coastguard Worker# /mnt/pd0 is the bigger disk mounted to the GCE VM.
24*c8dee2aaSAndroid Build Coastguard Worker# https://bazel.build/docs/output_directories#layout
25*c8dee2aaSAndroid Build Coastguard Workerbazelisk --output_user_root=/mnt/pd0/bazel_cache \
26*c8dee2aaSAndroid Build Coastguard Worker    build //infra/bots:all_task_drivers --platforms=@io_bazel_rules_go//go/toolchain:${PLATFORM} \
27*c8dee2aaSAndroid Build Coastguard Worker    --config=linux_rbe --jobs=100
28*c8dee2aaSAndroid Build Coastguard Worker
29*c8dee2aaSAndroid Build Coastguard Workertar -xf bazel-bin/infra/bots/built_task_drivers.tar -C ${1}
30*c8dee2aaSAndroid Build Coastguard Worker# Bazel outputs are write-protected, so we make sure everybody can write them. This way there
31*c8dee2aaSAndroid Build Coastguard Worker# are no expected errors in deleting them later.
32*c8dee2aaSAndroid Build Coastguard Workerchmod 0777 ${1}/*
33