|
4 | 4 |
|
5 | 5 | import argparse
|
6 | 6 | import os
|
| 7 | +import shutil |
7 | 8 | import subprocess
|
8 | 9 |
|
9 | 10 |
|
10 |
| -def main(): |
11 |
| - parser = argparse.ArgumentParser() |
12 |
| - parser.add_argument('--verbose', '-v', action='store_true') |
13 |
| - parser.add_argument('--package-path', type=str, required=True) |
14 |
| - parser.add_argument('--build-path', type=str, required=True) |
15 |
| - parser.add_argument('--toolchain', type=str, required=True) |
16 |
| - |
17 |
| - # Build the debug/release versions. |
18 |
| - args = parser.parse_args() |
19 |
| - swiftbuild_path = os.path.join(args.toolchain, 'usr', 'bin', 'swift-build') |
20 |
| - swiftbuild_args = [ |
21 |
| - swiftbuild_path, |
22 |
| - '--package-path', args.package_path, |
23 |
| - '--build-path', args.build_path, |
24 |
| - '--configuration', 'debug', |
25 |
| - ] |
26 |
| - if args.verbose: |
27 |
| - swiftbuild_args.append('--verbose') |
28 |
| - subprocess.call(swiftbuild_args) |
| 11 | +def perform_build(args, swiftbuild_path, config, binary_name, opt_flag): |
| 12 | + assert(config in ['debug', 'release']) |
| 13 | + assert(binary_name in ['Benchmark_O', 'Benchmark_Onone']) |
| 14 | + assert(opt_flag in ['-O', '-Onone']) |
29 | 15 |
|
| 16 | + inner_build_dir = os.path.join(args.build_path, binary_name) |
30 | 17 | swiftbuild_args = [
|
31 | 18 | swiftbuild_path,
|
32 | 19 | '--package-path', args.package_path,
|
33 |
| - '--build-path', args.build_path, |
34 |
| - '--configuration', 'release', |
| 20 | + '--build-path', inner_build_dir, |
| 21 | + '--configuration', config, |
35 | 22 | '-Xswiftc', '-Xllvm',
|
36 | 23 | '-Xswiftc', '-align-module-to-page-size',
|
| 24 | + '-Xswiftc', opt_flag, |
37 | 25 | ]
|
38 | 26 | if args.verbose:
|
39 | 27 | swiftbuild_args.append('--verbose')
|
40 | 28 | subprocess.call(swiftbuild_args)
|
41 | 29 |
|
| 30 | + # Copy the benchmark file into the final ./bin directory. |
| 31 | + binpath = os.path.join(inner_build_dir, config, 'SwiftBench') |
| 32 | + finalpath = os.path.join(args.build_path, 'bin', binary_name) |
| 33 | + shutil.copy(binpath, finalpath) |
| 34 | + |
| 35 | + |
| 36 | +def main(): |
| 37 | + parser = argparse.ArgumentParser() |
| 38 | + parser.add_argument('--verbose', '-v', action='store_true') |
| 39 | + parser.add_argument('--package-path', type=str, required=True) |
| 40 | + parser.add_argument('--build-path', type=str, required=True) |
| 41 | + parser.add_argument('--toolchain', type=str, required=True) |
| 42 | + |
| 43 | + args = parser.parse_args() |
| 44 | + |
| 45 | + # Create our bin directory so we can copy in the binaries. |
| 46 | + bin_dir = os.path.join(args.build_path, 'bin') |
| 47 | + if not os.path.isdir(bin_dir): |
| 48 | + os.makedirs(bin_dir) |
| 49 | + |
| 50 | + swiftbuild_path = os.path.join(args.toolchain, 'usr', 'bin', 'swift-build') |
| 51 | + perform_build(args, swiftbuild_path, 'debug', 'Benchmark_Onone', '-Onone') |
| 52 | + perform_build(args, swiftbuild_path, 'release', 'Benchmark_O', '-O') |
| 53 | + |
42 | 54 |
|
43 | 55 | if __name__ == "__main__":
|
44 | 56 | main()
|
0 commit comments