perf: Key the interpreter symbol cache by Name rather than FastString
[ghc.git] / boot
blobc73ed3a430b00e8fe088be6d4040950f548611a8
1 #!/usr/bin/env python3
3 import glob
4 import os
5 import os.path
6 import sys
7 from textwrap import dedent
8 import subprocess
9 import re
10 import shutil
12 # Packages whose libraries aren't in the submodule root
13 EXCEPTIONS = {
14     'libraries/containers/': 'libraries/containers/containers/'
17 def print_err(s):
18     print(dedent(s), file=sys.stderr)
20 def die(mesg):
21     print_err(mesg)
22     sys.exit(1)
24 def check_boot_packages():
25     # Check that we have all boot packages.
26     for l in open('packages', 'r'):
27         if l.startswith('#'):
28             continue
30         parts = [part for part in l.split(' ') if part]
31         if len(parts) != 4:
32             die("Error: Bad line in packages file: " + l)
34         dir_ = parts[0]
35         tag = parts[1]
37         # If tag is not "-" then it is an optional repository, so its
38         # absence isn't an error.
39         if tag == '-':
40             # We would like to just check for a .git directory here,
41             # but in an lndir tree we avoid making .git directories,
42             # so it doesn't exist. We therefore require that every repo
43             # has a LICENSE file instead.
44             license_path = os.path.join(EXCEPTIONS.get(dir_+'/', dir_), 'LICENSE')
45             if not os.path.isfile(license_path):
46                 die("""\
47                     Error: %s doesn't exist
48                     Maybe you haven't run 'git submodule update --init'?
49                     """ % license_path)
51 def autoreconf():
52     # Run autoreconf on everything that needs it.
53     processes = {}
54     if os.name == 'nt':
55         # Get the normalized ACLOCAL_PATH for Windows
56         # This is necessary since on Windows this will be a Windows
57         # path, which autoreconf doesn't know doesn't know how to handle.
58         ac_local = os.getenv('ACLOCAL_PATH', '')
59         ac_local_arg = re.sub(r';', r':', ac_local)
60         ac_local_arg = re.sub(r'\\', r'/', ac_local_arg)
61         ac_local_arg = re.sub(r'(\w):/', r'/\1/', ac_local_arg)
62         reconf_cmd = 'ACLOCAL_PATH=%s autoreconf' % ac_local_arg
63     else:
64         reconf_cmd = 'autoreconf'
66     for dir_ in ['.', 'rts'] + glob.glob('libraries/*/'):
67         if os.path.isfile(os.path.join(dir_, 'configure.ac')):
68             print("Booting %s" % dir_)
69             processes[dir_] = subprocess.Popen(['sh', '-c', reconf_cmd], cwd=dir_)
71     # Wait for all child processes to finish.
72     fail = False
73     for k,v in processes.items():
74         code = v.wait()
75         if code != 0:
76             print_err('autoreconf in %s failed with exit code %d' % (k, code))
77             fail = True
79     if fail:
80         sys.exit(1)
82 check_boot_packages()
83 autoreconf()