@@ -33,6 +33,9 @@ def parse_args():
33
33
- swift-refactor
34
34
- temp-dir
35
35
- enable-experimental-concurrency (sent to both)
36
+ - I (sent to both)
37
+ - sdk (sent to both)
38
+ - target (sent to both)
36
39
""" )
37
40
38
41
parser .add_argument (
@@ -71,6 +74,19 @@ def parse_args():
71
74
swift-frontend
72
75
'''
73
76
)
77
+ parser .add_argument (
78
+ '-I' ,
79
+ action = 'append' ,
80
+ help = 'Add a directory to the import search path'
81
+ )
82
+ parser .add_argument (
83
+ '-sdk' ,
84
+ help = 'Path to the SDK to build against'
85
+ )
86
+ parser .add_argument (
87
+ '-target' ,
88
+ help = 'The target triple to build for'
89
+ )
74
90
75
91
return parser .parse_known_args ()
76
92
@@ -81,10 +97,16 @@ def main():
81
97
args .pos .replace (':' , '.' )
82
98
temp_file_path = os .path .join (args .temp_dir , temp_file_name )
83
99
84
- extra_frontend_args = []
100
+ extra_both_args = []
85
101
if args .enable_experimental_concurrency :
86
- extra_refactor_args .append ('-enable-experimental-concurrency' )
87
- extra_frontend_args .append ('-enable-experimental-concurrency' )
102
+ extra_both_args .append ('-enable-experimental-concurrency' )
103
+ if args .I :
104
+ for path in args .I :
105
+ extra_both_args += ['-I' , path ]
106
+ if args .sdk :
107
+ extra_both_args += ['-sdk' , args .sdk ]
108
+ if args .target :
109
+ extra_both_args += ['-target' , args .target ]
88
110
89
111
# FIXME: `refactor-check-compiles` should generate both `-dump-text` and
90
112
# `dump-rewritten` from a single `swift-refactor` invocation (SR-14587).
@@ -93,14 +115,14 @@ def main():
93
115
'-dump-text' ,
94
116
'-source-filename' , args .source_filename ,
95
117
'-pos' , args .pos
96
- ] + extra_refactor_args , desc = 'producing edit' ).decode ("utf-8" )
118
+ ] + extra_refactor_args + extra_both_args , desc = 'producing edit' ).decode ("utf-8" )
97
119
98
120
dump_rewritten_output = run_cmd ([
99
121
args .swift_refactor ,
100
122
'-dump-rewritten' ,
101
123
'-source-filename' , args .source_filename ,
102
124
'-pos' , args .pos
103
- ] + extra_refactor_args , desc = 'producing rewritten file' )
125
+ ] + extra_refactor_args + extra_both_args , desc = 'producing rewritten file' )
104
126
with open (temp_file_path , 'wb' ) as f :
105
127
f .write (dump_rewritten_output )
106
128
@@ -110,7 +132,7 @@ def main():
110
132
temp_file_path ,
111
133
'-disable-availability-checking' ,
112
134
'-warn-on-editor-placeholder'
113
- ] + extra_frontend_args , desc = 'checking that rewritten file compiles' )
135
+ ] + extra_both_args , desc = 'checking that rewritten file compiles' )
114
136
sys .stdout .write (dump_text_output )
115
137
116
138
0 commit comments