[ci skip] minor updates to CHANGE/RELEASE
[scons.git] / bin / docs-update-generated.py
blob9fbd95c8701d8fceffabac84a8427aec510f15c1
1 #!/usr/bin/env python
3 # Searches through the whole source tree and updates
4 # the generated *.gen/*.mod files in the docs folder, keeping all
5 # documentation for the tools, builders and functions...
6 # as well as the entity declarations for them.
7 # Uses scons-proc.py under the hood...
9 import os
10 import sys
11 import subprocess
13 import SConsDoc
15 # Directory where all generated files are stored
16 gen_folder = os.path.join('doc', 'generated')
18 def argpair(key):
19 """ Return the argument pair *.gen,*.mod for the given key. """
20 arg = '%s,%s' % (
21 os.path.join(gen_folder, '%s.gen' % key),
22 os.path.join(gen_folder, '%s.mod' % key),
25 return arg
27 def generate_all():
28 """Generate the entity files.
30 Scan for XML files in the SCons directory and call scons-proc.py
31 to generate the *.gen/*.mod files from it.
32 """
33 flist = []
34 for path, dirs, files in os.walk('SCons'):
35 for f in files:
36 if f.endswith('.xml'):
37 fpath = os.path.join(path, f)
38 if SConsDoc.isSConsXml(fpath):
39 flist.append(fpath)
41 if flist:
42 # Does the destination folder exist
43 try:
44 os.makedirs(gen_folder, exist_ok=True)
45 except Exception:
46 print("Couldn't create destination folder %s! Exiting..." % gen_folder, file=sys.stdout)
47 return False
49 # Call scons-proc.py
50 cp = subprocess.run(
52 sys.executable,
53 os.path.join('bin', 'scons-proc.py'),
54 '-b', argpair('builders'),
55 '-f', argpair('functions'),
56 '-t', argpair('tools'),
57 '-v', argpair('variables'),
58 ] + flist,
59 shell=False,
62 if cp.returncode:
63 print("Generation failed", file=sys.stderr)
64 return False
65 return True
68 if __name__ == "__main__":
69 if not generate_all():
70 sys.exit(1)