• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 \
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_X86_64_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="Native execution"
40fi
41
42echo ""
43echo "crosvm builder is ready:"
44echo "  Cargo version: $(cargo --version)"
45echo "  Test target: ${test_target}"
46echo ""
47
48# Run user provided command or interactive shell
49if [[ $# -eq 0 ]]; then
50    /bin/bash
51else
52    echo "$ $@"
53    /bin/bash -c "$@"
54fi
55