[2.30,RFC] vcs-to-changelog quirks file for glibc

Message ID 20190127162522.5671-1-siddhesh@sourceware.org
State Committed
Headers

Commit Message

Siddhesh Poyarekar Jan. 27, 2019, 4:25 p.m. UTC
  A vcs-to-changelog script set has been posted on the gnulib mailing
list (archive not updated yet) and this script uses a quirks file in
the project for a number of things including determining the target
VCS and macro substitutions that are needed to allow the frontend
parser in the script to work correctly.

This is the glibc quirks file that makes a number of substitutions
including all the libc-symbol hack macros.

---

If all goes well, I intend to add this quirks file immediately upon
opening 2.30 development on master so that we don't have to put in
ChangeLog entries from 2.30 onwards.  Does that sound acceptable?  This
is of course assuming that the script is at least accepted in principle
in gnulib, i.e. the approach is considered acceptable and we only need
to iterate on making sure that code quality standards are met.

Siddhesh

 vcstocl_quirks.py | 64 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)
 create mode 100644 vcstocl_quirks.py
  

Comments

H.J. Lu Jan. 27, 2019, 4:54 p.m. UTC | #1
On Sun, Jan 27, 2019 at 8:26 AM Siddhesh Poyarekar
<siddhesh@sourceware.org> wrote:
>
> A vcs-to-changelog script set has been posted on the gnulib mailing
> list (archive not updated yet) and this script uses a quirks file in
> the project for a number of things including determining the target
> VCS and macro substitutions that are needed to allow the frontend
> parser in the script to work correctly.
>
> This is the glibc quirks file that makes a number of substitutions
> including all the libc-symbol hack macros.
>
> ---
>
> If all goes well, I intend to add this quirks file immediately upon
> opening 2.30 development on master so that we don't have to put in
> ChangeLog entries from 2.30 onwards.  Does that sound acceptable?  This
> is of course assuming that the script is at least accepted in principle
> in gnulib, i.e. the approach is considered acceptable and we only need
> to iterate on making sure that code quality standards are met.
>
> Siddhesh
>
>  vcstocl_quirks.py | 64 +++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 64 insertions(+)
>  create mode 100644 vcstocl_quirks.py
>
> diff --git a/vcstocl_quirks.py b/vcstocl_quirks.py
> new file mode 100644
> index 0000000000..b29ea56031
> --- /dev/null
> +++ b/vcstocl_quirks.py

Should it be in the "script" directory?
  
Siddhesh Poyarekar Jan. 28, 2019, 3:58 a.m. UTC | #2
On 27/01/19 10:24 PM, H.J. Lu wrote:
> Should it be in the "script" directory?


Other projects may not have a scripts directory.


Sidhesh
  
Florian Weimer Jan. 28, 2019, 6:48 a.m. UTC | #3
* Siddhesh Poyarekar:

> On 27/01/19 10:24 PM, H.J. Lu wrote:
>> Should it be in the "script" directory?
>
>
> Other projects may not have a scripts directory.

Can you load the script from . and scripts/?

Thanks,
Florian
  
Siddhesh Poyarekar Jan. 28, 2019, 6:56 a.m. UTC | #4
On 28/01/19 12:18 PM, Florian Weimer wrote:
>> On 27/01/19 10:24 PM, H.J. Lu wrote:
>>> Should it be in the "script" directory?
>>
>>
>> Other projects may not have a scripts directory.
> 
> Can you load the script from . and scripts/?

Sure, that should be easy.  However I was just pointed to the vc-dwim
project that seems to have something that does what we want, so if
that's good enough, we may not even need all this.

Siddhesh
  
Joseph Myers Jan. 28, 2019, 6:04 p.m. UTC | #5
On Mon, 28 Jan 2019, Siddhesh Poyarekar wrote:

> On 27/01/19 10:24 PM, H.J. Lu wrote:
> > Should it be in the "script" directory?
> 
> Other projects may not have a scripts directory.

Some projects might call it e.g. build-aux.  I think the script should not 
require this file at top-level, nor impose a particular naming of the 
subdirectory it goes in.
  

Patch

diff --git a/vcstocl_quirks.py b/vcstocl_quirks.py
new file mode 100644
index 0000000000..b29ea56031
--- /dev/null
+++ b/vcstocl_quirks.py
@@ -0,0 +1,64 @@ 
+#!/usr/bin/python3
+# VCSToChangeLog Quirks for the GNU C Library.
+
+# Copyright (C) 2019 Free Software Foundation, Inc.
+#
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+from frontend_c import Frontend
+from vcs_to_changelog import ProjectQuirks
+import re
+
+class GlibcProjectQuirks(ProjectQuirks):
+    repo = 'git'
+
+    IGNORE_LIST = [
+        'ChangeLog',
+        'sysdeps/x86_64/dl-trampoline.h'
+    ]
+
+    MACRO_QUIRKS = \
+        [{'orig': r'ElfW\((\w+)\)', 'sub': r'\1__ELF_NATIVE_CLASS_t'},
+         {'orig': r'(libc_freeres_fn)\s*\((\w+)\)', 'sub': r'static void \1__\2 (void)'},
+         {'orig': r'(IMPL)\s*\((\w+), .*\)$', 'sub': r'static void \1__\2 (void) {}'},
+         {'orig': r'__(BEGIN|END)_DECLS', 'sub': r''},
+         {'orig': 'weak_function', 'sub': '__attribute__ ((weak))'},
+         {'orig': r'ATTRIBUTE_(CONST|MALLOC|PURE|FORMAT)',
+          'sub': r'__attribute__ ((\1))'},
+         {'orig': r'__THROW', 'sub': r'__attribute__ ((__nothrow__ __LEAF))'},
+         {'orig': r'__THROWNL', 'sub': r'__attribute__ ((__nothrow__))'},
+         {'orig': r'([^_])attribute_(\w+)', 'sub': r'\1__attribute__ ((\2))'},
+         {'orig': r'^attribute_(\w+)', 'sub': r'__attribute__ ((\1))'}]
+
+    def __init__(self, debug):
+        self.debug = debug
+        ''' Build a list of macro calls used for symbol versioning and attributes.
+
+        glibc uses a set of macro calls that do not end with a semi-colon and hence
+        breaks our parser.  Identify those calls from include/libc-symbols.h and
+        filter them out.
+        '''
+        with open('include/libc-symbols.h') as macrofile:
+            op = macrofile.readlines()
+            op = Frontend.remove_comments(self, op)
+            self.C_MACROS = [re.sub(r'.*define (\w+).*', r'\1', x[:-1]) for x in op \
+                             if 'define ' in x]
+
+        super().__init__()
+
+def get_project_quirks(debug):
+    ''' Accessor function.
+    '''
+    return GlibcProjectQuirks(debug)