forked from indilib/indi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
developer-build.bash
executable file
·76 lines (49 loc) · 1.93 KB
/
developer-build.bash
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
#!/bin/bash
# Developer Build Script
#
# Copyright (C) 2021 Pedram Ashofte Ardakani <[email protected]>
#
# This script is free software you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation either version 2.1 of the
# License, or (at your option) any later version.
#
# This script is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110
# - 1301 USA
# This script is meant to build the program in RAM to prevent wear and
# tear stress on HDD/SDD. RAM is a volatile memory that handles such
# needs gracefully.
TOP_DIR=$PWD
BUILD_LINK=$TOP_DIR/build
BUILD_DIR=/dev/shm/indi-build
# ONLY continue if there is at least 1GB of RAM available
NEED_MEMORY=1000000
FREE_MEMORY=$(free | awk '$1 == "Mem:" {print $NF}')
if [ $FREE_MEMORY -lt $NEED_MEMORY ]; then
echo "*** Not enough memory available in RAM (current $FREE_MEMORY, need $NEED_MEMORY)"
exit 1
fi
# Create the build directory, and optionally a symbolic link for quick
# and easy access.
if [ ! -d $BUILD_DIR ]; then
echo ">>> Creating /dev/shm/indi-build"
mkdir /dev/shm/indi-build
fi
if [ ! -h $BUILD_LINK ]; then
echo ">>> Creating a symbolic link for easier access:"
ln -s $BUILD_DIR $BUILD_LINK
echo ">>> New link: $BUILD_LINK"
elif [ $(file $BUILD_LINK | awk '{print $NF}') == $BUILD_DIR ]; then
echo ">>> Symbolic link intact"
fi
# Begin the build process, with all cores available
cd $BUILD_DIR
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug $TOP_DIR
make -j