From: Junio C Hamano Date: Fri, 21 Nov 2025 21:39:01 GMT Subject: Re: [PATCH v3 6/6] rust: support for Windows Message-ID: In-Reply-To: Johannes Schindelin writes: > Here is my patch (with proper handling of MSVC, but obviously it no longer > applies without conflicts): Thanks. Here is my attempt to make it apply to 'master'. It seems to pass win+Meson build & test for 'master'. https://github.com/git/git/actions/runs/19583133885 But curiously, the tip of 'master' has been happy without this fix, and it does not help when brian's SHA-256 interop topic merged further on top, but I didn't look any further. --- >8 --- Subject: [PATCH] meson(cargo): Visual C produces gitcore.lib, not libgitcore.a On Windows, when Visual C compiler is used to compile, the resulting library that is created is called gitcore.lib instead of libgitcore.a library archive. Johannes sent a fix in that was based on an older code base, which I attempted to forward port it to apply to today's codebase. Based-on-the-patch-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- src/cargo-meson.sh | 14 ++++---------- src/meson.build | 11 ++++++++++- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/cargo-meson.sh b/src/cargo-meson.sh index 3998db0435..4a46f731d8 100755 --- a/src/cargo-meson.sh +++ b/src/cargo-meson.sh @@ -7,9 +7,10 @@ fi SOURCE_DIR="$1" BUILD_DIR="$2" +LIBNAME="$3" BUILD_TYPE=debug -shift 2 +shift 3 for arg do @@ -26,14 +27,7 @@ then exit $RET fi -case "$(cargo -vV | sed -s 's/^host: \(.*\)$/\1/')" in - *-windows-*) - LIBNAME=gitcore.lib;; - *) - LIBNAME=libgitcore.a;; -esac - -if ! cmp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a" >/dev/null 2>&1 +if ! cmp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/$LIBNAME" >/dev/null 2>&1 then - cp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a" + cp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/$LIBNAME" fi diff --git a/src/meson.build b/src/meson.build index 25b9ad5a14..f37f0a5f58 100644 --- a/src/meson.build +++ b/src/meson.build @@ -3,6 +3,14 @@ libgit_rs_sources = [ 'varint.rs', ] +# The exact file name depends on the compiler +if meson.get_compiler('c').get_id() == 'msvc' + libname = 'gitcore.lib' +else + libname = 'libgitcore.a' +endif + + # Unfortunately we must use a wrapper command to move the output file into the # current build directory. This can fixed once `cargo build --artifact-dir` # stabilizes. See https://github.com/rust-lang/cargo/issues/6790 for that @@ -12,6 +20,7 @@ cargo_command = [ meson.current_source_dir() / 'cargo-meson.sh', meson.project_source_root(), meson.current_build_dir(), + libname, ] if get_option('buildtype') == 'release' cargo_command += '--release' @@ -21,7 +30,7 @@ libgit_rs = custom_target('git_rs', input: libgit_rs_sources + [ meson.project_source_root() / 'Cargo.toml', ], - output: 'libgitcore.a', + output: libname, command: cargo_command, ) libgit_dependencies += declare_dependency(link_with: libgit_rs) -- 2.52.0-168-gcf2c56d51e