Git fork

rust: support for Windows

The initial patch series that introduced Rust into the core of Git only
cared about macOS and Linux. This specifically leaves out Windows, which
indeed fails to build right now due to two issues:

- The Rust runtime requires `GetUserProfileDirectoryW()`, but we don't
link against "userenv.dll".

- The path of the Rust library built on Windows is different than on
most other systems systems.

Fix both of these issues to support Windows.

Note that this commit fixes the Meson-based job in GitHub's CI. Meson
auto-detects the availability of Rust, and as the Windows runner has
Rust installed by default it already enabled Rust support there. But due
to the above issues that job fails consistently.

Install Rust on GitLab CI, as well, to improve test coverage there.

Based-on-patch-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Based-on-patch-by: Ezekiel Newren <ezekielnewren@gmail.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Patrick Steinhardt and committed by
Junio C Hamano
e509b5b8 1b43384f

+26 -5
+1 -1
.gitlab-ci.yml
··· 161 161 - saas-windows-medium-amd64 162 162 before_script: 163 163 - *windows_before_script 164 - - choco install -y git meson ninja 164 + - choco install -y git meson ninja rust-ms 165 165 - Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1 166 166 - refreshenv 167 167
+12 -2
Makefile
··· 929 929 LIB_FILE = libgit.a 930 930 XDIFF_LIB = xdiff/lib.a 931 931 REFTABLE_LIB = reftable/libreftable.a 932 + 932 933 ifdef DEBUG 933 - RUST_LIB = target/debug/libgitcore.a 934 + RUST_TARGET_DIR = target/debug 935 + else 936 + RUST_TARGET_DIR = target/release 937 + endif 938 + 939 + ifeq ($(uname_S),Windows) 940 + RUST_LIB = $(RUST_TARGET_DIR)/gitcore.lib 934 941 else 935 - RUST_LIB = target/release/libgitcore.a 942 + RUST_LIB = $(RUST_TARGET_DIR)/libgitcore.a 936 943 endif 937 944 938 945 # xdiff and reftable libs may in turn depend on what is in libgit.a ··· 1538 1545 ifdef WITH_RUST 1539 1546 BASIC_CFLAGS += -DWITH_RUST 1540 1547 GITLIBS += $(RUST_LIB) 1548 + ifeq ($(uname_S),Windows) 1549 + EXTLIBS += -luserenv 1550 + endif 1541 1551 endif 1542 1552 1543 1553 ifdef SANITIZE
+4
meson.build
··· 1707 1707 if rust_option.allowed() 1708 1708 subdir('src') 1709 1709 libgit_c_args += '-DWITH_RUST' 1710 + 1711 + if host_machine.system() == 'windows' 1712 + libgit_dependencies += compiler.find_library('userenv') 1713 + endif 1710 1714 else 1711 1715 libgit_sources += [ 1712 1716 'varint.c',
+9 -2
src/cargo-meson.sh
··· 26 26 exit $RET 27 27 fi 28 28 29 - if ! cmp "$BUILD_DIR/$BUILD_TYPE/libgitcore.a" "$BUILD_DIR/libgitcore.a" >/dev/null 2>&1 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 37 then 31 - cp "$BUILD_DIR/$BUILD_TYPE/libgitcore.a" "$BUILD_DIR/libgitcore.a" 38 + cp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a" 32 39 fi