1#!/usr/bin/env bash 2# Copyright 2021 The ChromiumOS Authors 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5# 6# To build crosvm using cargo against libraries and crates provided by ChromeOS 7# use this script to update path references in Cargo.toml. 8 9set -e 10 11CARGO_PATH=$(dirname "$0")/../../Cargo.toml 12 13if ! git diff "${CARGO_PATH}"; then 14 echo "There is pending Cargo.toml changes, please clean first." 15 exit 1 16fi 17 18declare -A replacements=( 19 ["libcras_stub"]="../../third_party/adhd/cras/client/libcras" 20 ["system_api_stub"]="../../platform2/system_api" 21 ["third_party/minijail"]="../../aosp/external/minijail" 22) 23 24for crate in "${!replacements[@]}"; do 25 echo "Replacing '${crate}' with '${replacements[$crate]}'" 26 sed -i "s|path = \"${crate}|path = \"${replacements[$crate]}|g" \ 27 "${CARGO_PATH}" 28done 29 30git commit "${CARGO_PATH}" -m 'crosvm: DO NOT SUBMIT: Cargo.toml changes. 31 32This is for local cargo {build,test} in your CrOS checkout. 33Please do not submit this change. 34 35BUG=None 36TEST=None 37 38Commit: false 39' 40 41echo "Modified Cargo.toml with new paths. Please do not submit the change." 42