| #!/bin/bash | |
| # Copyright 2023 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. | |
| # Bash launcher for client.py. For performance reasons, do not invoke | |
| # any sub-command before the final "exec" call. | |
| set -e | |
| function die { | |
| echo >&2 "ERROR: $*" | |
| exit 1 | |
| } | |
| # Compute parent directory without invoking any subcommand. | |
| function parent_dir { | |
| printf %s "${1%/[^/]*}" | |
| } | |
| # Compute Fuchsia host tag without invoking any subcommand. | |
| function fuchsia_host_tag { | |
| local host_os host_arch | |
| case "${OSTYPE}" in | |
| linux*) | |
| host_os=linux | |
| ;; | |
| darwin*) | |
| host_os=mac | |
| ;; | |
| *) | |
| die "Unknown host operating system: $OSTYPE" | |
| ;; | |
| esac | |
| case "${HOSTTYPE}" in | |
| x86_64|amd64) | |
| host_arch=x64 | |
| ;; | |
| aarch64|arm64) | |
| host_arch=arm64 | |
| ;; | |
| *) | |
| die "Unknown host CPU architecture: $HOSTTYPE" | |
| ;; | |
| esac | |
| echo "${host_os}-${host_arch}" | |
| } | |
| script_dir="$(parent_dir "${BASH_SOURCE[0]}")" | |
| readonly script_dir | |
| readonly fuchsia_dir="${script_dir}/../.." | |
| host_tag="$(fuchsia_host_tag)" | |
| readonly host_tag | |
| readonly python_prebuilt_dir="${fuchsia_dir}/prebuilt/third_party/python3/${host_tag}" | |
| export PYTHONPATH="${fuchsia_dir}" | |
| exec "${python_prebuilt_dir}/bin/python3" -S "${script_dir}/client.py" "--host-tag=${host_tag}" "$@" |