From cd8d21cf8edc80650b489ede844520313ae1b939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Domeradzki?= Date: Mon, 4 Aug 2014 03:58:37 +0200 Subject: [PATCH] Build.sh improvements --- build.sh | 71 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/build.sh b/build.sh index f5441036de..d5d6febde2 100755 --- a/build.sh +++ b/build.sh @@ -1,7 +1,7 @@ -#!/bin/sh +#!/bin/bash # 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 # 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. # If not, see . -flags="-DCMAKE_BUILD_PO=FALSE" -clean_build=0 -use_clang=0; +#set -e # This terminates the script in case of any error -for f in $* -do - case $f in - --dev|--devel ) flags="$flags -DCMAKE_BUILD_TYPE=Devel" ;; - --dbg|--debug ) flags="$flags -DCMAKE_BUILD_TYPE=Debug" ;; - --strip ) flags="$flags -DCMAKE_BUILD_STRIP=TRUE" ;; - --release ) flags="$flags -DCMAKE_BUILD_TYPE=Release" ;; - --glsl ) flags="$flags -DGLSL_API=TRUE" ;; - --egl ) flags="$flags -DEGL_API=TRUE" ;; - --gles ) flags="$flags -DGLES_API=TRUE" ;; - --sdl2 ) flags="$flags -DSDL2_API=TRUE" ;; - --extra ) flags="$flags -DEXTRA_PLUGINS=TRUE" ;; - --asan ) flags="$flags -DUSE_ASAN=TRUE";; - --clang ) use_clang=1; flags="$flags -DUSE_CLANG=TRUE" ;; - --clean ) clean_build=1 ;; - --wx28 ) flags="$flags -DWX28_API=TRUE" ;; - --wx30 ) flags="$flags -DWX28_API=FALSE" ;; +flags=(-DCMAKE_BUILD_PO=FALSE) +cleanBuild=0 +useClang=0 + +for ARG in "$@"; do + case "$ARG" in + --clean ) cleanBuild=1 ;; + --clang ) flags+=(-DUSE_CLANG=TRUE); useClang=1; ;; + --dev|--devel ) flags+=(-DCMAKE_BUILD_TYPE=Devel) ;; + --dbg|--debug ) flags+=(-DCMAKE_BUILD_TYPE=Debug) ;; + --strip ) flags+=(-DCMAKE_BUILD_STRIP=TRUE) ;; + --release ) flags+=(-DCMAKE_BUILD_TYPE=Release) ;; + --glsl ) flags+=(-DGLSL_API=TRUE) ;; + --egl ) flags+=(-DEGL_API=TRUE) ;; + --gles ) flags+=(-DGLES_API=TRUE) ;; + --sdl2 ) flags+=(-DSDL2_API=TRUE) ;; + --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 "--dev / --devel : Build PCSX2 as a Development build." echo "--debug : Build PCSX2 as a Debug build." @@ -47,33 +48,37 @@ do echo "--clang : Build with Clang/llvm" echo "--extra : Build all plugins" echo "--asan : Enable with Address sanitizer" - echo "" + echo echo "--wx28 : Force wxWidget 2.8" echo "--wx30 : Allow to use wxWidget 3.0" echo "--glsl : Replace CG backend of ZZogl by GLSL" echo "--egl : Replace GLX by EGL (ZZogl plugins only)" echo "--sdl2 : Build with SDL2 (crash if wx is linked to SDL1)" echo "--gles : Replace openGL backend of GSdx by openGLES3" - exit 1;; + exit 1 esac 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 cd build -if [ $use_clang -eq 1 ] -then - CC=clang CXX=clang++ cmake $flags .. 2>&1 | tee -a ../install_log.txt +if [[ "$useClang" -eq 1 ]]; then + CC=clang CXX=clang++ cmake "${flags[@]}" .. 2>&1 | tee -a ../install_log.txt else - cmake $flags .. 2>&1 | tee -a ../install_log.txt + cmake "${flags[@]}" .. 2>&1 | tee -a ../install_log.txt fi -CORE=`grep -w -c processor /proc/cpuinfo` -make -j $CORE 2>&1 | tee -a ../install_log.txt +make -j "$(grep -w -c processor /proc/cpuinfo)" 2>&1 | tee -a ../install_log.txt make install 2>&1 | tee -a ../install_log.txt cd .. +exit 0