Skip to content

Commit 3f89631

Browse files
committed
meson(cargo): support Windows again
For over a year, Git has been moved to a more modern build system than it had before (GNU make, or on Windows optionally CMake). Naturally, this new system breaks Windows support left and right. For example, c184795 (meson: add infrastructure to build internal Rust library, 2025-10-02) added support for building a Rust library, and it fails when Visual C is configured as compiler. This is the reason that the `win+Meson` job of Git's `master` branch fails for the past 16 days, i.e. the latest 9 pushes of the `master` branch as of time of writing. The symptom is: [697/905] Generating src/git_rs with a custom command FAILED: [code=1] src/libgitcore.a "C:\Program Files\Git\bin\sh.exe" "D:/a/git/git/src/cargo-meson.sh" "D:/a/git/git" "D:/a/git/git/build/src" "--release" cp: cannot stat 'D:/a/git/git/build/src/release/libgitcore.a': No such file or directory The reason is that Visual C's output is called `gitcore.lib`, not `libgitcore.a`. Let's special-case Visual C and use the correct filename in all cases. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent c2dd343 commit 3f89631

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/cargo-meson.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ then
55
exit 1
66
fi
77

8+
target="$1"
9+
shift
10+
811
SOURCE_DIR="$1"
912
BUILD_DIR="$2"
1013
BUILD_TYPE=debug
@@ -26,7 +29,7 @@ then
2629
exit $RET
2730
fi
2831

29-
if ! cmp "$BUILD_DIR/$BUILD_TYPE/libgitcore.a" "$BUILD_DIR/libgitcore.a" >/dev/null 2>&1
32+
if ! cmp "$BUILD_DIR/$BUILD_TYPE/$target" "$BUILD_DIR/$target" >/dev/null 2>&1
3033
then
31-
cp "$BUILD_DIR/$BUILD_TYPE/libgitcore.a" "$BUILD_DIR/libgitcore.a"
34+
cp "$BUILD_DIR/$BUILD_TYPE/$target" "$BUILD_DIR/$target"
3235
fi

src/meson.build

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@ libgit_rs_sources = [
33
'varint.rs',
44
]
55

6+
# The exact file name depends on the compiler
7+
if meson.get_compiler('c').get_id() == 'msvc'
8+
target = 'gitcore.lib'
9+
else
10+
target = 'libgitcore.a'
11+
endif
12+
613
# Unfortunately we must use a wrapper command to move the output file into the
714
# current build directory. This can fixed once `cargo build --artifact-dir`
815
# stabilizes. See https://github.com/rust-lang/cargo/issues/6790 for that
916
# effort.
1017
cargo_command = [
1118
shell,
1219
meson.current_source_dir() / 'cargo-meson.sh',
20+
target,
1321
meson.project_source_root(),
1422
meson.current_build_dir(),
1523
]
@@ -21,7 +29,7 @@ libgit_rs = custom_target('git_rs',
2129
input: libgit_rs_sources + [
2230
meson.project_source_root() / 'Cargo.toml',
2331
],
24-
output: 'libgitcore.a',
32+
output: target,
2533
command: cargo_command,
2634
)
2735
libgit_dependencies += declare_dependency(link_with: libgit_rs)

0 commit comments

Comments
 (0)