-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
command-line interface for vst3-bindgen
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,5 @@ members = [ | |
"com-scrape", | ||
"com-scrape-types", | ||
"vst3-bindgen", | ||
"vst3-bindgen-cli", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[package] | ||
name = "vst3-bindgen-cli" | ||
version = "0.1.0" | ||
authors = ["Micah Johnston <[email protected]>"] | ||
edition = "2021" | ||
description = "Binding generator for the VST 3 API" | ||
repository = "https://github.com/coupler-rs/vst3-rs" | ||
license = "MIT OR Apache-2.0" | ||
|
||
[[bin]] | ||
path = "src/main.rs" | ||
name = "vst3-bindgen" | ||
|
||
[dependencies] | ||
vst3-bindgen = { path = "../vst3-bindgen", version = "0.2.1" } | ||
clap = { version = "3.1.17", features = ["derive", "cargo"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use std::path::PathBuf; | ||
|
||
use std::error::Error; | ||
use std::fs::File; | ||
use std::io::{stdout, BufWriter, Write}; | ||
use std::process; | ||
|
||
use clap::Parser; | ||
use vst3_bindgen::generate; | ||
|
||
#[derive(Parser)] | ||
struct Vst3Bindgen { | ||
sdk_dir: PathBuf, | ||
|
||
#[clap(long, value_name = "TRIPLE")] | ||
target: Option<String>, | ||
|
||
#[clap(long, short, value_name = "OUTPUT")] | ||
output: Option<String>, | ||
} | ||
|
||
fn vst3_bindgen(cmd: &Vst3Bindgen) -> Result<(), Box<dyn Error>> { | ||
let mut bindings = Vec::new(); | ||
|
||
generate(&cmd.sdk_dir, cmd.target.as_deref(), &mut bindings)?; | ||
|
||
if let Some(output) = &cmd.output { | ||
let file = File::create(output)?; | ||
BufWriter::new(file).write_all(&bindings)?; | ||
} else { | ||
BufWriter::new(stdout()).write_all(&bindings)?; | ||
}; | ||
|
||
Ok(()) | ||
} | ||
|
||
fn main() { | ||
let cmd = Vst3Bindgen::parse(); | ||
if let Err(err) = vst3_bindgen(&cmd) { | ||
eprintln!("error: {}", err); | ||
process::exit(1); | ||
} | ||
} |