#!/usr/bin/env python3 # SPDX-FileCopyrightText: 2026 Reactorcoremeltdown # SPDX-License-Identifier: GPL-3.0-or-later """Generate the FX extension's Info.plist and Components.gen.h from components.txt. usage: gen_components.py """ import sys from xml.sax.saxutils import escape TAGS = {"aufx": "Effects", "aumu": "Synthesizer", "aumi": "MIDI", "aumf": "Effects"} def main(src, plist_out, header_out): rows = [] for line in open(src): line = line.split("#", 1)[0].strip() if not line: continue t, sub, toolbox, name = line.split(None, 3) assert len(t) == 4 and len(sub) == 4, line rows.append((t, sub, toolbox, name)) comps = [] for t, sub, _, name in rows: comps.append(f""" descriptionSizzle {escape(name)} factoryFunctionSizzleFXViewController manufacturerTsys nameTired Sysadmin: Sizzle {escape(name)} sandboxSafe subtype{sub} tags{TAGS[t]} type{t} version65536 """) plist = f""" CFBundleDevelopmentRegionen CFBundleDisplayNameSizzle FX CFBundleExecutable$(EXECUTABLE_NAME) CFBundleIdentifier$(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion6.0 CFBundleName$(PRODUCT_NAME) CFBundlePackageTypeXPC! CFBundleShortVersionString$(MARKETING_VERSION) CFBundleVersion$(CURRENT_PROJECT_VERSION) NSExtension NSExtensionAttributes AudioComponents {chr(10).join(comps)} NSExtensionPointIdentifiercom.apple.AudioUnit-UI NSExtensionPrincipalClassSizzleFXViewController """ open(plist_out, "w").write(plist) entries = ",\n".join(f' {{\'{sub}\', \'{t}\', "{toolbox}", "{name}"}}' for t, sub, toolbox, name in rows) header = f"""// GENERATED from components.txt by tools/gen_components.py. Do not edit. #pragma once #include typedef struct {{ OSType subtype; OSType type; const char *toolboxType; const char *name; }} SizzleComponent; static const SizzleComponent kSizzleComponents[] = {{ {entries} }}; static const int kSizzleComponentCount = {len(rows)}; """ open(header_out, "w").write(header) if __name__ == "__main__": main(*sys.argv[1:4])