@@ -195,14 +195,17 @@ def fq_name(node):
195
195
return enums
196
196
197
197
198
- def write_json (messages , modules , extra_inputs : list [str ], filename : str , stable_ids ):
198
+ def write_json (messages , modules , enums , extra_inputs : list [str ], filename : str , stable_ids ):
199
199
str_catalog = dict (messages = list (messages .values ()), modules = list (modules .values ()))
200
200
for msg in stable_ids .get ("messages" ):
201
201
if not msg in str_catalog ["messages" ]:
202
202
str_catalog ["messages" ].append (msg )
203
203
for mod in stable_ids .get ("modules" ):
204
204
if not mod in str_catalog ["modules" ]:
205
205
str_catalog ["modules" ].append (mod )
206
+ str_catalog ["enums" ] = {}
207
+ for (k , (_ , v )) in enums .items ():
208
+ str_catalog ["enums" ].update ({k : {value : name for (name , value ) in v .items ()}})
206
209
for extra in extra_inputs :
207
210
with open (extra , "r" ) as f :
208
211
str_catalog .update (json .load (f ))
@@ -427,11 +430,8 @@ def main():
427
430
428
431
check_module_limit (modules , args .module_id_max )
429
432
430
- if args .json_output is not None :
431
- write_json (messages , modules , args .json_input , args .json_output , stable_output )
432
-
433
- if args .xml_output is not None :
434
- enums = {}
433
+ enums = {}
434
+ if args .xml_output is not None or args .json_output is not None :
435
435
if args .cpp_output is not None :
436
436
try :
437
437
enums = {
@@ -452,6 +452,10 @@ def main():
452
452
else :
453
453
print ("XML output without C++ output: enum lookup will not be available" )
454
454
455
+ if args .json_output is not None :
456
+ write_json (messages , modules , enums , args .json_input , args .json_output , stable_output )
457
+
458
+ if args .xml_output is not None :
455
459
write_xml (
456
460
messages ,
457
461
modules ,
0 commit comments