36 lines
1.7 KiB
Python
36 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Build and package CLAP without modifying a DAW's plugin directories."""
|
|
import argparse
|
|
from pathlib import Path
|
|
import shutil
|
|
import subprocess
|
|
|
|
root = Path(__file__).resolve().parents[1]
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--target", help="Rust target triple; defaults to rustc's host")
|
|
parser.add_argument("--standalone", action="store_true", help="Also build the standalone preview app")
|
|
args = parser.parse_args()
|
|
target = args.target
|
|
if target is None:
|
|
info = subprocess.check_output(["rustc", "-vV"], text=True)
|
|
target = next(line.removeprefix("host: ") for line in info.splitlines() if line.startswith("host: "))
|
|
if "windows" not in target and "linux" not in target:
|
|
parser.error("This milestone packages Windows and Linux only.")
|
|
manifest = root / "plugins/motif-storyboard/Cargo.toml"
|
|
cmd = ["cargo", "build", "--manifest-path", str(manifest), "--release", "--locked", "--target", target, "--lib"]
|
|
if args.standalone:
|
|
cmd += ["--features", "standalone", "--bin", "motif-storyboard"]
|
|
subprocess.run(cmd, cwd=root, check=True)
|
|
build = root / "plugins/motif-storyboard/target" / target / "release"
|
|
destination = root / "dist" / target
|
|
destination.mkdir(parents=True, exist_ok=True)
|
|
library = build / ("motif_storyboard.dll" if "windows" in target else "libmotif_storyboard.so")
|
|
plugin = destination / "Motif Storyboard.clap"
|
|
shutil.copy2(library, plugin)
|
|
shutil.copy2(root / "LICENSE", destination)
|
|
shutil.copy2(root / "docs/fl-studio.md", destination / "FL-Studio-setup.md")
|
|
if args.standalone:
|
|
exe = "motif-storyboard.exe" if "windows" in target else "motif-storyboard"
|
|
shutil.copy2(build / exe, destination)
|
|
print(f"Packaged {plugin}")
|