diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/git-prune | 2 | ||||
-rwxr-xr-x | tools/make-directive-index.py | 3 | ||||
-rwxr-xr-x | tools/make-man-index.py | 3 | ||||
-rwxr-xr-x[-rw-r--r--] | tools/make-man-rules.py | 66 | ||||
-rwxr-xr-x | tools/test-header.sh | 2 | ||||
-rw-r--r-- | tools/xml_helper.py | 27 |
6 files changed, 74 insertions, 29 deletions
diff --git a/tools/git-prune b/tools/git-prune new file mode 100755 index 0000000000..d5a36dd4ee --- /dev/null +++ b/tools/git-prune @@ -0,0 +1,2 @@ +#!/bin/sh +git tag|grep '^elogind/v[0-9]*$'|xargs -n1 git tag -d diff --git a/tools/make-directive-index.py b/tools/make-directive-index.py index 256ff3dc5d..bbb328a8b7 100755 --- a/tools/make-directive-index.py +++ b/tools/make-directive-index.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # -*- Mode: python; coding: utf-8; indent-tabs-mode: nil -*- */ # # This file is part of systemd. @@ -179,7 +180,7 @@ referring to {pages} individual manual pages. ''' def _extract_directives(directive_groups, formatting, page): - t = xml_parse(page) + t, _ = xml_parse(page) section = t.find('./refmeta/manvolnum').text pagename = t.find('./refmeta/refentrytitle').text diff --git a/tools/make-man-index.py b/tools/make-man-index.py index 74a47b821a..7d11083b0b 100755 --- a/tools/make-man-index.py +++ b/tools/make-man-index.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # -*- Mode: python; coding: utf-8; indent-tabs-mode: nil -*- */ # # This file is part of systemd. @@ -77,7 +78,7 @@ def check_id(page, t): def make_index(pages): index = collections.defaultdict(list) for p in pages: - t = xml_parse(p) + t, _ = xml_parse(p) check_id(p, t) section = t.find('./refmeta/manvolnum').text refname = t.find('./refnamediv/refname').text diff --git a/tools/make-man-rules.py b/tools/make-man-rules.py index 5e61917d60..582e0f1132 100644..100755 --- a/tools/make-man-rules.py +++ b/tools/make-man-rules.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # -*- Mode: python; coding: utf-8; indent-tabs-mode: nil -*- */ # # This file is part of systemd. @@ -24,16 +25,15 @@ import os.path from xml_helper import * SECTION = '''\ -MANPAGES += \\ +sdman.MANPAGES += \\ {manpages} -MANPAGES_ALIAS += \\ +sdman.MANPAGES_ALIAS += \\ {aliases} {rules} -{htmlrules} ''' CONDITIONAL = '''\ -if {conditional} +ifneq ($({conditional}),) ''' \ + SECTION + \ '''\ @@ -52,27 +52,33 @@ HEADER = '''\ # to <refentry> element. ''' -HTML_ALIAS_RULE = '''\ -{}.html: {}.html - $(html-alias) +RULE_XSLT = ''' +$(outdir)/{refname}.{section}: $(srcdir)/{refname}.xml $(topsrcdir)/man/custom-man.xsl {deps} + $(sdman.man-xslt) +$(outdir)/{refname}.html: $(srcdir)/{refname}.xml $(topsrcdir)/man/custom-html.xsl {deps} + $(sdman.html-xslt) +''' + +RULE_ALIAS = '''\ +$(outdir)/{refname}.{section}: $(outdir)/{srcrefname}.{srcsection} + $(sdman.man-alias) +$(outdir)/{refname}.html: $(outdir)/{srcrefname}.html + $(sdman.html-alias) ''' FOOTER = '''\ # Really, do not edit this file. - -EXTRA_DIST += \\ - {dist_files} ''' def man(page, number): - return 'man/{}.{}'.format(page, number) + return '{}.{}'.format(page, number) def xml(file): - return 'man/{}'.format(os.path.basename(file)) + return '{}'.format(os.path.basename(file)) def add_rules(rules, name): - xml = xml_parse(name) + xml, deps = xml_parse(name) # print('parsing {}'.format(name), file=sys.stderr) if xml.getroot().tag != 'refentry': return @@ -89,11 +95,17 @@ def add_rules(rules, name): assert all(refname not in group for group in rules.values()), "duplicate page name" alias = man(refname.text, number) - rulegroup[alias] = target + if alias == target: + rulegroup[alias] = deps + else: + rulegroup[alias] = target # print('{} => {} [{}]'.format(alias, target, conditional), file=sys.stderr) def create_rules(xml_files): - " {conditional => {alias-name => source-name}} " + """ + {conditional => {alias-name => source-name, + page-name => [sources...]}} + """ rules = collections.defaultdict(dict) for name in xml_files: try: @@ -106,17 +118,25 @@ def create_rules(xml_files): def mjoin(files): return ' \\\n\t'.join(sorted(files) or '#') +def make_makefile_rule(k, v): + if isinstance(v, str): + return RULE_ALIAS.format( + refname=k[:-2], + section=k[-1:], + srcrefname=v[:-2], + srcsection=v[-1:]) + else: + return RULE_XSLT.format( + refname=k[:-2], + section=k[-1:], + deps=' '.join(v)) + def make_makefile(rules, dist_files): return HEADER + '\n'.join( (CONDITIONAL if conditional else SECTION).format( - manpages=mjoin(set(rulegroup.values())), - aliases=mjoin(k for k,v in rulegroup.items() if k != v), - rules='\n'.join('{}: {}'.format(k,v) - for k,v in sorted(rulegroup.items()) - if k != v), - htmlrules='\n'.join(HTML_ALIAS_RULE.format(k[:-2],v[:-2]) - for k,v in sorted(rulegroup.items()) - if k != v), + manpages=mjoin(k for k,v in rulegroup.items() if not isinstance(v, str)), + aliases=mjoin(k for k,v in rulegroup.items() if isinstance(v, str)), + rules='\n'.join(make_makefile_rule(k, v) for k,v in sorted(rulegroup.items())), conditional=conditional) for conditional,rulegroup in sorted(rules.items()) ) + FOOTER.format(dist_files=mjoin(sorted(dist_files))) diff --git a/tools/test-header.sh b/tools/test-header.sh index b11285af7d..d63177bde0 100755 --- a/tools/test-header.sh +++ b/tools/test-header.sh @@ -1,2 +1,2 @@ #!/bin/bash -gcc -c -o /dev/null -I/usr/include/efi -I/usr/include/efi/x86_64 -I/usr/include/libmount $(find src -type d |sed 's|^|-I&|') -include ./config.h -include "$(realpath -- "$1")" test-header.c +gcc -c -o /dev/null -I/usr/include/efi -I/usr/include/efi/x86_64 -I/usr/include/libmount $(find src -type d |sed 's|^|-I&|') -include ./config.h -include "$(realpath -- "$1")" "$(dirname -- "$0")"/test-header.c diff --git a/tools/xml_helper.py b/tools/xml_helper.py index e87126f2f7..862930e59c 100644 --- a/tools/xml_helper.py +++ b/tools/xml_helper.py @@ -18,17 +18,38 @@ # along with systemd; If not, see <http://www.gnu.org/licenses/>. from lxml import etree as tree +import os.path + +shared = { 'custom-entities.ent', + 'less-variables.xml', + 'standard-conf.xml', + 'standard-options.xml', + 'user-system-options.xml' } class CustomResolver(tree.Resolver): def resolve(self, url, id, context): - if 'custom-entities.ent' in url: - return self.resolve_filename('man/custom-entities.ent', context) + basename = os.path.basename(url) + if not basename in shared: + return None + + topsrcdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + makename = os.path.join('$(topsrcdir)', 'man', basename) + lxmlname = os.path.join(topsrcdir, 'man', basename) + if basename == 'custom-entities.ent': + makename = os.path.join('$(topoutdir)', 'man', basename) + lxmlname += '.in' + + _deps.add(makename) + return self.resolve_filename(lxmlname, context) _parser = tree.XMLParser() _parser.resolvers.add(CustomResolver()) +_deps = set() def xml_parse(page): + _deps.clear() doc = tree.parse(page, _parser) doc.xinclude() - return doc + return doc, _deps def xml_print(xml): return tree.tostring(xml, pretty_print=True, encoding='utf-8') |