fix hot shallow decls
[hiphop-php.git] / hphp / tools / convert_make_target_to_command.py
blob66f128f1c6e6a4efe1f4e2fb7ecf73a41e4334cb
1 #!/usr/bin/env python2
3 # Helper for running hphp/test in fbconfig builds. Examples:
5 # ./convert_make_target_to_command.py SlowVM
6 # ./convert_make_target_to_command.py QuickRepoJit
7 # ./convert_make_target_to_command.py ZendJitIR
9 # Components are:
11 # SuiteName [VM|Jit|JitIR] [<blank>|Repo] [-SubSuiteName]
14 import re
15 import os
16 import sys
18 suites = {
19 'Slow': 'slow',
20 'Quick': 'quick',
21 'Zend': 'zend/good',
22 'Facebook': '../facebook/test/',
24 modes = {
25 'JitIR': 'hhir',
26 'Jit': 'jit',
27 'VM': 'interp',
30 home = os.path.dirname(os.path.realpath(__file__)) + '/../..'
31 root = home + '/' + os.getenv('FBMAKE_BIN_ROOT', '_bin')
33 def main():
34 if len(sys.argv) < 2:
35 print "%s [Quick|Slow|Zend][<blank>|Repo][VM|Jit|JitIR][-SubSuiteName]" % sys.argv[0]
36 return
38 arg = sys.argv[1]
39 for suite, dir in suites.items():
40 if arg.startswith(suite):
41 arg = arg.replace(suite, '')
43 repo = ''
44 if arg.startswith('Repo'):
45 arg = arg.replace('Repo', '')
46 repo = '-r'
48 for mode, vq in modes.items():
49 if arg.startswith(mode):
50 arg = arg.replace(mode, '')
52 subpath = ''
53 if len(arg):
54 if arg[0] == '-':
55 subpath = '/' + camel_to_slash(arg[1:])
56 else:
57 raise Exception('Extra? "%s"' % arg)
59 path = relative_path('../test/' + dir + subpath)
60 return [relative_path('../test/run'), path, '-m', vq, repo]
62 raise Exception('Unknown mode "%s"' % arg)
64 raise Exception('Unknown Suite "%s"' % arg)
66 def camel_to_slash(name):
67 s1 = re.sub('(.)([A-Z][a-z]+)', r'\1/\2', name)
68 return re.sub('([a-z0-9])([A-Z])', r'\1/\2', s1).lower()
70 def relative_path(path):
71 """Given a path relative to this file, returns a path relative to cwd"""
72 to_file = os.path.join(os.path.realpath(os.path.dirname(__file__)), path)
73 return os.path.relpath(to_file)
75 print ' '.join(main())