-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cubeb-rs releases are now to be performed using `cargo xtask release`. This is a hack to allow us to ship a vendored copy of libcubeb *including* libcubeb's Rust crates. `cargo publish` excludes all subdirectories that contain a `Cargo.toml`, preventing a complete vendoring of libcubeb. The release xtask recursively renames `Cargo.toml` -> `Cargo.toml.in` before running `cargo release` and `cargo publish`, then renames them back. build.rs now always builds using $OUT_DIR/libcubeb, copying and renaming `Cargo.toml.in` as necessary.
- Loading branch information
Showing
11 changed files
with
195 additions
and
31 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[alias] | ||
xtask = "run --package xtask --" | ||
|
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "cubeb" | ||
version = "0.18.0" | ||
version = "0.20.0" | ||
authors = ["Dan Glastonbury <[email protected]>"] | ||
license = "ISC" | ||
readme = "README.md" | ||
|
@@ -19,4 +19,4 @@ circle-ci = { repository = "mozilla/cubeb-rs" } | |
gecko-in-tree = ["cubeb-core/gecko-in-tree"] | ||
|
||
[dependencies] | ||
cubeb-core = { path = "../cubeb-core", version = "0.18.0" } | ||
cubeb-core = { path = "../cubeb-core", version = "0.20.0" } |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "cubeb-backend" | ||
version = "0.18.0" | ||
version = "0.20.0" | ||
authors = ["Dan Glastonbury <[email protected]>"] | ||
license = "ISC" | ||
keywords = ["cubeb"] | ||
|
@@ -18,4 +18,4 @@ circle-ci = { repository = "mozilla/cubeb-rs" } | |
gecko-in-tree = ["cubeb-core/gecko-in-tree"] | ||
|
||
[dependencies] | ||
cubeb-core = { path = "../cubeb-core", version = "0.18.0" } | ||
cubeb-core = { path = "../cubeb-core", version = "0.20.0" } |
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "cubeb-core" | ||
version = "0.18.0" | ||
version = "0.20.0" | ||
authors = ["Dan Glastonbury <[email protected]>"] | ||
license = "ISC" | ||
keywords = ["cubeb"] | ||
|
@@ -19,7 +19,7 @@ gecko-in-tree = ["cubeb-sys/gecko-in-tree"] | |
|
||
[dependencies] | ||
bitflags = "1.2.0" | ||
cubeb-sys = { path = "../cubeb-sys", version = "0.18" } | ||
cubeb-sys = { path = "../cubeb-sys", version = "0.20" } | ||
|
||
[build-dependencies] | ||
cc = "1.1.30" |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
[package] | ||
name = "cubeb-sys" | ||
version = "0.18.0" | ||
version = "0.20.0" | ||
authors = ["Dan Glastonbury <[email protected]>"] | ||
repository = "https://github.com/mozilla/cubeb-rs" | ||
license = "ISC" | ||
description = "Native bindings to the cubeb library" | ||
exclude = ["libcubeb/"] | ||
exclude = ["libcubeb/googletest"] | ||
|
||
links = "cubeb" | ||
build = "build.rs" | ||
|
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
Binary file not shown.
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,8 @@ | ||
[package] | ||
name = "xtask" | ||
version = "0.3.0" | ||
edition = "2021" | ||
publish = false | ||
release = false | ||
|
||
[dependencies] |
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,134 @@ | ||
use std::{ | ||
env, fs, | ||
path::{Path, PathBuf}, | ||
process::Command, | ||
}; | ||
|
||
type DynError = Box<dyn std::error::Error>; | ||
|
||
fn main() { | ||
if let Err(e) = try_main() { | ||
eprintln!("{}", e); | ||
std::process::exit(-1); | ||
} | ||
} | ||
|
||
fn try_main() -> Result<(), DynError> { | ||
let task = env::args().nth(1); | ||
match task.as_deref() { | ||
Some("release") => release()?, | ||
_ => print_help(), | ||
} | ||
Ok(()) | ||
} | ||
|
||
fn print_help() { | ||
eprintln!( | ||
"Tasks: | ||
release runs 'cargo release' after preparing the source directory | ||
" | ||
) | ||
} | ||
|
||
fn visit_dirs(dir: &Path, cb: &dyn Fn(&fs::DirEntry)) -> std::io::Result<()> { | ||
if dir.is_dir() { | ||
for entry in fs::read_dir(dir)? { | ||
let entry = entry?; | ||
let path = entry.path(); | ||
if path.is_dir() { | ||
visit_dirs(&path, cb)?; | ||
} else { | ||
cb(&entry); | ||
} | ||
} | ||
} | ||
Ok(()) | ||
} | ||
|
||
fn release() -> Result<(), DynError> { | ||
let cargo = env::var("CARGO").unwrap_or_else(|_| "cargo".to_string()); | ||
|
||
let status = Command::new(&cargo) | ||
.current_dir(project_root()) | ||
.args(["release", "--workspace", "minor", "-x", "--no-publish"]) | ||
.status()?; | ||
|
||
if !status.success() { | ||
Err("cargo release failed")?; | ||
} | ||
|
||
// For packaged build: rename libcubeb Cargo.toml files to Cargo.toml.in. | ||
visit_dirs(Path::new("cubeb-sys/libcubeb"), &|entry| { | ||
let path = entry.path(); | ||
if path | ||
.file_name() | ||
.unwrap() | ||
.to_str() | ||
.unwrap() | ||
.ends_with("Cargo.toml") | ||
{ | ||
let new_path = path.with_file_name("Cargo.toml.in"); | ||
fs::rename(&path, &new_path).unwrap(); | ||
} | ||
}) | ||
.unwrap(); | ||
|
||
let status = Command::new(&cargo) | ||
.current_dir(project_root()) | ||
.args(["publish", "--package", "cubeb-sys", "--allow-dirty"]) | ||
.status()?; | ||
if !status.success() { | ||
Err("cargo publish failed")?; | ||
} | ||
|
||
// Rename libcubeb Cargo.toml.in files back to Cargo.toml. | ||
visit_dirs(Path::new("cubeb-sys/libcubeb"), &|entry| { | ||
let path = entry.path(); | ||
if path | ||
.file_name() | ||
.unwrap() | ||
.to_str() | ||
.unwrap() | ||
.ends_with("Cargo.toml.in") | ||
{ | ||
let new_path = path.with_file_name("Cargo.toml"); | ||
fs::rename(&path, &new_path).unwrap(); | ||
} | ||
}) | ||
.unwrap(); | ||
|
||
let status = Command::new(&cargo) | ||
.current_dir(project_root()) | ||
.args(["publish", "--package", "cubeb-core"]) | ||
.status()?; | ||
if !status.success() { | ||
Err("cargo publish failed")?; | ||
} | ||
|
||
let status = Command::new(&cargo) | ||
.current_dir(project_root()) | ||
.args(["publish", "--package", "cubeb-backend"]) | ||
.status()?; | ||
if !status.success() { | ||
Err("cargo publish failed")?; | ||
} | ||
|
||
let status = Command::new(&cargo) | ||
.current_dir(project_root()) | ||
.args(["publish", "--package", "cubeb"]) | ||
.status()?; | ||
if !status.success() { | ||
Err("cargo publish failed")?; | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
fn project_root() -> PathBuf { | ||
Path::new(&env!("CARGO_MANIFEST_DIR")) | ||
.ancestors() | ||
.nth(1) | ||
.unwrap() | ||
.to_path_buf() | ||
} |