Skip to content

Commit

Permalink
Add an is_musl method to the UbiBuilder struct
Browse files Browse the repository at this point in the history
  • Loading branch information
autarch committed Oct 28, 2024
1 parent 6288014 commit 3da2f7e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.2

- Added a `is_musl` method to the `UbiBuilder` struct to allow setting this manually.

## 0.2.1 - 2024-10-27

- When running on Linux, `ubi` now checks to see if the platform is using `musl` and will prefer a
Expand Down
22 changes: 21 additions & 1 deletion ubi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pub struct UbiBuilder<'a> {
exe: Option<&'a str>,
github_token: Option<&'a str>,
platform: Option<&'a Platform>,
is_musl: Option<bool>,
github_api_url_base: Option<String>,
}

Expand Down Expand Up @@ -156,6 +157,15 @@ impl<'a> UbiBuilder<'a> {
self
}

/// Set whether or not the platform uses musl as its libc. This is only relevant for Linux
/// platforms. If this isn't set then it will be determined based on the current platform's
/// libc. You cannot set this to `true` on a non-Linux platform.
#[must_use]
pub fn is_musl(mut self, is_musl: bool) -> Self {
self.is_musl = Some(is_musl);
self
}

/// Set the base URL for the GitHub API. This is useful for testing or if you want to operate
/// against a GitHub Enterprise installation.
#[must_use]
Expand Down Expand Up @@ -194,6 +204,13 @@ impl<'a> UbiBuilder<'a> {
))?
};

if self.is_musl.unwrap_or_default() && platform.target_os != OS::Linux {
return Err(anyhow!(
"You cannot set is_musl to true on a non-Linux platform - the current platform is {}",
platform.target_os,
));
}

Ubi::new(
self.project,
self.tag,
Expand All @@ -203,7 +220,10 @@ impl<'a> UbiBuilder<'a> {
self.exe,
self.github_token,
platform,
platform_is_musl(platform),
match self.is_musl {
Some(m) => m,
None => platform_is_musl(platform),
},
self.github_api_url_base,
)
}
Expand Down

0 comments on commit 3da2f7e

Please sign in to comment.