|
17 | 17 | from __future__ import print_function
|
18 | 18 |
|
19 | 19 | import argparse
|
20 |
| -import jinja2 |
21 | 20 | import os
|
22 | 21 | import re
|
23 | 22 | import subprocess
|
24 | 23 |
|
| 24 | +import jinja2 |
| 25 | + |
25 | 26 | script_dir = os.path.dirname(os.path.realpath(__file__))
|
26 | 27 | perf_dir = os.path.realpath(os.path.join(script_dir, '../..'))
|
27 |
| -gyb_script = os.path.realpath(os.path.join(perf_dir, '../utils/gyb')) |
| 28 | +gyb = os.path.realpath(os.path.join(perf_dir, '../utils/gyb')) |
28 | 29 | single_source_dir = os.path.join(perf_dir, 'single-source')
|
29 | 30 | multi_source_dir = os.path.join(perf_dir, 'multi-source')
|
30 | 31 | parser = argparse.ArgumentParser()
|
|
44 | 45 | template_env = jinja2.Environment(loader=template_loader, trim_blocks=True,
|
45 | 46 | lstrip_blocks=True)
|
46 | 47 |
|
47 |
| -def all_files(directory, extension): # matching: [directory]/**/*[extension] |
| 48 | + |
| 49 | +def all_files(directory, extension): # matching: [directory]/**/*[extension] |
48 | 50 | return [
|
49 | 51 | os.path.join(root, f)
|
50 | 52 | for root, _, files in os.walk(directory)
|
51 | 53 | for f in files if f.endswith(extension)
|
52 | 54 | ]
|
53 | 55 |
|
54 |
| -def will_write(filename): # ensure path to file exists before writing |
| 56 | + |
| 57 | +def will_write(filename): # ensure path to file exists before writing |
55 | 58 | print(filename)
|
56 | 59 | output_path = os.path.split(filename)[0]
|
57 |
| - if not os.path.exists(output_path): os.makedirs(output_path) |
| 60 | + if not os.path.exists(output_path): |
| 61 | + os.makedirs(output_path) |
| 62 | + |
58 | 63 |
|
59 | 64 | if __name__ == '__main__':
|
60 | 65 | # Generate Your Boilerplate
|
61 |
| - gyb_files = all_files(perf_dir, '.swift.gyb') |
| 66 | + gyb_files = all_files(perf_dir, '.gyb') |
62 | 67 | for f in gyb_files:
|
63 | 68 | relative_path = os.path.relpath(f[:-4], perf_dir)
|
64 | 69 | out_file = os.path.join(output_dir, relative_path)
|
65 | 70 | will_write(out_file)
|
66 |
| - subprocess.call([gyb_script, '--line-directive', '', '-o', out_file, f]) |
| 71 | + subprocess.call([gyb, '--line-directive', '', '-o', out_file, f]) |
67 | 72 |
|
68 | 73 | # CMakeList single-source
|
69 |
| - test_files = all_files(single_source_dir,'.swift') |
| 74 | + test_files = all_files(single_source_dir, '.swift') |
70 | 75 | tests = sorted(os.path.basename(x).split('.')[0] for x in test_files)
|
71 | 76 |
|
72 | 77 | # CMakeList multi-source
|
|
0 commit comments