From ef13d91beddc73b6d4a5b76b506e02e8277f063f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= <gaetan.harter@fu-berlin.de>
Date: Thu, 22 Mar 2018 17:21:09 +0100
Subject: [PATCH] tools/check: use RIOTTOOLS variable

Follow up to #9067 and part of #8821
---
 dist/tools/coccinelle/check.sh   | 12 +++++-------
 dist/tools/cppcheck/check.sh     |  3 ++-
 dist/tools/externc/check.sh      |  3 ++-
 dist/tools/flake8/check.sh       |  7 +++----
 dist/tools/headerguards/check.sh |  7 +++----
 dist/tools/licenses/check.sh     |  3 ++-
 dist/tools/pr_check/pr_check.sh  |  3 ++-
 7 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/dist/tools/coccinelle/check.sh b/dist/tools/coccinelle/check.sh
index 0afe8a5983..d2aa3a8055 100755
--- a/dist/tools/coccinelle/check.sh
+++ b/dist/tools/coccinelle/check.sh
@@ -6,9 +6,8 @@
 # General Public License v2.1. See the file LICENSE in the top level
 # directory for more details.
 
-: ${RIOTBASE:=$(pwd)}
-
-. ${RIOTBASE}/dist/tools/ci/changed_files.sh
+: "${RIOTTOOLS:=${PWD}/dist/tools}"
+. "${RIOTTOOLS}"/ci/changed_files.sh
 
 EXIT_CODE=0
 
@@ -26,7 +25,7 @@ indent() {
 
 coccinelle_checkone() {
     OUT="$(spatch --very-quiet \
-        --macro-file-builtins ${RIOTBASE}/dist/tools/coccinelle/include/riot-standard.h \
+        --macro-file-builtins ${RIOTTOOLS}/coccinelle/include/riot-standard.h \
         --sp-file $patch ${FILES} | filter)"
 
     if [ -n "$OUT" ]; then
@@ -65,10 +64,9 @@ fi
 : ${COCCINELLE_QUIET:=0}
 
 if [ -z "$*" ]; then
-    coccinelle_checkall ${RIOTBASE}/dist/tools/coccinelle/force
+    coccinelle_checkall "${RIOTTOOLS}"/coccinelle/force
 
-    COCCINELLE_WARNONLY=1 \
-        coccinelle_checkall ${RIOTBASE}/dist/tools/coccinelle/warn
+    COCCINELLE_WARNONLY=1 coccinelle_checkall "${RIOTTOOLS}"/coccinelle/warn
 else
     for patch in "$@"; do
         coccinelle_checkone "$patch"
diff --git a/dist/tools/cppcheck/check.sh b/dist/tools/cppcheck/check.sh
index ee8a2b6439..b09f0b14d8 100755
--- a/dist/tools/cppcheck/check.sh
+++ b/dist/tools/cppcheck/check.sh
@@ -8,7 +8,8 @@
 # General Public License v2.1. See the file LICENSE in the top level
 # directory for more details.
 
-. ${RIOTBASE:+${RIOTBASE}/}dist/tools/ci/changed_files.sh
+: "${RIOTTOOLS:=${PWD}/dist/tools}"
+. "${RIOTTOOLS}"/ci/changed_files.sh
 
 # Don't show warnings about unusedStructMembers by default
 DEFAULT_SUPPRESSIONS="${1}"
diff --git a/dist/tools/externc/check.sh b/dist/tools/externc/check.sh
index 45cd8d627f..74f30b932d 100755
--- a/dist/tools/externc/check.sh
+++ b/dist/tools/externc/check.sh
@@ -8,7 +8,8 @@
 # General Public License v2.1. See the file LICENSE in the top level
 # directory for more details.
 
-. ${RIOTBASE:+${RIOTBASE}/}dist/tools/ci/changed_files.sh
+: "${RIOTTOOLS:=${PWD}/dist/tools}"
+. "${RIOTTOOLS}"/ci/changed_files.sh
 
 # prepare
 ROOT=$(git rev-parse --show-toplevel)
diff --git a/dist/tools/flake8/check.sh b/dist/tools/flake8/check.sh
index ca869f6a75..0b604f6706 100755
--- a/dist/tools/flake8/check.sh
+++ b/dist/tools/flake8/check.sh
@@ -17,9 +17,8 @@ else
     CRESET=
 fi
 
-DIST_TOOLS=${RIOTBASE:-.}/dist/tools
-
-. "${DIST_TOOLS}/ci/changed_files.sh"
+: "${RIOTTOOLS:=${PWD}/dist/tools}"
+. "${RIOTTOOLS}"/ci/changed_files.sh
 
 FILES=$(FILEREGEX='(?=*.py$|pyterm$)' changed_files)
 
@@ -33,7 +32,7 @@ ${FLAKE8_CMD} --version &> /dev/null || {
     exit 1
 }
 
-ERRORS=$(${FLAKE8_CMD} --config="${DIST_TOOLS}/flake8/flake8.cfg" ${FILES})
+ERRORS=$(${FLAKE8_CMD} --config="${RIOTTOOLS}"/flake8/flake8.cfg ${FILES})
 
 if [ -n "${ERRORS}" ]
 then
diff --git a/dist/tools/headerguards/check.sh b/dist/tools/headerguards/check.sh
index a3ba4f0d45..bbac91323e 100755
--- a/dist/tools/headerguards/check.sh
+++ b/dist/tools/headerguards/check.sh
@@ -6,9 +6,8 @@
 # General Public License v2.1. See the file LICENSE in the top level
 # directory for more details.
 
-: ${RIOTBASE:=$(pwd)}
-
-. ${RIOTBASE}/dist/tools/ci/changed_files.sh
+: "${RIOTTOOLS:=${PWD}/dist/tools}"
+. "${RIOTTOOLS}"/ci/changed_files.sh
 
 EXIT_CODE=0
 
@@ -21,7 +20,7 @@ filter() {
 }
 
 _headercheck() {
-    OUT="$(${RIOTBASE}/dist/tools/headerguards/headerguards.py ${FILES} | filter)"
+    OUT="$(${RIOTTOOLS}/headerguards/headerguards.py ${FILES} | filter)"
 
     if [ -n "$OUT" ]; then
         EXIT_CODE=1
diff --git a/dist/tools/licenses/check.sh b/dist/tools/licenses/check.sh
index 74edd966b8..959f563800 100755
--- a/dist/tools/licenses/check.sh
+++ b/dist/tools/licenses/check.sh
@@ -7,7 +7,8 @@
 # General Public License v2.1. See the file LICENSE in the top level
 # directory for more details.
 
-. ${RIOTBASE:+${RIOTBASE}/}dist/tools/ci/changed_files.sh
+: "${RIOTTOOLS:=${PWD}/dist/tools}"
+. "${RIOTTOOLS}"/ci/changed_files.sh
 
 # customizable
 CHECKROOT=$(dirname "${0}")
diff --git a/dist/tools/pr_check/pr_check.sh b/dist/tools/pr_check/pr_check.sh
index e8dbd7ce3e..f8c93e687c 100755
--- a/dist/tools/pr_check/pr_check.sh
+++ b/dist/tools/pr_check/pr_check.sh
@@ -8,7 +8,8 @@
 #
 
 EXIT_CODE=0
-source ./dist/tools/pr_check/check_labels.sh
+: "${RIOTTOOLS:=${PWD}/dist/tools}"
+. "${RIOTTOOLS}"/pr_check/check_labels.sh
 
 if tput colors &> /dev/null && [ $(tput colors) -ge 8 ]; then
     CERROR="\e[1;31m"
-- 
GitLab