From bbadd0d4361db9423c788a9c9685ac3b3eefe734 Mon Sep 17 00:00:00 2001 From: messense Date: Thu, 1 Sep 2022 16:58:39 +0800 Subject: [PATCH] Add `zig ar` support --- Changelog.md | 1 + src/compile.rs | 1 + src/main.rs | 13 +++++++++++++ 3 files changed, 15 insertions(+) diff --git a/Changelog.md b/Changelog.md index 2c136fd97..015fc098f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Enable `--crate-type cdylib` on Rust 1.64.0 in [#1060](https://github.com/PyO3/maturin/pull/1060) * Update MSRV to 1.59.0 in [#1071](https://github.com/PyO3/maturin/pull/1071) * Fix abi3 wheel build when no Python interpreters found in [#1072](https://github.com/PyO3/maturin/pull/1072) +* Add `zig ar` support in [#1073](https://github.com/PyO3/maturin/pull/1073) ## [0.13.2] - 2022-08-14 diff --git a/src/compile.rs b/src/compile.rs index f617285dd..e07ecb656 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -272,6 +272,7 @@ fn compile_target( build.target = vec![target_triple.to_string()]; } } else { + build.enable_zig_ar = true; let zig_triple = if target.is_linux() && !target.is_musl_target() { match context.platform_tag.iter().find(|tag| tag.is_manylinux()) { Some(PlatformTag::Manylinux { x, y }) => { diff --git a/src/main.rs b/src/main.rs index f73b75a3b..c3ba9a6ab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -314,6 +314,19 @@ fn run() -> Result<()> { #[cfg(feature = "log")] pretty_env_logger::init(); + // Allow symlink `maturin` to `ar` to invoke `zig ar` + // See https://github.com/messense/cargo-zigbuild/issues/52 + let mut args = env::args(); + let program_path = PathBuf::from(args.next().expect("no program path")); + let program_name = program_path.file_stem().expect("no program name"); + if program_name.eq_ignore_ascii_case("ar") { + let zig = Zig::Ar { + args: args.collect(), + }; + zig.execute()?; + return Ok(()); + } + let opt = Opt::parse(); match opt {