MCPcopy Index your code
hub / github.com/nodejs/node / main

Function main

tools/gypi_to_gn.py:295–327  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

293
294
295def main():
296 parser = OptionParser()
297 parser.add_option("-r", "--replace", action="append",
298 help="Replaces substrings. If passed a=b, replaces all substrs a with b.")
299 (options, args) = parser.parse_args()
300
301 if len(args) != 1:
302 raise Exception("Need one argument which is the .gypi file to read.")
303
304 data = LoadPythonDictionary(args[0])
305 if options.replace:
306 # Do replacements for all specified patterns.
307 for replace in options.replace:
308 split = replace.split('=')
309 # Allow "foo=" to replace with nothing.
310 if len(split) == 1:
311 split.append('')
312 assert len(split) == 2, "Replacement must be of the form 'key=value'."
313 data = ReplaceSubstrings(data, split[0], split[1])
314
315 gn_dict = {}
316 for key in data:
317 gn_key = key.replace('-', '_')
318 # Sometimes .gypi files use the GYP syntax with percents at the end of the
319 # variable name (to indicate not to overwrite a previously-defined value):
320 # 'foo%': 'bar',
321 # Convert these to regular variables.
322 if len(key) > 1 and key[len(key) - 1] == '%':
323 gn_dict[gn_key[:-1]] = data[key]
324 else:
325 gn_dict[gn_key] = data[key]
326
327 print(ToGNString(DeduplicateLists(gn_dict)))
328
329if __name__ == '__main__':
330 try:

Callers 1

gypi_to_gn.pyFile · 0.70

Calls 8

LoadPythonDictionaryFunction · 0.85
ReplaceSubstringsFunction · 0.85
ToGNStringFunction · 0.85
DeduplicateListsFunction · 0.85
printFunction · 0.50
parse_argsMethod · 0.45
splitMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…