From e4f65c8bb8468e4391c0b38b51e86001cd7e0ed8 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 25 Oct 2016 01:55:19 -0400 Subject: tools/notsd-fixup: Merge the pre-includes pass the includes pass. This shaves off a decent chunk of time, and simplifies the code. --- tools/notsd-fixup | 20 +++++--------------- tools/notsd-fixup--includes | 4 ++++ 2 files changed, 9 insertions(+), 15 deletions(-) (limited to 'tools') 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)): -- cgit v1.2.3-54-g00ecf