summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-10-25 01:55:19 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-10-26 21:23:21 -0400
commite4f65c8bb8468e4391c0b38b51e86001cd7e0ed8 (patch)
treee9664217813baf61de3a1097ca2d2f478983aabf
parent52443abf0074a859472a373113a183e0ba518f26 (diff)
tools/notsd-fixup: Merge the pre-includes pass the includes pass.
This shaves off a decent chunk of time, and simplifies the code.
-rwxr-xr-xtools/notsd-fixup20
-rwxr-xr-xtools/notsd-fixup--includes4
2 files changed, 9 insertions, 15 deletions
diff --git a/tools/notsd-fixup b/tools/notsd-fixup
index 4bd4b3f94c..79b30b7c55 100755
--- a/tools/notsd-fixup
+++ b/tools/notsd-fixup
@@ -1,6 +1,11 @@
#!/usr/bin/env bash
# Copyright (C) 2015-2016 Luke Shumaker
+# We wrap the programs called by xargs with `sh` because xargs only exits early
+# if the status is 255, but we want to exit early for all non-zero statuses.
+# We use xargs instead of `find -exec` because `-exec` won't do much of
+# anything useful with the exit status.
+
fixup_makefiles() (
find "$@" -type f -name Makefile | while read -r filename; do
>&2 printf ' => fixup %q\n' "$filename"
@@ -21,21 +26,6 @@ fixup_makefiles() (
)
fixup_includes() (
- dirs=($(find "$@" -type d -name include))
- if [[ ${#dirs[@]} -gt 0 ]]; then
- find "${dirs[@]}" -type d | while read -r dir; do
- lib="${dir##*/}"
- find "$dir" -type f | while read -r filename; do
- >&2 printf ' => sed -r %q < %q\n' "s|$lib/||" "$filename"
- sed -r "s|$lib/||" < "$filename" | build-aux/write-ifchanged "$filename"
- done
- done
- fi
-
- # We wrap the $0--includes program with `sh` because xargs only exits
- # early if the status is 255, but we want to exit early for all
- # non-zero statuses. We use xargs instead of -exec because -exec won't
- # do much of anything useful with the exit status.
rm -rf -- "$0"--includes.cache
find "$@" \( -name '*.h' -o -name '*.c' -o -name '*.gperf' -o -name '*.gperf.m4' \) -type f -print0 |
xargs -r0 sh -c "$0--includes \"\$@\" || exit 255" --
diff --git a/tools/notsd-fixup--includes b/tools/notsd-fixup--includes
index d16a3e6500..a82247e175 100755
--- a/tools/notsd-fixup--includes
+++ b/tools/notsd-fixup--includes
@@ -35,6 +35,10 @@ import sys
# protected
# private
def classify(expensive, current_file, path):
+ if re.fullmatch('.*/include(-staging)?/.*/.*', current_file):
+ lib = os.path.basename(os.path.dirname(current_file))
+ if path.startswith(lib+'/'):
+ path = re.sub('^'+lib+'/', path)
if path.startswith('linux/'):
return 'linux', path
elif expensive.exists(os.path.join(os.path.dirname(current_file), path)):