Skip to content

Commit

Permalink
Allow missing AR/CC/etc tools for precompiled rubies
Browse files Browse the repository at this point in the history
  • Loading branch information
ianks committed Jul 1, 2024
1 parent 50f1697 commit 517ed56
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions crates/rb-sys-build/src/bindings/stable_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ pub fn categorize_bindings(syntax: &mut syn::File) {
}

/// Unstable items for usage internally in rb_sys to avoid deprecated warnings.
#[allow(dead_code)]
pub (crate) mod internal {
use super::uncategorized::*;

Expand Down
13 changes: 11 additions & 2 deletions crates/rb-sys-build/src/cc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ impl Build {
let rb = rb_config();

let object_files = self.compile_each_file(compiler, &rb, &out_dir)?;
debug_log!("INFO: compiled object files: {:?}", object_files);
let (lib_path, lib_name) =
self.archive_object_files(archiver.copied(), name, &out_dir, object_files)?;
self.strip_archived_objects(archiver, &lib_path)?;
if let Err(e) = self.strip_archived_objects(archiver, &lib_path) {
debug_log!("WARN: failed to strip archived objects: {:?}", e);
}

println!("cargo:rustc-link-search=native={}", out_dir.display());
println!("cargo:rustc-link-lib=static={}", lib_name);
Expand Down Expand Up @@ -270,7 +273,13 @@ fn get_tool(env_var: &str, default: &str) -> Command {
let mut tool_args = shellsplit(tool_args).into_iter();
let tool = tool_args.next().unwrap_or_else(|| default.to_string());

let mut cmd = new_command(&tool);
let mut cmd = if !Path::new(&tool).is_file() {
debug_log!("[WARN] {tool} tool not found, falling back to {default}");
new_command(default)
} else {
new_command(&tool)
};

cmd.args(tool_args.clone());

debug_log!("INFO: found {:?} tool ({:?})", env_var, &cmd);
Expand Down
2 changes: 1 addition & 1 deletion crates/rb-sys-build/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn shellsplit<S: AsRef<str>>(s: S) -> Vec<String> {
match shell_words::split(s) {
Ok(v) => v,
Err(e) => {
debug_log!("shellsplit failed: {}", e);
debug_log!("WARN: shellsplit failed: {}", e);
s.split_whitespace().map(Into::into).collect()
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/rb-sys-test-helpers/src/ruby_test_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ impl Drop for RubyTestExecutor {
}

pub fn global_executor() -> &'static RubyTestExecutor {
#[allow(static_mut_refs)]
unsafe { &GLOBAL_EXECUTOR }.get_or_init(RubyTestExecutor::start)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/rb-sys/build/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn main() {
export_cargo_cfg(&mut rbconfig, &mut cfg_capture_file);

#[cfg(feature = "stable-api")]
stable_api_config::setup(Version::current(&rbconfig)).unwrap();
stable_api_config::setup(Version::current(&rbconfig)).expect("could not setup stable API");

if is_link_ruby_enabled() {
link_libruby(&mut rbconfig);
Expand Down
2 changes: 2 additions & 0 deletions crates/rb-sys/build/stable_api_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,11 @@ fn maybe_warn_old_ruby_version(current_ruby_version: Version) {
}

fn compile() -> Result<(), Box<dyn Error>> {
eprintln!("INFO: Compiling the stable API compiled module");
let mut build = rb_sys_build::cc::Build::new();
let crate_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
let path = crate_dir.join("src").join("stable_api").join("compiled.c");
eprintln!("cargo:rerun-if-changed={}", path.display());

build.file(path);
build.try_compile("compiled")
Expand Down
1 change: 1 addition & 0 deletions crates/rb-sys/src/tracking_allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub struct TrackingAllocator;

impl TrackingAllocator {
/// Create a new [`TrackingAllocator`].
#[allow(clippy::new_without_default)]
pub const fn new() -> Self {
Self
}
Expand Down

0 comments on commit 517ed56

Please sign in to comment.