forked from swiftlang/swift-source-compat-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·219 lines (193 loc) · 7.8 KB
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/usr/bin/env python
# ===--- run --------------------------------------------------------------===
#
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See https://swift.org/LICENSE.txt for license information
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
#
# ===----------------------------------------------------------------------===
"""A run script to be executed as a Jenkins build step."""
import sys
import os
import argparse
import platform
import common
script_dir = os.path.abspath(os.path.dirname(__file__))
def main():
common.debug_print('** RUN **')
os.chdir(os.path.dirname(__file__))
args = parse_args()
common.set_swift_branch(args.swift_branch)
workspace = common.private_workspace('.')
if not args.skip_clone:
common.clone_repos()
if not args.skip_build:
build_swift_toolchain(workspace, args)
if not args.skip_runner:
if args.test_incremental:
execute_build_incremental(workspace, args)
else:
execute_runner(workspace, args)
return 0
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('swift_branch')
parser.add_argument('--sandbox', action='store_true')
parser.add_argument('--projects',
metavar='PATH',
help='JSON project file',
default='projects.json')
parser.add_argument("--verbose",
action='store_true')
parser.add_argument("--assertions",
help='Build Swift with asserts',
action='store_true')
parser.add_argument("--test-incremental",
help='Test incremental-mode over multiple commits',
action='store_true')
parser.add_argument('--swiftc',
metavar='PATH',
help='swiftc executable')
parser.add_argument('--skip-build',
action='store_true')
parser.add_argument('--skip-ci-steps',
action='store_true')
parser.add_argument('--skip-clone',
action='store_true')
parser.add_argument('--skip-runner',
action='store_true')
return parser.parse_args()
def get_swiftc_path(workspace, swiftc):
if platform.system() == 'Darwin':
swiftc_path = (
swiftc if swiftc else
os.path.join(workspace, 'build/compat_macos/install/toolchain/usr/bin/swiftc')
)
elif platform.system() == 'Linux':
swiftc_path = (
swiftc if swiftc else
os.path.join(workspace, 'build/compat_linux/install/usr/bin/swiftc')
)
else:
raise common.UnsupportedPlatform
return swiftc_path
def get_sandbox_profile_flags():
sandbox_flags = []
if platform.system() == 'Darwin':
sandbox_flags += [
'--sandbox-profile-xcodebuild',
'../../../workspace-private/swift-source-compat-suite-sandbox/sandbox_xcodebuild.sb',
'--sandbox-profile-package',
'../../../workspace-private/swift-source-compat-suite-sandbox/sandbox_package.sb'
]
elif platform.system() == 'Linux':
sandbox_flags += [
'--sandbox-profile-package',
'../../../workspace-private/swift-source-compat-suite-sandbox/sandbox_package_linux.profile'
]
else:
raise common.UnsupportedPlatform
return sandbox_flags
def execute_runner(workspace, args):
swiftc_path = get_swiftc_path(workspace, args.swiftc)
runner_command = [
'./runner.py',
'--swiftc', swiftc_path,
'--projects', args.projects,
'--swift-version', '3',
'--include-actions', 'action.startswith("Build")',
'--swift-branch', args.swift_branch
]
if args.sandbox:
runner_command += get_sandbox_profile_flags()
if args.verbose:
runner_command += ["--verbose"]
common.check_execute(runner_command, timeout=9999999)
def execute_build_incremental(workspace, args):
swiftc_path = get_swiftc_path(workspace, args.swiftc)
runner_command = [
'./build_incremental.py',
'--swiftc', swiftc_path,
# FIXME: do something clever with default args
# that vary by mode.
'--projects', 'projects-incremental.json',
'--swift-version', '3',
'--include-actions', 'action.startswith("Build")',
'--swift-branch', args.swift_branch,
'--check-stats'
]
if args.sandbox:
runner_command += get_sandbox_profile_flags()
common.check_execute(runner_command, timeout=9999999)
def build_swift_toolchain(workspace, args):
if platform.system() == 'Darwin':
build_command = [
os.path.join(workspace, 'swift/utils/build-script'),
'--debug' if args.assertions else '--release',
'--assertions' if args.assertions else '--no-assertions',
'--build-ninja',
'--llbuild',
'--swiftpm',
'--ios',
'--tvos',
'--watchos',
'--skip-build-benchmarks',
'--build-subdir=compat_macos',
'--compiler-vendor=apple',
'--',
'--darwin-install-extract-symbols',
'--darwin-toolchain-alias=swift',
'--darwin-toolchain-bundle-identifier=org.swift.compat-macos',
'--darwin-toolchain-display-name-short=Swift Development Snapshot'
'--darwin-toolchain-display-name=Swift Development Snapshot',
'--darwin-toolchain-name=swift-DEVELOPMENT-SNAPSHOT',
'--darwin-toolchain-version=3.999.999',
'--install-llbuild',
'--install-swift',
'--install-swiftpm',
'--install-destdir={}/build/compat_macos/install'.format(workspace),
'--install-prefix=/toolchain/usr',
'--install-symroot={}/build/compat_macos/symroot'.format(workspace),
'--installable-package={}/build/compat_macos/root.tar.gz'.format(workspace),
'--llvm-install-components=libclang;libclang-headers',
'--swift-install-components=compiler;clang-builtin-headers;stdlib;sdk-overlay;license;sourcekit-xpc-service;swift-remote-mirror;swift-remote-mirror-headers',
'--symbols-package={}/build/compat_macos/root-symbols.tar.gz'.format(workspace),
'--verbose-build',
'--reconfigure',
]
elif platform.system() == 'Linux':
build_command = [
os.path.join(workspace, 'swift/utils/build-script'),
'--debug' if args.assertions else '--release',
'--assertions' if args.assertions else '--no-assertions',
'--build-ninja',
'--llbuild',
'--swiftpm',
'--foundation',
'--libdispatch',
'--xctest',
'--skip-build-benchmarks',
'--build-subdir=compat_linux',
'--',
'--install-foundation',
'--install-libdispatch',
'--install-llbuild',
'--install-swift',
'--install-swiftpm',
'--install-xctest',
'--install-destdir={}/build/compat_linux/install'.format(workspace),
'--install-prefix=/usr',
'--installable-package={}/build/compat_linux/root.tar.gz'.format(workspace),
'--swift-install-components=autolink-driver;compiler;clang-builtin-headers;stdlib;swift-remote-mirror;sdk-overlay;license',
'--verbose-build',
'--reconfigure',
]
else:
raise common.UnsupportedPlatform
common.check_execute(build_command, timeout=9999999)
if __name__ == '__main__':
sys.exit(main())