summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/git/git-merge-forward.sh63
-rwxr-xr-xscripts/git/git-pull-all.sh92
-rwxr-xr-xscripts/git/git-push-all.sh111
-rwxr-xr-xscripts/maint/checkShellScripts.sh3
-rw-r--r--scripts/maint/practracker/exceptions.txt9
-rw-r--r--scripts/maint/practracker/metrics.py1
-rwxr-xr-xscripts/maint/practracker/practracker.py8
-rwxr-xr-xscripts/maint/practracker/test_practracker.sh8
-rw-r--r--scripts/maint/practracker/testdata/.may_include3
-rw-r--r--scripts/maint/practracker/testdata/a.c2
-rw-r--r--scripts/maint/practracker/testdata/ex0-expected.txt4
-rw-r--r--scripts/maint/practracker/testdata/ex1.txt4
-rw-r--r--scripts/maint/practracker/testdata/header.h8
-rw-r--r--scripts/maint/practracker/util.py43
14 files changed, 259 insertions, 100 deletions
diff --git a/scripts/git/git-merge-forward.sh b/scripts/git/git-merge-forward.sh
index cbd2f3c3bd..e481b40975 100755
--- a/scripts/git/git-merge-forward.sh
+++ b/scripts/git/git-merge-forward.sh
@@ -1,31 +1,47 @@
#!/usr/bin/env bash
-# Usage: git-merge-forward.sh -n -t <test-branch-prefix> -u
-# arguments:
-# -n: dry run mode
-# -t: test branch mode: create new branches from the commits checked
-# out in each maint directory. Call these branches prefix_029,
-# prefix_035, ... , prefix_master.
-# -u: in test branch mode, if a prefix_* branch exists, skip creating
-# that branch. Use after a merge error, to restart the merge
-# forward at the first unmerged branch.
-# env vars:
-# See the Configuration section for env vars and their default values.
+SCRIPT_NAME=`basename $0`
+
+function usage()
+{
+ echo "$SCRIPT_NAME [-h] [-n] [-t <test-branch-prefix> [-u]]"
+ echo
+ echo " arguments:"
+ echo " -h: show this help text"
+ echo " -n: dry run mode"
+ echo " (default: run commands)"
+ echo " -t: test branch mode: create new branches from the commits checked"
+ echo " out in each maint directory. Call these branches prefix_029,"
+ echo " prefix_035, ... , prefix_master."
+ echo " (default: merge forward maint-*, release-*, and master)"
+ echo " -u: in test branch mode, if a prefix_* branch already exists,"
+ echo " skip creating that branch. Use after a merge error, to"
+ echo " restart the merge forward at the first unmerged branch."
+ echo " (default: if a prefix_* branch already exists, fail and exit)"
+ echo
+ echo " env vars:"
+ echo " required:"
+ echo " TOR_FULL_GIT_PATH: where the git repository directories reside."
+ echo " You must set this env var, we recommend \$HOME/git/"
+ echo " (default: fail if this env var is not set;"
+ echo " current: $GIT_PATH)"
+ echo
+ echo " optional:"
+ echo " TOR_MASTER: the name of the directory containing the tor.git clone"
+ echo " The tor master git directory is \$GIT_PATH/\$TOR_MASTER"
+ echo " (default: tor; current: $TOR_MASTER_NAME)"
+ echo " TOR_WKT_NAME: the name of the directory containing the tor"
+ echo " worktrees. The tor worktrees are:"
+ echo " \$GIT_PATH/\$TOR_WKT_NAME/{maint-*,release-*}"
+ echo " (default: tor-wkt; current: $TOR_WKT_NAME)"
+ echo " we recommend that you set these env vars in your ~/.profile"
+}
#################
# Configuration #
#################
# Don't change this configuration - set the env vars in your .profile
-#
-# The general setup that is suggested here is:
-#
-# GIT_PATH = /home/<user>/git/
-# ... where the git repository directories resides.
-# TOR_MASTER_NAME = "tor"
-# ... which means that tor.git was cloned in /home/<user>/git/tor
-# TOR_WKT_NAME = "tor-wkt"
-# ... which means that the tor worktrees are in /home/<user>/git/tor-wkt
# Where are all those git repositories?
GIT_PATH=${TOR_FULL_GIT_PATH:-"FULL_PATH_TO_GIT_REPOSITORY_DIRECTORY"}
@@ -126,8 +142,11 @@ TEST_BRANCH_PREFIX=
# creating a new branch.
USE_EXISTING=0
-while getopts "nt:u" opt; do
+while getopts "hnt:u" opt; do
case "$opt" in
+ h) usage
+ exit 0
+ ;;
n) DRY_RUN=1
echo " *** DRY RUN MODE ***"
;;
@@ -138,6 +157,8 @@ while getopts "nt:u" opt; do
echo " *** USE EXISTING TEST BRANCHES MODE ***"
;;
*)
+ echo
+ usage
exit 1
;;
esac
diff --git a/scripts/git/git-pull-all.sh b/scripts/git/git-pull-all.sh
index 8eb42c7c18..0d6daf432d 100755
--- a/scripts/git/git-pull-all.sh
+++ b/scripts/git/git-pull-all.sh
@@ -1,17 +1,39 @@
#!/usr/bin/env bash
-##################################
-# User configuration (change me) #
-##################################
+SCRIPT_NAME=`basename $0`
-# The general setup that is suggested here is:
-#
-# GIT_PATH = /home/<user>/git/
-# ... where the git repository directories resides.
-# TOR_MASTER_NAME = "tor"
-# ... which means that tor.git was cloned in /home/<user>/git/tor
-# TOR_WKT_NAME = "tor-wkt"
-# ... which means that the tor worktrees are in /home/<user>/git/tor-wkt
+function usage()
+{
+ echo "$SCRIPT_NAME [-h] [-n]"
+ echo
+ echo " arguments:"
+ echo " -h: show this help text"
+ echo " -n: dry run mode"
+ echo " (default: run commands)"
+ echo
+ echo " env vars:"
+ echo " required:"
+ echo " TOR_FULL_GIT_PATH: where the git repository directories reside."
+ echo " You must set this env var, we recommend \$HOME/git/"
+ echo " (default: fail if this env var is not set;"
+ echo " current: $GIT_PATH)"
+ echo
+ echo " optional:"
+ echo " TOR_MASTER: the name of the directory containing the tor.git clone"
+ echo " The tor master git directory is \$GIT_PATH/\$TOR_MASTER"
+ echo " (default: tor; current: $TOR_MASTER_NAME)"
+ echo " TOR_WKT_NAME: the name of the directory containing the tor"
+ echo " worktrees. The tor worktrees are:"
+ echo " \$GIT_PATH/\$TOR_WKT_NAME/{maint-*,release-*}"
+ echo " (default: tor-wkt; current: $TOR_WKT_NAME)"
+ echo " we recommend that you set these env vars in your ~/.profile"
+}
+
+#################
+# Configuration #
+#################
+
+# Don't change this configuration - set the env vars in your .profile
# Where are all those git repositories?
GIT_PATH=${TOR_FULL_GIT_PATH:-"FULL_PATH_TO_GIT_REPOSITORY_DIRECTORY"}
@@ -21,11 +43,11 @@ TOR_MASTER_NAME=${TOR_MASTER_NAME:-"tor"}
# The worktrees location (directory).
TOR_WKT_NAME=${TOR_WKT_NAME:-"tor-wkt"}
-#########################
-# End of configuration. #
-#########################
+##########################
+# Git branches to manage #
+##########################
-# Configuration of the branches that needs merging. The values are in order:
+# Configuration of the branches that need pulling. The values are in order:
# (1) Branch name to pull (update).
# (2) Full path of the git worktree.
#
@@ -65,9 +87,9 @@ ${RELEASE_040[0]}
${RELEASE_041[0]}
EOF
-##########################
-# Git Worktree to manage #
-##########################
+###########################
+# Git worktrees to manage #
+###########################
# List of all worktrees to work on. All defined above. Ordering is important.
# Always the maint-* branch first then the release-*.
@@ -88,10 +110,34 @@ WORKTREE=(
)
COUNT=${#WORKTREE[@]}
+#######################
+# Argument processing #
+#######################
+
# Controlled by the -n option. The dry run option will just output the command
# that would have been executed for each worktree.
DRY_RUN=0
+while getopts "hn" opt; do
+ case "$opt" in
+ h) usage
+ exit 0
+ ;;
+ n) DRY_RUN=1
+ echo " *** DRY DRUN MODE ***"
+ ;;
+ *)
+ echo
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+#############
+# Constants #
+#############
+
# Control characters
CNRM=$'\x1b[0;0m' # Clear color
@@ -191,16 +237,6 @@ function fetch_tor_github
# Entry point #
###############
-while getopts "n" opt; do
- case "$opt" in
- n) DRY_RUN=1
- echo " *** DRY DRUN MODE ***"
- ;;
- *)
- ;;
- esac
-done
-
# First, fetch tor-github.
goto_repo "$ORIGIN_PATH"
fetch_tor_github
diff --git a/scripts/git/git-push-all.sh b/scripts/git/git-push-all.sh
index 8e49e81b9d..a388f01564 100755
--- a/scripts/git/git-push-all.sh
+++ b/scripts/git/git-push-all.sh
@@ -1,26 +1,65 @@
#!/usr/bin/env bash
-# Usage: git-push-all.sh -t <test-branch-prefix> -r <remote-name> -s
-# -- <git-opts>
-# arguments:
-# -t: test branch mode: Push test branches, rather than maint and
-# release branches. Pushes the branches called prefix_029,
-# prefix_035, ... , prefix_master.
-# -r: push to remote-name, rather than $TOR_UPSTREAM_REMOTE_NAME.
-# -s: push branches whose tips match upstream maint, release, or
-# master branches. The default is to skip these branches. Use
-# -s when testing for CI environment failures with old code.
-# --: pass any other arguments to git, rather than the script.
-# env vars:
-# TOR_GIT_PUSH: the git push command and arguments
-# TOR_UPSTREAM_REMOTE_NAME: the default upstream, overridden by -r
-# TOR_PUSH_DELAY: pushes the master and maint branches separately,
-# so that CI runs in a sensible order.
-# TOR_PUSH_SAME: push branches whose tips match upstream maint,
-# release, or master branches. Inverted by -s.
-# See the Configuration section for env var default values.
-# git-opts:
-# --no-atomic --dry-run (and any other git push option)
+SCRIPT_NAME=`basename $0`
+
+function usage()
+{
+ if [ "$TOR_PUSH_SAME" ]; then
+ CURRENT_PUSH_SAME="push"
+ else
+ CURRENT_PUSH_SAME="skip"
+ fi
+
+ echo "$SCRIPT_NAME [-h] [-r <remote-name> [-t <test-branch-prefix>]] [-s]"
+ # The next line looks misaligned, but it lines up in the output
+ echo " [-- [-n] [--no-atomic] <git push options>]"
+ echo
+ echo " arguments:"
+ echo " -h: show this help text"
+ echo " -n: dry run mode"
+ echo " (default: run commands)"
+ echo " -r: push to remote-name, rather than the default upstream remote."
+ echo " (default: $DEFAULT_UPSTREAM_REMOTE, current: $UPSTREAM_REMOTE)"
+ echo " -t: test branch mode: push test branches to remote-name. Pushes"
+ echo " branches prefix_029, prefix_035, ... , prefix_master."
+ echo " (default: push maint-*, release-*, and master)"
+ echo " -s: push branches whose tips match upstream maint, release, or"
+ echo " master branches. The default is to skip these branches,"
+ echo " because they do not contain any new code. Use -s to test for"
+ echo " CI environment failures, using code that previously passed CI."
+ echo " (default: skip; current: $CURRENT_PUSH_SAME matching branches)"
+ echo " --: pass further arguments to git push."
+ echo " (default: git push --atomic, current: $GIT_PUSH)"
+ echo
+ echo " env vars:"
+ echo " optional:"
+ echo " TOR_GIT_PUSH_PATH: change to this directory before pushing."
+ echo " (default: if \$TOR_FULL_GIT_PATH is set,"
+ echo " use \$TOR_FULL_GIT_PATH/\$TOR_MASTER;"
+ echo " Otherwise, use the current directory for pushes;"
+ echo " current: $TOR_GIT_PUSH_PATH)"
+ echo " TOR_FULL_GIT_PATH: where the git repository directories reside."
+ echo " We recommend using \$HOME/git/."
+ echo " (default: use the current directory for pushes;"
+ echo " current: $TOR_FULL_GIT_PATH)"
+ echo " TOR_MASTER: the name of the directory containing the tor.git clone"
+ echo " The tor master git directory is \$GIT_PATH/\$TOR_MASTER"
+ echo " (default: tor; current: $TOR_MASTER_NAME)"
+ echo
+ echo " TOR_UPSTREAM_REMOTE_NAME: the default upstream remote."
+ echo " Overridden by -r."
+ echo " (default: upstream; current: $UPSTREAM_REMOTE)"
+ echo " TOR_GIT_PUSH: the git push command and default arguments."
+ echo " Overridden by <git push options> after --."
+ echo " (default: git push --atomic; current: $GIT_PUSH)"
+ echo " TOR_PUSH_SAME: push branches whose tips match upstream maint,"
+ echo " release, or master branches. Inverted by -s."
+ echo " (default: skip; current: $CURRENT_PUSH_SAME matching branches)"
+ echo " TOR_PUSH_DELAY: pushes the master and maint branches separately,"
+ echo " so that CI runs in a sensible order."
+ echo " (default: push all branches immediately; current: $PUSH_DELAY)"
+ echo " we recommend that you set these env vars in your ~/.profile"
+}
set -e
@@ -30,6 +69,13 @@ set -e
# Don't change this configuration - set the env vars in your .profile
#
+# The tor master git repository directory from which all the worktree have
+# been created.
+TOR_MASTER_NAME=${TOR_MASTER_NAME:-"tor"}
+# Which directory do we push from?
+if [ "$TOR_FULL_GIT_PATH" ]; then
+ TOR_GIT_PUSH_PATH=${TOR_GIT_PUSH_PATH:-"$TOR_FULL_GIT_PATH/$TOR_MASTER_NAME"}
+fi
# git push command and default arguments
GIT_PUSH=${TOR_GIT_PUSH:-"git push --atomic"}
# The upstream remote which git.torproject.org/tor.git points to.
@@ -54,8 +100,11 @@ PUSH_SAME=${TOR_PUSH_SAME:-0}
# <tbbn>_029, <tbbn>_035, ... , <tbbn>_master, and merge forward.
TEST_BRANCH_PREFIX=
-while getopts ":r:st:" opt; do
+while getopts ":hr:st:" opt; do
case "$opt" in
+ h) usage
+ exit 0
+ ;;
r) UPSTREAM_REMOTE="$OPTARG"
echo " *** PUSHING TO REMOTE: ${UPSTREAM_REMOTE} ***"
shift
@@ -91,17 +140,25 @@ if [ "$1" = "--" ]; then
shift
fi
-echo "Calling $GIT_PUSH" "$@" "<branches>"
-
if [ "$TEST_BRANCH_PREFIX" ]; then
- if [ "$UPSTREAM_REMOTE" = "${TOR_UPSTREAM_REMOTE_NAME:-upstream}" ]; then
+ if [ "$UPSTREAM_REMOTE" = "$DEFAULT_UPSTREAM_REMOTE" ]; then
echo "Pushing test branches ${TEST_BRANCH_PREFIX}_nnn to " \
- "$UPSTREAM_REMOTE is not allowed."
- echo "Usage: $0 -r <remote-name> -t <test-branch-prefix> <git-opts>"
+ "the default remote $DEFAULT_UPSTREAM_REMOTE is not allowed."
+ echo
+ usage
exit 1
fi
fi
+if [ "$TOR_GIT_PUSH_PATH" ]; then
+ echo "Changing to $GIT_PUSH_PATH before pushing"
+ cd "$TOR_GIT_PUSH_PATH"
+else
+ echo "Pushing from the current directory"
+fi
+
+echo "Calling $GIT_PUSH" "$@" "<branches>"
+
################################
# Git upstream remote branches #
################################
diff --git a/scripts/maint/checkShellScripts.sh b/scripts/maint/checkShellScripts.sh
index 02d1275c48..318f0fb577 100755
--- a/scripts/maint/checkShellScripts.sh
+++ b/scripts/maint/checkShellScripts.sh
@@ -21,7 +21,7 @@ if command -v realpath ; then
HERE=$(dirname "$(realpath "$0")")
else
HERE=$(dirname "$0")
- if [ ! -d "$HERE" ]; then
+ if [ ! -d "$HERE" ] || [ "$HERE" = "." ]; then
HERE=$(dirname "$PWD/$0")
fi
fi
@@ -31,6 +31,7 @@ TOPLEVEL=$(dirname "$(dirname "$HERE")")
if [ ! -d "$TOPLEVEL/src" ]; then
printf "Error: Couldn't find src directory in expected location: %s\\n" \
"$TOPLEVEL/src"
+ exit 1
fi
# Check *.sh scripts, but ignore the ones that we can't fix
diff --git a/scripts/maint/practracker/exceptions.txt b/scripts/maint/practracker/exceptions.txt
index 3c27aacb15..4490382ccc 100644
--- a/scripts/maint/practracker/exceptions.txt
+++ b/scripts/maint/practracker/exceptions.txt
@@ -324,3 +324,12 @@ problem function-size /src/tools/tor-gencert.c:parse_commandline() 111
problem function-size /src/tools/tor-resolve.c:build_socks5_resolve_request() 102
problem function-size /src/tools/tor-resolve.c:do_resolve() 171
problem function-size /src/tools/tor-resolve.c:main() 112
+
+problem dependency-violation /scripts/maint/practracker/testdata/a.c 3
+problem dependency-violation /scripts/maint/practracker/testdata/header.h 3
+problem dependency-violation /src/core/crypto/hs_ntor.h 1
+problem dependency-violation /src/core/or/cell_queue_st.h 1
+problem dependency-violation /src/core/or/channel.h 1
+problem dependency-violation /src/core/or/circuitlist.h 1
+problem dependency-violation /src/core/or/connection_edge.h 1
+problem dependency-violation /src/core/or/or.h 1
diff --git a/scripts/maint/practracker/metrics.py b/scripts/maint/practracker/metrics.py
index 9f69b2ac1f..4c62bc2425 100644
--- a/scripts/maint/practracker/metrics.py
+++ b/scripts/maint/practracker/metrics.py
@@ -8,6 +8,7 @@ import re
def get_file_len(f):
"""Get file length of file"""
+ i = -1
for i, l in enumerate(f):
pass
return i + 1
diff --git a/scripts/maint/practracker/practracker.py b/scripts/maint/practracker/practracker.py
index b477cd60c0..ce9c5f5d82 100755
--- a/scripts/maint/practracker/practracker.py
+++ b/scripts/maint/practracker/practracker.py
@@ -200,6 +200,9 @@ def main(argv):
help="Maximum lines per function")
parser.add_argument("--max-dependency-violations", default=MAX_DEP_VIOLATIONS,
help="Maximum number of dependency violations to allow")
+ parser.add_argument("--include-dir", action="append",
+ default=["src"],
+ help="A directory (under topdir) to search for source")
parser.add_argument("topdir", default=".", nargs="?",
help="Top-level directory for the tor source")
args = parser.parse_args(argv[1:])
@@ -218,10 +221,11 @@ def main(argv):
filt.addThreshold(problem.FileSizeItem("*.h", int(args.max_h_file_size)))
filt.addThreshold(problem.IncludeCountItem("*.h", int(args.max_h_include_count)))
filt.addThreshold(problem.FunctionSizeItem("*.c", int(args.max_function_size)))
- filt.addThreshold(problem.DependencyViolationItem("*", int(args.max_dependency_violations)))
+ filt.addThreshold(problem.DependencyViolationItem("*.c", int(args.max_dependency_violations)))
+ filt.addThreshold(problem.DependencyViolationItem("*.h", int(args.max_dependency_violations)))
# 1) Get all the .c files we care about
- files_list = util.get_tor_c_files(TOR_TOPDIR)
+ files_list = util.get_tor_c_files(TOR_TOPDIR, args.include_dir)
# 2) Initialize problem vault and load an optional exceptions file so that
# we don't warn about the past
diff --git a/scripts/maint/practracker/test_practracker.sh b/scripts/maint/practracker/test_practracker.sh
index c878ca5580..bfbd0c6560 100755
--- a/scripts/maint/practracker/test_practracker.sh
+++ b/scripts/maint/practracker/test_practracker.sh
@@ -25,7 +25,13 @@ DATA="${PRACTRACKER_DIR}/testdata"
run_practracker() {
"${PYTHON:-python}" "${PRACTRACKER_DIR}/practracker.py" \
- --max-include-count=0 --max-file-size=0 --max-function-size=0 --terse \
+ --include-dir "" \
+ --max-file-size=0 \
+ --max-function-size=0 \
+ --max-h-file-size=0 \
+ --max-h-include-count=0 \
+ --max-include-count=0 \
+ --terse \
"${DATA}/" "$@";
}
compare() {
diff --git a/scripts/maint/practracker/testdata/.may_include b/scripts/maint/practracker/testdata/.may_include
new file mode 100644
index 0000000000..40bf8155d9
--- /dev/null
+++ b/scripts/maint/practracker/testdata/.may_include
@@ -0,0 +1,3 @@
+!advisory
+
+permitted.h
diff --git a/scripts/maint/practracker/testdata/a.c b/scripts/maint/practracker/testdata/a.c
index b52a14f56a..1939773f57 100644
--- a/scripts/maint/practracker/testdata/a.c
+++ b/scripts/maint/practracker/testdata/a.c
@@ -3,7 +3,7 @@
#include "two.h"
#incldue "three.h"
-# include "four.h"
+# include "permitted.h"
int
i_am_a_function(void)
diff --git a/scripts/maint/practracker/testdata/ex0-expected.txt b/scripts/maint/practracker/testdata/ex0-expected.txt
index c021e6f710..5f3d9e5aec 100644
--- a/scripts/maint/practracker/testdata/ex0-expected.txt
+++ b/scripts/maint/practracker/testdata/ex0-expected.txt
@@ -2,6 +2,10 @@ problem file-size a.c 38
problem include-count a.c 4
problem function-size a.c:i_am_a_function() 9
problem function-size a.c:another_function() 12
+problem dependency-violation a.c 3
problem file-size b.c 15
problem function-size b.c:foo() 4
problem function-size b.c:bar() 5
+problem file-size header.h 8
+problem include-count header.h 4
+problem dependency-violation header.h 3
diff --git a/scripts/maint/practracker/testdata/ex1.txt b/scripts/maint/practracker/testdata/ex1.txt
index db42ae8450..f619e33b22 100644
--- a/scripts/maint/practracker/testdata/ex1.txt
+++ b/scripts/maint/practracker/testdata/ex1.txt
@@ -9,3 +9,7 @@ problem file-size b.c 15
# This is removed, and so will produce an error.
# problem function-size b.c:foo() 4
problem function-size b.c:bar() 5
+problem dependency-violation a.c 3
+problem dependency-violation header.h 3
+problem file-size header.h 8
+problem include-count header.h 4
diff --git a/scripts/maint/practracker/testdata/header.h b/scripts/maint/practracker/testdata/header.h
new file mode 100644
index 0000000000..1183f5db9a
--- /dev/null
+++ b/scripts/maint/practracker/testdata/header.h
@@ -0,0 +1,8 @@
+
+// some forbidden includes
+#include "foo.h"
+#include "quux.h"
+#include "quup.h"
+
+// a permitted include
+#include "permitted.h"
diff --git a/scripts/maint/practracker/util.py b/scripts/maint/practracker/util.py
index 695668f561..4b42565528 100644
--- a/scripts/maint/practracker/util.py
+++ b/scripts/maint/practracker/util.py
@@ -3,36 +3,41 @@ import os
# We don't want to run metrics for unittests, automatically-generated C files,
# external libraries or git leftovers.
EXCLUDE_SOURCE_DIRS = {"src/test/", "src/trunnel/", "src/rust/",
- "src/ext/", ".git/"}
+ "src/ext/" }
EXCLUDE_FILES = {"orconfig.h"}
def _norm(p):
return os.path.normcase(os.path.normpath(p))
-def get_tor_c_files(tor_topdir):
+def get_tor_c_files(tor_topdir, include_dirs=None):
"""
Return a list with the .c and .h filenames we want to get metrics of.
"""
files_list = []
exclude_dirs = { _norm(os.path.join(tor_topdir, p)) for p in EXCLUDE_SOURCE_DIRS }
-
- for root, directories, filenames in os.walk(tor_topdir):
- # Remove all the directories that are excluded.
- directories[:] = [ d for d in directories
- if _norm(os.path.join(root,d)) not in exclude_dirs ]
- directories.sort()
- filenames.sort()
- for filename in filenames:
- # We only care about .c and .h files
- if not (filename.endswith(".c") or filename.endswith(".h")):
- continue
- if filename in EXCLUDE_FILES:
- continue
-
- full_path = os.path.join(root,filename)
-
- files_list.append(full_path)
+ if include_dirs is None:
+ topdirs = [ tor_topdir ]
+ else:
+ topdirs = [ os.path.join(tor_topdir, inc) for inc in include_dirs ]
+
+ for topdir in topdirs:
+ for root, directories, filenames in os.walk(topdir):
+ # Remove all the directories that are excluded.
+ directories[:] = [ d for d in directories
+ if _norm(os.path.join(root,d)) not in exclude_dirs ]
+ directories.sort()
+ filenames.sort()
+ for filename in filenames:
+ # We only care about .c and .h files
+ if not (filename.endswith(".c") or filename.endswith(".h")):
+ continue
+ if filename in EXCLUDE_FILES:
+ continue
+
+ full_path = os.path.join(root,filename)
+
+ files_list.append(full_path)
return files_list