Nicolas Iooss | 416900c | 2018-06-09 22:08:34 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # Run clang's static analyzer (scan-build) and record its output in output-scan-build/ |
| 3 | |
| 4 | # Ensure the current directory is where this script is |
| 5 | cd "$(dirname -- "$0")" || exit $? |
| 6 | |
| 7 | OUTPUTDIR="$(pwd)/output-scan-build" |
| 8 | |
| 9 | # Display the commands which are run, and make sure they succeed |
| 10 | set -x -e |
| 11 | |
| 12 | # Use a temporary directory as an installation directory, if $DESTDIR is not set |
| 13 | if [ -z "$DESTDIR" ] ; then |
| 14 | DESTDIR="$(mktemp --tmpdir -d scan-build-destdir-XXXXXXXXXX)" |
| 15 | fi |
| 16 | |
| 17 | # Make sure to use the newly-installed libraries when running tests |
| 18 | export LD_LIBRARY_PATH="$DESTDIR/usr/lib:$DESTDIR/lib" |
| 19 | export PATH="$DESTDIR/usr/sbin:$DESTDIR/usr/bin:$DESTDIR/sbin:$DESTDIR/bin:$PATH" |
Petr Lautrbach | 1952be6 | 2019-02-18 17:27:44 +0100 | [diff] [blame] | 20 | export PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "from distutils.sysconfig import *;print(get_python_lib(prefix='/usr'))")" |
Nicolas Iooss | 416900c | 2018-06-09 22:08:34 +0200 | [diff] [blame] | 21 | export RUBYLIB="$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorlibdir"]'):$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorarchdir"]')" |
| 22 | |
| 23 | # Build and analyze |
| 24 | make -C .. CC=clang clean distclean -j"$(nproc)" |
Nicolas Iooss | 120681c | 2019-09-27 00:04:05 +0200 | [diff] [blame] | 25 | scan-build -analyze-headers -o "$OUTPUTDIR" make -C .. \ |
| 26 | CC=clang \ |
| 27 | DESTDIR="$DESTDIR" \ |
| 28 | CFLAGS="-O2 -Wall -D__CHECKER__ -I$DESTDIR/usr/include" \ |
| 29 | install install-pywrap install-rubywrap all test |
Nicolas Iooss | 416900c | 2018-06-09 22:08:34 +0200 | [diff] [blame] | 30 | |
| 31 | # Reduce the verbosity in order to keep the message from scan-build saying |
| 32 | # "scan-build: Run 'scan-view /.../output-scan-build/2018-...' to examine bug reports. |
| 33 | set +x |
| 34 | |
| 35 | # Remove the destination directory without using "rm -rf" |
| 36 | chmod u+w "$DESTDIR/usr/bin/newrole" |
| 37 | rm -r "$DESTDIR" |