#!/usr/bin/env python

import argparse
import os
import subprocess


parser = argparse.ArgumentParser()
parser.add_argument("-l", "--library", required=True)
parser.add_argument("-o", "--output", required=True)
args = parser.parse_args()

output = os.path.abspath(args.output)
outdir = os.path.dirname(output)
if not os.path.exists(outdir):
    os.makedirs(outdir)

proc = subprocess.Popen(["doxygen", "-"], stdin=subprocess.PIPE, cwd=args.library)
proc.communicate(
    """

#@INCLUDE = doc/Doxyfile
GENERATE_TAGFILE = {}
GENERATE_HTML = no
GENERATE_LATEX = no
CASE_SENSE_NAMES = yes
INPUT = libavcodec libavdevice libavfilter libavformat libavresample libavutil libswresample libswscale

""".format(
        output
    ).encode()
)
