Skip to content

Commit 4e45170

Browse files
authored
build-using-self: Add ability to pass extra build/run/test arguments (#8723)
Add the ability to inject arbitrary arguments to the invocations of swift <build|run|test> from the build-using-self-script. Add a boolean flag to skip running the bootstrap subscript. Default is to run it. This allows one to add options like '--jobs' or '--event-stream-output-path' . Thus allowing for different use cases in pipelines, like collection of test output json to a specific path. For example: `build-using-self -v --skip-bootstrap --additional-test-args '--event-stream-output-path spm-test.json'`
1 parent 3eac931 commit 4e45170

File tree

1 file changed

+48
-18
lines changed

1 file changed

+48
-18
lines changed

Utilities/build-using-self

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def get_arguments() -> argparse.Namespace:
6868
dest="config",
6969
default=Configuration.DEBUG,
7070
choices=[e for e in Configuration],
71-
help="The configuraiton to use.",
71+
help="The configuration to use.",
7272
)
7373
parser.add_argument(
7474
"-t",
@@ -90,6 +90,36 @@ def get_arguments() -> argparse.Namespace:
9090
"--enable-xctest",
9191
action="store_true",
9292
)
93+
parser.add_argument(
94+
"--additional-build-args",
95+
type=str,
96+
dest="additional_build_args",
97+
default=""
98+
)
99+
parser.add_argument(
100+
"--additional-run-args",
101+
type=str,
102+
dest="additional_run_args",
103+
default=""
104+
)
105+
parser.add_argument(
106+
"--additional-test-args",
107+
type=str,
108+
dest="additional_test_args",
109+
default=""
110+
)
111+
parser.add_argument(
112+
"--additional-integration-test-args",
113+
type=str,
114+
dest="additional_integration_test_args",
115+
default=""
116+
)
117+
parser.add_argument(
118+
"--skip-bootstrap",
119+
dest="skip_bootstrap",
120+
action="store_true"
121+
)
122+
parser.set_defaults(skip_bootstrap=False)
93123
args = parser.parse_args()
94124
return args
95125

@@ -157,8 +187,8 @@ class GlobalArgs:
157187
value: t.Optional[GlobalArgsValueType]
158188

159189

160-
def filterNone(items: t.Iterable) -> t.Iterable:
161-
return list(filter(lambda x: x is not None, items))
190+
def filterNoneAndEmpty(items: t.Iterable) -> t.Iterable:
191+
return list(filter(lambda x: x is not None and x != '', items))
162192

163193

164194
def main() -> None:
@@ -181,7 +211,7 @@ def main() -> None:
181211
set_environment(swiftpm_bin_dir=swiftpm_bin_dir)
182212

183213
call(
184-
filterNone(
214+
filterNoneAndEmpty(
185215
[
186216
"swift",
187217
"--version",
@@ -190,7 +220,7 @@ def main() -> None:
190220
)
191221

192222
call(
193-
filterNone(
223+
filterNoneAndEmpty(
194224
[
195225
"swift",
196226
"package",
@@ -199,44 +229,42 @@ def main() -> None:
199229
)
200230
)
201231
call(
202-
filterNone(
232+
filterNoneAndEmpty(
203233
[
204234
"swift",
205235
"build",
206236
*global_args,
207237
"--configuration",
208238
args.config,
209239
*ignore_args,
240+
*args.additional_build_args.split(" ")
210241
]
211242
)
212243
)
213-
214-
swift_testing_arg = (
215-
"--enable-swift-testing" if args.enable_swift_testing else None
216-
)
217-
xctest_arg = "--enable-xctest" if args.enable_swift_testing else None
218244
call(
219-
filterNone(
245+
filterNoneAndEmpty(
220246
[
221247
"swift",
222248
"run",
249+
*args.additional_run_args.split(" "),
223250
"swift-test",
224251
*global_args,
225252
"--configuration",
226253
args.config,
227254
"--parallel",
228-
swift_testing_arg,
229-
xctest_arg,
255+
"--enable-swift-testing" if args.enable_swift_testing else None,
256+
"--enable-xctest" if args.enable_swift_testing else None,
230257
"--scratch-path",
231258
".test",
232259
*ignore_args,
260+
*args.additional_test_args.split(" ")
233261
]
234262
)
235263
)
236264

237265
integration_test_dir = (REPO_ROOT_PATH / "IntegrationTests").as_posix()
238266
call(
239-
filterNone(
267+
filterNoneAndEmpty(
240268
[
241269
"swift",
242270
"package",
@@ -247,21 +275,23 @@ def main() -> None:
247275
)
248276
)
249277
call(
250-
filterNone(
251-
[
278+
filterNoneAndEmpty(
279+
[
252280
"swift",
253281
"run",
282+
*args.additional_run_args.split(" "),
254283
"swift-test",
255284
*global_args,
256285
"--package-path",
257286
integration_test_dir,
258287
"--parallel",
259288
*ignore_args,
289+
*args.additional_integration_test_args.split(" ")
260290
]
261291
)
262292
)
263293

264-
if is_on_darwin():
294+
if is_on_darwin() and not args.skip_bootstrap:
265295
run_bootstrap(swiftpm_bin_dir=swiftpm_bin_dir)
266296
logging.info("Done")
267297

0 commit comments

Comments
 (0)