summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/histogram/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/boost/libs/histogram/tools')
-rwxr-xr-xsrc/boost/libs/histogram/tools/add_boilerplate.py53
-rw-r--r--src/boost/libs/histogram/tools/blacklist.supp14
-rwxr-xr-xsrc/boost/libs/histogram/tools/cov.sh50
-rwxr-xr-xsrc/boost/libs/histogram/tools/crlf_to_lf.sh9
-rwxr-xr-xsrc/boost/libs/histogram/tools/llvm-gcov.sh7
-rwxr-xr-xsrc/boost/libs/histogram/tools/tidy.py39
6 files changed, 172 insertions, 0 deletions
diff --git a/src/boost/libs/histogram/tools/add_boilerplate.py b/src/boost/libs/histogram/tools/add_boilerplate.py
new file mode 100755
index 00000000..3ba81c4d
--- /dev/null
+++ b/src/boost/libs/histogram/tools/add_boilerplate.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python3
+
+# Copyright Hans Dembinski 2019
+# Distributed under the Boost Software License, Version 1.0.
+# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
+
+import sys
+from os.path import abspath, join
+import re
+import datetime
+
+project_dir = "/".join(abspath(__file__).split("/")[:-2])
+
+filename = abspath(sys.argv[1])
+
+copyright = """// Copyright Hans Dembinski {}
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+""".format(datetime.datetime.today().year)
+
+if filename.endswith(".hpp"):
+ with open(filename) as f:
+ content = f.read()
+ if not content.startswith("// Copyright"):
+ content = copyright + content
+
+ sub = filename[len(project_dir) + 1:]
+ if sub.startswith("include/boost/"):
+ sub = sub[len("include/boost/"):]
+ if sub.startswith("test/"):
+ sub = "histogram/" + sub
+ guard_name = "BOOST_" + sub.replace(".", "_").replace("/", "_").upper()
+
+ if guard_name not in content:
+ lines = content.split("\n")
+ for end, line in enumerate(lines):
+ if line.startswith("//"):
+ continue
+ break
+ for start in range(end, len(lines)):
+ if lines[start] != "":
+ break
+ lines = lines[:end] + ["", "#ifndef " + guard_name, "#define " + guard_name, ""] + lines[start:]
+ while lines[-1] == "":
+ lines.pop()
+ lines += ["", "#endif // " + guard_name, ""]
+ content = "\n".join(lines)
+
+ with open(filename, "w") as f:
+ f.write(content)
diff --git a/src/boost/libs/histogram/tools/blacklist.supp b/src/boost/libs/histogram/tools/blacklist.supp
new file mode 100644
index 00000000..7df5aa56
--- /dev/null
+++ b/src/boost/libs/histogram/tools/blacklist.supp
@@ -0,0 +1,14 @@
+# boost/serialization/singleton.hpp:181:13: runtime error: reference binding to null pointer of type X
+src:../../boost/serialization/singleton.hpp
+
+# boost/archive/detail/interface_oarchive.hpp:47:16: runtime error: downcast of address X which does not point to an object of type Y
+src:../../boost/archive/detail/interface_oarchive.hpp
+
+# boost/archive/detail/interface_iarchive.hpp:46:16: runtime error: downcast of address X which does not point to an object of type Y
+src:../../boost/archive/detail/interface_iarchive.hpp
+
+# boost/archive/basic_binary_oprimitive.hpp:73:16: runtime error: downcast of address X which does not point to an object of type Y
+src:../../boost/archive/basic_binary_oprimitive.hpp
+
+# boost/archive/basic_binary_iprimitive.hpp:77:16: runtime error: downcast of address X which does not point to an object of type Y
+src:../../boost/archive/basic_binary_iprimitive.hpp
diff --git a/src/boost/libs/histogram/tools/cov.sh b/src/boost/libs/histogram/tools/cov.sh
new file mode 100755
index 00000000..f9fd8cec
--- /dev/null
+++ b/src/boost/libs/histogram/tools/cov.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+# must be executed in project root folder
+
+# Copyright Hans Dembinski 2018-2019
+# Distributed under the Boost Software License, Version 1.0.
+# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
+
+if [ -z $GCOV ]; then
+ # gcov-9, gcov-7, gcov-6 do not work
+ for i in 8 5; do
+ if test $(which gcov-$i); then
+ GCOV=gcov-$i
+ break;
+ fi;
+ done
+fi
+
+LCOV_VERSION="1.14"
+LCOV_DIR="tools/lcov-${LCOV_VERSION}"
+
+if [ ! -e $LCOV_DIR ]; then
+ cd tools
+ curl -L https://github.com/linux-test-project/lcov/releases/download/v${LCOV_VERSION}/lcov-${LCOV_VERSION}.tar.gz | tar zxf -
+ cd ..
+fi
+
+# --rc lcov_branch_coverage=1 doesn't work on travis
+# LCOV="${LCOV_DIR}/bin/lcov --gcov-tool=${GCOV} --rc lcov_branch_coverage=1"
+LCOV="${LCOV_DIR}/bin/lcov --gcov-tool=${GCOV}"
+
+# collect raw data
+$LCOV --base-directory `pwd` \
+ --directory `pwd`/../../bin.v2/libs/histogram/test \
+ --capture --output-file coverage.info
+
+# remove uninteresting entries
+$LCOV --extract coverage.info "*/boost/histogram/*" --output-file coverage.info
+
+if [ $CI ] || [ $1 ]; then
+ # upload if on CI or when token is passed as argument
+ which cpp-coveralls || echo "Error: you need to install cpp-coveralls"
+ if [ $1 ]; then
+ cpp-coveralls -l coverage.info -r ../.. -n -t $1
+ else
+ cpp-coveralls -l coverage.info -r ../.. -n
+ fi
+else
+ # otherwise generate html report
+ $LCOV_DIR/bin/genhtml coverage.info --demangle-cpp -o coverage-report
+fi
diff --git a/src/boost/libs/histogram/tools/crlf_to_lf.sh b/src/boost/libs/histogram/tools/crlf_to_lf.sh
new file mode 100755
index 00000000..62dee670
--- /dev/null
+++ b/src/boost/libs/histogram/tools/crlf_to_lf.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# Copyright Hans Dembinski 2019
+# Distributed under the Boost Software License, Version 1.0.
+# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
+
+# Find files with CRLF: `find <path> -not -type d -exec file "{}" ";" | grep CRLF`
+
+perl -pi -e 's/\r\n/\n/g' $1
diff --git a/src/boost/libs/histogram/tools/llvm-gcov.sh b/src/boost/libs/histogram/tools/llvm-gcov.sh
new file mode 100755
index 00000000..3b1fff46
--- /dev/null
+++ b/src/boost/libs/histogram/tools/llvm-gcov.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# Copyright Hans Dembinski 2018-2019
+# Distributed under the Boost Software License, Version 1.0.
+# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
+
+exec llvm-cov gcov "$@"
diff --git a/src/boost/libs/histogram/tools/tidy.py b/src/boost/libs/histogram/tools/tidy.py
new file mode 100755
index 00000000..7da34ecd
--- /dev/null
+++ b/src/boost/libs/histogram/tools/tidy.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python3
+
+# Copyright 2019 Hans Dembinski
+# Distributed under the Boost Software License, Version 1.0.
+# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
+
+import subprocess as subp
+from pathlib import Path
+from multiprocessing.pool import ThreadPool
+
+clang_tidy_cmd = None
+for version in range(15, 5, -1):
+ clang_tidy_cmd = f"clang-tidy-{version}"
+ if subp.run(("which", clang_tidy_cmd), stdout=subp.DEVNULL).returncode == 0:
+ break
+
+project_dir = Path(__file__).resolve().parents[1]
+assert project_dir.exists()
+boost_dir = project_dir.parents[1]
+
+filenames = (project_dir / "include").rglob("*.hpp")
+
+
+def run_tidy(filename):
+ n = len(project_dir.parts) + 2
+ cmd = f"{clang_tidy_cmd} {filename} -- -I{boost_dir}"
+ return (
+ cmd,
+ subp.run(cmd.split(), stdout=subp.PIPE, stderr=subp.STDOUT).stdout.decode(
+ "utf-8"
+ ),
+ )
+
+
+pool = ThreadPool()
+for cmd, report in pool.map(run_tidy, filenames):
+ if report:
+ print(cmd)
+ print(report)