Skip to content

Commit ef6e439

Browse files
committed
win+Meson: allow for xdiff to be compiled with MSVC
The `build_rust.sh` script is quite opinionated about the naming scheme of the C compiler: It assumes that the xdiff library file will be named `libxdiff.a`. However, MS Visual C generates `xdiff.lib` files instead; This naming scheme has been in use in a very, very long time. Let's allow for that. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 72c50ee commit ef6e439

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

build_rust.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ fi
4444

4545
cd $dir_rust && cargo clean && pwd && cargo build -p $crate $rust_args; cd ..
4646

47-
libfile="lib${crate}.a"
47+
if grep x86_64-pc-windows-msvc rust/target/.rustc_info.json
48+
then
49+
libfile="${crate}.lib"
50+
else
51+
libfile="lib${crate}.a"
52+
fi
4853
dst=$dir_build/$libfile
4954

5055
if [ "$dir_git_root" != "$dir_build" ]; then

meson.build

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,16 @@ else
277277
rustflags = '-Aunused_imports -Adead_code -C debuginfo=2 -C opt-level=1 -C force-frame-pointers=yes'
278278
endif
279279

280+
compiler = meson.get_compiler('c')
281+
282+
if compiler.get_id() == 'msvc'
283+
xdiff_lib_filename = 'xdiff.lib'
284+
else
285+
xdiff_lib_filename = 'libxdiff.a'
286+
endif
287+
280288
rust_build_xdiff = custom_target('rust_build_xdiff',
281-
output: 'libxdiff.a',
289+
output: xdiff_lib_filename,
282290
build_by_default: true,
283291
build_always_stale: true,
284292
command: [
@@ -288,8 +296,6 @@ rust_build_xdiff = custom_target('rust_build_xdiff',
288296
install: false,
289297
)
290298

291-
compiler = meson.get_compiler('c')
292-
293299
libgit_sources = [
294300
'abspath.c',
295301
'add-interactive.c',

0 commit comments

Comments
 (0)