-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·126 lines (94 loc) · 2.33 KB
/
build.sh
File metadata and controls
executable file
·126 lines (94 loc) · 2.33 KB
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
#!/bin/bash
#----------------------------#
#- Global Flags -#
#----------------------------#
NUM_THREADS_FLAG=0
NUM_THREADS=1
CMAKE_ARGS=''
#--------------------------------#
#- Clean Software -#
#--------------------------------#
clean_software(){
# Clean Software
echo '-> Cleaning Software'
rm -r release
}
#---------------------------------#
#- Build Directory -#
#---------------------------------#
build_module(){
# Get the Module
MODULE=$1
# Create the directory
mkdir -p $MODULE
# Enter the directory
pushd $MODULE
# Run CMake
cmake ../../$MODULE
if [ ! "$?" = '0' ]; then
echo 'Error with CMake. Aborting.'
exit 1
fi
# Run Make
make -j${NUM_THREADS}
if [ ! "$?" = '0' ]; then
echo 'Error with Make. Aborting.'
exit 1
fi
# Exit the directory
popd
}
#---------------------------------#
#- Make the software -#
#---------------------------------#
make_software(){
# Create release directory
mkdir -p release/cpp
mkdir -p release/fortran
# Enter Release
pushd release
# Build CPP
build_module cpp
# Build Fortran
build_module fortran
# Exit Release
popd
}
#--------------------------------------------------#
#- Iterate through Command-Line Arguments -#
#--------------------------------------------------#
for ARG in "$@"; do
case $ARG in
# Clean Code
'-c'|'--clean')
clean_software
exit 0
;;
# Build Software
'-m'|'--make')
make_software
exit 0
;;
# Set number of threads
'-j')
NUM_THREADS_FLAG=1
;;
# Set debugging
'-d')
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug"
;;
# Parse other args
*)
# Check if Num Threads flag requested
if [ "$NUM_THREADS_FLAG" = '1' ]; then
NUM_THREADS_FLAG=0
NUM_THREADS=$ARG
# Otherwise, error
else
echo "error: Unknown argument ($ARG)"
exit 1
fi
esac
done
# If no arg given, use default
make_software