Skip to content

Commit

Permalink
Split code into two packages, one for the CLI tool and one for the li…
Browse files Browse the repository at this point in the history
…brary
  • Loading branch information
autarch committed Sep 2, 2024
1 parent 10a8728 commit 584d46b
Show file tree
Hide file tree
Showing 27 changed files with 111 additions and 62 deletions.
15 changes: 14 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 10 additions & 44 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
[package]
name = "ubi"
version = "0.1.2"
[workspace.package]
authors = ["Dave Rolsky <[email protected]>"]
description = "The Universal Binary Installer library and CLI tool"
repository = "https://github.com/houseabsolute/ubi"
documentation = "https://docs.rs/ubi/latest/ubi/"
readme = "README.md"
license = "MIT OR Apache-2.0"
edition = "2021"
license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/houseabsolute/precious"
version = "0.2.0"

[lib]
name = "ubi"
path = "src/ubi.rs"

[[bin]]
name = "ubi"
path = "src/main.rs"
[workspace]
members = ["ubi", "ubi-cli"]
resolver = "2"

[dependencies]
[workspace.dependencies]
anyhow = "1.0.86"
binstall-tar = "0.4.42"
bzip2 = "0.4.4"
Expand All @@ -28,6 +21,7 @@ flate2 = "1.0.33"
itertools = "0.13.0"
lazy-regex = "3.3.0"
log = "0.4.22"
mockito = "1.5.0"
platforms = "=3.2.0"
regex = "1.10.6"
reqwest = { version = "0.12.7", default-features = false, features = ["gzip", "json"] }
Expand All @@ -50,31 +44,3 @@ zip = { version = "2.2.0", default-features = false, features = [
"lzma",
"zstd",
] }

[features]
default = ["rustls-tls"]
## enables the `rustls-tls` feature for the `reqwest` crate.
rustls-tls = ["reqwest/rustls-tls"]
## enables the `rustls-tls-native-roots` feature for the `reqwest` crate.
rustls-tls-native-roots = ["reqwest/rustls-tls-native-roots"]
## enables the `native-tls` feature for the `reqwest` crate.
native-tls = ["reqwest/native-tls"]
## enables the `native-tls-vendored` feature for the `reqwest` crate.
native-tls-vendored = ["reqwest/native-tls-vendored"]

[workspace.metadata.release]
allow-branch = ["master"]

[dev-dependencies]
mockito = "1.5.0"

# workaround for https://github.com/cross-rs/cross/issues/1345
[package.metadata.cross.target.x86_64-unknown-netbsd]
pre-build = [
"mkdir -p /tmp/netbsd",
"curl https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.2/amd64/binary/sets/base.tar.xz -O",
"tar -C /tmp/netbsd -xJf base.tar.xz",
"cp /tmp/netbsd/usr/lib/libexecinfo.so /usr/local/x86_64-unknown-netbsd/lib",
"rm base.tar.xz",
"rm -rf /tmp/netbsd",
]
11 changes: 11 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
[build.env]
passthrough = ["GITHUB_TOKEN"]

# workaround for https://github.com/cross-rs/cross/issues/1345
[target.x86_64-unknown-netbsd]
pre-build = [
"mkdir -p /tmp/netbsd",
"curl https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.2/amd64/binary/sets/base.tar.xz -O",
"tar -C /tmp/netbsd -xJf base.tar.xz",
"cp /tmp/netbsd/usr/lib/libexecinfo.so /usr/local/x86_64-unknown-netbsd/lib",
"rm base.tar.xz",
"rm -rf /tmp/netbsd",
]
22 changes: 22 additions & 0 deletions ubi-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "ubi-cli"
version.workspace = true
authors.workspace = true
description = "The Universal Binary Installer CLI tool"
repository.workspace = true
readme.workspace = true
license.workspace = true
edition.workspace = true

[dependencies]
anyhow.workspace = true
clap.workspace = true
log.workspace = true
tempfile.workspace = true
thiserror.workspace = true
tokio.workspace = true
ubi = { version = "0.2.0", path = "../ubi" }

[[bin]]
name = "ubi"
path = "src/main.rs"
File renamed without changes.
13 changes: 2 additions & 11 deletions tests/ubi.rs → ubi-cli/tests/ubi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,10 @@ impl PreservableTempdir {
#[allow(clippy::too_many_lines)]
fn integration_tests() -> Result<()> {
let cargo = make_exe_pathbuf(&["cargo"]);

let features = if env::var("CARGO_FEATURE_RUSTLS_TLS_NATIVE_ROOTS").unwrap_or_default() == "1" {
"rustls-tls-native-roots"
} else if env::var("CARGO_FEATURE_NATIVE_TLS").unwrap_or_default() == "1" {
"native-tls"
} else if env::var("CARGO_FEATURE_NATIVE_TLS_VENDORED").unwrap_or_default() == "1" {
"native-tls-vendored"
} else {
"default"
};
run_command(&cargo, &["build", "--features", features])?;
run_command(&cargo, &["build"])?;

let mut ubi = env::current_dir()?;
ubi.push("..");
ubi.push("target");
ubi.push("debug");
ubi.push(if cfg!(windows) { "ubi.exe" } else { "ubi" });
Expand Down
50 changes: 50 additions & 0 deletions ubi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[package]
name = "ubi"
version.workspace = true
authors.workspace = true
description = "The Universal Binary Installer library"
repository.workspace = true
readme.workspace = true
license.workspace = true
edition.workspace = true

[dependencies]
anyhow.workspace = true
binstall-tar.workspace = true
bzip2.workspace = true
clap.workspace = true
document-features.workspace = true
fern.workspace = true
flate2.workspace = true
itertools.workspace = true
lazy-regex.workspace = true
log.workspace = true
platforms.workspace = true
regex.workspace = true
reqwest.workspace = true
result.workspace = true
serde.workspace = true
strum.workspace = true
tempfile.workspace = true
test-case.workspace = true
thiserror.workspace = true
tokio.workspace = true
url.workspace = true
xz.workspace = true
zip.workspace = true

[features]
default = ["rustls-tls"]
## enables the `rustls-tls` feature for the `reqwest` crate.
rustls-tls = ["reqwest/rustls-tls"]
## enables the `rustls-tls-native-roots` feature for the `reqwest` crate.
rustls-tls-native-roots = ["reqwest/rustls-tls-native-roots"]
## enables the `native-tls` feature for the `reqwest` crate.
native-tls = ["reqwest/native-tls"]
## enables the `native-tls-vendored` feature for the `reqwest` crate.
native-tls-vendored = ["reqwest/native-tls-vendored"]

[dev-dependencies]
mockito.workspace = true
test-case.workspace = true
tokio.workspace = true
5 changes: 0 additions & 5 deletions build.rs → ubi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ use std::env;

// mostly copied from the current_platform crate.
fn main() {
// We need this to build `ubi` properly in the integration tests.
for (key, value) in env::vars().filter(|(k, _)| k.starts_with("CARGO_FEATURE_")) {
println!("cargo:rustc-env={key}={value}");
}

// Cargo sets the host and target env vars for build scripts, but not
// crates:
// https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion src/ubi.rs → ubi/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! A library (and CLI tool) for downloading and installing pre-built binaries from GitHub.
//! A library for downloading and installing pre-built binaries from GitHub.
//!
//! UBI stands for "Universal Binary Installer". It downloads and installs pre-built binaries from
//! GitHub releases. It is designed to be used in shell scripts and other automation.
//!
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 584d46b

Please sign in to comment.