-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathlit.cfg
2846 lines (2507 loc) · 137 KB
/
lit.cfg
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# swift/test/lit.cfg - Configuration for the 'lit' test runner -*- python -*-
#
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2014 - 2021 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
#
# -----------------------------------------------------------------------------
#
# This is a configuration file for the 'lit' test runner.
#
# Refer to docs/Testing.md for documentation.
#
# Update docs/Testing.md when changing this file.
#
# -----------------------------------------------------------------------------
import os
import platform
import re
import shlex
import shutil
import subprocess
import sys
import socket
import glob
from distutils.sysconfig import get_python_lib
import lit
import lit.formats
import lit.util
import site
site.addsitedir(os.path.dirname(__file__))
import swift_test
def make_path(*args):
return os.path.normpath(os.path.join(*args))
#
# Helper functions.
#
def darwin_get_sdk_version(sdk_path):
system_version_plist_path = make_path(sdk_path, "System", "Library",
"CoreServices", "SystemVersion.plist")
name = subprocess.check_output(
["defaults", "read", system_version_plist_path,
"ProductName"]).rstrip()
vers = subprocess.check_output(
["defaults", "read", system_version_plist_path,
"ProductVersion"]).rstrip()
build = subprocess.check_output(
["defaults", "read", system_version_plist_path,
"ProductBuildVersion"]).rstrip()
return (name, vers, build)
# Run sw_vers on the target to be tested and return the results.
def darwin_get_sw_vers(commandPrefix=[]):
name = lit.util.executeCommand(
commandPrefix + ['/usr/bin/sw_vers', '-productName'])[0].rstrip()
vers = lit.util.executeCommand(
commandPrefix + ['/usr/bin/sw_vers', '-productVersion'])[0].rstrip()
build = lit.util.executeCommand(
commandPrefix + ['/usr/bin/sw_vers', '-buildVersion'])[0].rstrip()
return (name, vers, build)
def darwin_get_ios_sim_vers():
sim_output = subprocess.check_output(['xcrun', 'simctl', 'list', 'runtimes'])
ios_version_str = re.findall(r'iOS \d+\.*\d*', sim_output.decode('utf-8'))
return [float(v.strip('iOS')) for v in ios_version_str]
def darwin_get_watchos_sim_vers():
sim_output = subprocess.check_output(['xcrun', 'simctl', 'list', 'runtimes'])
watchos_version_str = re.findall(r'watchOS \d+\.*\d*', sim_output.decode('utf-8'))
return [float(v.strip('watchOS')) for v in watchos_version_str]
# Returns the "prefix" command that should be prepended to the command line to
# run an executable compiled for an iOS, tvOS, or watchOS simulator.
def get_simulator_command(run_os, run_cpu):
mac_ver_tuple = tuple(int(v) for v in
platform.mac_ver()[0].replace('.', ' ').split())
if run_os == 'ios':
if run_cpu == "i386":
if mac_ver_tuple >= (11,):
print("ERROR: The 32-bit iOS simulator is unavailable on macOS 11.0+")
sys.exit(1)
elif min(darwin_get_ios_sim_vers()) > 10.3:
print("ERROR: Your system does not have a 32-bit iOS simulator installed.")
print("INFO: 1. Install iOS 10.3 or older simulator (Xcode -> Preferences -> Components -> Simulators).")
print("INFO: 2. Create a 32-bit iPhone 5 device. Run:")
print("INFO: $ xcrun simctl create 'iPhone 5' com.apple.CoreSimulator.SimDeviceType.iPhone-5 com.apple.CoreSimulator.SimRuntime.iOS-10-3")
sys.exit(1)
else:
return "simctl spawn --standalone 'iPhone 5'"
else:
return "simctl spawn --standalone 'iPhone 12'"
elif run_os == 'tvos':
return "simctl spawn --standalone 'Apple TV'"
elif run_os == 'watchos':
if run_cpu == "i386":
if min(darwin_get_watchos_sim_vers()) > 6.2:
print("ERROR: Your system does not have a 32-bit watchOS simulator installed.")
print("INFO: 1. Install watchOS 6.2.1 simulator (Xcode -> Preferences -> Components -> Simulators).")
print("INFO: 2. Create a 32-bit watchOS device. Run:")
print("INFO: $ xcrun simctl create 'Apple Watch Series 2 - 42mm' com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-42mm com.apple.CoreSimulator.SimRuntime.watchOS-6-2")
sys.exit(1)
else:
return "simctl spawn --standalone 'Apple Watch Series 2 - 42mm'"
else:
return "simctl spawn --standalone 'Apple Watch Series 5 - 44mm'"
else:
lit_config.fatal("Unknown simulator OS %r" % run_os)
def get_lldb_python_path(lldb_build_root):
lldb_path = os.path.join(lldb_build_root, 'bin', 'lldb')
if not os.access(lldb_path, os.F_OK):
return None
return subprocess.check_output([lldb_path, "-P"]).rstrip().decode('utf-8')
def get_lldb_python_interpreter(lldb_build_root):
python_path = os.path.join(lldb_build_root, 'bin', 'lldb-python')
if not os.access(python_path, os.F_OK):
return None
return python_path
if not platform.system() == 'Windows':
shell_quote = shlex.quote
else:
# In Windows neither pipe.quote nor shlex.quote works.
def shell_quote(s):
# Quote the argument if it is empty, or contains a quote or a space.
if len(s) == 0 or re.search(r'["\s]', s):
s = '"' + s.replace('"', r'\"') + '"'
return s
def escape_for_substitute_captures(s):
# SubstituteCaptures strings are used as replacement patterns for regular
# expressions. In them escapes like \1, \2 are used as references, but that
# means that simple \ will try to be interpreted, so we need to escape them
# with \\.
return s.replace("\\", "\\\\")
###
# Check that the object root is known.
if config.test_exec_root is None:
# Otherwise, we haven't loaded the site specific configuration (the user is
# probably trying to run on a test file directly, and either the site
# configuration hasn't been created by the build system, or we are in an
# out-of-tree build situation).
# Check for 'swift_site_config' user parameter, and use that if available.
site_cfg = lit_config.params.get('swift_site_config', None)
if site_cfg and os.path.exists(site_cfg):
lit_config.load_config(config, site_cfg)
raise SystemExit
lit_config.fatal("lit must be pointed at a build folder")
###
# name: The name of this test suite.
config.name = 'Swift(%s)' % config.variant_suffix[1:]
# Respect the TOOLCHAINS environment variable when deciding the xcrun
# toolchain for Darwin platforms.
if platform.system() == 'Darwin':
config.environment['TOOLCHAINS'] = \
os.environ.get('TOOLCHAINS', config.darwin_xcrun_toolchain)
# NOTE: this mirrors the kIsWindows from lit.lit.TestRunner in LLVM
kIsWindows = platform.system() == 'Windows'
# testFormat: The test format to use to interpret tests.
# Choose between lit's internal shell pipeline runner and a real shell. If
# LIT_USE_INTERNAL_SHELL is in the environment, we use that as an override.
use_lit_shell = os.environ.get('LIT_USE_INTERNAL_SHELL', kIsWindows)
if not use_lit_shell:
config.available_features.add('shell')
config.test_format = swift_test.SwiftTest(coverage_mode=config.coverage_mode,
execute_external=not use_lit_shell)
# suffixes: A list of file extensions to treat as test files.
config.suffixes = ['.swift', '.ll', '.sil', '.gyb', '.m', '.c',
'.swiftinterface', '.test-sh', '.test', '.cpp']
# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
# subdirectories contain auxiliary inputs for various tests in their parent
# directories.
config.excludes = ['Inputs']
if lit_config.params.get('disable_unittests', None) is not None:
config.excludes += ['Unit']
# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)
# swift_obj_root: The path to the swift build root.
swift_obj_root = getattr(config, 'swift_obj_root', None)
# cmake. The path to the cmake executable we used to configure swift.
assert(config.cmake)
config.substitutions.append( ('%cmake', config.cmake) )
lit_config.note('Using cmake: ' + config.cmake)
# Set llvm_{src,obj}_root for use by others.
config.llvm_src_root = getattr(config, 'llvm_src_root', None)
config.llvm_obj_root = getattr(config, 'llvm_obj_root', None)
lto_flags = ""
use_just_built_liblto = ""
llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
llvm_plugin_ext = getattr(config, 'llvm_plugin_ext', None)
if platform.system() == 'OpenBSD':
if not llvm_libs_dir:
lit_config.fatal('No LLVM libs dir set.')
config.environment['LD_LIBRARY_PATH'] = llvm_libs_dir
elif platform.system() == 'Darwin':
if not llvm_libs_dir:
lit_config.fatal('No LLVM libs dir set.')
lto_flags = "-Xlinker -lto_library -Xlinker %s/libLTO.dylib" % llvm_libs_dir
use_just_built_liblto = "LIBLTO_PATH=%s/libLTO.dylib" % llvm_libs_dir
config.substitutions.append( ('%lto_flags', lto_flags) )
config.substitutions.append( ('%use_just_built_liblto', use_just_built_liblto) )
config.substitutions.append( ('%llvm_libs_dir', llvm_libs_dir) )
config.substitutions.append( ('%llvm_plugin_ext', llvm_plugin_ext) )
def append_to_env_path(directory):
config.environment['PATH'] = \
os.path.pathsep.join((directory, config.environment['PATH']))
if sys.version_info[0] >= 3:
config.environment['PYTHONIOENCODING'] = 'UTF8'
# Tweak the PATH to include the tools dir and the scripts dir.
if swift_obj_root is not None:
llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
if not llvm_tools_dir:
lit_config.fatal('No LLVM tools dir set!')
append_to_env_path(llvm_tools_dir)
build_mode = lit_config.params.get('build_mode', '')
append_to_env_path(make_path(swift_obj_root, build_mode, 'bin'))
native_llvm_tools_path = lit_config.params.get('native_llvm_tools_path')
if native_llvm_tools_path is not None:
append_to_env_path(native_llvm_tools_path)
native_clang_tools_path = lit_config.params.get('native_clang_tools_path')
if native_clang_tools_path is not None:
append_to_env_path(native_clang_tools_path)
native_swift_tools_path = lit_config.params.get('native_swift_tools_path')
if native_swift_tools_path is not None:
append_to_env_path(native_swift_tools_path)
array_cow_checks = lit_config.params.get('array_cow_checks')
if array_cow_checks is not None:
config.available_features.add('array_cow_checks')
###
# Discover the Swift binaries to use.
def inferSwiftBinary(binaryName):
# Determine which executable to use.
envVarName = binaryName.upper().replace("-", "_")
execPath = os.getenv(envVarName)
# If the user set the variable in the environment, definitely use that and
# don't try to validate.
if execPath:
return execPath
# Otherwise look in the path.
PATH = config.environment['PATH']
execPath = lit.util.which(binaryName, PATH)
if execPath:
if not lit_config.quiet:
lit_config.note('using %s: %s' % (binaryName, execPath))
else:
msg = "couldn't find '%s' program, try setting %s in your environment"
lit_config.warning(msg % (binaryName, envVarName))
# Just substitute the plain executable name, so the run line remains
# reasonable.
execPath = binaryName
return execPath
if 'gmalloc' in lit_config.params:
config.environment['DYLD_INSERT_LIBRARIES'] = '/usr/lib/libgmalloc.dylib'
config.environment['MALLOC_LOG_FILE'] = '/dev/null'
config.available_features.add('gmalloc')
config.python_unquoted = sys.executable
config.python = shell_quote(config.python_unquoted)
config.swift_frontend = inferSwiftBinary('swift-frontend')
config.swift = inferSwiftBinary('swift')
config.swiftc = inferSwiftBinary('swiftc')
config.sil_opt = inferSwiftBinary('sil-opt')
config.sil_func_extractor = inferSwiftBinary('sil-func-extractor')
config.sil_llvm_gen = inferSwiftBinary('sil-llvm-gen')
config.sil_nm = inferSwiftBinary('sil-nm')
config.sil_passpipeline_dumper = inferSwiftBinary('sil-passpipeline-dumper')
config.lldb_moduleimport_test = inferSwiftBinary('lldb-moduleimport-test')
config.swift_ide_test = inferSwiftBinary('swift-ide-test')
config.swift_dependency_tool = inferSwiftBinary('swift-dependency-tool')
config.swift_reflection_dump = inferSwiftBinary('swift-reflection-dump')
config.swift_remoteast_test = inferSwiftBinary('swift-remoteast-test')
config.swift_indent = inferSwiftBinary('swift-indent')
config.swift_symbolgraph_extract = inferSwiftBinary('swift-symbolgraph-extract')
config.swift_api_extract = inferSwiftBinary('swift-api-extract')
config.clang = inferSwiftBinary('clang')
config.clangxx = inferSwiftBinary('clang++')
config.llvm_link = inferSwiftBinary('llvm-link')
config.swift_llvm_opt = inferSwiftBinary('swift-llvm-opt')
config.llvm_profdata = inferSwiftBinary('llvm-profdata')
config.llvm_cov = inferSwiftBinary('llvm-cov')
config.llvm_strings = inferSwiftBinary('llvm-strings')
config.filecheck = inferSwiftBinary('FileCheck')
config.llvm_dwarfdump = inferSwiftBinary('llvm-dwarfdump')
config.llvm_readelf = inferSwiftBinary('llvm-readelf')
config.llvm_dis = inferSwiftBinary('llvm-dis')
config.llvm_nm = inferSwiftBinary('llvm-nm')
config.llvm_readtapi = inferSwiftBinary('llvm-readtapi')
config.llvm_size = inferSwiftBinary('llvm-size')
config.sourcekitd_test = inferSwiftBinary('sourcekitd-test')
config.complete_test = inferSwiftBinary('complete-test')
config.swift_api_digester = inferSwiftBinary('swift-api-digester')
config.swift_cache_tool = inferSwiftBinary('swift-cache-tool')
config.swift_refactor = inferSwiftBinary('swift-refactor')
config.swift_demangle_yamldump = inferSwiftBinary('swift-demangle-yamldump')
config.swift_demangle = inferSwiftBinary('swift-demangle')
config.benchmark_o = inferSwiftBinary('Benchmark_O')
config.benchmark_driver = inferSwiftBinary('Benchmark_Driver')
config.wasm_ld = inferSwiftBinary('wasm-ld')
config.swift_plugin_server = inferSwiftBinary('swift-plugin-server')
config.swift_utils = make_path(config.swift_src_root, 'utils')
config.line_directive = make_path(config.swift_utils, 'line-directive')
config.gyb = make_path(config.swift_utils, 'gyb.py')
config.rth = make_path(config.swift_utils, 'rth') # Resilience test helper
config.scale_test = make_path(config.swift_utils, 'scale-test')
config.PathSanitizingFileCheck = make_path(config.swift_utils, 'PathSanitizingFileCheck')
config.swift_bin_dir = make_path(config.swift, '..', '..', 'bin')
config.swift_lib_dir = make_path(config.swift, '..', '..', 'lib')
config.swift_share_dir = make_path(config.swift, '..', '..', 'share')
config.round_trip_syntax_test = make_path(config.swift_utils, 'round-trip-syntax-test')
config.refactor_check_compiles = make_path(config.swift_utils, 'refactor-check-compiles.py')
config.link = lit.util.which('link', config.environment.get('PATH', '')) or \
lit.util.which('lld-link', config.environment.get('PATH', ''))
# Find the resource directory. Assume it's near the swift compiler if not set.
test_resource_dir = lit_config.params.get('test_resource_dir')
config.resource_dir_opt = ""
if test_resource_dir:
config.resource_dir_opt = ("-resource-dir %s" % test_resource_dir)
else:
test_resource_dir = make_path(config.swift_lib_dir, 'swift')
config.swift_system_overlay_opt = ""
config.clang_system_overlay_opt = ""
if kIsWindows:
config.swift_system_overlay_opt = "-vfsoverlay {}".format(
os.path.join(config.swift_obj_root, "stdlib", "windows-vfs-overlay.yaml")
)
config.clang_system_overlay_opt = "-Xcc -ivfsoverlay -Xcc {}".format(
os.path.join(config.swift_obj_root, "stdlib", "windows-vfs-overlay.yaml")
)
stdlib_resource_dir_opt = config.resource_dir_opt
sourcekitd_framework_dir = config.swift_lib_dir
config.substitutions.append( ('%test-resource-dir', test_resource_dir) )
lit_config.note('Using resource dir: ' + test_resource_dir)
# Parse the variant triple.
(run_cpu, run_vendor, run_os, run_vers) = re.match('([^-]+)-([^-]+)-([^0-9]+)(.*)', config.variant_triple).groups()
if run_os == 'ios' and run_vers.endswith('-macabi'):
run_vers = run_vers[0:-len('-macabi')]
run_os = 'maccatalyst'
if run_vers.endswith('-simulator'):
run_vers = run_vers[0:-len('-simulator')]
run_environment='-simulator'
else:
run_environment=''
target_arch = run_cpu
if run_os == 'openbsd' and run_cpu == 'amd64':
target_arch = run_cpu
run_cpu = 'x86_64'
run_ptrsize = '64' if ('64' in run_cpu or run_cpu == "s390x") else '32'
if run_cpu == 'arm64_32':
run_ptrsize = '32'
run_ptrauth = 'ptrauth' if run_cpu == 'arm64e' else 'noptrauth'
run_endian = 'little' if run_cpu != 's390x' else 'big'
run_objc_interop = 'nonobjc' # overwritten later
sdk_overlay_link_path = ""
sdk_overlay_linker_opt = ""
sdk_overlay_dir_opt = ""
test_sdk_overlay_dir = lit_config.params.get('test_sdk_overlay_dir', None)
if test_sdk_overlay_dir is not None:
config.available_features.add('sdk_overlay')
sdk_overlay_dir_opt = ("-I %s" % make_path(test_sdk_overlay_dir, run_cpu))
sdk_overlay_link_path_dir = make_path(test_sdk_overlay_dir, run_cpu)
sdk_overlay_link_path = ("-L %s" % sdk_overlay_link_path_dir)
sdk_overlay_linker_opt = (
"-L %s -Xlinker -rpath -Xlinker %s" %
(sdk_overlay_link_path_dir, sdk_overlay_link_path_dir))
lit_config.note('Using SDK overlay dir: ' + test_sdk_overlay_dir)
config.resource_dir_opt += (" %s" % sdk_overlay_dir_opt)
# Default to Swift 4 for now.
# Note that this accepts both `--param swift-version` (like the compiler flag)
# and `--param swift_version` (like a lit configuration parameter).
swift_version = lit_config.params.get('swift-version',
lit_config.params.get('swift_version', '4'))
lit_config.note('Compiling with -swift-version ' + swift_version)
config.swift_test_options = '-swift-version ' + swift_version
# Loads availability macros for known stdlib releases.
def load_availability_macros():
path = os.path.join(os.path.dirname(__file__), "../utils/availability-macros.def")
lines = open(path, 'r').read().splitlines()
pattern = re.compile(r"\s*(#.*)?")
return filter(lambda l: pattern.fullmatch(l) is None, lines)
# Returns a tuple with the Swift ABI version (e.g. '5.0') and the corresponding
# target triple (e.g. 'arm64-apple-ios12.2')
def availability_macro_to_swift_abi_target_triple(macro):
# Use a regex and split to pull out the components of an availability macro
# that is formatted like this:
# SwiftStdlib 5.0:macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2
matches = re.search(r'^[\s]*SwiftStdlib[\s]+([0-9\.]+)[\s]*:[\s]*(.+)', macro)
stdlib_vers = matches.group(1)
vers_by_platform = {}
for platform_vers in matches.group(2).split(', '):
components = platform_vers.split(' ')
vers_by_platform[components[0]] = components[1]
platform = {
'macosx': 'macOS',
'ios': 'iOS',
'maccatalyst': 'iOS',
'tvos': 'tvOS',
'watchos': 'watchOS'
}.get(run_os)
if platform is None:
return stdlib_vers, config.variant_triple
os_vers = vers_by_platform.get(platform)
if os_vers is None:
return stdlib_vers, config.variant_triple
if run_os == 'maccatalyst':
return stdlib_vers, '%s-%s-ios%s-macabi' % (run_cpu, run_vendor, os_vers)
return stdlib_vers, '%s-%s-%s%s%s' % (run_cpu, run_vendor, run_os,
os_vers, run_environment)
# Add availability macros to the default frontend/driver flags and create target
# triple substitutions for each stdlib version.
for macro in load_availability_macros():
config.swift_frontend_test_options += " -define-availability '{0}'".format(macro)
config.swift_driver_test_options += " -Xfrontend -define-availability -Xfrontend '{0}'".format(macro)
(stdlib_vers, triple) = availability_macro_to_swift_abi_target_triple(macro)
config.substitutions.append(('%target-swift-abi-{}-triple'.format(stdlib_vers), triple))
differentiable_programming = lit_config.params.get('differentiable_programming', None)
if differentiable_programming is not None:
config.available_features.add('differentiable_programming')
string_processing = lit_config.params.get('string_processing', None)
if string_processing is not None:
config.available_features.add('string_processing')
backtracing = lit_config.params.get('backtracing', None)
if backtracing is not None:
config.available_features.add('backtracing')
backtrace_on_crash = lit_config.params.get('backtrace_on_crash', None)
if backtrace_on_crash is not None:
config.environment['SWIFT_BACKTRACE'] = 'enable=on'
# Make an explicit setting in the environment override whatever we did above
swift_backtrace = os.environ.get('SWIFT_BACKTRACE')
if swift_backtrace:
config.environment['SWIFT_BACKTRACE'] = swift_backtrace
threading = lit_config.params.get('threading', 'none')
config.available_features.add('threading_{}'.format(threading))
if threading != "none":
config.available_features.add('thread_safe_runtime')
config.substitutions.append(('%target-threading-opt',
'-DSWIFT_THREADING_{0}=1'.format(threading.upper())))
test_options = os.environ.get('SWIFT_TEST_OPTIONS')
if test_options:
config.swift_test_options += ' '
config.swift_test_options += test_options
config.swift_frontend_test_options += os.environ.get('SWIFT_FRONTEND_TEST_OPTIONS', '')
config.swift_driver_test_options += os.environ.get('SWIFT_DRIVER_TEST_OPTIONS', '')
config.swift_ide_test_test_options += os.environ.get('SWIFT_IDE_TEST_TEST_OPTIONS', '')
config.sil_test_options = os.environ.get('SIL_TEST_OPTIONS', '')
config.clang_module_cache_path = make_path(config.swift_test_results_dir, "clang-module-cache")
shutil.rmtree(config.clang_module_cache_path, ignore_errors=True)
mcp_opt = "-module-cache-path %s" % shell_quote(config.clang_module_cache_path)
clang_mcp_opt = "-fmodules-cache-path=%r" % config.clang_module_cache_path
lit_config.note("Using Clang module cache: " + config.clang_module_cache_path)
lit_config.note("Using test results dir: " + config.swift_test_results_dir)
completion_cache_path = make_path(config.swift_test_results_dir, "completion-cache")
shutil.rmtree(completion_cache_path, ignore_errors=True)
ccp_opt = "-completion-cache-path %r" % completion_cache_path
lit_config.note("Using code completion cache: " + completion_cache_path)
if kIsWindows:
config.swift_plugin_dir = config.swift_bin_dir
# FIXME: this is a workaround for the collsion between the build toolchain
# and the current build, this should be `make_path(config.swift_lib_dir, 'swift')`
config.swift_build_lib_dir = make_path(config.swift_lib_dir, 'swift', 'host')
else:
config.swift_plugin_dir = make_path(config.swift_lib_dir, 'swift', 'host', 'plugins')
config.swift_build_lib_dir = make_path(config.swift_lib_dir, 'swift', 'host')
if platform.system() == 'Darwin':
config.swift_driver = (
"env SDKROOT=%s %r %s %s %s"
% (shell_quote(config.host_sdkroot), config.swift, mcp_opt, config.swift_test_options, config.swift_driver_test_options))
config.swiftc_driver = (
"env SDKROOT=%s %r -toolchain-stdlib-rpath -Xlinker -rpath -Xlinker /usr/lib/swift %s %s %s"
% (shell_quote(config.host_sdkroot), config.swiftc, mcp_opt, config.swift_test_options, config.swift_driver_test_options))
config.host_build_swift = (
"%s -sdk %s -target %s -no-toolchain-stdlib-rpath -I %s -L %s" % (
config.swiftc_driver,
config.host_sdkroot,
config.host_triple,
config.swift_build_lib_dir,
config.swift_build_lib_dir
)
)
else:
config.swift_driver = (
"%r %s %s %s"
% (config.swift, mcp_opt, config.swift_test_options, config.swift_driver_test_options))
if kIsWindows:
config.swift_driver += " -libc " + config.swift_stdlib_msvc_runtime
config.swiftc_driver = (
"%r %s %s %s %s" % (
config.swiftc,
'' if kIsWindows else '-toolchain-stdlib-rpath',
mcp_opt,
config.swift_test_options,
config.swift_driver_test_options,
)
)
# Parse the host triple.
(host_cpu, host_vendor, host_os, host_vers) = re.match('([^-]+)-([^-]+)-([^0-9-]+)(.*)', config.host_triple).groups()
toolchain_lib_dir = make_path(config.swift_lib_dir, 'swift', host_os)
config.host_build_swift = (
"%s -target %s -g %s -I %s -L %s %s" % (
config.swiftc_driver,
config.host_triple,
'' if kIsWindows else '-no-toolchain-stdlib-rpath',
config.swift_build_lib_dir,
config.swift_build_lib_dir,
'' if kIsWindows else '-Xlinker -rpath -Xlinker {}'.format(toolchain_lib_dir)
)
)
config.substitutions.append( ('%llvm_obj_root', config.llvm_obj_root) )
config.substitutions.append( ('%swift-bin-dir', config.swift_bin_dir) )
config.substitutions.append( ('%swift-lib-dir', config.swift_lib_dir) )
config.substitutions.append( ('%swift-share-dir', config.swift_share_dir) )
config.substitutions.append( ('%swift-plugin-dir', config.swift_plugin_dir) )
config.substitutions.append( ('%llvm_src_root', config.llvm_src_root) )
config.substitutions.append( ('%swift_obj_root', config.swift_obj_root) )
config.substitutions.append( ('%swift_src_root', config.swift_src_root) )
config.substitutions.append( ('%{python}', config.python) )
config.substitutions.append( ('%{python.unquoted}', config.python_unquoted) )
config.substitutions.append( ('%mcp_opt', mcp_opt) )
config.substitutions.append( ('%swift_driver_plain', "%r" % config.swift) )
config.substitutions.append( ('%swiftc_driver_plain', "%r" % config.swiftc) )
config.substitutions.append( ('%swift_frontend_plain', "%r" % config.swift_frontend))
config.substitutions.append( ('%swift_driver', config.swift_driver) )
config.substitutions.append( ('%swiftc_driver', config.swiftc_driver) )
config.substitutions.append( ('%host-build-swift', config.host_build_swift) )
config.substitutions.append( ('%host_sdk', config.host_sdkroot) )
config.substitutions.append( ('%host_triple', config.host_triple) )
config.substitutions.append( ('%sil-opt', "%r %s %s" % (config.sil_opt, mcp_opt, config.sil_test_options)) )
config.substitutions.append( ('%sil-func-extractor', "%r %s" % (config.sil_func_extractor, mcp_opt)) )
config.substitutions.append( ('%sil-llvm-gen', "%r %s" % (config.sil_llvm_gen, mcp_opt)) )
config.substitutions.append( ('%sil-nm', "%r %s" % (config.sil_nm, mcp_opt)) )
config.substitutions.append( ('%sil-passpipeline-dumper', "%r" % (config.sil_passpipeline_dumper)) )
config.substitutions.append( ('%lldb-moduleimport-test', "%r %s" % (config.lldb_moduleimport_test, mcp_opt)) )
config.substitutions.append( ('%lldb-moduleimport-test-with-sdk',
'%s -sdk %r' % (config.lldb_moduleimport_test, config.variant_sdk)) )
config.substitutions.append( ('%swift-dump-pcm', "%r -dump-pcm" % config.swiftc) )
config.substitutions.append( ('%swift-ide-test_plain', config.swift_ide_test) )
config.substitutions.append( ('%swift-ide-test', "%r %s %s -swift-version %s %s" % (config.swift_ide_test, mcp_opt, ccp_opt, swift_version, config.resource_dir_opt)) )
config.substitutions.append( ('%swift-dependency-tool', config.swift_dependency_tool) )
config.substitutions.append( ('%swift-indent', config.swift_indent) )
config.substitutions.append( ('%llvm-link', config.llvm_link) )
config.substitutions.append( ('%swift-llvm-opt', config.swift_llvm_opt) )
config.substitutions.append( ('%llvm-dwarfdump', config.llvm_dwarfdump) )
config.substitutions.append( ('%llvm-readelf', config.llvm_readelf) )
config.substitutions.append( ('%llvm-dis', config.llvm_dis) )
config.substitutions.append( ('%llvm-nm', config.llvm_nm) )
config.substitutions.append( ('%llvm-readtapi', config.llvm_readtapi) )
config.substitutions.append( ('%llvm-size', config.llvm_size) )
config.substitutions.append( ('%swift-demangle-yamldump', config.swift_demangle_yamldump) )
config.substitutions.append( ('%swift-demangle', config.swift_demangle) )
config.substitutions.append( ('%Benchmark_O', config.benchmark_o) )
config.substitutions.append( ('%Benchmark_Driver', config.benchmark_driver) )
config.substitutions.append( ('%llvm-strings', config.llvm_strings) )
config.substitutions.append( ('%target-ptrauth', run_ptrauth ) )
config.substitutions.append( ('%swift-path', config.swift) )
config.substitutions.append( ('%swift-plugin-server', config.swift_plugin_server) )
config.substitutions.append( ('%validate-json', f"{config.python} -m json.tool") )
# This must come after all substitutions containing "%swift".
config.substitutions.append(
('%swift',
"%r %s -disable-objc-attr-requires-foundation-module %s %s"
% (config.swift_frontend, mcp_opt, config.swift_test_options, config.swift_frontend_test_options)) )
config.clang_include_dir = make_path(config.swift, '..', '..', 'include')
config.substitutions.append( ('%clang-include-dir', config.clang_include_dir) )
# Use this to build the basic set of Objective-C overlays.
config.substitutions.append(('%build-clang-importer-objc-overlays',
'%target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -enable-objc-interop -emit-module -o %t %clang-importer-sdk-path/swift-modules/ObjectiveC.swift -disable-objc-attr-requires-foundation-module && '
'%target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -enable-objc-interop -emit-module -o %t %clang-importer-sdk-path/swift-modules/CoreGraphics.swift && '
'%target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -enable-objc-interop -emit-module -o %t %clang-importer-sdk-path/swift-modules/CoreFoundation.swift && '
'%target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -enable-objc-interop -emit-module -o %t %clang-importer-sdk-path/swift-modules/Foundation.swift'))
# FIXME: BEGIN -enable-source-import hackaround
config.substitutions.append(('%clang-importer-sdk-concurrency-without-job-path',
'%r' % (make_path(config.test_source_root, 'Inputs', 'clang-importer-sdk'))))
config.substitutions.append(('%clang-importer-sdk-concurrency-without-job-nosource',
'-sdk %r' % (make_path(config.test_source_root, 'Inputs', 'clang-importer-sdk'))))
# FIXME: END -enable-source-import hackaround
config.substitutions.append(('%clang-importer-sdk-concurrency-without-job',
'-enable-source-import -sdk %r -I %r ' % (make_path(config.test_source_root, 'Inputs', 'clang-importer-sdk'),
make_path(config.test_source_root, 'Inputs', 'clang-importer-sdk', 'swift-modules-concurrency-without-job'))))
# FIXME: BEGIN -enable-source-import hackaround
config.substitutions.append(('%clang-importer-sdk-concurrency-typealias-struct-job-path',
'%r' % (make_path(config.test_source_root, 'Inputs', 'clang-importer-sdk'))))
config.substitutions.append(('%clang-importer-sdk-concurrency-typealias-struct-job-nosource',
'-sdk %r' % (make_path(config.test_source_root, 'Inputs', 'clang-importer-sdk'))))
# FIXME: END -enable-source-import hackaround
config.substitutions.append(('%clang-importer-sdk-concurrency-typealias-struct-job',
'-enable-source-import -sdk %r -I %r ' % (make_path(config.test_source_root, 'Inputs', 'clang-importer-sdk'),
make_path(config.test_source_root, 'Inputs', 'clang-importer-sdk', 'swift-modules-concurrency-typealias-struct-job'))))
# FIXME: BEGIN -enable-source-import hackaround
config.substitutions.append(('%clang-importer-sdk-concurrency-consuming-job-param-path',
'%r' % (make_path(config.test_source_root, 'Inputs', 'clang-importer-sdk'))))
config.substitutions.append(('%clang-importer-sdk-concurrency-consuming-job-param-nosource',
'-sdk %r' % (make_path(config.test_source_root, 'Inputs', 'clang-importer-sdk'))))
# FIXME: END -enable-source-import hackaround
config.substitutions.append(('%clang-importer-sdk-concurrency-consuming-job-param',
'-enable-source-import -sdk %r -I %r ' % (make_path(config.test_source_root, 'Inputs', 'clang-importer-sdk'),
make_path(config.test_source_root, 'Inputs', 'clang-importer-sdk', 'swift-modules-concurrency-consuming-job-param'))))
# FIXME: BEGIN -enable-source-import hackaround
config.substitutions.append(('%clang-importer-sdk-concurrency-owned-job-param-path',
'%r' % (make_path(config.test_source_root, 'Inputs', 'clang-importer-sdk'))))
config.substitutions.append(('%clang-importer-sdk-concurrency-owned-job-param-nosource',
'-sdk %r' % (make_path(config.test_source_root, 'Inputs', 'clang-importer-sdk'))))
# FIXME: END -enable-source-import hackaround
config.substitutions.append(('%clang-importer-sdk-concurrency-owned-job-param',
'-enable-source-import -sdk %r -I %r ' % (make_path(config.test_source_root, 'Inputs', 'clang-importer-sdk'),
make_path(config.test_source_root, 'Inputs', 'clang-importer-sdk', 'swift-modules-concurrency-owned-job-param'))))
# FIXME: BEGIN -enable-source-import hackaround
config.substitutions.append(('%clang-importer-sdk-path',
'%r' % (make_path(config.test_source_root, 'Inputs', 'clang-importer-sdk'))))
config.substitutions.append(('%clang-importer-sdk-nosource',
'-sdk %r' % (make_path(config.test_source_root, 'Inputs', 'clang-importer-sdk'))))
# FIXME: END -enable-source-import hackaround
config.substitutions.append(('%clang-importer-sdk',
'-enable-source-import -sdk %r -I %r ' % (make_path(config.test_source_root, 'Inputs', 'clang-importer-sdk'),
make_path(config.test_source_root, 'Inputs', 'clang-importer-sdk', 'swift-modules'))))
config.substitutions.append( ('%clang_apinotes',
"%r -cc1apinotes" %
(config.clang)) )
config.substitutions.append( ('%clangxx',
"%r %s" %
(config.clangxx, clang_mcp_opt)) )
# This must come after all substitutions containing "%clang".
# Note: %clang is the locally-built clang.
# To get Xcode's clang, use %target-clang.
config.substitutions.append( ('%clang',
"%r %s" %
(config.clang, clang_mcp_opt)) )
###
def disallow(execName):
warning = '''
echo '*** Do not use \'{0}\' in tests; use \'%''{0}\'. ***' &&
exit 1 && echo
'''
config.substitutions.append((' {0} '.format(execName),
warning.format(execName)))
disallow('swift')
disallow('swiftc')
disallow('swift_driver')
disallow('swiftc_driver')
disallow('sil-opt')
disallow('sil-func-extractor')
disallow('sil-llvm-gen')
disallow('sil-nm')
disallow('sil-passpipeline-dumper')
disallow('lldb-moduleimport-test')
disallow('swift-ide-test')
disallow('clang')
disallow('FileCheck')
disallow('llvm-dwarfdump')
disallow('llvm-dis')
config.substitutions.insert(0,
('%p',
'$(echo "*** Use %""S instead of %""p in the Swift test suite ***" >&2)'))
###
# Set available features we allow tests to conditionalize on.
if platform.system() != 'Windows':
config.available_features.add('crash-recovery')
# Add each available build target CPU as a feature.
for target in config.llvm_code_generators:
config.available_features.add("CODEGENERATOR=" + target)
# Add the run target CPU, OS, and pointer size as features.
config.available_features.add("CPU=" + run_cpu)
config.available_features.add("OS=" + run_os)
config.available_features.add("PTRSIZE=" + run_ptrsize)
config.available_features.add("VENDOR=" + run_vendor)
config.available_features.add("SWIFT_VERSION=" + swift_version)
if "optimized_stdlib" in config.available_features:
config.available_features.add("optimized_stdlib_" + run_cpu)
swift_test_mode = lit_config.params.get('swift_test_mode', 'optimize_none')
swift_execution_tests_extra_flags = ''
if swift_test_mode == 'optimize_none':
config.available_features.add("nonexecutable_test")
config.available_features.add("executable_test")
config.available_features.add("swift_test_mode_optimize_none")
# Add the cpu as a feature so we can selectively disable tests in an
# optimize mode for a cpu.
config.available_features.add("swift_test_mode_optimize_none_" + run_cpu)
swift_execution_tests_extra_flags = ''
elif swift_test_mode == 'optimize_none_with_implicit_dynamic':
config.available_features.add("executable_test")
config.limit_to_features.add("executable_test")
config.available_features.add("swift_test_mode_optimize_none_with_implicit_dynamic")
# Add the cpu as a feature so we can selectively disable tests in an
# optimize mode for a cpu.
config.available_features.add("swift_test_mode_optimize_none_" + run_cpu)
swift_execution_tests_extra_flags = '-Xfrontend -enable-implicit-dynamic -Xfrontend -enable-private-imports -Xfrontend -enable-dynamic-replacement-chaining'
elif swift_test_mode == 'optimize_with_implicit_dynamic':
config.available_features.add("executable_test")
config.limit_to_features.add("executable_test")
config.available_features.add("swift_test_mode_optimize_with_implicit_dynamic")
# Add the cpu as a feature so we can selectively disable tests in an
# optimize mode for a cpu.
config.available_features.add("swift_test_mode_optimize_" + run_cpu)
swift_execution_tests_extra_flags = '-O -Xfrontend -enable-implicit-dynamic -Xfrontend -enable-private-imports -Xfrontend -enable-dynamic-replacement-chaining'
elif swift_test_mode == 'optimize':
config.available_features.add("executable_test")
config.limit_to_features.add("executable_test")
config.available_features.add("swift_test_mode_optimize")
# Add the cpu as a feature so we can selectively disable tests in an
# optimize mode for a cpu.
config.available_features.add("swift_test_mode_optimize_" + run_cpu)
swift_execution_tests_extra_flags = '-O'
elif swift_test_mode == 'optimize_size':
config.available_features.add("executable_test")
config.limit_to_features.add("executable_test")
config.available_features.add("swift_test_mode_optimize_size")
# Add the cpu as a feature so we can selectively disable tests in an
# optimize mode for a cpu.
config.available_features.add("swift_test_mode_optimize_" + run_cpu)
swift_execution_tests_extra_flags = '-Osize'
elif swift_test_mode == 'optimize_unchecked':
config.available_features.add("executable_test")
config.limit_to_features.add("executable_test")
config.available_features.add("swift_test_mode_optimize_unchecked")
# Add the cpu as a feature so we can selectively disable tests in an
# optimize mode for a cpu.
config.available_features.add("swift_test_mode_optimize_unchecked_" + run_cpu)
swift_execution_tests_extra_flags = '-Ounchecked'
elif swift_test_mode == 'only_executable':
config.available_features.add("executable_test")
config.limit_to_features.add("executable_test")
elif swift_test_mode == 'only_non_executable':
config.available_features.add("nonexecutable_test")
elif swift_test_mode == 'with_cxx_interop':
config.available_features.add("nonexecutable_test")
config.available_features.add("executable_test")
config.available_features.add("with_cxx_interop")
config.swift_frontend_test_options += ' -cxx-interoperability-mode=default'
config.swift_driver_test_options += ' -cxx-interoperability-mode=default'
config.swift_ide_test_test_options += ' -cxx-interoperability-mode=default'
else:
lit_config.fatal("Unknown test mode %r" % swift_test_mode)
swift_test_subset = lit_config.params.get('swift_test_subset', 'validation')
if swift_test_subset in ['primary', 'validation', 'only_validation']:
# No extra flags needed.
pass
elif swift_test_subset == 'all':
config.available_features.add("long_test")
config.available_features.add("stress_test")
elif swift_test_subset == 'only_long':
config.available_features.add("long_test")
config.limit_to_features.add("long_test")
config.limit_to_features.discard("executable_test")
elif swift_test_subset == 'only_stress':
config.available_features.add("stress_test")
config.limit_to_features.add("stress_test")
config.limit_to_features.discard("executable_test")
elif swift_test_subset == 'only_early_swiftdriver':
# Point this subset at a driver-specific set of tests. These are the known reduced subset
# of tests to verify the basic functionality of the standalone (early) swift-driver.
config.test_source_root = os.path.join(config.test_source_root, 'Driver', 'Dependencies')
else:
lit_config.fatal("Unknown test mode %r" % swift_test_subset)
if 'swift_evolve' in lit_config.params:
config.available_features.add("swift_evolve")
if not 'swift_driver' in lit_config.params:
config.available_features.add("cplusplus_driver")
# Check if we need to run lit tests using the legacy driver or the new driver
# The default for existing test runs is to use the legacy driver.
# The new driver is tested separately.
if swift_test_subset != 'only_early_swiftdriver' and\
os.environ.get('SWIFT_FORCE_TEST_NEW_DRIVER') is None:
config.environment['SWIFT_USE_OLD_DRIVER'] = '1'
config.environment['SWIFT_AVOID_WARNING_USING_OLD_DRIVER'] = '1'
# Enable benchmark testing when the binary is found (has fully qualified path).
if config.benchmark_o != 'Benchmark_O':
config.available_features.add('benchmark')
# Add substitutions for the run target triple, CPU, OS, and pointer size.
config.substitutions.append(('%target-triple', config.variant_triple))
# Keep track of which sanitizers need to be enabled (matters for some tests)
config.sanitizers = []
if 'asan' in config.available_features:
config.sanitizers.append('address')
if run_vendor == 'apple':
if run_os == 'maccatalyst':
config.stable_abi_triple = '%s-%s-ios13.1-macabi' % (run_cpu, run_vendor)
config.pre_stable_abi_triple = config.stable_abi_triple
config.next_stable_abi_triple = config.stable_abi_triple
config.future_abi_triple = '%s-%s-ios99-macabi' % (run_cpu, run_vendor)
config.available_features.add('swift_stable_abi')
else:
# iOS 12.2 does not support 32-bit targets, so we cannot run tests that
# want to deploy to an iOS that has Swift in the OS.
if run_os == 'ios' and run_ptrsize == '32':
pre_stable_version = '10'
else:
config.available_features.add('swift_stable_abi')
PRE_STABLE_VERSION = {
'macosx': '10.14.3',
'ios': '12.1',
'maccatalyst': '12.1',
'tvos': '12.1',
'watchos': '5.1'
}
pre_stable_version = PRE_STABLE_VERSION.get(run_os, '')
config.pre_stable_abi_triple = '%s-%s-%s%s%s' % (run_cpu, run_vendor, run_os,
pre_stable_version, run_environment)
STABLE_VERSION = {
'macosx': '10.14.4',
'ios': '12.2',
'maccatalyst': '12.2',
'tvos': '12.2',
'watchos': '5.2'
}
stable_version = STABLE_VERSION.get(run_os, '')
config.stable_abi_triple = '%s-%s-%s%s%s' % (run_cpu, run_vendor, run_os,
stable_version, run_environment)
NEXT_STABLE_VERSION = {
'macosx': '10.15',
'ios': '13',
'maccatalyst': '13',
'tvos': '13',
'watchos': '6'
}
next_stable_version = NEXT_STABLE_VERSION.get(run_os, '')
config.next_stable_abi_triple = '%s-%s-%s%s%s' % (run_cpu, run_vendor, run_os,
next_stable_version, run_environment)
FUTURE_VERSION = {
'macosx': '99.99',
'ios': '99.99',
'maccatalyst': '99.99',
'tvos': '99.99',
'watchos': '99.99'
}
future_version = FUTURE_VERSION.get(run_os, '')
config.future_triple = '%s-%s-%s%s%s' % (run_cpu, run_vendor, run_os,
future_version, run_environment)
else:
config.pre_stable_abi_triple = config.variant_triple
config.stable_abi_triple = config.variant_triple
config.next_stable_abi_triple = config.variant_triple
config.future_triple = config.variant_triple
# On Apple platforms, this substitution names the maximum OS version *without*
# Swift in the OS. On non-Apple platforms this is equivalent to %target-triple.
config.substitutions.append(('%target-pre-stable-abi-triple',
config.pre_stable_abi_triple))
# On Apple platforms, this substitution names the minimum OS version with
# Swift 5.0 in the OS. On non-Apple platforms this is equivalent to %target-triple.
config.substitutions.append(('%target-stable-abi-triple',
config.stable_abi_triple))
# On Apple platforms, this substitution names the minimum OS version with
# Swift 5.1 in the OS, and an Objective-C runtime supporting class stubs.
config.substitutions.append(('%target-next-stable-abi-triple',
config.next_stable_abi_triple))
config.substitutions.append(('%target-future-triple',
config.future_triple))
config.substitutions.append(('%target-cpu', run_cpu))
target_os_abi = run_os
target_os_is_maccatalyst = "FALSE"
target_mandates_stable_abi = "FALSE"
if (run_cpu in ('arm64e',) or \
(run_os == 'watchos' and run_cpu == 'x86_64')):
target_mandates_stable_abi = "TRUE"
config.available_features.add('swift_only_stable_abi')
if run_os in ('maccatalyst',):
# For purposes of ABI, treat maccatalyst as macosx since the maccatalyst ABI
# must match the macosx ABI.
target_os_abi = 'macosx'
target_os_is_maccatalyst = "TRUE"
config.available_features.add("OS=ios")
# macOS and simulators on ASi use the stable ABI
if (run_os in ('macosx',) or 'simulator' in run_environment) and run_cpu in ('arm64',):
target_mandates_stable_abi = "TRUE"
config.available_features.add('swift_only_stable_abi')
if run_os in (
'linux-android', 'linux-androideabi', # Android
'freebsd', 'openbsd', # BSD
'linux-gnu', 'linux-gnueabihf', # Linux
'windows-cygnus', 'windows-gnu', 'windows-msvc', # Windows
):
target_mandates_stable_abi = "TRUE"
config.available_features.add('swift_only_stable_abi')
config.substitutions.append(('%target-os-abi', target_os_abi))
config.substitutions.append(('%target-os-is-maccatalyst', target_os_is_maccatalyst))
config.substitutions.append(('%target-mandates-stable-abi',
target_mandates_stable_abi))
config.substitutions.append(('%target-endian', run_endian))
config.substitutions.append(('%target-os', run_os))