-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathAllwmake
executable file
·135 lines (118 loc) · 6.01 KB
/
Allwmake
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
# COLORS
RED_BOLD='\e[1;31m'
RESET_FONT='\e[0m'
set -e
checkRepoStatus()
{
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ $GIT_BRANCH == "master" ]]; then
NUM_MODIFIED_FILES=$(git diff-index --name-only HEAD | wc -l)
if [[ $NUM_MODIFIED_FILES > 0 ]]; then
# Set color to red and bold
echo -e "${RED_BOLD}ABORT COMPILATION"
echo " There are modified files in your working directory"
echo " Compilation on master branch is only allowed for a clean working directory"
echo -e "${RESET_FONT}"
echo "Modified files are: "
echo "$(git diff-index --name-only HEAD)"
echo "Force compiling with ./Allwmake --force or ./Allwmake -f"
exit 1
fi
fi
}
display_usage()
{
echo "Usage: Allwmake [OPTIONS]"
echo "Options:"
echo " -j|--parallel <#cores> Compile in parallel"
echo " -f|--force Force compilation for a dirty git state"
echo " -h|--help Print usage"
echo " *) All other commands are forwarded to CMake"
exit 1
}
# ==============================================================================
# Parse command line enties
# ==============================================================================
POSITIONAL=()
PARALLEL=false
FORCE=false
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-j|--parallel)
PARALLEL="YES"
shift # past argument
re='^[0-9]+$'
if [[ $1 =~ $re ]] ; then
NUM_CORES="$1"
shift
else
NUM_CORES=$(cat /proc/cpuinfo | grep processor | wc -l)
fi
;;
-f|--force)
FORCE="YES"
shift # past argument
;;
-h|--help|-help)
display_usage
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
# ==============================================================================
# Print header
# ==============================================================================
echo "==========================================================================="
echo " ██╗ ██╗███████╗███╗ ██╗ ██████╗ ███████╗██╗ ██╗████████╗ "
echo " ██║ ██║██╔════╝████╗ ██║██╔═══██╗ ██╔════╝╚██╗██╔╝╚══██╔══╝ "
echo " ██║ █╗ ██║█████╗ ██╔██╗ ██║██║ ██║ █████╗ ╚███╔╝ ██║ "
echo " ██║███╗██║██╔══╝ ██║╚██╗██║██║ ██║ ██╔══╝ ██╔██╗ ██║ "
echo " ╚███╔███╔╝███████╗██║ ╚████║╚██████╔╝ ███████╗██╔╝ ██╗ ██║ "
echo " ╚══╝╚══╝ ╚══════╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ "
echo "==========================================================================="
echo " "
echo "License "
echo " This file is part of WENOExt. "
echo " "
echo " WENOExt is free software: you can redistribute it and/or modify "
echo " it under the terms of the GNU General Public License as published by "
echo " the Free Software Foundation, either version 3 of the License, or "
echo " (at your option) any later version. "
echo " "
echo " WENOExt is distributed in the hope that it will be useful, but "
echo " WITHOUT ANY WARRANTY; without even the implied warranty of "
echo " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. "
echo " See the GNU General Public License for more details. "
echo " "
echo " You should have received a copy of the GNU General Public License "
echo " along with WENOExt. If not, see <http://www.gnu.org/licenses/>. "
echo "==========================================================================="
echo " "
echo "Build with these options: "
echo "Parallel: ${PARALLEL} "
echo "Number of cores: ${NUM_CORES} "
echo " "
echo "==========================================================================="
echo " Start CMake Process "
echo "==========================================================================="
cd ${0%/*} || exit 1 # Run from this directory
mkdir -p build
cd build
if [[ ${FORCE} != "YES" ]]; then
checkRepoStatus
fi
cmake .. ${POSITIONAL[@]}
if [[ ${PARALLEL} == "YES" ]]; then
make -j ${NUM_CORES}
else
make
fi
make install
echo "==========================================================================="
echo " Done Building WENOExt "
echo "==========================================================================="