2014-08-04 01:58:37 +00:00
|
|
|
#!/bin/bash
|
2011-12-24 11:15:42 +00:00
|
|
|
|
2012-04-18 14:09:18 +00:00
|
|
|
# PCSX2 - PS2 Emulator for PCs
|
2014-08-04 01:58:37 +00:00
|
|
|
# Copyright (C) 2002-2014 PCSX2 Dev Team
|
2012-04-18 14:09:18 +00:00
|
|
|
#
|
|
|
|
# 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-
|
|
|
|
# ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
# PURPOSE. See the GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along with PCSX2.
|
|
|
|
# If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2014-08-04 01:58:37 +00:00
|
|
|
#set -e # This terminates the script in case of any error
|
2011-12-24 11:15:42 +00:00
|
|
|
|
2014-08-04 01:58:37 +00:00
|
|
|
flags=(-DCMAKE_BUILD_PO=FALSE)
|
2014-12-29 12:25:07 +00:00
|
|
|
|
2014-08-04 01:58:37 +00:00
|
|
|
cleanBuild=0
|
|
|
|
useClang=0
|
2015-01-04 05:56:47 +00:00
|
|
|
# 0 => no, 1 => yes, 2 => force yes
|
2015-01-04 06:32:04 +00:00
|
|
|
useCross=2
|
2015-09-10 11:40:45 +00:00
|
|
|
CoverityBuild=0
|
2015-11-05 08:49:06 +00:00
|
|
|
cppcheck=0
|
2015-11-06 20:36:38 +00:00
|
|
|
clangTidy=0
|
2014-08-04 01:58:37 +00:00
|
|
|
|
2016-01-13 07:58:50 +00:00
|
|
|
root=$PWD/$(dirname "$0")
|
|
|
|
log="$root/install_log.txt"
|
|
|
|
build="$root/build"
|
|
|
|
coverity_dir="cov-int"
|
|
|
|
coverity_result=pcsx2-coverity.xz
|
|
|
|
|
2015-11-17 17:25:12 +00:00
|
|
|
if [[ $(uname -s) == 'Darwin' ]]; then
|
|
|
|
ncpu=$(sysctl -n hw.ncpu)
|
|
|
|
release=$(uname -r)
|
|
|
|
if [[ ${release:0:2} -lt 13 ]]; then
|
|
|
|
echo "This old OSX version is not supported! Build will fail."
|
|
|
|
toolfile=cmake/darwin-compiler-i386-clang.cmake
|
|
|
|
else
|
|
|
|
echo "Using Mavericks build with C++11 support."
|
|
|
|
toolfile=cmake/darwin13-compiler-i386-clang.cmake
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
ncpu=$(grep -w -c processor /proc/cpuinfo)
|
|
|
|
toolfile=cmake/linux-compiler-i386-multilib.cmake
|
|
|
|
fi
|
|
|
|
|
2014-08-04 01:58:37 +00:00
|
|
|
for ARG in "$@"; do
|
|
|
|
case "$ARG" in
|
2015-01-06 20:54:55 +00:00
|
|
|
--clean ) cleanBuild=1 ;;
|
2015-11-06 20:36:38 +00:00
|
|
|
--clang-tidy ) flags+=(-DCMAKE_EXPORT_COMPILE_COMMANDS=ON); clangTidy=1 ;;
|
2015-11-05 08:49:06 +00:00
|
|
|
--clang ) useClang=1 ;;
|
|
|
|
--cppcheck ) cppcheck=1 ;;
|
2016-01-13 07:58:50 +00:00
|
|
|
--dev|--devel ) flags+=(-DCMAKE_BUILD_TYPE=Devel) build="$root/build_dev";;
|
|
|
|
--dbg|--debug ) flags+=(-DCMAKE_BUILD_TYPE=Debug) build="$root/build_dbg";;
|
2016-02-21 15:22:31 +00:00
|
|
|
--rel|--release ) flags+=(-DCMAKE_BUILD_TYPE=Release) build="$root/build_rel";;
|
|
|
|
--prof ) flags+=(-DCMAKE_BUILD_TYPE=Prof) build="$root/build_prof";;
|
2015-01-06 20:54:55 +00:00
|
|
|
--strip ) flags+=(-DCMAKE_BUILD_STRIP=TRUE) ;;
|
|
|
|
--glsl ) flags+=(-DGLSL_API=TRUE) ;;
|
|
|
|
--egl ) flags+=(-DEGL_API=TRUE) ;;
|
2015-10-21 20:33:15 +00:00
|
|
|
--sdl12 ) flags+=(-DSDL2_API=FALSE) ;;
|
2015-01-06 20:54:55 +00:00
|
|
|
--extra ) flags+=(-DEXTRA_PLUGINS=TRUE) ;;
|
|
|
|
--asan ) flags+=(-DUSE_ASAN=TRUE) ;;
|
|
|
|
--gtk3 ) flags+=(-DGTK3_API=TRUE) ;;
|
|
|
|
--no-simd ) flags+=(-DDISABLE_ADVANCE_SIMD=TRUE) ;;
|
2015-11-17 17:25:12 +00:00
|
|
|
--cross-multilib ) flags+=(-DCMAKE_TOOLCHAIN_FILE=$toolfile); useCross=1; ;;
|
2015-01-06 20:54:55 +00:00
|
|
|
--no-cross-multilib ) useCross=0; ;;
|
2015-09-10 11:40:45 +00:00
|
|
|
--coverity ) CoverityBuild=1; cleanBuild=1; ;;
|
2015-01-06 20:54:55 +00:00
|
|
|
-D* ) flags+=($ARG) ;;
|
2014-04-10 07:20:42 +00:00
|
|
|
|
|
|
|
*)
|
2014-08-04 01:58:37 +00:00
|
|
|
# Unknown option
|
2014-04-10 07:20:42 +00:00
|
|
|
echo "** User options **"
|
|
|
|
echo "--dev / --devel : Build PCSX2 as a Development build."
|
|
|
|
echo "--debug : Build PCSX2 as a Debug build."
|
2016-02-21 15:22:31 +00:00
|
|
|
echo "--prof : Build PCSX2 as a Profiler build (release + debug symbol)."
|
2014-04-10 07:20:42 +00:00
|
|
|
echo "--release : Build PCSX2 as a Release build."
|
2014-12-07 21:06:39 +00:00
|
|
|
echo
|
2014-04-10 07:20:42 +00:00
|
|
|
echo "--clean : Do a clean build."
|
2014-12-07 21:06:39 +00:00
|
|
|
echo "--extra : Build all plugins"
|
2015-01-06 20:54:55 +00:00
|
|
|
echo "--no-simd : Only allow sse2"
|
2014-12-07 21:06:39 +00:00
|
|
|
echo
|
2014-12-24 23:15:55 +00:00
|
|
|
echo "** Developer option **"
|
2014-03-29 10:24:39 +00:00
|
|
|
echo "--glsl : Replace CG backend of ZZogl by GLSL"
|
2015-05-11 13:33:40 +00:00
|
|
|
echo "--egl : Replace GLX by EGL (ZZogl/GSdx plugins)"
|
2014-12-24 23:15:55 +00:00
|
|
|
echo "--cross-multilib: Build a 32bit PCSX2 on a 64bit machine using multilib."
|
2014-09-12 18:01:43 +00:00
|
|
|
echo
|
2015-10-21 20:33:15 +00:00
|
|
|
echo "** Distribution Compatibilities **"
|
|
|
|
echo "--sdl12 : Build with SDL1.2 (requires if wx is linked against SDL1.2)"
|
|
|
|
echo
|
2015-01-06 20:54:55 +00:00
|
|
|
echo "** Expert Developer option **"
|
2014-12-07 21:06:39 +00:00
|
|
|
echo "--gtk3 : replace GTK2 by GTK3"
|
2015-01-06 20:54:55 +00:00
|
|
|
echo "--no-cross-multilib: Build a native PCSX2"
|
|
|
|
echo "--clang : Build with Clang/llvm"
|
2015-11-05 08:49:06 +00:00
|
|
|
echo
|
|
|
|
echo "** Quality & Assurance (Please install the external tool) **"
|
2015-01-06 20:54:55 +00:00
|
|
|
echo "--asan : Enable Address sanitizer"
|
2015-11-06 20:36:38 +00:00
|
|
|
echo "--clang-tidy : Do a clang-tidy analysis. Results can be found in build directory"
|
2015-11-05 17:24:16 +00:00
|
|
|
echo "--cppcheck : Do a cppcheck analysis. Results can be found in build directory"
|
2015-11-05 08:49:06 +00:00
|
|
|
echo "--coverity : Do a build for coverity"
|
2015-01-06 20:54:55 +00:00
|
|
|
|
2014-08-04 01:58:37 +00:00
|
|
|
exit 1
|
2014-04-10 07:20:42 +00:00
|
|
|
esac
|
2012-01-07 22:20:50 +00:00
|
|
|
done
|
2011-12-24 11:15:42 +00:00
|
|
|
|
2014-08-04 01:58:37 +00:00
|
|
|
if [[ "$cleanBuild" -eq 1 ]]; then
|
|
|
|
echo "Doing a clean build."
|
2014-08-05 19:55:14 +00:00
|
|
|
# allow to keep build as a symlink (for example to a ramdisk)
|
2015-12-18 00:45:23 +00:00
|
|
|
rm -fr "$build"/*
|
2014-08-04 01:58:37 +00:00
|
|
|
fi
|
2012-10-21 18:10:13 +00:00
|
|
|
|
2015-01-04 06:32:04 +00:00
|
|
|
if [[ "$useCross" -eq 2 ]] && [[ "$(getconf LONG_BIT 2> /dev/null)" != 32 ]]; then
|
|
|
|
echo "Forcing cross compilation."
|
2015-11-17 17:25:12 +00:00
|
|
|
flags+=(-DCMAKE_TOOLCHAIN_FILE=$toolfile)
|
2015-01-04 06:32:04 +00:00
|
|
|
elif [[ "$useCross" -ne 1 ]]; then
|
|
|
|
useCross=0
|
|
|
|
fi
|
|
|
|
|
2016-01-16 13:32:55 +00:00
|
|
|
# Helper to easily switch wx-config on my system
|
|
|
|
if [[ "$useCross" -eq 0 ]] && [[ "$(uname -m)" == "x86_64" ]] && [[ -e "/usr/lib/i386-linux-gnu/wx/config/gtk2-unicode-3.0" ]]; then
|
|
|
|
sudo update-alternatives --set wx-config /usr/lib/x86_64-linux-gnu/wx/config/gtk2-unicode-3.0
|
|
|
|
fi
|
|
|
|
if [[ "$useCross" -eq 2 ]] && [[ "$(uname -m)" == "x86_64" ]] && [[ -e "/usr/lib/x86_64-linux-gnu/wx/config/gtk2-unicode-3.0" ]]; then
|
|
|
|
sudo update-alternatives --set wx-config /usr/lib/i386-linux-gnu/wx/config/gtk2-unicode-3.0
|
|
|
|
fi
|
|
|
|
|
2015-11-30 05:58:40 +00:00
|
|
|
echo "Building pcsx2 with ${flags[*]}" | tee "$log"
|
2012-10-21 18:10:13 +00:00
|
|
|
|
2014-08-05 19:55:14 +00:00
|
|
|
# Resolve the symlink otherwise cmake is lost
|
|
|
|
# Besides, it allows 'mkdir' to create the real destination directory
|
2015-12-18 00:45:23 +00:00
|
|
|
if [[ -L "$build" ]]; then
|
|
|
|
build=`readlink "$build"`
|
2014-08-05 19:55:14 +00:00
|
|
|
fi
|
|
|
|
|
2015-12-18 00:45:23 +00:00
|
|
|
mkdir -p "$build"
|
2014-08-05 19:55:14 +00:00
|
|
|
# Cmake will generate file inside $CWD. It would be nicer if an option to cmake can be provided.
|
2015-12-18 00:45:23 +00:00
|
|
|
cd "$build"
|
2011-12-24 11:15:42 +00:00
|
|
|
|
2014-08-04 01:58:37 +00:00
|
|
|
if [[ "$useClang" -eq 1 ]]; then
|
2015-01-04 05:56:47 +00:00
|
|
|
if [[ "$useCross" -eq 0 ]]; then
|
2015-11-30 05:58:40 +00:00
|
|
|
CC=clang CXX=clang++ cmake "${flags[@]}" "$root" 2>&1 | tee -a "$log"
|
2015-01-04 05:56:47 +00:00
|
|
|
else
|
2015-11-30 05:58:40 +00:00
|
|
|
CC="clang -m32" CXX="clang++ -m32" cmake "${flags[@]}" "$root" 2>&1 | tee -a "$log"
|
2015-01-04 05:56:47 +00:00
|
|
|
fi
|
2014-07-04 21:50:51 +00:00
|
|
|
else
|
2015-11-30 05:58:40 +00:00
|
|
|
cmake "${flags[@]}" "$root" 2>&1 | tee -a "$log"
|
2014-07-04 21:50:51 +00:00
|
|
|
fi
|
2012-10-21 18:10:13 +00:00
|
|
|
|
2015-11-17 17:25:12 +00:00
|
|
|
|
2014-09-10 17:49:17 +00:00
|
|
|
|
2015-11-06 20:36:38 +00:00
|
|
|
############################################################
|
|
|
|
# CPP check build
|
|
|
|
############################################################
|
2015-11-05 08:49:06 +00:00
|
|
|
if [[ "$cppcheck" -eq 1 ]] && [[ -x `which cppcheck` ]]; then
|
|
|
|
summary=cpp_check_summary.log
|
|
|
|
rm -f $summary
|
|
|
|
touch $summary
|
|
|
|
|
2015-11-07 17:07:23 +00:00
|
|
|
for undef in _WINDOWS _M_AMD64 _MSC_VER WIN32 __INTEL_COMPILER __x86_64__ \
|
|
|
|
__SSE4_1__ __SSSE3__ __SSE__ __AVX2__ __USE_ISOC11 ASAN_WORKAROUND ENABLE_OPENCL ENABLE_OGL_DEBUG
|
|
|
|
do
|
|
|
|
define="$define -U$undef"
|
|
|
|
done
|
2015-11-05 08:49:06 +00:00
|
|
|
check="--enable=warning,style,missingInclude"
|
|
|
|
for d in pcsx2 common plugins/GSdx plugins/spu2\-x plugins/onepad
|
|
|
|
do
|
|
|
|
flat_d=`echo $d | sed -e 's@/@_@'`
|
|
|
|
log=cpp_check__${flat_d}.log
|
2015-11-30 05:58:40 +00:00
|
|
|
rm -f "$log"
|
2015-11-05 08:49:06 +00:00
|
|
|
|
2016-01-13 07:14:46 +00:00
|
|
|
cppcheck $check -j $ncpu --platform=unix32 $define "$root/$d" 2>&1 | tee "$log"
|
2015-11-05 08:49:06 +00:00
|
|
|
# Create a small summary (warning it might miss some issues)
|
2015-11-30 05:58:40 +00:00
|
|
|
fgrep -e "(warning)" -e "(error)" -e "(style)" -e "(performance)" -e "(portability)" "$log" >> $summary
|
2015-11-05 08:49:06 +00:00
|
|
|
done
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2015-11-06 20:36:38 +00:00
|
|
|
############################################################
|
|
|
|
# Clang tidy build
|
|
|
|
############################################################
|
|
|
|
if [[ "$clangTidy" -eq 1 ]] && [[ -x `which clang-tidy` ]]; then
|
|
|
|
compile_json=compile_commands.json
|
|
|
|
cpp_list=cpp_file.txt
|
|
|
|
summary=clang_tidy_summary.txt
|
|
|
|
rm -f $summary
|
|
|
|
touch $summary
|
|
|
|
|
|
|
|
grep '"file"' $compile_json | sed -e 's/"//g' | sed -e 's/^\s*file\s*:\s*//' > $cpp_list
|
|
|
|
|
|
|
|
for cpp in `cat $cpp_list`
|
|
|
|
do
|
|
|
|
# Check all, likely severals millions of log...
|
|
|
|
#clang-tidy -p $compile_json $cpp -checks='*' -header-filter='.*'
|
|
|
|
|
|
|
|
# Don't check header, don't check google/llvm coding conventions
|
|
|
|
echo "$count/$total"
|
|
|
|
clang-tidy -p $compile_json $cpp -checks='*,-llvm-*,-google-*' >> $summary
|
|
|
|
done
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
############################################################
|
|
|
|
# Coverity build
|
|
|
|
############################################################
|
2015-11-05 08:49:06 +00:00
|
|
|
if [[ "$CoverityBuild" -eq 1 ]] && [[ -x `which cov-build` ]]; then
|
2015-12-18 00:47:48 +00:00
|
|
|
cov-build --dir "$coverity_dir" make -j"$ncpu" 2>&1 | tee -a "$log"
|
2015-09-10 11:40:45 +00:00
|
|
|
# Warning: $coverity_dir must be the root directory
|
2015-12-18 00:47:48 +00:00
|
|
|
(cd "$build"; tar caf $coverity_result "$coverity_dir")
|
2015-11-06 20:36:38 +00:00
|
|
|
exit 0
|
2015-09-10 11:40:45 +00:00
|
|
|
fi
|
2011-12-24 11:15:42 +00:00
|
|
|
|
2015-11-06 20:36:38 +00:00
|
|
|
############################################################
|
|
|
|
# Real build
|
|
|
|
############################################################
|
2015-11-30 05:58:40 +00:00
|
|
|
make -j"$ncpu" 2>&1 | tee -a "$log"
|
|
|
|
make install 2>&1 | tee -a "$log"
|
2015-11-06 20:36:38 +00:00
|
|
|
|
2014-08-04 01:58:37 +00:00
|
|
|
exit 0
|