-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·47 lines (39 loc) · 890 Bytes
/
run
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
#!/usr/bin/env bash
# Copyright 2023-2024 GlitchyByte
# SPDX-License-Identifier: MIT-0
# Runs project.
# [Setup]
set -u # Exit with an error if a variable is used without being set.
set -e # Exit if any command returns an error.
# Capture caller directory and script directory.
readonly calling_dir="${PWD}"
readonly script_dir="$(cd "$(dirname "$0")" && pwd)"
# Go to script directory and load utilities.
cd "${script_dir}"
. ./_gcolors
# [Main]
if [ $# -lt 1 ]; then
echoerr "Need project name."
exit 1
fi
name=$1
# Regroup arguments.
shift
args=()
if [ "$#" -gt 0 ]; then
for arg in "$@"; do
args+=("$arg")
done
fi
# Build.
# ./build MinSizeRel
./build Debug
# Run.
echo "${c_bold}${cf_black}Running: ${cf_white}${name}${c_reset}"
if [ "$#" -gt 0 ]; then
"./code/build/bin/${name}" "${args[@]}"
else
"./code/build/bin/${name}"
fi
# [Teardown]
cd "${calling_dir}"