Skip to content

misterdownloadmanager: The ultimate open-source, clean-room download manager written from scratch in pure Rust for Windows, Mac, and Linux

1.5 KB
Raw Blame
#!/usr/bin/env python3
"""Writes website/content/third-party.tsv: every Rust library compiled into the app, the CLI and
the browser helper (normal and build dependencies, every target), with its version, licence and
repository, for the site's License page. Run after changing dependencies:

    python tools/website/third_party.py
"""
import subprocess
from pathlib import Path

ROOT = Path(__file__).resolve().parents[2]
OURS = {"mdm-app", "mdm-cli", "mdm-nmhost", "mdm-engine", "mdm-ipc", "mdm-tools", "mdm-torrent"}

rows = set()
for package in ("mdm-app", "mdm-cli", "mdm-nmhost"):
    out = subprocess.run(
        ["cargo", "tree", "-p", package, "-e", "normal,build", "--prefix", "none", "--target", "all",
         "-f", "{p}\t{l}\t{r}"],
        cwd=ROOT, capture_output=True, text=True, check=True).stdout
    for line in out.splitlines():
        line = line.replace(" (*)", "").replace(" (proc-macro)", "")
        name_ver, licence, repo = (line.split("\t") + ["", ""])[:3]
        name, _, ver = name_ver.partition(" v")
        ver = ver.split(" ")[0]
        if name in OURS or not name:
            continue
        rows.add((name, ver, licence.strip() or "see its source", repo.strip()))

lines = ["# Generated by tools/website/third_party.py: name, version, licence, repository."]
lines += ["\t".join(r) for r in sorted(rows, key=lambda r: (r[0].lower(), r[1]))]
(ROOT / "website" / "content" / "third-party.tsv").write_text("\n".join(lines) + "\n", "utf-8", newline="\n")
print(len(rows), "libraries")