1#!/usr/bin/env python3 2# SPDX-License-Identifier: BSD-3-Clause 3# (c) 2018 Luca Boccassi <bluca@debian.org> 4# (c) 2022 Dmitry Kozlyuk <dmitry.kozliuk@gmail.com> 5 6import os, re, subprocess, sys 7 8pattern = re.compile('^Preprocessing (.*)...$') 9out_dir, *doxygen_command = sys.argv[1:] 10out_file = os.path.join(os.path.dirname(out_dir), 'doxygen.out') 11dep_file = f'{out_dir}.d' 12with open(out_file, 'w') as out: 13 subprocess.run(doxygen_command, check=True, stdout=out) 14with open(out_file) as out, open(dep_file, 'w') as dep: 15 print(f'{out_dir}:', end=' ', file=dep) 16 for line in out: 17 match = re.match(pattern, line) 18 if match: 19 print(match.group(1), end=' ', file=dep) 20