2020-08-13 13:37:57 +00:00
|
|
|
#!/usr/bin/env bash
|
2019-08-20 21:14:45 +00:00
|
|
|
|
|
|
|
# Copyright (c) 2018-2019 Status Research & Development GmbH. Licensed under
|
|
|
|
# either of:
|
|
|
|
# - Apache License, version 2.0
|
|
|
|
# - MIT license
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except
|
|
|
|
# according to those terms.
|
|
|
|
|
|
|
|
#PWD_CMD="pwd"
|
|
|
|
## get native Windows paths on Mingw
|
|
|
|
#uname | grep -qi mingw && PWD_CMD="pwd -W"
|
|
|
|
|
2019-08-23 18:24:45 +00:00
|
|
|
# We use ${BASH_SOURCE[0]} instead of $0 to allow sourcing this file
|
2019-08-28 12:44:42 +00:00
|
|
|
# and we fall back to a Zsh-specific special var to also support Zsh.
|
2019-08-23 18:24:45 +00:00
|
|
|
export REL_PATH="$(dirname ${BASH_SOURCE[0]:-${(%):-%x}})"
|
2019-08-21 15:06:22 +00:00
|
|
|
export ABS_PATH="$(cd ${REL_PATH}; pwd)"
|
2019-08-20 21:14:45 +00:00
|
|
|
# do we still need this?
|
|
|
|
#ABS_PATH_NATIVE="$(cd ${REL_PATH}; ${PWD_CMD})"
|
|
|
|
|
|
|
|
export NIMBUS_ENV_DIR="${ABS_PATH}"
|
|
|
|
|
2019-09-04 16:58:26 +00:00
|
|
|
# looks like oh-my-zsh can't handle dots in PATH
|
2019-09-04 14:51:58 +00:00
|
|
|
export NIM_PATH=$(cd "${ABS_PATH}/../vendor/Nim/bin"; pwd)
|
|
|
|
|
2019-08-20 21:14:45 +00:00
|
|
|
# Nimble needs this to be an absolute path
|
2020-02-25 13:46:29 +00:00
|
|
|
export NIMBLE_DIR=$(cd "${ABS_PATH}/../../.nimble"; pwd)
|
2019-08-20 21:14:45 +00:00
|
|
|
|
2020-04-15 15:25:03 +00:00
|
|
|
# we don't use Nimble-installed binaries, but just in case
|
|
|
|
export PATH="${NIMBLE_DIR}/bin:${PATH}"
|
|
|
|
|
2020-02-24 14:41:32 +00:00
|
|
|
#- make it an absolute path, so we can call this script from other dirs
|
|
|
|
#- we can't use native Windows paths in here, because colons can't be escaped in PATH
|
2020-04-15 15:25:03 +00:00
|
|
|
if [[ "$USE_SYSTEM_NIM" != "1" ]]; then
|
|
|
|
export PATH="${NIM_PATH}:${PATH}"
|
2020-05-22 13:41:50 +00:00
|
|
|
else
|
2020-10-13 23:25:15 +00:00
|
|
|
echo "[using system Nim: $(which nim)]" 1>&2
|
2020-04-15 15:25:03 +00:00
|
|
|
fi
|
2020-02-24 14:41:32 +00:00
|
|
|
|
2021-03-02 17:03:30 +00:00
|
|
|
if [[ -n "${NIM_COMMIT}" && "${NIM_COMMIT}" != "nimbus" ]]; then
|
|
|
|
echo "[using Nim version ${NIM_COMMIT}]" 1>&2
|
|
|
|
fi
|
|
|
|
|
2019-08-20 21:14:45 +00:00
|
|
|
# used by nim-beacon-chain/tests/simulation/start.sh
|
|
|
|
export BUILD_OUTPUTS_DIR="${ABS_PATH}/../../../build"
|
|
|
|
|
|
|
|
# change the prompt in shells that source this file
|
2019-08-23 18:24:45 +00:00
|
|
|
if [[ -n "$BASH_VERSION" ]]; then
|
|
|
|
export PS1="${PS1%\\\$ } [Nimbus env]\\$ "
|
|
|
|
EXPORT_FUNC="export -f"
|
|
|
|
fi
|
|
|
|
if [[ -n "$ZSH_VERSION" ]]; then
|
|
|
|
export PS1="[Nimbus env] $PS1"
|
|
|
|
EXPORT_FUNC="export" # doesn't actually work, because Zsh doesn't support exporting functions
|
|
|
|
fi
|
2019-08-20 21:14:45 +00:00
|
|
|
|
2019-08-21 15:06:22 +00:00
|
|
|
# functions, instead of aliases, to avoid typing long paths (aliases don't seem
|
|
|
|
# to be expanded by default for command line arguments)
|
|
|
|
nimble() {
|
|
|
|
"${ABS_PATH}/nimble.sh" "$@"
|
|
|
|
}
|
2019-08-23 18:24:45 +00:00
|
|
|
$EXPORT_FUNC nimble
|
2019-08-21 15:06:22 +00:00
|
|
|
|
|
|
|
add_submodule() {
|
|
|
|
"${ABS_PATH}/add_submodule.sh" "$@"
|
|
|
|
}
|
2019-08-23 18:24:45 +00:00
|
|
|
$EXPORT_FUNC add_submodule
|
2019-08-21 15:06:22 +00:00
|
|
|
|
2019-08-23 16:55:16 +00:00
|
|
|
if [[ $# == 1 && $1 == "bash" ]]; then
|
|
|
|
# the only way to change PS1 in a child shell, apparently
|
|
|
|
# (we're not getting the original PS1 value in here, so set a complete and nice prompt)
|
|
|
|
export PS1="[Nimbus env] \[\033[0;31m\]\l \[\033[1;33m\]\d \[\033[1;36m\]\t \[\033[0;32m\]|\w|\[\033[0m\]\n\u\$ "
|
|
|
|
exec "$1" --login --noprofile
|
|
|
|
else
|
|
|
|
# can't use "exec" here if we're getting function names as params
|
|
|
|
"$@"
|
|
|
|
fi
|
2019-08-20 21:14:45 +00:00
|
|
|
|