blob: ca6a410ab30491641ed3509f5352cca5e6b592ac [file] [log] [blame]
#!/usr/bin/env bash
# Copyright 2018 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.
# Installs or updates prebuilt tools.
set -o errexit
set -o pipefail
script_root="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd)"
"${script_root}/cipd.py" ensure \
-ensure-file "${script_root}/cipd.ensure" \
-root "${script_root}" \
-log-level warning
# Write vpython3 wrapper. The gLinux version of Python 3.8 is broken, so we need
# to make sure that vpython uses the custom Chromium version of Python from
# CIPD.
# TODO(crbug.com/1176014): Assuming gLinux Python 3.9 doesn't have the same
# issues as 3.8, this will likely no longer be necessary once vpython supports
# Python 3.9. At that point we can delete this shim and go back to running
# vpython3 directly.
echo '#!/usr/bin/env bash
tools_dir="$(dirname "$0")"
exec "${tools_dir}/vpython_upstream/vpython3" -vpython-interpreter "${tools_dir}/python3/bin/python3" "$@"
' > "${script_root}/tools/vpython3"
# Write vpython wrapper. gLinux no longer ships python2 by default, so we need
# to make sure to use the vendored one.
#
# This is also necessary because vpython and vpython3 are in the same CIPD
# package, so if we nest vpython3 in a subdirectory of "tools" then we need to
# do the same for vpython.
echo '#!/usr/bin/env bash
tools_dir="$(dirname "$0")"
exec "${tools_dir}/vpython_upstream/vpython" -vpython-interpreter "${tools_dir}/python2/bin/python2" "$@"
' > "${script_root}/tools/vpython"
chmod +x "${script_root}/tools/vpython"
chmod +x "${script_root}/tools/vpython3"
# Make sure that `python` on $PATH points to Python 2, as the recipe engine
# assumes.
ln -s -f "${script_root}/tools/python2/bin/python" "${script_root}/tools/python"