Source: u-boot Followup-For: Bug #979296 The attached targets.py generates a slightly improved indentation than the one in previous message.
Also, a redirection was wissing in # python3 PATH/TO/ATTACHED/targets.py debian/targets > debian/targets.mk Please use # python3 PATH/TO/ATTACHED/targets.py < debian/targets > debian/targets.mk instead.
#!/usr/bin/python3 # Convert debian/targets to a Makefile snippet included by # debian/rules. # python3 debian/targets.py < debian/targets > debian/targets.mk qemu = {} architectures = {} maintainers = [] with open ('debian/targets') as i: assert i.readline () == '# ARCH subarch platform target\n' assert i.readline () == '# --------------------------------------------\n' for line in i: if line == '\n': maintainers = [] continue if line.startswith('#'): maintainers.append (line.rstrip ()) continue fields = line.rstrip ().split () arch, subarch, platform = fields [:3] targets = fields [3:] if arch.startswith ('all'): assert subarch == 'qemu' qemu [platform] = (arch, targets) else: if arch not in architectures: architectures [arch] = {} packages = architectures [arch] if subarch == '-': package = 'u-boot' else: package = f'u-boot-{subarch}' if package not in packages: packages [package] = {} platforms = packages [package] platforms [platform] = (targets, maintainers) print ('# Target architectures supported by u-boot in Debian.') print ('# debian/rules includes this Makefile snippet.') def format_targets (platform : str, targets : list): s = f' {platform}_targets :=' for t in sorted (targets): if 75 < len (s) + len (t): print (s + ' \\') s = ' ' s += f' {t}' print (s) else_ifeq = False for arch in sorted (architectures.keys ()): print ('') if else_ifeq: print ('else ', end='') else: else_ifeq = True print ('ifeq (${DEB_HOST_ARCH},' + arch + ')') packages = architectures [arch] for package in sorted (packages.keys ()): print ('') print (f'# {package}') platforms = packages [package] for platform in sorted (platforms.keys ()): targets, maintainers = platforms [platform] print ('') for maintainer in maintainers: print (f' {maintainer}') print (f' {package}_platforms += {platform}') if targets [0].startswith ('/usr/lib/arm-trusted-firmware/'): print (f' {platform}_assigns := BL31={targets.pop (0)}') if platform != 'novena-rawsd': targets.append ('uboot.elf') format_targets (platform, targets) print ('') print ('endif') print ('') print ('# u-boot-qemu (Architecture: all)') for platform in sorted (qemu.keys ()): arch, targets = qemu [platform] print ('') print (f' u-boot-qemu_platforms += {platform}') gnu_type = arch[4:] print (f' {platform}_CROSS_COMPILE := {gnu_type}-') targets.append ('uboot.elf') format_targets (platform, targets)