1#!/bin/bash 2# Copyright 2021 The Chromium OS Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6# Clean scratch directory if requested. 7if [ "$1" = "--clean" ]; then 8 shift 9 echo "Cleaning scratch directory..." 10 rm -rf /workspace/scratch/* 11fi 12 13echo "Building ChromeOS dependencies..." 14if ! make -j $(nproc) -C ci/build_environment TARGET_ARCH=aarch64 \ 15 >/workspace/logs/build_environment.log 2>&1; then 16 echo "Failed to build ChromeOS dependencies" 17 cat /workspace/logs/build_environment.log 18 # Drop into an interactive shell for debugging. 19 if [[ $# -eq 0 ]]; then 20 /bin/bash 21 fi 22 exit 1 23fi 24 25if [ "$1" = "--vm" ]; then 26 shift 27 echo "Starting testing vm..." 28 (cd /workspace/vm && screen -Sdm vm ./start_vm) 29 export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="\ 30 /workspace/src/platform/crosvm/ci/vm_tools/exec_binary_in_vm" 31 32 if [[ $# -eq 0 ]]; then 33 test_target="Virtual Machine (See 'screen -r vm' or 'ssh vm')" 34 else 35 test_target="Virtual Machine" 36 fi 37 export CROSVM_USE_VM=1 38else 39 test_target="User-space emulation" 40 export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="\ 41 qemu-${target_arch}-static \ 42 -E LD_LIBRARY_PATH=/workspace/scratch/lib" 43fi 44 45echo "" 46echo "crosvm builder is ready:" 47echo " Cargo version: $(cargo --version)" 48echo " Target architecture: ${CARGO_BUILD_TARGET}" 49echo " Test target: ${test_target}" 50echo "" 51 52# Run user provided command or interactive shell 53if [[ $# -eq 0 ]]; then 54 /bin/bash 55else 56 echo "$ $@" 57 /bin/bash -c "$@" 58fi 59