mirror of
https://github.com/rwf2/Rocket.git
synced 2024-12-27 04:42:40 +00:00
35 lines
825 B
Bash
Executable File
35 lines
825 B
Bash
Executable File
# 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
|
|
# Use readlink as a fallback to readpath for cross-platform compat.
|
|
if ! command -v realpath >/dev/null 2>&1; then
|
|
echo $(readlink -f "${full_path}")
|
|
else
|
|
echo $(realpath "${full_path}")
|
|
fi
|
|
else
|
|
# when the directory doesn't exist, fallback to this.
|
|
echo "${full_path}"
|
|
fi
|
|
}
|
|
|
|
EXAMPLES_DIR=$(relative "examples")
|
|
LIB_DIR=$(relative "lib")
|
|
CODEGEN_DIR=$(relative "codegen")
|
|
CONTRIB_DIR=$(relative "contrib")
|
|
DOC_DIR=$(relative "target/doc")
|
|
|
|
if [ "${1}" = "-p" ]; then
|
|
echo $SCRIPT_DIR
|
|
echo $EXAMPLES_DIR
|
|
echo $LIB_DIR
|
|
echo $CODEGEN_DIR
|
|
echo $CONTRIB_DIR
|
|
echo $DOC_DIR
|
|
fi
|