mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Use bash arrays instead of strings for static analysis scripts.
These are more robust wrt. spaces in names.
This commit is contained in:
parent
f8ab7218f0
commit
c1a2ea3309
|
@ -1,44 +1,51 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
CPPFLAGS="$CPPFLAGS -DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE"
|
CPPFLAGS="-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE"
|
||||||
CPPFLAGS="$CPPFLAGS -isystem /usr/include/opus"
|
CPPFLAGS+=("-isystem" "/usr/include/opus")
|
||||||
CPPFLAGS="$CPPFLAGS -Iauto_tests"
|
CPPFLAGS+=("-Iauto_tests")
|
||||||
CPPFLAGS="$CPPFLAGS -Iother"
|
CPPFLAGS+=("-Iother")
|
||||||
CPPFLAGS="$CPPFLAGS -Iother/bootstrap_daemon/src"
|
CPPFLAGS+=("-Iother/bootstrap_daemon/src")
|
||||||
CPPFLAGS="$CPPFLAGS -Iother/fun"
|
CPPFLAGS+=("-Iother/fun")
|
||||||
CPPFLAGS="$CPPFLAGS -Itesting"
|
CPPFLAGS+=("-Itesting")
|
||||||
CPPFLAGS="$CPPFLAGS -Itoxcore"
|
CPPFLAGS+=("-Itesting/groupchats")
|
||||||
CPPFLAGS="$CPPFLAGS -Itoxav"
|
CPPFLAGS+=("-Itoxcore")
|
||||||
CPPFLAGS="$CPPFLAGS -Itoxencryptsave"
|
CPPFLAGS+=("-Itoxav")
|
||||||
|
CPPFLAGS+=("-Itoxencryptsave")
|
||||||
|
|
||||||
LDFLAGS="$LDFLAGS -lopus -lsodium -lvpx -lpthread -lconfig"
|
LDFLAGS=("-lopus" "-lsodium" "-lvpx" "-lpthread" "-lconfig")
|
||||||
|
LDFLAGS+=("-fuse-ld=gold")
|
||||||
|
LDFLAGS+=("-Wl,--detect-odr-violations")
|
||||||
|
LDFLAGS+=("-Wl,--warn-common")
|
||||||
|
LDFLAGS+=("-Wl,--warn-execstack")
|
||||||
|
LDFLAGS+=("-Wl,-z,noexecstack")
|
||||||
|
LDFLAGS+=("-Wl,-z,now")
|
||||||
|
|
||||||
put() {
|
put() {
|
||||||
if [ "$SKIP_LINES" = "" ]; then
|
if [ "$SKIP_LINES" = "" ]; then
|
||||||
echo "#line 1 \"$1\"" >> amalgamation.cc
|
echo "#line 1 \"$1\"" >>amalgamation.cc
|
||||||
fi
|
fi
|
||||||
cat "$1" >> amalgamation.cc
|
cat "$1" >>amalgamation.cc
|
||||||
}
|
}
|
||||||
|
|
||||||
putmain() {
|
putmain() {
|
||||||
echo "namespace $(echo "$1" | sed -e 's/[^a-zA-Z0-9_]/_/g') {" >> amalgamation.cc
|
echo "namespace ${1//[^a-zA-Z0-9_]/_} {" >>amalgamation.cc
|
||||||
if [ "$SKIP_LINES" = "" ]; then
|
if [ "$SKIP_LINES" = "" ]; then
|
||||||
echo "#line 1 \"$1\"" >> amalgamation.cc
|
echo "#line 1 \"$1\"" >>amalgamation.cc
|
||||||
fi
|
fi
|
||||||
sed -e 's/^int main(/static &/' "$1" >> amalgamation.cc
|
sed -e 's/^int main(/static &/' "$1" >>amalgamation.cc
|
||||||
echo "} // namespace $(echo "$1" | sed -e 's/[^a-zA-Z0-9_]/_/g')" >> amalgamation.cc
|
echo "} // namespace ${1//[^a-zA-Z0-9_]/_}" >>amalgamation.cc
|
||||||
}
|
}
|
||||||
|
|
||||||
callmain() {
|
callmain() {
|
||||||
echo " call($(echo "$1" | sed -e 's/[^a-zA-Z0-9_]/_/g')::main, argc, argv);" >> amalgamation.cc
|
echo " call(${1//[^a-zA-Z0-9_]/_}::main, argc, argv);" >>amalgamation.cc
|
||||||
}
|
}
|
||||||
|
|
||||||
:> amalgamation.cc
|
: >amalgamation.cc
|
||||||
|
|
||||||
echo "#include <algorithm>" >> amalgamation.cc
|
echo "#include <algorithm>" >>amalgamation.cc
|
||||||
echo "#include <cstdio>" >> amalgamation.cc
|
echo "#include <cstdio>" >>amalgamation.cc
|
||||||
echo "#include <memory>" >> amalgamation.cc
|
echo "#include <memory>" >>amalgamation.cc
|
||||||
echo "#include <random>" >> amalgamation.cc
|
echo "#include <random>" >>amalgamation.cc
|
||||||
|
|
||||||
put auto_tests/check_compat.h
|
put auto_tests/check_compat.h
|
||||||
|
|
||||||
|
@ -53,33 +60,35 @@ FIND_QUERY="$FIND_QUERY -and -not -name av_test.c"
|
||||||
FIND_QUERY="$FIND_QUERY -and -not -name dht_test.c"
|
FIND_QUERY="$FIND_QUERY -and -not -name dht_test.c"
|
||||||
FIND_QUERY="$FIND_QUERY -and -not -name version_test.c"
|
FIND_QUERY="$FIND_QUERY -and -not -name version_test.c"
|
||||||
|
|
||||||
(for i in $(eval "$FIND_QUERY"); do
|
readarray -t FILES <<<"$(eval "$FIND_QUERY")"
|
||||||
grep -o '#include <[^>]*>' "$i" \
|
|
||||||
| grep -E -v '<win|<ws|<iphlp|<libc|<mach/|<crypto_|<randombytes|<u.h>|<sys/filio|<linux'
|
|
||||||
done) | sort -u >> amalgamation.cc
|
|
||||||
|
|
||||||
echo 'namespace {' >> amalgamation.cc
|
(for i in "${FILES[@]}"; do
|
||||||
for i in $(eval "$FIND_QUERY"); do
|
grep -o '#include <[^>]*>' "$i" |
|
||||||
|
grep -E -v '<win|<ws|<iphlp|<libc|<mach/|<crypto_|<randombytes|<u.h>|<sys/filio|<linux'
|
||||||
|
done) | sort -u >>amalgamation.cc
|
||||||
|
|
||||||
|
echo 'namespace {' >>amalgamation.cc
|
||||||
|
for i in "${FILES[@]}"; do
|
||||||
if ! grep -q '^int main(' "$i"; then
|
if ! grep -q '^int main(' "$i"; then
|
||||||
put "$i"
|
put "$i"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
for i in $(eval "$FIND_QUERY"); do
|
for i in "${FILES[@]}"; do
|
||||||
if grep -q '^int main(' "$i"; then
|
if grep -q '^int main(' "$i"; then
|
||||||
putmain "$i"
|
putmain "$i"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "static void call(int m(), int argc, char **argv) { m(); }" >> amalgamation.cc
|
echo "static void call(int m(), int argc, char **argv) { m(); }" >>amalgamation.cc
|
||||||
echo "static void call(int m(int, char **), int argc, char **argv) { m(argc, argv); }" >> amalgamation.cc
|
echo "static void call(int m(int, char **), int argc, char **argv) { m(argc, argv); }" >>amalgamation.cc
|
||||||
echo '} // namespace' >> amalgamation.cc
|
echo '} // namespace' >>amalgamation.cc
|
||||||
|
|
||||||
echo "int main(int argc, char **argv) {" >> amalgamation.cc
|
echo "int main(int argc, char **argv) {" >>amalgamation.cc
|
||||||
for i in $(eval "$FIND_QUERY"); do
|
for i in "${FILES[@]}"; do
|
||||||
if grep -q '^int main(' "$i"; then
|
if grep -q '^int main(' "$i"; then
|
||||||
callmain "$i"
|
callmain "$i"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo " return 0;" >> amalgamation.cc
|
echo " return 0;" >>amalgamation.cc
|
||||||
echo "}" >> amalgamation.cc
|
echo "}" >>amalgamation.cc
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
. other/analysis/gen-file.sh
|
. other/analysis/gen-file.sh
|
||||||
|
|
||||||
echo "Running Clang compiler"
|
echo "Running Clang compiler"
|
||||||
clang++ -o /dev/null amalgamation.cc \
|
clang++ -o /dev/null amalgamation.cc \
|
||||||
$CPPFLAGS \
|
"${CPPFLAGS[@]}" \
|
||||||
$LDFLAGS \
|
"${LDFLAGS[@]}" \
|
||||||
-std=c++11 \
|
-std=c++11 \
|
||||||
-Werror \
|
-Werror \
|
||||||
-Weverything \
|
-Weverything \
|
||||||
-Wno-c++98-compat-pedantic \
|
-Wno-c++98-compat-pedantic \
|
||||||
-Wno-c99-extensions \
|
-Wno-c99-extensions \
|
||||||
-Wno-cast-align \
|
-Wno-cast-align \
|
||||||
-Wno-conversion \
|
-Wno-conversion \
|
||||||
-Wno-covered-switch-default \
|
-Wno-covered-switch-default \
|
||||||
-Wno-disabled-macro-expansion \
|
-Wno-disabled-macro-expansion \
|
||||||
-Wno-documentation-deprecated-sync \
|
-Wno-documentation-deprecated-sync \
|
||||||
-Wno-missing-field-initializers \
|
-Wno-missing-field-initializers \
|
||||||
-Wno-old-style-cast \
|
-Wno-old-style-cast \
|
||||||
-Wno-padded \
|
-Wno-padded \
|
||||||
-Wno-sign-compare \
|
-Wno-sign-compare \
|
||||||
-Wno-unreachable-code-return \
|
-Wno-unreachable-code-return \
|
||||||
-Wno-unused-parameter \
|
-Wno-unused-parameter \
|
||||||
-Wno-used-but-marked-unused \
|
-Wno-used-but-marked-unused
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
. other/analysis/gen-file.sh
|
. other/analysis/gen-file.sh
|
||||||
|
|
||||||
echo "Running Clang static analyzer"
|
echo "Running Clang static analyzer"
|
||||||
clang++ --analyze amalgamation.cc \
|
clang++ --analyze amalgamation.cc \
|
||||||
$CPPFLAGS \
|
"${CPPFLAGS[@]}" \
|
||||||
-std=c++11
|
-std=c++11
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
. other/analysis/gen-file.sh
|
. other/analysis/gen-file.sh
|
||||||
|
|
||||||
cppcheck amalgamation.cc $CPPFLAGS
|
cppcheck amalgamation.cc "${CPPFLAGS[@]}"
|
||||||
|
|
|
@ -1,63 +1,63 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
. other/analysis/gen-file.sh
|
. other/analysis/gen-file.sh
|
||||||
|
|
||||||
echo "Running GCC"
|
echo "Running GCC"
|
||||||
# TODO(iphydf): Get rid of all VLAs, then enable -fstack-protector -Wstack-protector
|
# TODO(iphydf): Get rid of all VLAs, then enable -fstack-protector -Wstack-protector
|
||||||
g++ -O3 -o /dev/null amalgamation.cc \
|
g++ -O3 -o /dev/null amalgamation.cc \
|
||||||
$CPPFLAGS \
|
"${CPPFLAGS[@]}" \
|
||||||
$LDFLAGS \
|
"${LDFLAGS[@]}" \
|
||||||
-std=c++11 \
|
-std=c++11 \
|
||||||
-pedantic \
|
-pedantic \
|
||||||
-fdiagnostics-color=always \
|
-fdiagnostics-color=always \
|
||||||
-Wall \
|
-Wall \
|
||||||
-Wextra \
|
-Wextra \
|
||||||
-Wno-aggregate-return \
|
-Wno-aggregate-return \
|
||||||
-Wno-aggressive-loop-optimizations \
|
-Wno-aggressive-loop-optimizations \
|
||||||
-Wno-float-conversion \
|
-Wno-float-conversion \
|
||||||
-Wno-format-signedness \
|
-Wno-format-signedness \
|
||||||
-Wno-missing-field-initializers \
|
-Wno-missing-field-initializers \
|
||||||
-Wno-padded \
|
-Wno-padded \
|
||||||
-Wno-sign-compare \
|
-Wno-sign-compare \
|
||||||
-Wno-sign-conversion \
|
-Wno-sign-conversion \
|
||||||
-Wno-switch-default \
|
-Wno-switch-default \
|
||||||
-Wno-unused-parameter \
|
-Wno-unused-parameter \
|
||||||
-Wstrict-aliasing=0 \
|
-Wstrict-aliasing=0 \
|
||||||
-Wstrict-overflow=1 \
|
-Wstrict-overflow=1 \
|
||||||
\
|
\
|
||||||
-Wmissing-declarations \
|
-Wmissing-declarations \
|
||||||
-Wbool-compare \
|
-Wbool-compare \
|
||||||
-Wcast-align \
|
-Wcast-align \
|
||||||
-Wcast-qual \
|
-Wcast-qual \
|
||||||
-Wchar-subscripts \
|
-Wchar-subscripts \
|
||||||
-Wdouble-promotion \
|
-Wdouble-promotion \
|
||||||
-Wduplicated-cond \
|
-Wduplicated-cond \
|
||||||
-Wempty-body \
|
-Wempty-body \
|
||||||
-Wenum-compare \
|
-Wenum-compare \
|
||||||
-Wfloat-equal \
|
-Wfloat-equal \
|
||||||
-Wformat=2 \
|
-Wformat=2 \
|
||||||
-Wframe-address \
|
-Wframe-address \
|
||||||
-Wframe-larger-than=133168 \
|
-Wframe-larger-than=133168 \
|
||||||
-Wignored-qualifiers \
|
-Wignored-qualifiers \
|
||||||
-Wignored-attributes \
|
-Wignored-attributes \
|
||||||
-Winit-self \
|
-Winit-self \
|
||||||
-Winline \
|
-Winline \
|
||||||
-Wlarger-than=133120 \
|
-Wlarger-than=133120 \
|
||||||
-Wmaybe-uninitialized \
|
-Wmaybe-uninitialized \
|
||||||
-Wmemset-transposed-args \
|
-Wmemset-transposed-args \
|
||||||
-Wmisleading-indentation \
|
-Wmisleading-indentation \
|
||||||
-Wnonnull \
|
-Wnonnull \
|
||||||
-Wnonnull-compare \
|
-Wnonnull-compare \
|
||||||
-Wnull-dereference \
|
-Wnull-dereference \
|
||||||
-Wodr \
|
-Wodr \
|
||||||
-Wredundant-decls \
|
-Wredundant-decls \
|
||||||
-Wreturn-type \
|
-Wreturn-type \
|
||||||
-Wshadow \
|
-Wshadow \
|
||||||
-Wsuggest-attribute=format \
|
-Wsuggest-attribute=format \
|
||||||
-Wundef \
|
-Wundef \
|
||||||
-Wunsafe-loop-optimizations \
|
-Wunsafe-loop-optimizations \
|
||||||
-Wunused-label \
|
-Wunused-label \
|
||||||
-Wunused-local-typedefs \
|
-Wunused-local-typedefs \
|
||||||
-Wunused-value \
|
-Wunused-value \
|
||||||
-Wunused-but-set-parameter \
|
-Wunused-but-set-parameter \
|
||||||
-Wunused-but-set-variable \
|
-Wunused-but-set-variable
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
# Infer ignores everything that's not in the "current file".
|
# Infer ignores everything that's not in the "current file".
|
||||||
SKIP_LINES=1
|
SKIP_LINES=1
|
||||||
|
|
||||||
. other/analysis/gen-file.sh
|
. other/analysis/gen-file.sh
|
||||||
|
|
||||||
infer -- clang++ -fsyntax-only amalgamation.cc $CPPFLAGS
|
infer -- clang++ -fsyntax-only amalgamation.cc "${CPPFLAGS[@]}"
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
set -eux
|
set -eux
|
||||||
|
|
||||||
docker_build() {
|
docker_build() {
|
||||||
tar c $(git ls-files) | docker build -f other/bootstrap_daemon/docker/Dockerfile -t toxchat/bootstrap-node -
|
readarray -t FILES <<<"$(git ls-files)"
|
||||||
|
tar c "${FILES[@]}" | docker build -f other/bootstrap_daemon/docker/Dockerfile -t toxchat/bootstrap-node -
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run Docker build once. If it succeeds, we're good.
|
# Run Docker build once. If it succeeds, we're good.
|
||||||
|
@ -17,7 +18,7 @@ OUTPUT=$(docker_build || true 2>&1)
|
||||||
if echo "$OUTPUT" | grep '/usr/local/bin/tox-bootstrapd: FAILED'; then
|
if echo "$OUTPUT" | grep '/usr/local/bin/tox-bootstrapd: FAILED'; then
|
||||||
# This is a checksum warning, so we need to update it.
|
# This is a checksum warning, so we need to update it.
|
||||||
IMAGE=$(echo "$OUTPUT" | grep '^ ---> [0-9a-f]*$' | grep -o '[0-9a-f]*$' | tail -n1)
|
IMAGE=$(echo "$OUTPUT" | grep '^ ---> [0-9a-f]*$' | grep -o '[0-9a-f]*$' | tail -n1)
|
||||||
docker run --rm "$IMAGE" sha256sum /usr/local/bin/tox-bootstrapd > other/bootstrap_daemon/docker/tox-bootstrapd.sha256
|
docker run --rm "$IMAGE" sha256sum /usr/local/bin/tox-bootstrapd >other/bootstrap_daemon/docker/tox-bootstrapd.sha256
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run once last time to complete the build.
|
# Run once last time to complete the build.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user