@@ -1190,19 +1190,26 @@ def use_interpreter_for_simple_runs():
11901190 # path.
11911191 result += (
11921192 'env SWIFT_INTERPRETER=%r %s %r %s -module-name main %s %s %s '
1193- % (config .swift , xcrun_prefix , config .swift , target_options ,
1194- config .swift_test_options ,
1195- config .swift_driver_test_options ,
1196- swift_execution_tests_extra_flags ))
1193+ % (
1194+ escape_for_substitute_captures (config .swift ),
1195+ escape_for_substitute_captures (xcrun_prefix ),
1196+ escape_for_substitute_captures (config .swift ),
1197+ escape_for_substitute_captures (target_options ),
1198+ escape_for_substitute_captures (config .swift_test_options ),
1199+ escape_for_substitute_captures (config .swift_driver_test_options ),
1200+ escape_for_substitute_captures (swift_execution_tests_extra_flags )
1201+ )
1202+ )
11971203 if stdlib :
11981204 result += '-Xfrontend -disable-access-control '
11991205 if parameterized :
1200- result += ' \ \ 1 '
1206+ result += r' \1 '
12011207 if gyb :
12021208 result += '%t/main.swift'
12031209 else :
12041210 result += '%s'
1205- return result
1211+ return SubstituteCaptures (result )
1212+
12061213 config .target_run_stdlib_swiftgyb = make_simple_target_run (gyb = True )
12071214 config .target_run_simple_swiftgyb = make_simple_target_run (gyb = True )
12081215 config .target_run_stdlib_swift = make_simple_target_run (stdlib = True )
@@ -1597,11 +1604,12 @@ if run_vendor == 'apple':
15971604 "%s %s %s" %
15981605 (xcrun_prefix , config .clangxx , config .target_cc_options ))
15991606
1600- config .target_build_swift_dylib = (
1601- "%s -parse-as-library -emit-library -o '\\ 1' "
1602- "-Xlinker -install_name -Xlinker @executable_path/$(basename '\\ 1')"
1603- % (config .target_build_swift ))
1604- config .target_add_rpath = r'-Xlinker -rpath -Xlinker \1'
1607+ config .target_build_swift_dylib = SubstituteCaptures (
1608+ f"{ escape_for_substitute_captures (config .target_build_swift )} "
1609+ r" -parse-as-library -emit-library -o '\1'"
1610+ r" -Xlinker -install_name -Xlinker @executable_path/$(basename '\1')"
1611+ )
1612+ config .target_add_rpath = SubstituteCaptures (r'-Xlinker -rpath -Xlinker \1' )
16051613
16061614 target_future = format ('%s-apple-%s%s%s' % (run_cpu , run_os , target_future_version , run_environment ))
16071615
@@ -1833,10 +1841,11 @@ elif (run_os in ['linux-gnu', 'linux-gnueabihf', 'freebsd', 'openbsd', 'windows-
18331841 config .swift_test_options , config .swift_driver_test_options ,
18341842 swift_execution_tests_extra_flags ))
18351843 config .target_codesign = "echo"
1836- config .target_build_swift_dylib = (
1837- "%s -parse-as-library -emit-library -o '\\ 1'"
1838- % (config .target_build_swift ))
1839- config .target_add_rpath = r'-Xlinker -rpath -Xlinker \1'
1844+ config .target_build_swift_dylib = SubstituteCaptures (
1845+ f"{ escape_for_substitute_captures (config .target_build_swift )} "
1846+ r" -parse-as-library -emit-library -o '\1'"
1847+ )
1848+ config .target_add_rpath = SubstituteCaptures (r'-Xlinker -rpath -Xlinker \1' )
18401849 config .target_swift_frontend = (
18411850 '%s -target %s %s %s %s %s '
18421851 % (config .swift_frontend , config .variant_triple , config .resource_dir_opt , mcp_opt ,
@@ -1926,11 +1935,11 @@ elif run_os == 'linux-androideabi' or run_os == 'linux-android':
19261935 config .resource_dir_opt , mcp_opt , config .swift_test_options ,
19271936 config .swift_driver_test_options , swift_execution_tests_extra_flags ])
19281937 config .target_codesign = "echo"
1929- config .target_build_swift_dylib = ' ' . join ([
1930- config .target_build_swift ,
1931- ' -parse-as-library' , ' -emit-library' ,
1932- '-o' , "' \\ 1'" ] )
1933- config .target_add_rpath = r'-Xlinker -rpath -Xlinker \1'
1938+ config .target_build_swift_dylib = SubstituteCaptures (
1939+ f" { escape_for_substitute_captures ( config .target_build_swift ) } "
1940+ r" -parse-as-library -emit-library -o '\1'"
1941+ )
1942+ config .target_add_rpath = SubstituteCaptures ( r'-Xlinker -rpath -Xlinker \1' )
19341943 config .target_swift_frontend = ' ' .join ([
19351944 config .swift_frontend ,
19361945 '-target' , config .variant_triple ,
@@ -2010,9 +2019,10 @@ elif run_os == 'wasi':
20102019 mcp_opt , config .swift_test_options ,
20112020 config .swift_driver_test_options , swift_execution_tests_extra_flags ])
20122021 config .target_codesign = "echo"
2013- config .target_build_swift_dylib = (
2014- "%s -parse-as-library -emit-library -static -o '\\ 1'"
2015- % (config .target_build_swift ))
2022+ config .target_build_swift_dylib = SubstituteCaptures (
2023+ f"{ escape_for_substitute_captures (config .target_build_swift )} "
2024+ r" -parse-as-library -emit-library -static -o '\1'"
2025+ )
20162026 config .target_add_rpath = ''
20172027 config .target_swift_frontend = ' ' .join ([
20182028 config .swift_frontend ,
@@ -2093,9 +2103,10 @@ elif config.external_embedded_platform:
20932103 mcp_opt , config .swift_test_options ,
20942104 config .swift_driver_test_options , swift_execution_tests_extra_flags ])
20952105 config .target_codesign = "echo"
2096- config .target_build_swift_dylib = (
2097- "%s -parse-as-library -emit-library -static -o '\\ 1'"
2098- % (config .target_build_swift ))
2106+ config .target_build_swift_dylib = SubstituteCaptures (
2107+ f"{ escape_for_substitute_captures (config .target_build_swift )} "
2108+ r" -parse-as-library -emit-library -static -o '\1'"
2109+ )
20992110 config .target_add_rpath = ''
21002111 config .target_swift_frontend = ' ' .join ([
21012112 config .swift_frontend ,
@@ -2965,8 +2976,7 @@ config.substitutions.insert(0, ('%target-static-library-name\(([^)]+)\)',
29652976 SubstituteCaptures (r'%s\1%s' % (
29662977 escape_for_substitute_captures (config .target_static_library_prefix ),
29672978 escape_for_substitute_captures (config .target_static_library_suffix )))))
2968- config .substitutions .append (('%target-rpath\(([^)]+)\)' ,
2969- SubstituteCaptures (config .target_add_rpath )))
2979+ config .substitutions .append (('%target-rpath\(([^)]+)\)' , config .target_add_rpath ))
29702980
29712981config .substitutions .append (('%target-resilience-test' , config .target_resilience_test ))
29722982
0 commit comments