-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-allocator.sh
executable file
·81 lines (67 loc) · 4.5 KB
/
build-allocator.sh
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
#!/bin/bash
#
# ██╗ ██╗███████╗ █████╗ ██████╗ ██████╗ ██╗ ██╗██╗ ███████╗███████╗
# ██║ ██║██╔════╝██╔══██╗██╔══██╗██╔══██╗██║ ██║██║ ██╔════╝██╔════╝
# ███████║█████╗ ███████║██████╔╝██████╔╝██║ ██║██║ ███████╗█████╗
# ██╔══██║██╔══╝ ██╔══██║██╔═══╝ ██╔═══╝ ██║ ██║██║ ╚════██║██╔══╝
# ██║ ██║███████╗██║ ██║██║ ██║ ╚██████╔╝███████╗███████║███████╗
# ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚══════╝╚══════╝
#
# ███╗ ███╗███████╗███╗ ███╗ ██████╗ ██████╗ ██╗ ██╗
# ████╗ ████║██╔════╝████╗ ████║██╔═══██╗██╔══██╗╚██╗ ██╔╝
# ██╔████╔██║█████╗ ██╔████╔██║██║ ██║██████╔╝ ╚████╔╝
# ██║╚██╔╝██║██╔══╝ ██║╚██╔╝██║██║ ██║██╔══██╗ ╚██╔╝
# ██║ ╚═╝ ██║███████╗██║ ╚═╝ ██║╚██████╔╝██║ ██║ ██║
# ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝
#
# ██████╗ ██████╗ ██████╗ ███████╗██╗██╗ ███████╗██████╗
# ██╔══██╗██╔══██╗██╔═══██╗██╔════╝██║██║ ██╔════╝██╔══██╗
# ██████╔╝██████╔╝██║ ██║█████╗ ██║██║ █████╗ ██████╔╝
# ██╔═══╝ ██╔══██╗██║ ██║██╔══╝ ██║██║ ██╔══╝ ██╔══██╗
# ██║ ██║ ██║╚██████╔╝██║ ██║███████╗███████╗██║ ██║
# ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝
#
# If we are root, demote to the user
if (( $EUID == 0 )); then
echo "Tried to run build as root, demoting to user🚨..."
su $SUDO_USER -c "$0 $*"
exit
fi
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
pushd $SCRIPT_DIR > /dev/null
# Check args to see if we do a full build or a partial build
# If the arg is "full", clean the build first
if [ $# -gt 0 ]; then
if [ "$1" == "full" ]; then
rm -rf build
fi
fi
echo "Building allocator🚧..."
echo "========================================================================="
# Check if `build` directory exists
if [ ! -d "build" ]; then
mkdir build
fi
# Compile the allocator
pushd build > /dev/null
echo "Building in $(pwd)🏗️"
cmake .. || { echo "Failed to run cmake❌"; exit 1; }
# Run make and check if it was successful
make || { echo "Failed to build allocator❌"; exit 1; }
if [ ! -f "libbkmalloc.so" ]; then
echo "libbkmalloc.so not found❌"
exit 1
fi
if [ ! -f "libheappulse.so" ]; then
echo "libheappulse.so not found❌"
exit 1
fi
# If the files already exist, delete them
rm -f ../libbkmalloc.so
rm -f ../libheappulse.so
cp libbkmalloc.so ../libbkmalloc.so
cp libheappulse.so ../libheappulse.so
popd > /dev/null
echo "Successfully built allocator $(pwd)✅"
echo "libbkmalloc.so and libheappulse.so are in $(pwd)✅"
popd > /dev/null