nimbus-build-system-desktop/scripts/env.sh

60 lines
1.8 KiB
Bash
Raw Normal View History

2019-08-21 15:43:00 +00:00
#!/bin/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"
export REL_PATH="$(dirname $BASH_SOURCE)"
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}"
# used by libp2p/go-libp2p-daemon
export GOPATH="${ABS_PATH}/../../go"
export GO111MODULE=on
#- 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
export PATH="${ABS_PATH}/../../Nim/bin:${GOPATH}/bin:${PATH}"
# Nimble needs this to be an absolute path
export NIMBLE_DIR="${ABS_PATH}/../../.nimble"
# 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
export PS1="${PS1%\\\$ } [Nimbus env]\\$ "
# 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" "$@"
}
export -f nimble
add_submodule() {
"${ABS_PATH}/add_submodule.sh" "$@"
}
export -f add_submodule
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