Build.sh improvements

This commit is contained in:
Łukasz Domeradzki 2014-08-04 03:58:37 +02:00
parent 82c7bcd761
commit cd8d21cf8e
1 changed files with 38 additions and 33 deletions

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/bash
# PCSX2 - PS2 Emulator for PCs # PCSX2 - PS2 Emulator for PCs
# Copyright (C) 2002-2011 PCSX2 Dev Team # Copyright (C) 2002-2014 PCSX2 Dev Team
# #
# PCSX2 is free software: you can redistribute it and/or modify it under the terms # PCSX2 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 Found- # of the GNU Lesser General Public License as published by the Free Software Found-
@ -14,30 +14,31 @@
# You should have received a copy of the GNU General Public License along with PCSX2. # You should have received a copy of the GNU General Public License along with PCSX2.
# If not, see <http://www.gnu.org/licenses/>. # If not, see <http://www.gnu.org/licenses/>.
flags="-DCMAKE_BUILD_PO=FALSE" #set -e # This terminates the script in case of any error
clean_build=0
use_clang=0;
for f in $* flags=(-DCMAKE_BUILD_PO=FALSE)
do cleanBuild=0
case $f in useClang=0
--dev|--devel ) flags="$flags -DCMAKE_BUILD_TYPE=Devel" ;;
--dbg|--debug ) flags="$flags -DCMAKE_BUILD_TYPE=Debug" ;; for ARG in "$@"; do
--strip ) flags="$flags -DCMAKE_BUILD_STRIP=TRUE" ;; case "$ARG" in
--release ) flags="$flags -DCMAKE_BUILD_TYPE=Release" ;; --clean ) cleanBuild=1 ;;
--glsl ) flags="$flags -DGLSL_API=TRUE" ;; --clang ) flags+=(-DUSE_CLANG=TRUE); useClang=1; ;;
--egl ) flags="$flags -DEGL_API=TRUE" ;; --dev|--devel ) flags+=(-DCMAKE_BUILD_TYPE=Devel) ;;
--gles ) flags="$flags -DGLES_API=TRUE" ;; --dbg|--debug ) flags+=(-DCMAKE_BUILD_TYPE=Debug) ;;
--sdl2 ) flags="$flags -DSDL2_API=TRUE" ;; --strip ) flags+=(-DCMAKE_BUILD_STRIP=TRUE) ;;
--extra ) flags="$flags -DEXTRA_PLUGINS=TRUE" ;; --release ) flags+=(-DCMAKE_BUILD_TYPE=Release) ;;
--asan ) flags="$flags -DUSE_ASAN=TRUE";; --glsl ) flags+=(-DGLSL_API=TRUE) ;;
--clang ) use_clang=1; flags="$flags -DUSE_CLANG=TRUE" ;; --egl ) flags+=(-DEGL_API=TRUE) ;;
--clean ) clean_build=1 ;; --gles ) flags+=(-DGLES_API=TRUE) ;;
--wx28 ) flags="$flags -DWX28_API=TRUE" ;; --sdl2 ) flags+=(-DSDL2_API=TRUE) ;;
--wx30 ) flags="$flags -DWX28_API=FALSE" ;; --extra ) flags+=(-DEXTRA_PLUGINS=TRUE) ;;
--asan ) flags+=(-DUSE_ASAN=TRUE) ;;
--wx28 ) flags+=(-DWX28_API=TRUE) ;;
--wx30 ) flags+=(-DWX28_API=FALSE) ;;
*) *)
# unknown option # Unknown option
echo "** User options **" echo "** User options **"
echo "--dev / --devel : Build PCSX2 as a Development build." echo "--dev / --devel : Build PCSX2 as a Development build."
echo "--debug : Build PCSX2 as a Debug build." echo "--debug : Build PCSX2 as a Debug build."
@ -47,33 +48,37 @@ do
echo "--clang : Build with Clang/llvm" echo "--clang : Build with Clang/llvm"
echo "--extra : Build all plugins" echo "--extra : Build all plugins"
echo "--asan : Enable with Address sanitizer" echo "--asan : Enable with Address sanitizer"
echo "" echo
echo "--wx28 : Force wxWidget 2.8" echo "--wx28 : Force wxWidget 2.8"
echo "--wx30 : Allow to use wxWidget 3.0" echo "--wx30 : Allow to use wxWidget 3.0"
echo "--glsl : Replace CG backend of ZZogl by GLSL" echo "--glsl : Replace CG backend of ZZogl by GLSL"
echo "--egl : Replace GLX by EGL (ZZogl plugins only)" echo "--egl : Replace GLX by EGL (ZZogl plugins only)"
echo "--sdl2 : Build with SDL2 (crash if wx is linked to SDL1)" echo "--sdl2 : Build with SDL2 (crash if wx is linked to SDL1)"
echo "--gles : Replace openGL backend of GSdx by openGLES3" echo "--gles : Replace openGL backend of GSdx by openGLES3"
exit 1;; exit 1
esac esac
done done
[ $clean_build -eq 1 ] && (echo "Doing a clean build."; rm -fr build ) cd "$(dirname "$0")" # Navigate to script's directory
echo "Building pcsx2 with $flags\n" | tee install_log.txt if [[ "$cleanBuild" -eq 1 ]]; then
echo "Doing a clean build."
rm -fr build
fi
echo "Building pcsx2 with ${flags[*]}" | tee install_log.txt
mkdir -p build mkdir -p build
cd build cd build
if [ $use_clang -eq 1 ] if [[ "$useClang" -eq 1 ]]; then
then CC=clang CXX=clang++ cmake "${flags[@]}" .. 2>&1 | tee -a ../install_log.txt
CC=clang CXX=clang++ cmake $flags .. 2>&1 | tee -a ../install_log.txt
else else
cmake $flags .. 2>&1 | tee -a ../install_log.txt cmake "${flags[@]}" .. 2>&1 | tee -a ../install_log.txt
fi fi
CORE=`grep -w -c processor /proc/cpuinfo` make -j "$(grep -w -c processor /proc/cpuinfo)" 2>&1 | tee -a ../install_log.txt
make -j $CORE 2>&1 | tee -a ../install_log.txt
make install 2>&1 | tee -a ../install_log.txt make install 2>&1 | tee -a ../install_log.txt
cd .. cd ..
exit 0