@@ -25,7 +25,7 @@ Skylib.
25
25
"""
26
26
27
27
load (
28
- "//swift/internal :feature_names.bzl" ,
28
+ ":feature_names.bzl" ,
29
29
"SWIFT_FEATURE_CODEVIEW_DEBUG_INFO" ,
30
30
"SWIFT_FEATURE_DEBUG_PREFIX_MAP" ,
31
31
"SWIFT_FEATURE_EMIT_SWIFTDOC" ,
41
41
"SWIFT_FEATURE_USE_MODULE_WRAP" ,
42
42
"SWIFT_FEATURE_USE_OLD_DRIVER" ,
43
43
)
44
+ load (":toolchain_utils.bzl" , "SWIFT_TOOLCHAIN_TYPE" )
44
45
45
46
def _scratch_file (repository_ctx , temp_dir , name , content = "" ):
46
47
"""Creates and returns a scratch file with the given name and content.
@@ -237,6 +238,10 @@ def _create_linux_toolchain(repository_ctx):
237
238
repository_ctx .file (
238
239
"BUILD" ,
239
240
"""
241
+ load(
242
+ "@build_bazel_apple_support//configs:platforms.bzl",
243
+ "APPLE_PLATFORMS_CONSTRAINTS",
244
+ )
240
245
load(
241
246
"@build_bazel_rules_swift//swift/toolchains:swift_toolchain.bzl",
242
247
"swift_toolchain",
@@ -252,13 +257,29 @@ swift_toolchain(
252
257
root = "{root}",
253
258
version_file = "{version_file}",
254
259
)
260
+
261
+ [
262
+ toolchain(
263
+ name = "xcode-toolchain-" + arch + "-{cpu}",
264
+ exec_compatible_with = [
265
+ "@platforms//os:linux",
266
+ "@platforms//cpu:{cpu}",
267
+ ],
268
+ target_compatible_with = APPLE_PLATFORMS_CONSTRAINTS[arch],
269
+ toolchain = ":toolchain",
270
+ toolchain_type = "{toolchain_type}",
271
+ visibility = ["//visibility:public"],
272
+ )
273
+ for arch in APPLE_PLATFORMS_CONSTRAINTS.keys()
274
+ ]
255
275
""" .format (
256
276
cpu = _normalized_linux_cpu (repository_ctx .os .arch ),
257
277
feature_list = ", " .join ([
258
278
'"{}"' .format (feature )
259
279
for feature in feature_values
260
280
]),
261
281
root = root ,
282
+ toolchain_type = SWIFT_TOOLCHAIN_TYPE ,
262
283
version_file = version_file ,
263
284
),
264
285
)
@@ -279,22 +300,48 @@ def _create_xcode_toolchain(repository_ctx):
279
300
repository_ctx .file (
280
301
"BUILD" ,
281
302
"""
303
+ load(
304
+ "@build_bazel_apple_support//configs:platforms.bzl",
305
+ "APPLE_PLATFORMS_CONSTRAINTS",
306
+ )
282
307
load(
283
308
"@build_bazel_rules_swift//swift/toolchains:xcode_swift_toolchain.bzl",
284
309
"xcode_swift_toolchain",
285
310
)
286
311
287
312
package(default_visibility = ["//visibility:public"])
288
313
314
+ _OSX_DEVELOPER_PLATFORM_CPUS = [
315
+ "arm64",
316
+ "x86_64",
317
+ ]
318
+
289
319
xcode_swift_toolchain(
290
320
name = "toolchain",
291
321
features = [{feature_list}],
292
322
)
323
+
324
+ [
325
+ toolchain(
326
+ name = "xcode-toolchain-" + arch + "-" + cpu,
327
+ exec_compatible_with = [
328
+ "@platforms//os:macos",
329
+ "@platforms//cpu:" + cpu,
330
+ ],
331
+ target_compatible_with = APPLE_PLATFORMS_CONSTRAINTS[arch],
332
+ toolchain = ":toolchain",
333
+ toolchain_type = "{toolchain_type}",
334
+ visibility = ["//visibility:public"],
335
+ )
336
+ for arch in APPLE_PLATFORMS_CONSTRAINTS.keys()
337
+ for cpu in _OSX_DEVELOPER_PLATFORM_CPUS
338
+ ]
293
339
""" .format (
294
340
feature_list = ", " .join ([
295
341
'"{}"' .format (feature )
296
342
for feature in feature_values
297
343
]),
344
+ toolchain_type = SWIFT_TOOLCHAIN_TYPE ,
298
345
),
299
346
)
300
347
@@ -345,6 +392,10 @@ def _create_windows_toolchain(repository_ctx):
345
392
repository_ctx .file (
346
393
"BUILD" ,
347
394
"""
395
+ load(
396
+ "@build_bazel_apple_support//configs:platforms.bzl",
397
+ "APPLE_PLATFORMS_CONSTRAINTS",
398
+ )
348
399
load(
349
400
"@build_bazel_rules_swift//swift/toolchains:swift_toolchain.bzl",
350
401
"swift_toolchain",
@@ -364,11 +415,27 @@ swift_toolchain(
364
415
tool_executable_suffix = ".exe",
365
416
xctest_version = "{xctest_version}",
366
417
)
418
+
419
+ [
420
+ toolchain(
421
+ name = "windows-toolchain-" + arch + "-x86_64",
422
+ exec_compatible_with = [
423
+ "@platforms//os:windows",
424
+ "@platforms//cpu:x86_64",
425
+ ],
426
+ target_compatible_with = APPLE_PLATFORMS_CONSTRAINTS[arch],
427
+ toolchain = ":toolchain",
428
+ toolchain_type = "{toolchain_type}",
429
+ visibility = ["//visibility:public"],
430
+ )
431
+ for arch in APPLE_PLATFORMS_CONSTRAINTS.keys()
432
+ ]
367
433
""" .format (
368
434
features = ", " .join (['"{}"' .format (feature ) for feature in enabled_features ] + ['"-{}"' .format (feature ) for feature in disabled_features ]),
369
435
root = root ,
370
436
env = env ,
371
437
sdkroot = repository_ctx .os .environ ["SDKROOT" ].replace ("\\ " , "/" ),
438
+ toolchain_type = SWIFT_TOOLCHAIN_TYPE ,
372
439
xctest_version = xctest_version .stdout .rstrip (),
373
440
version_file = version_file ,
374
441
),
0 commit comments