summarylogtreecommitdiffstats
path: root/build
blob: 594ea102c5596405ef81793423345121521e102d (plain)
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
#!/usr/bin/env bash

#TODO: check distro and packages
#Edited for PKGBUILD

function echo_orange {
	echo -e "\\e[33m$*\\e[0m"
}

function echo_red {
	echo -e "\\e[31m$*\\e[0m"
}

cd Fuzion/
cmake . || exit 1

if ! hash patchelf 2>/dev/null; then
    echo_red -e "You need to install the \"patchelf\" command!\nUse your package manager to install it, or get source here:\nhttps://github.com/NixOS/patchelf"
    exit 1
fi

rm build_id_hex
# Get a Random name from the build_names file.
BUILD_ID="fz_git-$(shuf -n 1 build_names)"

# In case this file exists, get another one. ( checked it works )
while [ -f "/usr/lib/${BUILD_ID}" ] || grep -q ${BUILD_ID} /proc/$(pidof csgo_linux64)/maps; do
	BUILD_ID=$(shuf -n 1 build_names)
done

# Hexify it and put it into build_id_hex
for (( i=0; i<${#BUILD_ID}; i++ )); do
  printf '0x%x,\n' "'${BUILD_ID:$i:1}" >> build_id_hex
done
printf '0x0' >> build_id_hex

make -j"$(grep -c "^processor" /proc/cpuinfo)" "$@" || exit 1

if [ -f build_id ]; then
    filename=$(cat build_id)
    rm "$filename"
    if [ -f "/usr/lib/${filename}" ]; then
    	echo -e "Note: Old file found at /usr/lib/${filename}\n"
        #sudo rm "/usr/lib/${filename}"

    fi
    chmod 660 build_id
    mv build_id build_id_old
fi

echo $BUILD_ID > build_id
mv libFuzion.so "$BUILD_ID"

strip -s -v "$BUILD_ID"
patchelf --set-soname "$BUILD_ID" "$BUILD_ID" || echo_orange "Warning: your patchelf version does not support \"--set-soname\"\nConsider building from source: https://github.com/NixOS/patchelf"

chmod 400 build_id # Make the build_id read-only for safety.

echo "Build Completed."