Parse target dir location from cargo metadata
This commit is contained in:
parent
245add6530
commit
bb274976ca
|
@ -10,6 +10,13 @@ Since there is no stable release yet, the changes are organized per day in
|
||||||
reverse chronological order. The main purpose of this document in its current
|
reverse chronological order. The main purpose of this document in its current
|
||||||
state is to list breaking changes.
|
state is to list breaking changes.
|
||||||
|
|
||||||
|
## [2024-03-23]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- `nih_plug_xtask` now detects and uses non-standard `target` directory
|
||||||
|
locations if overridden through Cargo's settings.
|
||||||
|
|
||||||
## [2024-03-18]
|
## [2024-03-18]
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
94
Cargo.lock
generated
94
Cargo.lock
generated
|
@ -459,7 +459,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.43",
|
"syn 2.0.53",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -521,7 +521,7 @@ checksum = "fdf6721fb0140e4f897002dd086c06f6c27775df19cfe1fccb21181a48fd2c98"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.43",
|
"syn 2.0.53",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -654,7 +654,7 @@ dependencies = [
|
||||||
"regex",
|
"regex",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"shlex",
|
"shlex",
|
||||||
"syn 2.0.43",
|
"syn 2.0.53",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -749,7 +749,7 @@ checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.43",
|
"syn 2.0.53",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -770,6 +770,15 @@ version = "1.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "981520c98f422fcc584dc1a95c334e6953900b9106bc47a9839b81790009eb21"
|
checksum = "981520c98f422fcc584dc1a95c334e6953900b9106bc47a9839b81790009eb21"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "camino"
|
||||||
|
version = "1.1.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cargo-nih-plug"
|
name = "cargo-nih-plug"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -777,6 +786,29 @@ dependencies = [
|
||||||
"nih_plug_xtask",
|
"nih_plug_xtask",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cargo-platform"
|
||||||
|
version = "0.1.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cargo_metadata"
|
||||||
|
version = "0.18.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037"
|
||||||
|
dependencies = [
|
||||||
|
"camino",
|
||||||
|
"cargo-platform",
|
||||||
|
"semver",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.0.83"
|
version = "1.0.83"
|
||||||
|
@ -891,7 +923,7 @@ dependencies = [
|
||||||
"heck",
|
"heck",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.43",
|
"syn 2.0.53",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1305,7 +1337,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331"
|
checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.43",
|
"syn 2.0.53",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1411,7 +1443,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.43",
|
"syn 2.0.53",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1538,7 +1570,7 @@ checksum = "f95e2801cd355d4a1a3e3953ce6ee5ae9603a5c833455343a8bfe3f44d418246"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.43",
|
"syn 2.0.53",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1899,7 +1931,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.43",
|
"syn 2.0.53",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3025,6 +3057,7 @@ name = "nih_plug_xtask"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
"cargo_metadata",
|
||||||
"goblin",
|
"goblin",
|
||||||
"reflink",
|
"reflink",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -3183,7 +3216,7 @@ dependencies = [
|
||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.43",
|
"syn 2.0.53",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3670,9 +3703,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.71"
|
version = "1.0.79"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8"
|
checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
@ -3705,9 +3738,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.33"
|
version = "1.0.35"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
|
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
@ -4077,7 +4110,7 @@ checksum = "1db149f81d46d2deba7cd3c50772474707729550221e69588478ebf9ada425ae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.43",
|
"syn 2.0.53",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -4116,25 +4149,28 @@ name = "semver"
|
||||||
version = "1.0.20"
|
version = "1.0.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090"
|
checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.193"
|
version = "1.0.197"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89"
|
checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.193"
|
version = "1.0.197"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
|
checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.43",
|
"syn 2.0.53",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -4156,7 +4192,7 @@ checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.43",
|
"syn 2.0.53",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -4393,9 +4429,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.43"
|
version = "2.0.53"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53"
|
checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -4467,7 +4503,7 @@ checksum = "e7fbe9b594d6568a6a1443250a7e67d80b74e1e96f6d1715e1e21cc1888291d3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.43",
|
"syn 2.0.53",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -4589,7 +4625,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.43",
|
"syn 2.0.53",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -4714,7 +4750,7 @@ checksum = "fea2a4c80deb4fb3ca51f66b5e2dd91e3642bbce52234bcf22e41668281208e4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro-hack",
|
"proc-macro-hack",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.43",
|
"syn 2.0.53",
|
||||||
"unic-langid-impl",
|
"unic-langid-impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -5015,7 +5051,7 @@ dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.43",
|
"syn 2.0.53",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -5049,7 +5085,7 @@ checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.43",
|
"syn 2.0.53",
|
||||||
"wasm-bindgen-backend",
|
"wasm-bindgen-backend",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
|
@ -5794,7 +5830,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.43",
|
"syn 2.0.53",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -8,6 +8,7 @@ license = "ISC"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
|
cargo_metadata = "0.18.1"
|
||||||
goblin = "0.6.1"
|
goblin = "0.6.1"
|
||||||
# Version 0.1.3 from crates.io assumes a 64-bit toolchain
|
# Version 0.1.3 from crates.io assumes a 64-bit toolchain
|
||||||
reflink = { git = "https://github.com/nicokoch/reflink.git", rev = "e8d93b465f5d9ad340cd052b64bbc77b8ee107e2" }
|
reflink = { git = "https://github.com/nicokoch/reflink.git", rev = "e8d93b465f5d9ad340cd052b64bbc77b8ee107e2" }
|
||||||
|
|
|
@ -14,9 +14,6 @@ mod util;
|
||||||
/// Re-export for the main function.
|
/// Re-export for the main function.
|
||||||
pub use anyhow::Result;
|
pub use anyhow::Result;
|
||||||
|
|
||||||
/// The base directory for the bundler's output.
|
|
||||||
const BUNDLE_HOME: &str = "target/bundled";
|
|
||||||
|
|
||||||
fn build_usage_string(command_name: &str) -> String {
|
fn build_usage_string(command_name: &str) -> String {
|
||||||
format!(
|
format!(
|
||||||
"Usage:
|
"Usage:
|
||||||
|
@ -79,6 +76,11 @@ pub fn main() -> Result<()> {
|
||||||
/// `std::env::args()` before passing it to this function.
|
/// `std::env::args()` before passing it to this function.
|
||||||
pub fn main_with_args(command_name: &str, args: impl IntoIterator<Item = String>) -> Result<()> {
|
pub fn main_with_args(command_name: &str, args: impl IntoIterator<Item = String>) -> Result<()> {
|
||||||
chdir_workspace_root()?;
|
chdir_workspace_root()?;
|
||||||
|
let cargo_metadata = cargo_metadata::MetadataCommand::new()
|
||||||
|
.manifest_path("./Cargo.toml")
|
||||||
|
.exec()
|
||||||
|
.context("Could not parse `cargo-metadata`")?;
|
||||||
|
let target_dir = cargo_metadata.target_directory.as_std_path();
|
||||||
|
|
||||||
let mut args = args.into_iter();
|
let mut args = args.into_iter();
|
||||||
let usage_string = build_usage_string(command_name);
|
let usage_string = build_usage_string(command_name);
|
||||||
|
@ -96,9 +98,9 @@ pub fn main_with_args(command_name: &str, args: impl IntoIterator<Item = String>
|
||||||
// As explained above, for efficiency's sake this is a two step process
|
// As explained above, for efficiency's sake this is a two step process
|
||||||
build(&packages, &other_args)?;
|
build(&packages, &other_args)?;
|
||||||
|
|
||||||
bundle(&packages[0], &other_args, false)?;
|
bundle(target_dir, &packages[0], &other_args, false)?;
|
||||||
for package in packages.into_iter().skip(1) {
|
for package in packages.into_iter().skip(1) {
|
||||||
bundle(&package, &other_args, false)?;
|
bundle(target_dir, &package, &other_args, false)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -134,9 +136,9 @@ pub fn main_with_args(command_name: &str, args: impl IntoIterator<Item = String>
|
||||||
|
|
||||||
// This `true` indicates a universal build. This will cause the two sets of built
|
// This `true` indicates a universal build. This will cause the two sets of built
|
||||||
// binaries to beq lipo'd together into universal binaries before bundling
|
// binaries to beq lipo'd together into universal binaries before bundling
|
||||||
bundle(&packages[0], &other_args, true)?;
|
bundle(target_dir, &packages[0], &other_args, true)?;
|
||||||
for package in packages.into_iter().skip(1) {
|
for package in packages.into_iter().skip(1) {
|
||||||
bundle(&package, &other_args, true)?;
|
bundle(target_dir, &package, &other_args, true)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -214,7 +216,7 @@ pub fn build(packages: &[String], args: &[String]) -> Result<()> {
|
||||||
/// Normally this respects the `--target` option for cross compilation. If the `universal` option is
|
/// Normally this respects the `--target` option for cross compilation. If the `universal` option is
|
||||||
/// specified instead, then this will assume both `x86_64-apple-darwin` and `aarch64-apple-darwin`
|
/// specified instead, then this will assume both `x86_64-apple-darwin` and `aarch64-apple-darwin`
|
||||||
/// have been built and it will try to lipo those together instead.
|
/// have been built and it will try to lipo those together instead.
|
||||||
pub fn bundle(package: &str, args: &[String], universal: bool) -> Result<()> {
|
pub fn bundle(target_dir: &Path, package: &str, args: &[String], universal: bool) -> Result<()> {
|
||||||
let mut build_type_dir = "debug";
|
let mut build_type_dir = "debug";
|
||||||
let mut cross_compile_target: Option<String> = None;
|
let mut cross_compile_target: Option<String> = None;
|
||||||
for arg_idx in (0..args.len()).rev() {
|
for arg_idx in (0..args.len()).rev() {
|
||||||
|
@ -252,7 +254,8 @@ pub fn bundle(package: &str, args: &[String], universal: bool) -> Result<()> {
|
||||||
// We can bundle both library targets (for plugins) and binary targets (for standalone
|
// We can bundle both library targets (for plugins) and binary targets (for standalone
|
||||||
// applications)
|
// applications)
|
||||||
if universal {
|
if universal {
|
||||||
let x86_64_target_base = target_base(Some("x86_64-apple-darwin"))?.join(build_type_dir);
|
let x86_64_target_base =
|
||||||
|
target_base(target_dir, Some("x86_64-apple-darwin"))?.join(build_type_dir);
|
||||||
let x86_64_bin_path = x86_64_target_base.join(binary_basename(
|
let x86_64_bin_path = x86_64_target_base.join(binary_basename(
|
||||||
package,
|
package,
|
||||||
CompilationTarget::MacOS(Architecture::X86_64),
|
CompilationTarget::MacOS(Architecture::X86_64),
|
||||||
|
@ -262,7 +265,8 @@ pub fn bundle(package: &str, args: &[String], universal: bool) -> Result<()> {
|
||||||
CompilationTarget::MacOS(Architecture::X86_64),
|
CompilationTarget::MacOS(Architecture::X86_64),
|
||||||
));
|
));
|
||||||
|
|
||||||
let aarch64_target_base = target_base(Some("aarch64-apple-darwin"))?.join(build_type_dir);
|
let aarch64_target_base =
|
||||||
|
target_base(target_dir, Some("aarch64-apple-darwin"))?.join(build_type_dir);
|
||||||
let aarch64_bin_path = aarch64_target_base.join(binary_basename(
|
let aarch64_bin_path = aarch64_target_base.join(binary_basename(
|
||||||
package,
|
package,
|
||||||
CompilationTarget::MacOS(Architecture::AArch64),
|
CompilationTarget::MacOS(Architecture::AArch64),
|
||||||
|
@ -281,6 +285,7 @@ pub fn bundle(package: &str, args: &[String], universal: bool) -> Result<()> {
|
||||||
eprintln!();
|
eprintln!();
|
||||||
if build_bin {
|
if build_bin {
|
||||||
bundle_binary(
|
bundle_binary(
|
||||||
|
target_dir,
|
||||||
package,
|
package,
|
||||||
&[&x86_64_bin_path, &aarch64_bin_path],
|
&[&x86_64_bin_path, &aarch64_bin_path],
|
||||||
CompilationTarget::MacOSUniversal,
|
CompilationTarget::MacOSUniversal,
|
||||||
|
@ -288,6 +293,7 @@ pub fn bundle(package: &str, args: &[String], universal: bool) -> Result<()> {
|
||||||
}
|
}
|
||||||
if build_lib {
|
if build_lib {
|
||||||
bundle_plugin(
|
bundle_plugin(
|
||||||
|
target_dir,
|
||||||
package,
|
package,
|
||||||
&[&x86_64_lib_path, &aarch64_lib_path],
|
&[&x86_64_lib_path, &aarch64_lib_path],
|
||||||
CompilationTarget::MacOSUniversal,
|
CompilationTarget::MacOSUniversal,
|
||||||
|
@ -295,7 +301,8 @@ pub fn bundle(package: &str, args: &[String], universal: bool) -> Result<()> {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let compilation_target = compilation_target(cross_compile_target.as_deref())?;
|
let compilation_target = compilation_target(cross_compile_target.as_deref())?;
|
||||||
let target_base = target_base(cross_compile_target.as_deref())?.join(build_type_dir);
|
let target_base =
|
||||||
|
target_base(target_dir, cross_compile_target.as_deref())?.join(build_type_dir);
|
||||||
let bin_path = target_base.join(binary_basename(package, compilation_target));
|
let bin_path = target_base.join(binary_basename(package, compilation_target));
|
||||||
let lib_path = target_base.join(library_basename(package, compilation_target));
|
let lib_path = target_base.join(library_basename(package, compilation_target));
|
||||||
if !bin_path.exists() && !lib_path.exists() {
|
if !bin_path.exists() && !lib_path.exists() {
|
||||||
|
@ -314,10 +321,10 @@ to your Cargo.toml file?"#,
|
||||||
|
|
||||||
eprintln!();
|
eprintln!();
|
||||||
if bin_path.exists() {
|
if bin_path.exists() {
|
||||||
bundle_binary(package, &[&bin_path], compilation_target)?;
|
bundle_binary(target_dir, package, &[&bin_path], compilation_target)?;
|
||||||
}
|
}
|
||||||
if lib_path.exists() {
|
if lib_path.exists() {
|
||||||
bundle_plugin(package, &[&lib_path], compilation_target)?;
|
bundle_plugin(target_dir, package, &[&lib_path], compilation_target)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,10 +335,12 @@ to your Cargo.toml file?"#,
|
||||||
/// combined into a single binary using a method that depends on the compilation target. For
|
/// combined into a single binary using a method that depends on the compilation target. For
|
||||||
/// universal macOS builds this uses lipo.
|
/// universal macOS builds this uses lipo.
|
||||||
fn bundle_binary(
|
fn bundle_binary(
|
||||||
|
target_dir: &Path,
|
||||||
package: &str,
|
package: &str,
|
||||||
bin_paths: &[&Path],
|
bin_paths: &[&Path],
|
||||||
compilation_target: CompilationTarget,
|
compilation_target: CompilationTarget,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
let bundle_home_dir = bundle_home(target_dir);
|
||||||
let bundle_name = match load_bundler_config()?.and_then(|c| c.get(package).cloned()) {
|
let bundle_name = match load_bundler_config()?.and_then(|c| c.get(package).cloned()) {
|
||||||
Some(PackageConfig { name: Some(name) }) => name,
|
Some(PackageConfig { name: Some(name) }) => name,
|
||||||
_ => package.to_string(),
|
_ => package.to_string(),
|
||||||
|
@ -340,7 +349,7 @@ fn bundle_binary(
|
||||||
// On MacOS the standalone target needs to be in a bundle
|
// On MacOS the standalone target needs to be in a bundle
|
||||||
let standalone_bundle_binary_name =
|
let standalone_bundle_binary_name =
|
||||||
standalone_bundle_binary_name(&bundle_name, compilation_target);
|
standalone_bundle_binary_name(&bundle_name, compilation_target);
|
||||||
let standalone_binary_path = Path::new(BUNDLE_HOME).join(&standalone_bundle_binary_name);
|
let standalone_binary_path = bundle_home_dir.join(&standalone_bundle_binary_name);
|
||||||
|
|
||||||
fs::create_dir_all(standalone_binary_path.parent().unwrap())
|
fs::create_dir_all(standalone_binary_path.parent().unwrap())
|
||||||
.context("Could not create standalone bundle directory")?;
|
.context("Could not create standalone bundle directory")?;
|
||||||
|
@ -363,7 +372,7 @@ fn bundle_binary(
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let standalone_bundle_home = Path::new(BUNDLE_HOME).join(
|
let standalone_bundle_home = bundle_home_dir.join(
|
||||||
Path::new(&standalone_bundle_binary_name)
|
Path::new(&standalone_bundle_binary_name)
|
||||||
.components()
|
.components()
|
||||||
.next()
|
.next()
|
||||||
|
@ -390,10 +399,12 @@ fn bundle_binary(
|
||||||
/// the libraries will be combined into a single library using a method that depends on the
|
/// the libraries will be combined into a single library using a method that depends on the
|
||||||
/// compilation target. For universal macOS builds this uses lipo.
|
/// compilation target. For universal macOS builds this uses lipo.
|
||||||
fn bundle_plugin(
|
fn bundle_plugin(
|
||||||
|
target_dir: &Path,
|
||||||
package: &str,
|
package: &str,
|
||||||
lib_paths: &[&Path],
|
lib_paths: &[&Path],
|
||||||
compilation_target: CompilationTarget,
|
compilation_target: CompilationTarget,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
let bundle_home_dir = bundle_home(target_dir);
|
||||||
let bundle_name = match load_bundler_config()?.and_then(|c| c.get(package).cloned()) {
|
let bundle_name = match load_bundler_config()?.and_then(|c| c.get(package).cloned()) {
|
||||||
Some(PackageConfig { name: Some(name) }) => name,
|
Some(PackageConfig { name: Some(name) }) => name,
|
||||||
_ => package.to_string(),
|
_ => package.to_string(),
|
||||||
|
@ -419,7 +430,7 @@ fn bundle_plugin(
|
||||||
|
|
||||||
if bundle_clap {
|
if bundle_clap {
|
||||||
let clap_bundle_library_name = clap_bundle_library_name(&bundle_name, compilation_target);
|
let clap_bundle_library_name = clap_bundle_library_name(&bundle_name, compilation_target);
|
||||||
let clap_lib_path = Path::new(BUNDLE_HOME).join(&clap_bundle_library_name);
|
let clap_lib_path = bundle_home_dir.join(&clap_bundle_library_name);
|
||||||
|
|
||||||
fs::create_dir_all(clap_lib_path.parent().unwrap())
|
fs::create_dir_all(clap_lib_path.parent().unwrap())
|
||||||
.context("Could not create CLAP bundle directory")?;
|
.context("Could not create CLAP bundle directory")?;
|
||||||
|
@ -428,7 +439,7 @@ fn bundle_plugin(
|
||||||
|
|
||||||
// In contrast to VST3, CLAP only uses bundles on macOS, so we'll just take the first
|
// In contrast to VST3, CLAP only uses bundles on macOS, so we'll just take the first
|
||||||
// component of the library name instead
|
// component of the library name instead
|
||||||
let clap_bundle_home = Path::new(BUNDLE_HOME).join(
|
let clap_bundle_home = bundle_home_dir.join(
|
||||||
Path::new(&clap_bundle_library_name)
|
Path::new(&clap_bundle_library_name)
|
||||||
.components()
|
.components()
|
||||||
.next()
|
.next()
|
||||||
|
@ -447,7 +458,7 @@ fn bundle_plugin(
|
||||||
}
|
}
|
||||||
if bundle_vst2 {
|
if bundle_vst2 {
|
||||||
let vst2_bundle_library_name = vst2_bundle_library_name(&bundle_name, compilation_target);
|
let vst2_bundle_library_name = vst2_bundle_library_name(&bundle_name, compilation_target);
|
||||||
let vst2_lib_path = Path::new(BUNDLE_HOME).join(&vst2_bundle_library_name);
|
let vst2_lib_path = bundle_home_dir.join(&vst2_bundle_library_name);
|
||||||
|
|
||||||
fs::create_dir_all(vst2_lib_path.parent().unwrap())
|
fs::create_dir_all(vst2_lib_path.parent().unwrap())
|
||||||
.context("Could not create VST2 bundle directory")?;
|
.context("Could not create VST2 bundle directory")?;
|
||||||
|
@ -456,7 +467,7 @@ fn bundle_plugin(
|
||||||
|
|
||||||
// VST2 only uses bundles on macOS, so we'll just take the first component of the library
|
// VST2 only uses bundles on macOS, so we'll just take the first component of the library
|
||||||
// name instead
|
// name instead
|
||||||
let vst2_bundle_home = Path::new(BUNDLE_HOME).join(
|
let vst2_bundle_home = bundle_home_dir.join(
|
||||||
Path::new(&vst2_bundle_library_name)
|
Path::new(&vst2_bundle_library_name)
|
||||||
.components()
|
.components()
|
||||||
.next()
|
.next()
|
||||||
|
@ -475,7 +486,7 @@ fn bundle_plugin(
|
||||||
}
|
}
|
||||||
if bundle_vst3 {
|
if bundle_vst3 {
|
||||||
let vst3_lib_path =
|
let vst3_lib_path =
|
||||||
Path::new(BUNDLE_HOME).join(vst3_bundle_library_name(&bundle_name, compilation_target));
|
bundle_home_dir.join(vst3_bundle_library_name(&bundle_name, compilation_target));
|
||||||
|
|
||||||
fs::create_dir_all(vst3_lib_path.parent().unwrap())
|
fs::create_dir_all(vst3_lib_path.parent().unwrap())
|
||||||
.context("Could not create VST3 bundle directory")?;
|
.context("Could not create VST3 bundle directory")?;
|
||||||
|
@ -604,13 +615,18 @@ fn compilation_target(cross_compile_target: Option<&str>) -> Result<CompilationT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The directory bundled plugins should be written to.
|
||||||
|
fn bundle_home(target_directory: &Path) -> PathBuf {
|
||||||
|
target_directory.join("bundled")
|
||||||
|
}
|
||||||
|
|
||||||
/// The base directory for the compiled binaries. This does not use [`CompilationTarget`] as we need
|
/// The base directory for the compiled binaries. This does not use [`CompilationTarget`] as we need
|
||||||
/// to be able to differentiate between native and cross-compilation.
|
/// to be able to differentiate between native and cross-compilation.
|
||||||
fn target_base(cross_compile_target: Option<&str>) -> Result<PathBuf> {
|
fn target_base(target_directory: &Path, cross_compile_target: Option<&str>) -> Result<PathBuf> {
|
||||||
match cross_compile_target {
|
match cross_compile_target {
|
||||||
// Unhandled targets will already be handled in `compilation_target`
|
// Unhandled targets will already be handled in `compilation_target`
|
||||||
Some(target) => Ok(Path::new("target").join(target)),
|
Some(target) => Ok(target_directory.join(target)),
|
||||||
None => Ok(PathBuf::from("target")),
|
None => Ok(target_directory.to_owned()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue