245def print_dep_graph(graph, args, package_paths={}):
246 """Output final graph"""
247
248
249 if args.batch or not args.dot:
250 f = open(graph.name+'.txt', 'w') if args.batch else sys.stdout
251 nodes = [e[0] for e in graph.in_edges_iter()] if args.clients \
252 else [e[1] for e in graph.out_edges_iter()]
253
254 output = []
256 suffix = ':py' if p.attr['style']==py_style else ''
257 output.append('%s%s' % (package_paths.get(p,p), suffix))
258 print(
'\n'.join(sorted(output)), file=f)
259
260
261 if args.batch or args.dot:
262 f = open(graph.name+'.dot', 'w') if args.batch else sys.stdout
263 if args.legend:
264 add_legend(graph)
266
267
268
269
270
271@acmdlib.command(name='cmake.depends',
272 description=__doc__)
273
274@acmdlib.argument('names', nargs='+', metavar='NAME',
275 help='package/target name or regular expression')
276
277@acmdlib.argument('-t', '--target', action='store_true',
278 help='treat NAME as target instead of package name')
279
280@acmdlib.argument('-c', '--clients', action='store_true',
281 help='show clients (instead of dependencies)')
282
283@acmdlib.argument('-e', '--externals', action='store_true',
284 help='include external dependencies')
285
286@acmdlib.argument('-l', '--long', action='store_true',
287 help='show full package names (only for txt output)')
288
289@acmdlib.argument('-r', '--recursive', nargs='?', metavar='DEPTH',
290 type=int, default=1, const=None,
291 help='recursively resolve dependencies up to DEPTH (default: unlimited)')
292
293@acmdlib.argument('--py', action='store_true',
294 help=f'add Python dependencies (marked with ":py" in printout, {py_style} in graph)')
295
296@acmdlib.argument('--regex', action='store_true',
297 help='treat NAME as regular expression')
298
299@acmdlib.argument('--all', action='store_true',
300 help='do not apply any target filter (e.g. custom targets)')
301
302@acmdlib.argument('-d', '--dot', action='store_true',
303 help='print DOT graph')
304
305@acmdlib.argument('--legend', action='store_true',
306 help='add legend to graph')
307
308@acmdlib.argument('--batch', nargs='?', metavar='N', type=int, const=1,
309 help='Batch mode using N jobs (default: 1). Create dot and txt dependencies '
310 'for all NAMEs and store them in separate files.')
311
312
313
314@acmdlib.argument('--cmakedot', help=argparse.SUPPRESS)
315@acmdlib.argument('--pydot', help=argparse.SUPPRESS)
316
317