Skip to content

Commit c43a20b

Browse files
committed
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 <dc753c0e-eb93-948c-55f7-bb0e91772c83@gmx.de> 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 <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent debbc87 commit c43a20b

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

src/cargo-meson.sh

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ fi
77

88
SOURCE_DIR="$1"
99
BUILD_DIR="$2"
10+
LIBNAME="$3"
1011
BUILD_TYPE=debug
1112

12-
shift 2
13+
shift 3
1314

1415
for arg
1516
do
@@ -26,14 +27,7 @@ then
2627
exit $RET
2728
fi
2829

29-
case "$(cargo -vV | sed -s 's/^host: \(.*\)$/\1/')" in
30-
*-windows-*)
31-
LIBNAME=gitcore.lib;;
32-
*)
33-
LIBNAME=libgitcore.a;;
34-
esac
35-
36-
if ! cmp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a" >/dev/null 2>&1
30+
if ! cmp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/$LIBNAME" >/dev/null 2>&1
3731
then
38-
cp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a"
32+
cp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/$LIBNAME"
3933
fi

src/meson.build

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ 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+
libname = 'gitcore.lib'
9+
else
10+
libname = 'libgitcore.a'
11+
endif
12+
13+
614
# Unfortunately we must use a wrapper command to move the output file into the
715
# current build directory. This can fixed once `cargo build --artifact-dir`
816
# stabilizes. See https://github.com/rust-lang/cargo/issues/6790 for that
@@ -12,6 +20,7 @@ cargo_command = [
1220
meson.current_source_dir() / 'cargo-meson.sh',
1321
meson.project_source_root(),
1422
meson.current_build_dir(),
23+
libname,
1524
]
1625
if get_option('buildtype') == 'release'
1726
cargo_command += '--release'
@@ -21,7 +30,7 @@ libgit_rs = custom_target('git_rs',
2130
input: libgit_rs_sources + [
2231
meson.project_source_root() / 'Cargo.toml',
2332
],
24-
output: 'libgitcore.a',
33+
output: libname,
2534
command: cargo_command,
2635
)
2736
libgit_dependencies += declare_dependency(link_with: libgit_rs)

0 commit comments

Comments
 (0)