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