forked from multitheftauto/mtasa-blue
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinux-build.sh
More file actions
executable file
·107 lines (96 loc) · 2.68 KB
/
linux-build.sh
File metadata and controls
executable file
·107 lines (96 loc) · 2.68 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
#!/bin/bash -e
# Set variable defaults
: ${BUILD_OS:=linux}
: ${BUILD_ARCHITECTURE:=x64}
: ${BUILD_CONFIG:=release}
: ${PREMAKE_FILE:=premake5.lua}
# Find premake binary location
if [ "$(uname)" == "Darwin" ]; then
PREMAKE5=utils/premake5-macos
else
PREMAKE5=utils/premake5
fi
# Number of cores
if [ "$(uname)" == "Darwin" ]; then
NUM_CORES=$(sysctl -n hw.ncpu)
: ${GCC_PREFIX:=}
: ${AR:=ar}
: ${CC:=gcc}
: ${CXX:=g++}
else
NUM_CORES=$(grep -c ^processor /proc/cpuinfo)
fi
# Read script arguments
while [ $# -gt 0 ]; do
case "$1" in
--os=*) BUILD_OS="${1#*=}" ;;
--arch=*) BUILD_ARCHITECTURE="${1#*=}" ;;
--config=*) BUILD_CONFIG="${1#*=}" ;;
--cores=*) NUM_CORES="${1#*=}" ;;
--file=*) PREMAKE_FILE="${1#*=}" ;;
*)
echo "Error: Invalid argument: $1" >&2
exit 1
esac
shift
done
# Display script arguments
echo "Build configuration:"
echo " BUILD_ARCHITECTURE = $BUILD_ARCHITECTURE"
echo " BUILD_CONFIG = $BUILD_CONFIG"
# Verify script arguments
case $BUILD_CONFIG in
debug|release) ;;
*)
echo "Error: Invalid build configuration" >&2
exit 1
esac
case $BUILD_ARCHITECTURE in
32|x86)
CONFIG=${BUILD_CONFIG}_x86
: ${GCC_PREFIX:=i386-linux-gnu-}
: ${AR:=x86_64-linux-gnu-gcc-ar-10}
: ${CC:=x86_64-linux-gnu-gcc-10}
: ${CXX:=x86_64-linux-gnu-g++-10}
;;
64|x64)
CONFIG=${BUILD_CONFIG}_x64
: ${GCC_PREFIX:=x86_64-linux-gnu-}
: ${AR:=x86_64-linux-gnu-gcc-ar-10}
: ${CC:=x86_64-linux-gnu-gcc-10}
: ${CXX:=x86_64-linux-gnu-g++-10}
;;
arm)
CONFIG=${BUILD_CONFIG}_${BUILD_ARCHITECTURE}
: ${GCC_PREFIX:=arm-linux-gnueabihf-}
: ${AR:=arm-linux-gnueabihf-ar}
: ${CC:=arm-linux-gnueabihf-gcc-10}
: ${CXX:=arm-linux-gnueabihf-g++-10}
;;
arm64)
CONFIG=${BUILD_CONFIG}_${BUILD_ARCHITECTURE}
: ${GCC_PREFIX:=aarch64-linux-gnu-}
: ${AR:=aarch64-linux-gnu-gcc-ar-10}
: ${CC:=aarch64-linux-gnu-gcc-10}
: ${CXX:=aarch64-linux-gnu-g++-10}
;;
*)
echo "Error: Invalid build architecture" >&2
exit 1
esac
echo " OS = $BUILD_OS"
echo " CONFIG = $CONFIG"
echo " AR = $AR"
echo " CC = $CC"
echo " CXX = $CXX"
# Clean old build files
rm -Rf Build/
rm -Rf Bin/
# Generate Makefiles
if [[ -n "$GCC_PREFIX" ]]; then
$PREMAKE5 --gccprefix="$GCC_PREFIX" --os="$BUILD_OS" --file=$PREMAKE_FILE gmake
else
$PREMAKE5 --os="$BUILD_OS" --file=$PREMAKE_FILE gmake
fi
# Build!
make -C Build/ -j ${NUM_CORES} AR=${AR} CC=${CC} CXX=${CXX} config=${CONFIG} all