forked from hrydgard/ppsspp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
b.sh
executable file
·116 lines (110 loc) · 3.23 KB
/
b.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
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
#!/bin/bash
CMAKE=1
# Check arguments
while test $# -gt 0
do
case "$1" in
--qt) echo "Qt enabled"
QT=1
CMAKE_ARGS="-DUSING_QT_UI=ON ${CMAKE_ARGS}"
;;
--qtbrew) echo "Qt enabled (homebrew)"
QT=1
CMAKE_ARGS="-DUSING_QT_UI=ON -DCMAKE_PREFIX_PATH=$(brew --prefix qt5) ${CMAKE_ARGS}"
;;
--ios) CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/ios.cmake ${CMAKE_ARGS}"
TARGET_OS=iOS
;;
--ios-xcode) CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/ios.cmake -DIOS_PLATFORM=OS -GXcode ${CMAKE_ARGS}"
TARGET_OS=iOS-xcode
;;
--fat) CMAKE_ARGS="-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64 ${CMAKE_ARGS}"
;;
--no-png) CMAKE_ARGS="-DUSE_SYSTEM_LIBPNG=OFF ${CMAKE_ARGS}"
;;
--no-sdl2) CMAKE_ARGS="-DUSE_SYSTEM_LIBSDL2=OFF ${CMAKE_ARGS}"
;;
--rpi-armv6)
CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/raspberry.armv6.cmake ${CMAKE_ARGS}"
;;
--rpi)
CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/raspberry.armv7.cmake ${CMAKE_ARGS}"
;;
--rpi64)
CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/raspberry.armv8.cmake ${CMAKE_ARGS}"
;;
--android) CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=android/android.toolchain.cmake ${CMAKE_ARGS}"
TARGET_OS=Android
PACKAGE=1
;;
--simulator) echo "Simulator mode enabled"
CMAKE_ARGS="-DSIMULATOR=ON ${CMAKE_ARGS}"
;;
--release)
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release ${CMAKE_ARGS}"
;;
--debug)
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Debug ${CMAKE_ARGS}"
;;
--reldebug)
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=RelWithDebInfo ${CMAKE_ARGS}"
;;
--headless) echo "Headless mode enabled"
CMAKE_ARGS="-DHEADLESS=ON ${CMAKE_ARGS}"
;;
--libretro) echo "Build Libretro core"
CMAKE_ARGS="-DLIBRETRO=ON ${CMAKE_ARGS}"
;;
--libretro_android) echo "Build Libretro Android core"
CMAKE_ARGS="-DLIBRETRO=ON -DCMAKE_TOOLCHAIN_FILE=${NDK}/build/cmake/android.toolchain.cmake -DANDROID_ABI=${APP_ABI} ${CMAKE_ARGS}"
;;
--unittest) echo "Build unittest"
CMAKE_ARGS="-DUNITTEST=ON ${CMAKE_ARGS}"
;;
--no-package) echo "Packaging disabled"
PACKAGE=0
;;
--clang) echo "Clang enabled"
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
;;
--sanitize) echo "Enabling address-sanitizer if available"
CMAKE_ARGS="-DUSE_ASAN=ON ${CMAKE_ARGS}"
;;
--sanitizeub) echo "Enabling ub-sanitizer if available"
CMAKE_ARGS="-DUSE_UBSAN=ON ${CMAKE_ARGS}"
;;
--gold) echo "Gold build enabled"
CMAKE_ARGS="-DGOLD=ON ${CMAKE_ARGS}"
;;
--alderlake) echo "Alderlake opt"
CMAKE_ARGS="-DCMAKE_C_FLAGS=\"-march=alderlake\" -DCMAKE_CPP_FLAGS=\"-march=alderlake\""
;;
--no_mmap) echo "Disable mmap"
CMAKE_ARGS="-DUSE_NO_MMAP=ON ${CMAKE_ARGS}"
;;
*) MAKE_OPT="$1 ${MAKE_OPT}"
;;
esac
shift
done
if [ ! -z "$TARGET_OS" ]; then
echo "Building for $TARGET_OS"
BUILD_DIR="$(tr [A-Z] [a-z] <<< build-"$TARGET_OS")"
else
echo "Building for native host."
BUILD_DIR="build"
fi
CORES_COUNT=4
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
CORES_COUNT="$(nproc)"
elif [[ "$OSTYPE" == "darwin"* ]]; then
CORES_COUNT="$(sysctl -n hw.physicalcpu)"
fi
# Strict errors. Any non-zero return exits this script
set -e
mkdir -p ${BUILD_DIR}
pushd ${BUILD_DIR}
cmake $CMAKE_ARGS ..
make -j$CORES_COUNT $MAKE_OPT
popd