forked from rwf2/Rocket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.sh
executable file
·80 lines (70 loc) · 2.6 KB
/
config.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Simply sets up a few useful variables.
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function relative() {
local full_path="${SCRIPT_DIR}/../${1}"
if [ -d "${full_path}" ]; then
# Try to use readlink as a fallback to readpath for cross-platform compat.
if command -v realpath >/dev/null 2>&1; then
realpath "${full_path}"
elif ! (readlink -f 2>&1 | grep illegal > /dev/null); then
readlink -f "${full_path}"
else
echo "Rocket's scripts require 'realpath' or 'readlink -f' support." >&2
echo "Install realpath or GNU readlink via your package manager." >&2
echo "Aborting." >&2
exit 1
fi
else
# when the directory doesn't exist, fallback to this.
echo "${full_path}"
fi
}
# Versioning information. These are toggled as versions change.
ROCKET_VERSION="0.5.0-dev"
CURRENT_RELEASE=false
PRE_RELEASE=true
# A generated codename for this version. Use the git branch for pre-releases.
case $PRE_RELEASE in
true) VERSION_CODENAME="$(git branch --show-current)" ;;
false) VERSION_CODENAME="$(echo "${ROCKET_VERSION}" | cut -d'.' -f1-2)" ;;
esac
# Root of workspace-like directories.
PROJECT_ROOT=$(relative "") || exit $?
CORE_ROOT=$(relative "core") || exit $?
CONTRIB_ROOT=$(relative "contrib") || exit $?
SITE_ROOT=$(relative "site") || exit $?
# Root of project-like directories.
CORE_LIB_ROOT=$(relative "core/lib") || exit $?
CORE_CODEGEN_ROOT=$(relative "core/codegen") || exit $?
CORE_HTTP_ROOT=$(relative "core/http") || exit $?
CONTRIB_LIB_ROOT=$(relative "contrib/lib") || exit $?
CONTRIB_CODEGEN_ROOT=$(relative "contrib/codegen") || exit $?
# Root of infrastructure directories.
EXAMPLES_DIR=$(relative "examples") || exit $?
DOC_DIR=$(relative "target/doc") || exit $?
ALL_PROJECT_DIRS=(
"${CORE_HTTP_ROOT}"
"${CORE_CODEGEN_ROOT}"
"${CORE_LIB_ROOT}"
"${CONTRIB_CODEGEN_ROOT}"
"${CONTRIB_LIB_ROOT}"
)
if [ "${1}" = "-p" ]; then
echo "ROCKET_VERSION: ${ROCKET_VERSION}"
echo "CURRENT_RELEASE: ${CURRENT_RELEASE}"
echo "PRE_RELEASE: ${PRE_RELEASE}"
echo "VERSION_CODENAME: ${VERSION_CODENAME}"
echo "SCRIPT_DIR: ${SCRIPT_DIR}"
echo "PROJECT_ROOT: ${PROJECT_ROOT}"
echo "CORE_ROOT: ${CORE_ROOT}"
echo "CONTRIB_ROOT: ${CONTRIB_ROOT}"
echo "SITE_ROOT: ${SITE_ROOT}"
echo "CORE_LIB_ROOT: ${CORE_LIB_ROOT}"
echo "CORE_CODEGEN_ROOT: ${CORE_CODEGEN_ROOT}"
echo "CORE_HTTP_ROOT: ${CORE_HTTP_ROOT}"
echo "CONTRIB_LIB_ROOT: ${CONTRIB_LIB_ROOT}"
echo "CONTRIB_CODEGEN_ROOT: ${CONTRIB_CODEGEN_ROOT}"
echo "EXAMPLES_DIR: ${EXAMPLES_DIR}"
echo "DOC_DIR: ${DOC_DIR}"
echo "ALL_PROJECT_DIRS: ${ALL_PROJECT_DIRS[*]}"
fi