Skip to content

Commit 2887f40

Browse files
committed
Have refactor-check-compiles pass down -I -sdk -target
Forward these flags to both swift-frontend and swift-refactor.
1 parent b03c06f commit 2887f40

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

utils/refactor-check-compiles.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ def parse_args():
3333
- swift-refactor
3434
- temp-dir
3535
- enable-experimental-concurrency (sent to both)
36+
- I (sent to both)
37+
- sdk (sent to both)
38+
- target (sent to both)
3639
""")
3740

3841
parser.add_argument(
@@ -71,6 +74,19 @@ def parse_args():
7174
swift-frontend
7275
'''
7376
)
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+
)
7490

7591
return parser.parse_known_args()
7692

@@ -81,18 +97,24 @@ def main():
8197
args.pos.replace(':', '.')
8298
temp_file_path = os.path.join(args.temp_dir, temp_file_name)
8399

84-
extra_frontend_args = []
100+
extra_both_args = []
85101
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]
88110

89111
dump_text_output = run_cmd([
90112
args.swift_refactor,
91113
'-dump-text',
92114
'-source-filename', args.source_filename,
93115
'-rewritten-output-file', temp_file_path,
94116
'-pos', args.pos
95-
] + extra_refactor_args, desc='producing edit').decode("utf-8")
117+
] + extra_refactor_args + extra_both_args, desc='producing edit').decode("utf-8")
96118
sys.stdout.write(dump_text_output)
97119

98120
run_cmd([
@@ -101,7 +123,7 @@ def main():
101123
temp_file_path,
102124
'-disable-availability-checking',
103125
'-warn-on-editor-placeholder'
104-
] + extra_frontend_args, desc='checking that rewritten file compiles')
126+
] + extra_both_args, desc='checking that rewritten file compiles')
105127

106128

107129
if __name__ == '__main__':

0 commit comments

Comments
 (0)