Skip to content

Commit 901a95f

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 <[email protected]> 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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 89d8df9 commit 901a95f

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

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
@@ -6,6 +6,14 @@ libgit_rs_sources = [
66
'varint.rs',
77
]
88

9+
# The exact file name depends on the compiler
10+
if meson.get_compiler('c').get_id() == 'msvc'
11+
libname = 'gitcore.lib'
12+
else
13+
libname = 'libgitcore.a'
14+
endif
15+
16+
917
# Unfortunately we must use a wrapper command to move the output file into the
1018
# current build directory. This can fixed once `cargo build --artifact-dir`
1119
# stabilizes. See https://github.com/rust-lang/cargo/issues/6790 for that
@@ -15,6 +23,7 @@ cargo_command = [
1523
meson.current_source_dir() / 'cargo-meson.sh',
1624
meson.project_source_root(),
1725
meson.current_build_dir(),
26+
libname,
1827
]
1928
if get_option('buildtype') == 'release'
2029
cargo_command += '--release'
@@ -24,7 +33,7 @@ libgit_rs = custom_target('git_rs',
2433
input: libgit_rs_sources + [
2534
meson.project_source_root() / 'Cargo.toml',
2635
],
27-
output: 'libgitcore.a',
36+
output: libname,
2837
command: cargo_command,
2938
)
3039
libgit_dependencies += declare_dependency(link_with: libgit_rs)

0 commit comments

Comments
 (0)