summaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorHolger Schurig <holgerschurig@gmail.com>2014-07-22 09:56:47 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-07-22 21:16:06 +0200
commit46e8bf74874809846c366ca6bfc542076e17770d (patch)
treee68f3566ba5c0fa1e6782f46ccf13b94189955d1 /Documentation
parentf8373506353969a2d09fe30f34882ab6b223fc5c (diff)
downloadbarebox-46e8bf74874809846c366ca6bfc542076e17770d.tar.gz
barebox-46e8bf74874809846c366ca6bfc542076e17770d.tar.xz
Documentation: only write changed *.rst files
Documentation/gen_commands.py use to re-write all auto-generated *.rst file, changed or not. That in turn didn't work well with the internal cache of the Sphinx documentation generator. By comparing the SHA1 hash of the newly generated *.rst with the current sha1 file, the time to execute "make docs" can be reduced from 6.2s to 2.4s on my humble laptop. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'Documentation')
-rwxr-xr-xDocumentation/gen_commands.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Documentation/gen_commands.py b/Documentation/gen_commands.py
index d3db350bf7..eadea9e189 100755
--- a/Documentation/gen_commands.py
+++ b/Documentation/gen_commands.py
@@ -4,6 +4,7 @@ import errno
import os
import re
import sys
+import hashlib
from collections import defaultdict
from pprint import pprint
@@ -169,5 +170,18 @@ for name, cmd in CMDS.items():
else:
raise
target = os.path.join(subdir, name+'.rst')
+
+ # Only write the new rst if it differs from the old one. Wroto
+ hash_old = hashlib.sha1()
+ try:
+ f = open(target, 'rb')
+ hash_old.update(f.read())
+ except:
+ pass
+ hash_new = hashlib.sha1()
+ hash_new.update(rst)
+ if hash_old.hexdigest() == hash_new.hexdigest():
+ continue
+
file(target, 'w').write(rst)