153bb9a07SDmitry Kozlyuk#!/usr/bin/env python3 253bb9a07SDmitry Kozlyuk# SPDX-License-Identifier: BSD-3-Clause 353bb9a07SDmitry Kozlyuk# (c) 2018 Luca Boccassi <bluca@debian.org> 453bb9a07SDmitry Kozlyuk# (c) 2022 Dmitry Kozlyuk <dmitry.kozliuk@gmail.com> 553bb9a07SDmitry Kozlyuk 653bb9a07SDmitry Kozlyukimport os, sys 753bb9a07SDmitry Kozlyuk 853bb9a07SDmitry Kozlyukexamples_dir, api_examples = sys.argv[1:] 953bb9a07SDmitry Kozlyuk 1053bb9a07SDmitry Kozlyuksources = [] 1153bb9a07SDmitry Kozlyukwith open(f'{api_examples}.d', 'w') as dep: 1253bb9a07SDmitry Kozlyuk print(f'{api_examples}:', end=' ', file=dep) 1353bb9a07SDmitry Kozlyuk for root, _, files in os.walk(examples_dir): 14*fac23f03SLuca Boccassi for name in sorted(files): 1553bb9a07SDmitry Kozlyuk is_source = name.endswith('.c') 1653bb9a07SDmitry Kozlyuk if is_source or name == 'meson.build': 1753bb9a07SDmitry Kozlyuk path = os.path.join(root, name) 1853bb9a07SDmitry Kozlyuk if is_source: 1953bb9a07SDmitry Kozlyuk sources.append(path) 2053bb9a07SDmitry Kozlyuk print(path , end=' ', file=dep) 2153bb9a07SDmitry Kozlyuk 2253bb9a07SDmitry Kozlyukwith open(api_examples, 'w') as out: 2353bb9a07SDmitry Kozlyuk print('''/** 2453bb9a07SDmitry Kozlyuk@page examples DPDK Example Programs 2553bb9a07SDmitry Kozlyuk''', file=out) 26*fac23f03SLuca Boccassi for path in sorted(sources): 2753bb9a07SDmitry Kozlyuk # Produce consistent output with forward slashes on all systems. 2853bb9a07SDmitry Kozlyuk # Every \ in paths within examples directory is a separator, not escape. 2953bb9a07SDmitry Kozlyuk relpath = os.path.relpath(path, examples_dir).replace('\\', '/') 3053bb9a07SDmitry Kozlyuk print(f'@example examples/{relpath}', file=out) 3153bb9a07SDmitry Kozlyuk print('*/', file=out) 32