-
Notifications
You must be signed in to change notification settings - Fork 0
/
wmake
executable file
·96 lines (83 loc) · 1.89 KB
/
wmake
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
#!/usr/bin/env bash
set -o errexit
trap 'echo "Aborting due to errexit on line $LINENO. Exit code: $?" >&2' ERR
set -o errtrace
set -o pipefail
DEFAULT_IFS="${IFS}"
SAFER_IFS=$'\n\t'
IFS="${SAFER_IFS}"
_ME=$(basename "${0}")
_print_help() {
cat <<HEREDOC
__ .__
__ _ _______ _/ |_ ___________| | ____ ____ ______
\\ \\/ \\/ /\\__ \\\\ __\\/ __ \\_ __ \\ | / _ \\ / _ \\\\____ \\
\\ / / __ \\| | \\ ___/| | \\/ |_( <_> | <_> ) |_> >
\\/\\_/ (____ /__| \\___ >__| |____/\\____/ \\____/| __/
\\/ \\/ |__|
The Embedded C++ code base builder
HEREDOC
}
BUILD_DIR=cmake-build-debug
_build() {
_glsl_compile
mkdir -p $BUILD_DIR
cd $BUILD_DIR
cmake ..
make -j10
}
_clean() {
rm $(pwd)/include/*.glsl
cd $BUILD_DIR
make clean -j10
}
_run() {
cd $BUILD_DIR
./shadertoy
}
_env() {
source $(pwd)/wenv
}
_setup() {
sudo apt-get install libsfml-dev libglew-dev
}
_glsl_compile() {
mkdir -p $(pwd)/include
cd $(pwd)/glsl
find ./ -type f -name "*.glsl" \
-exec xxd -i {} ../include/{} \;
cd ../
}
_simple() {
root_dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
root_dir_name=$(basename "$root_dir")
cd "$root_dir"
if [ "$1" == 'build' ] ; then
echo "Building project"
_build
elif [ "$1" == 'clean' ] ; then
echo "Cleaning project"
_clean
elif [ "$1" == 'run' ] ; then
_run
elif [ "$1" == 'env' ] ; then
_env
elif [ "$1" == 'setup' ] ; then
echo "Setting up environment for Linux"
_env
_setup
else
_print_help
fi
}
_main() {
# Avoid complex option parsing when only one program option is expected.
if [[ "${1:-}" =~ ^-h|--help$ ]] || [ $# -lt "1" ]
then
_print_help
else
_simple "$@"
fi
}
_main "$@"