Skip to content

Latest commit

 

History

History
executable file
·
51 lines (40 loc) · 1.86 KB

run-scan-build

File metadata and controls

executable file
·
51 lines (40 loc) · 1.86 KB
 
1
2
3
#!/bin/sh
# Run clang's static analyzer (scan-build) and record its output in output-scan-build/
Jul 19, 2021
Jul 19, 2021
4
5
6
7
# Allow overriding binariy names, like clang-12
export CC=${CC:-clang}
SCAN_BUILD=${SCAN_BUILD:-scan-build}
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Ensure the current directory is where this script is
cd "$(dirname -- "$0")" || exit $?
OUTPUTDIR="$(pwd)/output-scan-build"
# Display the commands which are run, and make sure they succeed
set -x -e
# Use a temporary directory as an installation directory, if $DESTDIR is not set
if [ -z "$DESTDIR" ] ; then
DESTDIR="$(mktemp --tmpdir -d scan-build-destdir-XXXXXXXXXX)"
fi
# Make sure to use the newly-installed libraries when running tests
export LD_LIBRARY_PATH="$DESTDIR/usr/lib:$DESTDIR/lib"
export PATH="$DESTDIR/usr/sbin:$DESTDIR/usr/bin:$DESTDIR/sbin:$DESTDIR/bin:$PATH"
Nov 9, 2022
Nov 9, 2022
24
export PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "import sysconfig; print(sysconfig.get_path('purelib', vars={'platbase': '/usr', 'base': '/usr'}))")"
25
26
export RUBYLIB="$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorlibdir"]'):$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorarchdir"]')"
Jul 6, 2022
Jul 6, 2022
27
if [ -f /etc/debian_version ] && [ -z "${IS_CIRCLE_CI:-}" ] ; then
Jul 19, 2021
Jul 19, 2021
28
29
30
export PYTHON_SETUP_ARGS='--install-layout=deb'
fi
31
# Build and analyze
Jul 19, 2021
Jul 19, 2021
32
33
make -C .. clean distclean -j"$(nproc)"
$SCAN_BUILD -analyze-headers -o "$OUTPUTDIR" make -C .. \
Sep 30, 2019
Sep 30, 2019
34
DESTDIR="$DESTDIR" \
Jul 19, 2021
Jul 19, 2021
35
36
CFLAGS="-O2 -Wall -Wextra -D_FORTIFY_SOURCE=2 -D__CHECKER__ -I$DESTDIR/usr/include" \
-j"$(nproc)" \
Sep 30, 2019
Sep 30, 2019
37
install install-pywrap install-rubywrap all test
Jul 19, 2021
Jul 19, 2021
39
40
41
42
43
44
if [ $? -eq 0 ]; then
echo "++ Build succeeded"
else
echo "++ Build failed"
fi
45
46
47
48
49
50
51
# Reduce the verbosity in order to keep the message from scan-build saying
# "scan-build: Run 'scan-view /.../output-scan-build/2018-...' to examine bug reports.
set +x
# Remove the destination directory without using "rm -rf"
chmod u+w "$DESTDIR/usr/bin/newrole"
rm -r "$DESTDIR"