From: peterz@infradead.org
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>
Subject: Re: [PATCH -v2] scipts/tags.sh: Add custom sort order
Date: Fri, 4 Sep 2020 16:53:22 +0200 [thread overview]
Message-ID: <20200904145322.GA35926@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20200903072604.GT1362448@hirez.programming.kicks-ass.net>
On Thu, Sep 03, 2020 at 09:26:04AM +0200, peterz@infradead.org wrote:
> On Thu, Sep 03, 2020 at 11:07:28AM +0900, Masahiro Yamada wrote:
> > Will re-implementing your sorting logic
> > in bash look cleaner?
>
> Possibly, I can try, we'll see.
It is somewhat cleaner, but it is _abysmally_ slow. Bash sucks :-(
It is still broken in all the same ways as before, I figured I'd get it
'working' first.
---
diff --git a/scripts/tags.sh b/scripts/tags.sh
index 32d3f53af10b..ec2688b3441a 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -239,10 +239,65 @@ setup_regex()
done
}
+sort_tags()
+{
+ export LC_ALL=C
+
+ # start concurrent sort
+ coproc sort
+ # HACK, clone sort output into 3 to ensure we can still read it
+ # after sort terminates
+ exec 3<&${COPROC[0]}
+
+ while read tag file rest;
+ do
+ local tmp=${rest#*;\"}
+
+ case "${tmp:1:1}" in # Precedence for 'C' kinds
+
+ c) order="A";; # classes
+ s) order="B";; # structure names
+ t) order="C";; # typedefs
+ g) order="D";; # enumeration names
+ u) order="E";; # union names
+ n) order="F";; # namespaces
+
+ f) order="G";; # function definitions
+ p) order="H";; # function prototypes
+ d) order="I";; # macro definitions
+
+ e) order="J";; # enumerators (values inside an enumeration)
+ m) order="K";; # class, struct and union members
+ v) order="L";; # variable definitions
+
+ l) order="M";; # local variables [off]
+ x) order="N";; # external and forward variable declarations
+
+ *) order="Z";;
+
+ esac
+
+ # write to sort with a new sort-key prepended
+ echo "${tag}${order} ${tag} ${file} ${rest}" >&${COPROC[1]}
+ done
+
+ # close sort input
+ exec {COPROC[1]}>&-
+
+ # consume sort output
+ while read -u 3 key line;
+ do
+ # strip the sort-key
+ echo "${line}"
+ done
+}
+
exuberant()
{
+ (
+
setup_regex exuberant asm c
- all_target_sources | xargs $1 -a \
+ all_target_sources | xargs $1 \
-I __initdata,__exitdata,__initconst,__ro_after_init \
-I __initdata_memblock \
-I __refdata,__attribute,__maybe_unused,__always_unused \
@@ -256,12 +311,16 @@ exuberant()
-I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \
-I static,const \
--extra=+fq --c-kinds=+px --fields=+iaS --langmap=c:+.h \
+ --sort=no -o - \
"${regex[@]}"
setup_regex exuberant kconfig
- all_kconfigs | xargs $1 -a \
+ all_kconfigs | xargs $1 \
+ --sort=no -o - \
--langdef=kconfig --language-force=kconfig "${regex[@]}"
+ ) | sort_tags > tags
+
}
emacs()
prev parent reply other threads:[~2020-09-04 14:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-05 10:25 [PATCH] scipts/tags.sh: Add custom sort order peterz
2020-08-06 12:04 ` [PATCH -v2] " peterz
2020-08-26 10:20 ` peterz
2020-09-02 15:58 ` Masahiro Yamada
2020-09-02 16:10 ` Masahiro Yamada
2020-09-02 16:26 ` peterz
2020-09-03 2:07 ` Masahiro Yamada
2020-09-03 7:26 ` peterz
2020-09-04 14:53 ` peterz [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200904145322.GA35926@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).