aboutsummaryrefslogtreecommitdiff
path: root/newlib/doc
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2022-10-28 17:56:09 +0100
committerJon Turney <jon.turney@dronecode.org.uk>2022-10-29 18:34:05 +0100
commitd3d63cecbb295ea476edeb75f0d7ca1d507085e5 (patch)
treed98d48ba86f314487540a9cfe06a4369c7fc1a89 /newlib/doc
parent9b89811c9fc0cc859c8d43a5a162e5fe8cc1ff2c (diff)
downloadnewlib-d3d63cecbb295ea476edeb75f0d7ca1d507085e5.zip
newlib-d3d63cecbb295ea476edeb75f0d7ca1d507085e5.tar.gz
newlib-d3d63cecbb295ea476edeb75f0d7ca1d507085e5.tar.bz2
makedocbook: Add explicit locking for PLY parser table generation
Drop 'makedocbook --cache' (any dependency on the man-cache rule which invokes that was dropped by the non-recursive make changes) Instead, add some explicit locking which prevents processes colliding over the file containing generated python code for the parser table.
Diffstat (limited to 'newlib/doc')
-rw-r--r--newlib/doc/Makefile.inc5
-rwxr-xr-xnewlib/doc/makedocbook.py16
2 files changed, 11 insertions, 10 deletions
diff --git a/newlib/doc/Makefile.inc b/newlib/doc/Makefile.inc
index 630681c..d2c26a1 100644
--- a/newlib/doc/Makefile.inc
+++ b/newlib/doc/Makefile.inc
@@ -14,11 +14,6 @@ doc/makedoc.o: doc/makedoc.c
$(MKDIR_P) doc
$(CC_FOR_BUILD) -g $(CFLAGS_FOR_BUILD) -o $@ -c $<
-man-cache:
- ${srcdir}/doc/makedocbook.py --cache
-
-PHONY += man-cache
-
#
# Subdir documentation rules.
#
diff --git a/newlib/doc/makedocbook.py b/newlib/doc/makedocbook.py
index 66481a6..4e83ab6 100755
--- a/newlib/doc/makedocbook.py
+++ b/newlib/doc/makedocbook.py
@@ -22,7 +22,9 @@
from __future__ import print_function
+import fcntl
import sys
+import os
import re
from optparse import OptionParser
import lxml.etree
@@ -796,7 +798,15 @@ def p_error(t):
print('parse error at line %d, token %s, next token %s' % (t.lineno, t, parser.token()), file=sys.stderr)
exit(1)
-parser = yacc.yacc(start='input')
+# protect creating the parser with a lockfile, so that when multiple processes
+# are running this script simultaneously, we don't get one of them generating a
+# parsetab.py file, while another one attempts to read it...
+#
+# see also https://github.com/dabeaz/ply/pull/184
+with open(os.path.join(os.path.dirname(__file__), 'parsetab.lock'), 'w+') as lockfile:
+ fcntl.flock(lockfile.fileno(), fcntl.LOCK_EX)
+ parser = yacc.yacc(start='input')
+ fcntl.flock(lockfile.fileno(), fcntl.LOCK_UN)
#
#
@@ -829,12 +839,8 @@ def main(file):
if __name__ == '__main__' :
options = OptionParser()
options.add_option('-v', '--verbose', action='count', dest = 'verbose', default = 0)
- options.add_option('-c', '--cache', action='store_true', dest = 'cache', help="just ensure PLY cache is up to date")
(opts, args) = options.parse_args()
- if opts.cache:
- sys.exit()
-
verbose = opts.verbose
if len(args) > 0: