@@ -37,13 +37,16 @@ import site
37
37
site .addsitedir (os .path .dirname (__file__ ))
38
38
import swift_test
39
39
40
+ def make_path (* args ):
41
+ return os .path .normpath (os .path .join (* args ))
42
+
40
43
#
41
44
# Helper functions.
42
45
#
43
46
44
47
def darwin_get_sdk_version (sdk_path ):
45
- system_version_plist_path = os . path . join (
46
- sdk_path , "System" , "Library" , "CoreServices" , "SystemVersion.plist" )
48
+ system_version_plist_path = make_path ( sdk_path , "System" , "Library" ,
49
+ "CoreServices" , "SystemVersion.plist" )
47
50
name = subprocess .check_output (
48
51
["defaults" , "read" , system_version_plist_path ,
49
52
"ProductName" ]).rstrip ()
@@ -194,7 +197,7 @@ if swift_obj_root is not None:
194
197
append_to_env_path (llvm_tools_dir )
195
198
196
199
build_mode = lit_config .params .get ('build_mode' , '' )
197
- append_to_env_path (os . path . join (swift_obj_root , build_mode , 'bin' ))
200
+ append_to_env_path (make_path (swift_obj_root , build_mode , 'bin' ))
198
201
199
202
native_llvm_tools_path = lit_config .params .get ('native_llvm_tools_path' )
200
203
if native_llvm_tools_path is not None :
@@ -269,21 +272,21 @@ config.complete_test = inferSwiftBinary('complete-test')
269
272
config .swift_api_digester = inferSwiftBinary ('swift-api-digester' )
270
273
config .swift_refactor = inferSwiftBinary ('swift-refactor' )
271
274
272
- config .swift_utils = os . path . join (config .swift_src_root , 'utils' )
273
- config .line_directive = os . path . join (config .swift_utils , 'line-directive' )
274
- config .gyb = os . path . join (config .swift_utils , 'gyb' )
275
- config .rth = os . path . join (config .swift_utils , 'rth' ) # Resilience test helper
276
- config .scale_test = os . path . join (config .swift_utils , 'scale-test' )
277
- config .PathSanitizingFileCheck = os . path . join (config .swift_utils , 'PathSanitizingFileCheck' )
278
- config .swift_lib_dir = os . path . join ( os . path . dirname ( os . path . dirname ( config . swift )) , 'lib' )
279
- config .round_trip_syntax_test = os . path . join (config .swift_utils , 'round-trip-syntax-test' )
275
+ config .swift_utils = make_path (config .swift_src_root , 'utils' )
276
+ config .line_directive = make_path (config .swift_utils , 'line-directive' )
277
+ config .gyb = make_path (config .swift_utils , 'gyb' )
278
+ config .rth = make_path (config .swift_utils , 'rth' ) # Resilience test helper
279
+ config .scale_test = make_path (config .swift_utils , 'scale-test' )
280
+ config .PathSanitizingFileCheck = make_path (config .swift_utils , 'PathSanitizingFileCheck' )
281
+ config .swift_lib_dir = make_path ( config . swift , '..' , '..' , 'lib' )
282
+ config .round_trip_syntax_test = make_path (config .swift_utils , 'round-trip-syntax-test' )
280
283
281
284
# Find the resource directory. Assume it's near the swift compiler if not set.
282
285
test_resource_dir = lit_config .params .get ('test_resource_dir' )
283
286
if test_resource_dir :
284
287
resource_dir_opt = ("-resource-dir %s" % test_resource_dir )
285
288
else :
286
- test_resource_dir = os . path . join (config .swift_lib_dir , 'swift' )
289
+ test_resource_dir = make_path (config .swift_lib_dir , 'swift' )
287
290
resource_dir_opt = ""
288
291
stdlib_resource_dir_opt = resource_dir_opt
289
292
sourcekitd_framework_dir = config .swift_lib_dir
@@ -300,8 +303,8 @@ test_sdk_overlay_dir = lit_config.params.get('test_sdk_overlay_dir', None)
300
303
if test_sdk_overlay_dir is not None :
301
304
config .available_features .add ('sdk_overlay' )
302
305
303
- sdk_overlay_dir_opt = ("-I %s" % os . path . join (test_sdk_overlay_dir , run_cpu ))
304
- sdk_overlay_link_path_dir = os . path . join (test_sdk_overlay_dir , run_cpu )
306
+ sdk_overlay_dir_opt = ("-I %s" % make_path (test_sdk_overlay_dir , run_cpu ))
307
+ sdk_overlay_link_path_dir = make_path (test_sdk_overlay_dir , run_cpu )
305
308
sdk_overlay_link_path = ("-L %s" % sdk_overlay_link_path_dir )
306
309
sdk_overlay_linker_opt = (
307
310
"-L %s -Xlinker -rpath -Xlinker %s" %
@@ -326,14 +329,14 @@ config.swift_frontend_test_options = os.environ.get('SWIFT_FRONTEND_TEST_OPTIONS
326
329
config .swift_driver_test_options = os .environ .get ('SWIFT_DRIVER_TEST_OPTIONS' , '' )
327
330
config .sil_test_options = os .environ .get ('SIL_TEST_OPTIONS' , '' )
328
331
329
- clang_module_cache_path = os . path . join (config .swift_test_results_dir , "clang-module-cache" )
332
+ clang_module_cache_path = make_path (config .swift_test_results_dir , "clang-module-cache" )
330
333
shutil .rmtree (clang_module_cache_path , ignore_errors = True )
331
334
mcp_opt = "-module-cache-path %r" % clang_module_cache_path
332
335
clang_mcp_opt = "-fmodules-cache-path=%r" % clang_module_cache_path
333
336
lit_config .note ("Using Clang module cache: " + clang_module_cache_path )
334
337
lit_config .note ("Using test results dir: " + config .swift_test_results_dir )
335
338
336
- completion_cache_path = os . path . join (config .swift_test_results_dir , "completion-cache" )
339
+ completion_cache_path = make_path (config .swift_test_results_dir , "completion-cache" )
337
340
shutil .rmtree (completion_cache_path , ignore_errors = True )
338
341
ccp_opt = "-completion-cache-path %r" % completion_cache_path
339
342
lit_config .note ("Using code completion cache: " + completion_cache_path )
@@ -367,8 +370,7 @@ config.substitutions.append(
367
370
"%r -frontend %s -disable-objc-attr-requires-foundation-module %s %s"
368
371
% (config .swift , mcp_opt , config .swift_test_options , config .swift_frontend_test_options )) )
369
372
370
- config .clang_include_dir = \
371
- os .path .join (os .path .dirname (os .path .dirname (config .swift )), 'include' )
373
+ config .clang_include_dir = make_path (config .swift , '..' , '..' , 'include' )
372
374
config .substitutions .append ( ('%clang-include-dir' , config .clang_include_dir ) )
373
375
374
376
# Use this to build the basic set of Objective-C overlays.
@@ -380,15 +382,15 @@ config.substitutions.append(
380
382
381
383
# FIXME: BEGIN -enable-source-import hackaround
382
384
config .substitutions .append (('%clang-importer-sdk-path' ,
383
- '%r' % (os . path . join (config .test_source_root , 'Inputs' , 'clang-importer-sdk' ))))
385
+ '%r' % (make_path (config .test_source_root , 'Inputs' , 'clang-importer-sdk' ))))
384
386
385
387
config .substitutions .append (('%clang-importer-sdk-nosource' ,
386
- '-sdk %r' % (os . path . join (config .test_source_root , 'Inputs' , 'clang-importer-sdk' ))))
388
+ '-sdk %r' % (make_path (config .test_source_root , 'Inputs' , 'clang-importer-sdk' ))))
387
389
# FIXME: END -enable-source-import hackaround
388
390
389
391
config .substitutions .append (('%clang-importer-sdk' ,
390
- '-enable-source-import -sdk %r -I %r ' % (os . path . join (config .test_source_root , 'Inputs' , 'clang-importer-sdk' ),
391
- os . path . join (config .test_source_root , 'Inputs' , 'clang-importer-sdk' , 'swift-modules' ))))
392
+ '-enable-source-import -sdk %r -I %r ' % (make_path (config .test_source_root , 'Inputs' , 'clang-importer-sdk' ),
393
+ make_path (config .test_source_root , 'Inputs' , 'clang-importer-sdk' , 'swift-modules' ))))
392
394
393
395
config .substitutions .append ( ('%clang_apinotes' ,
394
396
"%r -cc1apinotes" %
@@ -567,8 +569,8 @@ if run_vendor == 'apple':
567
569
xcrun_prefix = (
568
570
"xcrun --toolchain %s --sdk %s" %
569
571
(config .darwin_xcrun_toolchain , config .variant_sdk ))
570
- extra_frameworks_dir = os . path . join (config .variant_sdk ,
571
- ".." , ".." , ".." , "Developer" , "Library" , "Frameworks" )
572
+ extra_frameworks_dir = make_path (config .variant_sdk , ".." , ".." , ".." ,
573
+ "Developer" , "Library" , "Frameworks" )
572
574
target_options = (
573
575
"-target %s %s %s" %
574
576
(config .variant_triple , resource_dir_opt , mcp_opt ))
@@ -711,9 +713,7 @@ if run_vendor == 'apple':
711
713
(sw_vers_name , sw_vers_vers , sw_vers_build ))
712
714
713
715
config .target_sdk_name = xcrun_sdk_name
714
- config .target_ld = (
715
- "%s ld -L%s" %
716
- (xcrun_prefix , os .path .join (test_resource_dir , config .target_sdk_name )))
716
+ config .target_ld = "%s ld -L%r" % (xcrun_prefix , make_path (test_resource_dir , config .target_sdk_name ))
717
717
config .target_swift_frontend = (
718
718
"%s -frontend %s -sdk %s %s %s" %
719
719
(config .swiftc , target_options , config .variant_sdk ,
@@ -826,9 +826,7 @@ elif run_os in ['linux-gnu', 'linux-gnueabihf', 'freebsd', 'windows-cygnus', 'wi
826
826
config .target_clang = (
827
827
"clang++ -target %s %s" %
828
828
(config .variant_triple , clang_mcp_opt ))
829
- config .target_ld = (
830
- "ld -L%s" %
831
- (os .path .join (test_resource_dir , config .target_sdk_name )))
829
+ config .target_ld = "ld -L%r" % (make_path (test_resource_dir , config .target_sdk_name ))
832
830
elif run_os == 'linux-androideabi' :
833
831
lit_config .note ("Testing Android " + config .variant_triple )
834
832
config .target_object_format = "elf"
@@ -837,16 +835,15 @@ elif run_os == 'linux-androideabi':
837
835
config .target_swift_autolink_extract = inferSwiftBinary ("swift-autolink-extract" )
838
836
config .target_sdk_name = "android"
839
837
android_linker_opt = "-L {libcxx} -L {libgcc}" .format (
840
- libcxx = os .path .join (config .android_ndk_path ,
841
- "sources" , "cxx-stl" , "llvm-libc++" , "libs" ,
842
- "armeabi-v7a" ),
843
- libgcc = os .path .join (config .android_ndk_path ,
844
- "toolchains" ,
845
- "arm-linux-androideabi-{}" .format (
846
- config .android_ndk_gcc_version ),
847
- "prebuilt" , "linux-x86_64" , "lib" , "gcc" ,
848
- "arm-linux-androideabi" ,
849
- "{}.x" .format (config .android_ndk_gcc_version )))
838
+ libcxx = make_path (config .android_ndk_path ,
839
+ "sources" , "cxx-stl" , "llvm-libc++" , "libs" ,
840
+ "armeabi-v7a" ),
841
+ libgcc = make_path (config .android_ndk_path ,
842
+ "toolchains" ,
843
+ "arm-linux-androideabi-{}" .format (config .android_ndk_gcc_version ),
844
+ "prebuilt" , "linux-x86_64" , "lib" , "gcc" ,
845
+ "arm-linux-androideabi" ,
846
+ "{}.x" .format (config .android_ndk_gcc_version )))
850
847
config .target_build_swift = (
851
848
'%s -target %s -sdk %s %s -Xlinker -pie %s %s %s %s %s'
852
849
% (config .swiftc , config .variant_triple , config .variant_sdk ,
@@ -864,8 +861,7 @@ elif run_os == 'linux-androideabi':
864
861
config .swift_frontend_test_options ))
865
862
subst_target_swift_frontend_mock_sdk = config .target_swift_frontend
866
863
subst_target_swift_frontend_mock_sdk_after = ""
867
- config .target_run = os .path .join (
868
- config .swift_src_root , 'utils' , 'android' , 'adb_test_runner.py' )
864
+ config .target_run = make_path (config .swift_src_root , 'utils' , 'android' , 'adb_test_runner.py' )
869
865
# FIXME: Include -sdk in this invocation.
870
866
config .target_sil_opt = (
871
867
'%s -target %s %s %s %s' %
@@ -887,15 +883,10 @@ elif run_os == 'linux-androideabi':
887
883
"clang++ -target %s %s" %
888
884
(config .variant_triple , clang_mcp_opt ))
889
885
config .target_ld = "{} -L{}" .format (
890
- os .path .join (
891
- config .android_ndk_path ,
892
- 'toolchains' ,
893
- 'arm-linux-androideabi-{}' .format (config .android_ndk_gcc_version ),
894
- 'prebuilt' ,
895
- 'linux-x86_64' ,
896
- 'arm-linux-androideabi' ,
897
- 'bin' ),
898
- os .path .join (test_resource_dir , config .target_sdk_name ))
886
+ make_path (config .android_ndk_path , 'toolchains' ,
887
+ 'arm-linux-androideabi-{}' .format (config .android_ndk_gcc_version ),
888
+ 'prebuilt' , 'linux-x86_64' , 'arm-linux-androideabi' , 'bin' ),
889
+ make_path (test_resource_dir , config .target_sdk_name ))
899
890
# The Swift interpreter is not available when targeting Android.
900
891
config .available_features .remove ('swift_interpreter' )
901
892
@@ -936,7 +927,7 @@ def source_compiler_rt_libs(path):
936
927
if lib .startswith ('libclang_rt.' )
937
928
and config .compiler_rt_platform in lib ])
938
929
939
- source_compiler_rt_libs (os . path . join (test_resource_dir , 'clang' , 'lib' ,
930
+ source_compiler_rt_libs (make_path (test_resource_dir , 'clang' , 'lib' ,
940
931
platform .system ().lower ()))
941
932
942
933
def check_runtime_libs (features_to_check ):
@@ -1089,10 +1080,10 @@ if hasattr(config, 'target_swift_autolink_extract'):
1089
1080
config .substitutions .append (('%target-swift-modulewrap' ,
1090
1081
config .target_swift_modulewrap ))
1091
1082
1092
- platform_module_dir = os . path . join (test_resource_dir , '%target-sdk-name' , run_cpu )
1083
+ platform_module_dir = make_path (test_resource_dir , '%target-sdk-name' , run_cpu )
1093
1084
lit_config .note ('Using platform module dir: ' + platform_module_dir )
1094
1085
if test_sdk_overlay_dir is not None :
1095
- platform_sdk_overlay_dir = os . path . join (test_sdk_overlay_dir , run_cpu )
1086
+ platform_sdk_overlay_dir = make_path (test_sdk_overlay_dir , run_cpu )
1096
1087
else :
1097
1088
platform_sdk_overlay_dir = platform_module_dir
1098
1089
@@ -1121,8 +1112,8 @@ config.substitutions.append(
1121
1112
config .substitutions .append (('%raw-FileCheck' , pipes .quote (config .filecheck )))
1122
1113
1123
1114
# If static stdlib is present, enable static stdlib tests
1124
- static_stdlib_path = os . path . join ( os . path . join ( config .swift_lib_dir ,"swift_static" ) , config .target_sdk_name )
1125
- libswiftCore_path = os . path . join (static_stdlib_path ,"libswiftCore.a" )
1115
+ static_stdlib_path = make_path ( config .swift_lib_dir , "swift_static" , config .target_sdk_name )
1116
+ libswiftCore_path = make_path (static_stdlib_path , "libswiftCore.a" )
1126
1117
if os .path .exists (libswiftCore_path ):
1127
1118
config .available_features .add ("static_stdlib" )
1128
1119
config .substitutions .append (('%target-static-stdlib-path' , static_stdlib_path ))
0 commit comments