2021-05-07 13:45:52 +00:00
|
|
|
#!/bin/sh
|
2011-12-24 11:15:42 +00:00
|
|
|
|
2012-04-18 14:09:18 +00:00
|
|
|
# PCSX2 - PS2 Emulator for PCs
|
2022-11-19 13:50:28 +00:00
|
|
|
# Copyright (C) 2002-2022 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
|
2021-05-07 13:45:52 +00:00
|
|
|
set -u
|
2011-12-24 11:15:42 +00:00
|
|
|
|
2019-07-05 02:49:11 +00:00
|
|
|
# Function declarations
|
|
|
|
find_freetype()
|
|
|
|
{
|
2022-03-28 00:38:41 +00:00
|
|
|
if [ "$(uname -m)" = "x86_64" ] && [ -e "/usr/include/x86_64-linux-gnu/freetype2/ft2build.h" ]; then
|
2019-07-05 02:49:11 +00:00
|
|
|
export GTKMM_BASEPATH=/usr/include/x86_64-linux-gnu/freetype2
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
set_make()
|
|
|
|
{
|
2022-04-28 20:35:15 +00:00
|
|
|
ncpu=$(getconf NPROCESSORS_ONLN 2>/dev/null || getconf _NPROCESSORS_ONLN)
|
2019-07-05 02:49:11 +00:00
|
|
|
if command -v ninja >/dev/null ; then
|
|
|
|
flags="$flags -GNinja"
|
|
|
|
make=ninja
|
|
|
|
else
|
|
|
|
make="make -j$ncpu"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
set_compiler()
|
|
|
|
{
|
|
|
|
if [ "$useClang" -eq 1 ]; then
|
2022-03-28 00:38:41 +00:00
|
|
|
CC=clang CXX=clang++ cmake $flags "$root" 2>&1 | tee -a "$log"
|
2019-07-05 02:49:11 +00:00
|
|
|
else
|
|
|
|
if [ "$useIcc" -eq 1 ]; then
|
2022-03-28 00:38:41 +00:00
|
|
|
CC="icc" CXX="icpc" cmake $flags "$root" 2>&1 | tee -a "$log"
|
2019-07-05 02:49:11 +00:00
|
|
|
else
|
|
|
|
# Default compiler AKA GCC
|
|
|
|
cmake $flags "$root" 2>&1 | tee -a "$log"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
run_cppcheck()
|
|
|
|
{
|
|
|
|
summary=cpp_check_summary.log
|
|
|
|
rm -f $summary
|
|
|
|
touch $summary
|
|
|
|
|
|
|
|
define=""
|
|
|
|
for undef in _WINDOWS _M_AMD64 _MSC_VER WIN32 __INTEL_COMPILER __x86_64__ \
|
2020-09-17 22:17:26 +00:00
|
|
|
__SSE4_1__ __SSSE3__ __SSE__ __AVX2__ __USE_ISOC11 ASAN_WORKAROUND ENABLE_OGL_DEBUG \
|
2019-07-05 02:49:11 +00:00
|
|
|
XBYAK_USE_MMAP_ALLOCATOR MAP_ANONYMOUS MAP_ANON XBYAK_DISABLE_AVX512
|
|
|
|
do
|
|
|
|
define="$define -U$undef"
|
|
|
|
done
|
|
|
|
|
|
|
|
check="--enable=warning,style,missingInclude"
|
|
|
|
|
2021-06-20 03:59:14 +00:00
|
|
|
for d in pcsx2 common
|
2019-07-05 02:49:11 +00:00
|
|
|
do
|
|
|
|
flat_d=$(echo $d | sed -e 's@/@_@')
|
|
|
|
log=cpp_check__${flat_d}.log
|
|
|
|
rm -f "$log"
|
|
|
|
|
2021-05-07 13:45:52 +00:00
|
|
|
cppcheck $check -j "$ncpu" --platform=unix32 "$define" "$root/$d" 2>&1 | tee "$log"
|
2019-07-05 02:49:11 +00:00
|
|
|
# Create a small summary (warning it might miss some issues)
|
|
|
|
fgrep -e "(warning)" -e "(error)" -e "(style)" -e "(performance)" -e "(portability)" "$log" >> $summary
|
|
|
|
done
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
run_clangtidy()
|
|
|
|
{
|
|
|
|
compile_json=compile_commands.json
|
|
|
|
cpp_list=cpp_file.txt
|
|
|
|
summary=clang_tidy_summary.txt
|
2020-05-25 02:08:12 +00:00
|
|
|
grep '"file"' $compile_json | sed -e 's/"//g' -e 's/^\s*file\s*:\s*//' | sort -u > $cpp_list
|
2019-07-05 02:49:11 +00:00
|
|
|
|
|
|
|
# EXAMPLE
|
|
|
|
#
|
|
|
|
# Modernize loop syntax, fix if old style found.
|
2021-06-20 03:59:14 +00:00
|
|
|
# $ clang-tidy -p build_dev/compile_commands.json pcsx2/GS/Renderers/HW/GSTextureCache.cpp -checks='modernize-loop-convert' -fix
|
2019-07-05 02:49:11 +00:00
|
|
|
# Check all, tons of output:
|
|
|
|
# $ clang-tidy -p $compile_json $cpp -checks='*' -header-filter='.*'
|
|
|
|
# List of modernize checks:
|
|
|
|
# modernize-loop-convert
|
|
|
|
# modernize-make-unique
|
|
|
|
# modernize-pass-by-value
|
|
|
|
# modernize-redundant-void-arg
|
|
|
|
# modernize-replace-auto-ptr
|
|
|
|
# modernize-shrink-to-fit
|
|
|
|
# modernize-use-auto
|
|
|
|
# modernize-use-default
|
|
|
|
# modernize-use-nullptr
|
|
|
|
# modernize-use-override
|
|
|
|
|
|
|
|
# Don't check headers, don't check google/llvm coding conventions
|
|
|
|
if command -v parallel >/dev/null ; then
|
|
|
|
# Run clang-tidy in parallel with as many jobs as there are CPUs.
|
|
|
|
parallel -v --keep-order "clang-tidy -p $compile_json -checks='*,-llvm-*,-google-*' {}"
|
|
|
|
else
|
|
|
|
# xargs(1) can also run jobs in parallel with -P, but will mix the
|
|
|
|
# output from the distinct processes together willy-nilly.
|
|
|
|
xargs clang-tidy -p $compile_json -checks='*,-llvm-*,-google-*'
|
|
|
|
fi < $cpp_list > $summary
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Main script
|
2016-08-14 20:29:12 +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
|
2016-07-28 08:35:21 +00:00
|
|
|
useIcc=0
|
2019-07-05 02:49:11 +00:00
|
|
|
|
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"
|
|
|
|
|
2019-07-05 02:49:11 +00:00
|
|
|
set_make
|
2016-09-07 16:58:31 +00:00
|
|
|
|
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 ;;
|
2016-08-20 17:01:14 +00:00
|
|
|
--clang-tidy ) flags="$flags -DCMAKE_EXPORT_COMPILE_COMMANDS=ON"; clangTidy=1 ; useClang=1;;
|
2020-05-07 15:32:34 +00:00
|
|
|
--ftime-trace ) flags="$flags -DTIMETRACE=TRUE"; useClang=1;;
|
2015-11-05 08:49:06 +00:00
|
|
|
--clang ) useClang=1 ;;
|
2016-07-28 08:35:21 +00:00
|
|
|
--intel ) useIcc=1 ;;
|
2015-11-05 08:49:06 +00:00
|
|
|
--cppcheck ) cppcheck=1 ;;
|
2016-08-14 20:29:12 +00:00
|
|
|
--dev|--devel ) flags="$flags -DCMAKE_BUILD_TYPE=Devel" ; build="$root/build_dev";;
|
|
|
|
--dbg|--debug ) flags="$flags -DCMAKE_BUILD_TYPE=Debug" ; build="$root/build_dbg";;
|
|
|
|
--rel|--release ) flags="$flags -DCMAKE_BUILD_TYPE=Release" ; build="$root/build_rel";;
|
2021-04-17 22:29:55 +00:00
|
|
|
--prof ) flags="$flags -DCMAKE_BUILD_TYPE=RelWithDebInfo"; build="$root/build_prof";;
|
2016-08-14 20:29:12 +00:00
|
|
|
--strip ) flags="$flags -DCMAKE_BUILD_STRIP=TRUE" ;;
|
|
|
|
--asan ) flags="$flags -DUSE_ASAN=TRUE" ;;
|
2020-10-30 05:30:03 +00:00
|
|
|
--gtk2 ) flags="$flags -DGTK2_API=TRUE" ;;
|
2022-06-08 04:45:40 +00:00
|
|
|
--qt6 ) flags="$flags -DQT_BUILD=TRUE" ;;
|
|
|
|
--use-system ) flags="$flags -DUSE_SYSTEM_LIBS=ON" ;;
|
|
|
|
--use-bundled ) flags="$flags -DUSE_SYSTEM_LIBS=OFF" ;;
|
2021-04-17 06:44:02 +00:00
|
|
|
--lto ) flags="$flags -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=TRUE" ;;
|
2016-12-05 15:57:53 +00:00
|
|
|
--pgo-optimize ) flags="$flags -DUSE_PGO_OPTIMIZE=TRUE" ;;
|
|
|
|
--pgo-generate ) flags="$flags -DUSE_PGO_GENERATE=TRUE" ;;
|
2016-08-14 20:29:12 +00:00
|
|
|
--no-simd ) flags="$flags -DDISABLE_ADVANCE_SIMD=TRUE" ;;
|
2018-09-10 03:54:15 +00:00
|
|
|
--no-trans ) flags="$flags -DNO_TRANSLATION=TRUE" ;;
|
2016-11-18 21:40:52 +00:00
|
|
|
--vtune ) flags="$flags -DUSE_VTUNE=TRUE" ;;
|
2016-08-14 20:29:12 +00:00
|
|
|
-D* ) flags="$flags $ARG" ;;
|
2014-04-10 07:20:42 +00:00
|
|
|
|
|
|
|
*)
|
2019-07-05 02:49:11 +00:00
|
|
|
echo $ARG
|
2014-08-04 01:58:37 +00:00
|
|
|
# Unknown option
|
2014-04-10 07:20:42 +00:00
|
|
|
echo "** User options **"
|
2022-04-15 05:04:26 +00:00
|
|
|
echo "--dev / --devel : Build PCSX2 as a Development build."
|
|
|
|
echo "--dbg / --debug : Build PCSX2 as a Debug build."
|
|
|
|
echo "--prof : Build PCSX2 as a Profiler build (release + debug symbol)."
|
|
|
|
echo "--rel / --release : Build PCSX2 as a Release build."
|
2014-12-07 21:06:39 +00:00
|
|
|
echo
|
2022-04-15 05:04:26 +00:00
|
|
|
echo "--clean : Do a clean build. (Remove anything in the build directory)"
|
|
|
|
echo "--no-simd : Only allow sse2."
|
2014-12-07 21:06:39 +00:00
|
|
|
echo
|
2015-01-06 20:54:55 +00:00
|
|
|
echo "** Expert Developer option **"
|
2022-04-15 05:04:26 +00:00
|
|
|
echo "--gtk2 : use GTK 2 instead of GTK 3."
|
2022-06-08 04:45:40 +00:00
|
|
|
echo "--qt6 : Experimental qt 6 ui."
|
2022-04-15 05:04:26 +00:00
|
|
|
echo "--no-trans : Don't regenerate mo files when building."
|
|
|
|
echo "--strip : Strip binaries to save a small amount of space."
|
|
|
|
echo "--clang : Build with Clang/llvm."
|
2022-06-08 04:45:40 +00:00
|
|
|
echo "--use-system : Only use system libs."
|
|
|
|
echo "--use-bundled : Only use bundled libs."
|
2022-04-15 05:04:26 +00:00
|
|
|
echo "--intel : Build with ICC (Intel compiler)."
|
|
|
|
echo "--lto : Use Link Time Optimization."
|
|
|
|
echo "--pgo-generate : Executable will generate profiling information when run."
|
|
|
|
echo "--pgo-optimize : Use previously generated profiling information."
|
|
|
|
echo "-D<argument> : Add <argument> to the flags passed."
|
2015-11-05 08:49:06 +00:00
|
|
|
echo
|
|
|
|
echo "** Quality & Assurance (Please install the external tool) **"
|
2022-04-15 05:04:26 +00:00
|
|
|
echo "--asan : Enable Address sanitizer."
|
|
|
|
echo "--clang-tidy : Do a clang-tidy analysis. Results can be found in build directory."
|
|
|
|
echo "--cppcheck : Do a cppcheck analysis. Results can be found in build directory."
|
|
|
|
echo "--vtune : Plug GS with VTUNE."
|
|
|
|
echo "--ftime-trace : Analyse build time. Clang only."
|
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
|
|
|
|
2016-08-14 20:29:12 +00:00
|
|
|
if [ "$cleanBuild" -eq 1 ]; then
|
2014-08-04 01:58:37 +00:00
|
|
|
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
|
|
|
|
2017-01-07 12:45:49 +00:00
|
|
|
# Workaround for Debian. Cmake failed to find freetype include path
|
2019-07-05 02:49:11 +00:00
|
|
|
find_freetype
|
2016-01-16 13:32:55 +00:00
|
|
|
|
2016-08-14 20:29:12 +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
|
2016-08-14 20:29:12 +00:00
|
|
|
if [ -L "$build" ]; then
|
2016-08-20 11:08:29 +00:00
|
|
|
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
|
|
|
|
2019-07-05 02:49:11 +00:00
|
|
|
set_compiler
|
2014-09-10 17:49:17 +00:00
|
|
|
|
2016-08-20 17:24:35 +00:00
|
|
|
if [ "$cppcheck" -eq 1 ] && command -v cppcheck >/dev/null ; then
|
2019-07-05 02:49:11 +00:00
|
|
|
run_cppcheck
|
2015-11-05 08:49:06 +00:00
|
|
|
fi
|
|
|
|
|
2016-08-20 17:24:35 +00:00
|
|
|
if [ "$clangTidy" -eq 1 ] && command -v clang-tidy >/dev/null ; then
|
2019-07-05 02:49:11 +00:00
|
|
|
run_clangtidy
|
2015-11-06 20:36:38 +00:00
|
|
|
fi
|
|
|
|
|
2016-09-07 16:58:31 +00:00
|
|
|
$make 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
|