@@ -97,7 +97,7 @@ def create_directory(path):
97
97
98
98
99
99
class DumpConfig :
100
- def __init__ (self , tool_path , platform , platform_alias ):
100
+ def __init__ (self , tool_path , platform , platform_alias , verbose ):
101
101
target_map = {
102
102
'iphoneos' : 'arm64-apple-ios13.0' ,
103
103
'macosx' : 'x86_64-apple-macosx10.15' ,
@@ -120,30 +120,45 @@ def __init__(self, tool_path, platform, platform_alias):
120
120
iOSSupport = self .sdk + \
121
121
'/System/iOSSupport/System/Library/Frameworks'
122
122
self .frameworks .extend ([iOSSupport ])
123
-
124
- def run (self , output , module , swift_ver , opts , verbose ,
123
+ self ._environ = dict (os .environ )
124
+ self ._environ ['SWIFT_FORCE_MODULE_LOADING' ] = 'prefer-interface'
125
+ self .verbose = verbose
126
+
127
+ def dumpZipperedContent (self , cmd , output , module ):
128
+ dir_path = os .path .realpath (output + '/' + module )
129
+ file_path = os .path .realpath (dir_path + '/' + self .platform_alias +
130
+ '.json' )
131
+ create_directory (dir_path )
132
+ current_cmd = list (cmd )
133
+ current_cmd .extend (['-module' , module ])
134
+ current_cmd .extend (['-o' , file_path ])
135
+ check_call (current_cmd , env = self ._environ , verbose = self .verbose )
136
+
137
+ def run (self , output , module , swift_ver , opts ,
125
138
module_filter_flags , include_fixed_clang_modules ,
126
- separate_by_module ):
139
+ separate_by_module , zippered ):
127
140
cmd = [self .tool_path , '-sdk' , self .sdk , '-target' ,
128
141
self .target , '-dump-sdk' , '-module-cache-path' ,
129
142
'/tmp/ModuleCache' , '-swift-version' ,
130
143
swift_ver , '-abort-on-module-fail' ]
131
- _environ = dict (os .environ )
132
- _environ ['SWIFT_FORCE_MODULE_LOADING' ] = 'prefer-interface'
133
144
for path in self .frameworks :
134
145
cmd .extend (['-iframework' , path ])
135
146
for path in self .inputs :
136
147
cmd .extend (['-I' , path ])
137
148
cmd .extend (['-' + o for o in opts ])
138
- if verbose :
149
+ if self . verbose :
139
150
cmd .extend (['-v' ])
140
151
if module :
141
- cmd .extend (['-module' , module ])
142
- cmd .extend (['-o' , output ])
143
- check_call (cmd , env = _environ , verbose = verbose )
152
+ if zippered :
153
+ create_directory (output )
154
+ self .dumpZipperedContent (cmd , output , module )
155
+ else :
156
+ cmd .extend (['-module' , module ])
157
+ cmd .extend (['-o' , output ])
158
+ check_call (cmd , env = self ._environ , verbose = self .verbose )
144
159
else :
145
160
with tempfile .NamedTemporaryFile () as tmp :
146
- prepare_module_list (self .platform , tmp , verbose ,
161
+ prepare_module_list (self .platform , tmp , self . verbose ,
147
162
module_filter_flags ,
148
163
include_fixed_clang_modules )
149
164
if separate_by_module :
@@ -153,19 +168,11 @@ def run(self, output, module, swift_ver, opts, verbose,
153
168
# Skip comments
154
169
if module .startswith ('//' ):
155
170
continue
156
- dir_path = os .path .realpath (output + '/' + module )
157
- file_path = os .path .realpath (dir_path + '/' +
158
- self .platform_alias +
159
- '.json' )
160
- create_directory (dir_path )
161
- current_cmd = list (cmd )
162
- current_cmd .extend (['-module' , module ])
163
- current_cmd .extend (['-o' , file_path ])
164
- check_call (current_cmd , env = _environ , verbose = verbose )
171
+ self .dumpZipperedContent (cmd , output , module )
165
172
else :
166
173
cmd .extend (['-o' , output ])
167
174
cmd .extend (['-module-list-file' , tmp .name ])
168
- check_call (cmd , env = _environ , verbose = verbose )
175
+ check_call (cmd , env = self . _environ , verbose = self . verbose )
169
176
170
177
171
178
class DiagnoseConfig :
@@ -246,6 +253,11 @@ def main():
246
253
help = 'When importing entire SDK, dump content '
247
254
'seprately by module names' )
248
255
256
+ basic_group .add_argument ('--zippered' ,
257
+ action = 'store_true' ,
258
+ help = 'dump module content to a dir with files for'
259
+ 'seprately targets' )
260
+
249
261
basic_group .add_argument ('--platform-alias' , default = '' , help = '''
250
262
Specify a file name to use if using a platform name in json file isn't
251
263
optimal
@@ -272,13 +284,14 @@ def main():
272
284
if args .platform_alias == '' :
273
285
args .platform_alias = args .target
274
286
runner = DumpConfig (tool_path = args .tool_path , platform = args .target ,
275
- platform_alias = args .platform_alias )
287
+ platform_alias = args .platform_alias ,
288
+ verbose = args .v )
276
289
runner .run (output = args .output , module = args .module ,
277
290
swift_ver = args .swift_version , opts = args .opts ,
278
- verbose = args .v ,
279
291
module_filter_flags = module_filter_flags ,
280
292
include_fixed_clang_modules = include_fixed_clang_modules ,
281
- separate_by_module = args .separate_by_module )
293
+ separate_by_module = args .separate_by_module ,
294
+ zippered = args .zippered )
282
295
elif args .action == 'diagnose' :
283
296
if not args .dump_before :
284
297
fatal_error ("Need to specify --dump-before" )
0 commit comments