From 0b45281df75b89c3ba1d6e02295d8b320add2dff Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 3 Apr 2019 00:01:36 +0200 Subject: [PATCH 01/13] fixup! msvc: support building Git using MS Visual C++ The `SET p=...` inside a `FOR` loop does not actually seem to work... Signed-off-by: Johannes Schindelin --- compat/vcbuild/vcpkg_install.bat | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compat/vcbuild/vcpkg_install.bat b/compat/vcbuild/vcpkg_install.bat index 3d086c39c31a53..ebd0bad242a8ca 100644 --- a/compat/vcbuild/vcpkg_install.bat +++ b/compat/vcbuild/vcpkg_install.bat @@ -53,8 +53,7 @@ REM ================================================================ echo Installing third-party libraries... FOR %%i IN (zlib expat libiconv openssl libssh2 curl) DO ( cd %cwd%vcpkg - SET p="packages\%%i_%arch%" - IF NOT EXIST "%p%" CALL :sub__install_one %%i + IF NOT EXIST "packages\%%i_%arch%" CALL :sub__install_one %%i IF ERRORLEVEL 1 ( EXIT /B 1 ) ) From 3a90a020d61dea08cfb071764cbe94f7c1808b77 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 10 Apr 2019 14:10:38 +0200 Subject: [PATCH 02/13] fixup! msvc: support building Git using MS Visual C++ This seems to be recommended when building in parallel, which we want to do (especially in the Azure Pipeline). Signed-off-by: Johannes Schindelin --- config.mak.uname | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.mak.uname b/config.mak.uname index a89649ac60c9fc..5cbac1cbff4695 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -451,7 +451,7 @@ endif # Always give "-Zi" to the compiler and "-debug" to linker (even in # release mode) to force a PDB to be generated (like RelWithDebInfo). BASIC_CFLAGS += -Zi - BASIC_LDFLAGS += -debug + BASIC_LDFLAGS += -debug -Zf ifdef NO_SAFESEH LDFLAGS += -SAFESEH:NO From 0a8bdb71852fb934201b09c80fd484b977ff661e Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 3 Apr 2019 16:35:57 +0200 Subject: [PATCH 03/13] push: do not pretend to return `int` from `die_push_simple()` This function is marked as `NORETURN`, and it indeed does not want to return anything. So let's not declare it with the return type `int`. This fixes the following warning when building with MSVC: C4646: function declared with 'noreturn' has non-void return type Signed-off-by: Johannes Schindelin --- builtin/push.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/push.c b/builtin/push.c index 021dd3b1e48979..d216270d5fa39f 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -143,8 +143,8 @@ static int push_url_of_remote(struct remote *remote, const char ***url_p) return remote->url_nr; } -static NORETURN int die_push_simple(struct branch *branch, - struct remote *remote) +static NORETURN void die_push_simple(struct branch *branch, + struct remote *remote) { /* * There's no point in using shorten_unambiguous_ref here, From a98ce0a032978a9694db197bff8e58ddb872691f Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 3 Apr 2019 14:30:15 +0200 Subject: [PATCH 04/13] msvc: avoid using minus operator on unsigned types MSVC complains about this with `-Wall`, which can be taken as a sign that this is indeed a real bug. The symptom is: C4146: unary minus operator applied to unsigned type, result still unsigned Let's avoid this warning in the minimal way, e.g. writing `-1 - ` instead of `- - 1`. Note that the change in the `estimate_cache_size()` function is needed because MSVC considers the "return type" of the `sizeof()` operator to be `size_t`, i.e. unsigned, and therefore it cannot be negated using the unary minus operator. Even worse, that arithmetic is doing extra work, in vain. We want to calculate the entry extra cache size as the difference between the size of the `cache_entry` structure minus the size of the `ondisk_cache_entry` structure, padded to the appropriate alignment boundary. To that end, we start by assigning that difference to the `per_entry` variable, and then abuse the `len` parameter of the `align_padding_size()` macro to take the negative size of the ondisk entry size. Essentially, we try to avoid passing the already calculated difference to that macro by passing the operands of that difference instead, when the macro expects operands of an addition: #define align_padding_size(size, len) \ ((size + (len) + 8) & ~7) - (size + len) Currently, we pass A and -B to that macro instead of passing A - B and 0, where A - B is already stored in the `per_entry` variable, ready to be used. This is neither necessary, nor intuitive. Let's fix this, and have code that is both easier to read and that also does not trigger MSVC's warning. Signed-off-by: Johannes Schindelin --- read-cache.c | 4 ++-- sha1-lookup.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/read-cache.c b/read-cache.c index bbcf488c20a483..4ed05df715276c 100644 --- a/read-cache.c +++ b/read-cache.c @@ -1266,7 +1266,7 @@ static int add_index_entry_with_check(struct index_state *istate, struct cache_e */ if (istate->cache_nr > 0 && strcmp(ce->name, istate->cache[istate->cache_nr - 1]->name) > 0) - pos = -istate->cache_nr - 1; + pos = -1 - istate->cache_nr; else pos = index_name_stage_pos(istate, ce->name, ce_namelen(ce), ce_stage(ce)); @@ -1899,7 +1899,7 @@ static size_t estimate_cache_size(size_t ondisk_size, unsigned int entries) /* * Account for potential alignment differences. */ - per_entry += align_padding_size(sizeof(struct cache_entry), -sizeof(struct ondisk_cache_entry)); + per_entry += align_padding_size(per_entry, 0); return ondisk_size + entries * per_entry; } diff --git a/sha1-lookup.c b/sha1-lookup.c index 796ab68da83c3a..c8196877309369 100644 --- a/sha1-lookup.c +++ b/sha1-lookup.c @@ -97,7 +97,7 @@ int sha1_pos(const unsigned char *sha1, void *table, size_t nr, lo = mi + 1; mi = lo + (hi - lo) / 2; } while (lo < hi); - return -lo-1; + return -1 - lo; } int bsearch_hash(const unsigned char *sha1, const uint32_t *fanout_nbo, From 2b96775024af67025e23e571966adadd64a38677 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 3 Apr 2019 14:52:30 +0200 Subject: [PATCH 05/13] winansi: use FLEX_ARRAY to avoid compiler warning MSVC would complain thusly: C4200: nonstandard extension used: zero-sized array in struct/union Let's just use the `FLEX_ARRAY` constant that we introduced for exactly this type of scenario. Signed-off-by: Johannes Schindelin --- compat/winansi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/winansi.c b/compat/winansi.c index 087406a4f7f70a..32aca79dd34af6 100644 --- a/compat/winansi.c +++ b/compat/winansi.c @@ -546,7 +546,7 @@ static HANDLE swap_osfhnd(int fd, HANDLE new_handle) typedef struct _OBJECT_NAME_INFORMATION { UNICODE_STRING Name; - WCHAR NameBuffer[0]; + WCHAR NameBuffer[FLEX_ARRAY]; } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION; #define ObjectNameInformation 1 From f0bc6eae243afe11b5683f48e375e62394cb0402 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 3 Apr 2019 14:54:32 +0200 Subject: [PATCH 06/13] fscache: avoid unnamed struct to avoid compiler warning MSVC's `cl.exe`, when run with `-Wall` complains like this: C4201: nonstandard extension used: nameless struct/union So let's just name the union and be done with it. Signed-off-by: Johannes Schindelin --- compat/win32/fscache.c | 26 +++++++++++++------------- compat/win32/ntifs.h | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/compat/win32/fscache.c b/compat/win32/fscache.c index a80c59c948e95e..f1d885c6d888db 100644 --- a/compat/win32/fscache.c +++ b/compat/win32/fscache.c @@ -65,8 +65,8 @@ struct fsentry { struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; - }; - }; + } s; + } u; }; /* @@ -127,7 +127,7 @@ static struct fsentry *fsentry_alloc(struct fscache *cache, struct fsentry *list /* init the rest of the structure */ fsentry_init(fse, list, nm, len); fse->next = NULL; - fse->refcnt = 1; + fse->u.refcnt = 1; return fse; } @@ -139,7 +139,7 @@ inline static void fsentry_addref(struct fsentry *fse) if (fse->list) fse = fse->list; - InterlockedIncrement(&(fse->refcnt)); + InterlockedIncrement(&(fse->u.refcnt)); } /* @@ -150,7 +150,7 @@ static void fsentry_release(struct fsentry *fse) if (fse->list) fse = fse->list; - InterlockedDecrement(&(fse->refcnt)); + InterlockedDecrement(&(fse->u.refcnt)); } static int xwcstoutfn(char *utf, int utflen, const wchar_t *wcs, int wcslen) @@ -205,11 +205,11 @@ static struct fsentry *fseentry_create_entry(struct fscache *cache, struct fsent fse->st_mode = file_attr_to_st_mode(fdata->FileAttributes, fdata->EaSize, buf); - fse->st_size = S_ISLNK(fse->st_mode) ? MAX_LONG_PATH : + fse->u.s.st_size = S_ISLNK(fse->st_mode) ? MAX_LONG_PATH : fdata->EndOfFile.LowPart | (((off_t)fdata->EndOfFile.HighPart) << 32); - filetime_to_timespec((FILETIME *)&(fdata->LastAccessTime), &(fse->st_atim)); - filetime_to_timespec((FILETIME *)&(fdata->LastWriteTime), &(fse->st_mtim)); - filetime_to_timespec((FILETIME *)&(fdata->CreationTime), &(fse->st_ctim)); + filetime_to_timespec((FILETIME *)&(fdata->LastAccessTime), &(fse->u.s.st_atim)); + filetime_to_timespec((FILETIME *)&(fdata->LastWriteTime), &(fse->u.s.st_mtim)); + filetime_to_timespec((FILETIME *)&(fdata->CreationTime), &(fse->u.s.st_ctim)); return fse; } @@ -578,10 +578,10 @@ int fscache_lstat(const char *filename, struct stat *st) st->st_rdev = 0; st->st_nlink = 1; st->st_mode = fse->st_mode; - st->st_size = fse->st_size; - st->st_atim = fse->st_atim; - st->st_mtim = fse->st_mtim; - st->st_ctim = fse->st_ctim; + st->st_size = fse->u.s.st_size; + st->st_atim = fse->u.s.st_atim; + st->st_mtim = fse->u.s.st_mtim; + st->st_ctim = fse->u.s.st_ctim; /* don't forget to release fsentry */ fsentry_release(fse); diff --git a/compat/win32/ntifs.h b/compat/win32/ntifs.h index bcc71c7dd9c5ef..3098f863cbdb21 100644 --- a/compat/win32/ntifs.h +++ b/compat/win32/ntifs.h @@ -99,7 +99,7 @@ typedef struct _IO_STATUS_BLOCK { union { NTSTATUS Status; PVOID Pointer; - } DUMMYUNIONNAME; + } u; ULONG_PTR Information; } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; From c2baa5de9753bbdafc9e3ed35b6e11b82d8e7e9b Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 3 Apr 2019 13:25:48 +0200 Subject: [PATCH 07/13] compat/win32/path-utils.h: add #include guards This adds the common guards that allow headers to be #include'd multiple times. Signed-off-by: Johannes Schindelin --- compat/win32/path-utils.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compat/win32/path-utils.h b/compat/win32/path-utils.h index 0f70d439204fbe..8ed062a6b7887e 100644 --- a/compat/win32/path-utils.h +++ b/compat/win32/path-utils.h @@ -1,3 +1,6 @@ +#ifndef WIN32_PATH_UTILS_H +#define WIN32_PATH_UTILS_H + #define has_dos_drive_prefix(path) \ (isalpha(*(path)) && (path)[1] == ':' ? 2 : 0) int win32_skip_dos_drive_prefix(char **path); @@ -18,3 +21,5 @@ static inline char *win32_find_last_dir_sep(const char *path) #define find_last_dir_sep win32_find_last_dir_sep int win32_offset_1st_component(const char *path); #define offset_1st_component win32_offset_1st_component + +#endif From 9e108a02e6869bc595675b4600c57edfae97634e Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 3 Apr 2019 13:28:08 +0200 Subject: [PATCH 08/13] msvc: include path-utils.h The Cygwin and the MINGW parts were handled correctly in 1cadad6f658b (git clone C:\cygwin\home\USER\repo' is working (again), 2018-12-15), but the MSVC part was forgotten. Fix this. Signed-off-by: Johannes Schindelin --- git-compat-util.h | 1 + 1 file changed, 1 insertion(+) diff --git a/git-compat-util.h b/git-compat-util.h index e0275da7e0a794..9be177e588114c 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -210,6 +210,7 @@ #include "compat/mingw.h" #include "compat/win32/fscache.h" #elif defined(_MSC_VER) +#include "compat/win32/path-utils.h" #include "compat/msvc.h" #include "compat/win32/fscache.h" #else From e66505cb1b53d4caa00c0e6dd1e0f584ae03c6e5 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 3 Apr 2019 16:53:22 +0200 Subject: [PATCH 09/13] msvc: ignore some libraries when linking To build with MSVC, we "translate" GCC options to MSVC options, and part of those options refer to the libraries to link into the final executable. Currently, this part looks somewhat like this on Windows: -lcurl -lnghttp2 -lidn2 -lssl -lcrypto -lssl -lcrypto -lgdi32 -lcrypt32 -lwldap32 -lz -lws2_32 -lexpat Some of those are direct dependencies (such as curl and ssl) and others are indirect (nghttp2 and idn2, for example, are dependencies of curl, but need to be linked in for reasons). We already handle the direct dependencies, e.g. `-liconv` is already handled as adding `libiconv.lib` to the list of libraries to link against. Let's just ignore the remaining `-l*` options so that MSVC does not have to warn us that it ignored e.g. the `/lnghttp2` option. We do that by extending the clause that already "eats" the `-R*` options to also eat the `-l*` options. Signed-off-by: Johannes Schindelin --- compat/vcbuild/scripts/clink.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/vcbuild/scripts/clink.pl b/compat/vcbuild/scripts/clink.pl index 3d6fa21c1e5690..34af8f824557f0 100755 --- a/compat/vcbuild/scripts/clink.pl +++ b/compat/vcbuild/scripts/clink.pl @@ -55,7 +55,7 @@ } elsif ("$arg" =~ /^-L/ && "$arg" ne "-LTCG") { $arg =~ s/^-L/-LIBPATH:/; push(@lflags, $arg); - } elsif ("$arg" =~ /^-R/) { + } elsif ("$arg" =~ /^-[Rl]/) { # eat } else { push(@args, $arg); From 29cb9ba5f8b7aa9df17802897c879889c139dc90 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 3 Apr 2019 11:21:59 +0200 Subject: [PATCH 10/13] msvc: handle DEVELOPER=1 We frequently build Git using the `DEVELOPER=1` make setting as a shortcut to enable all kinds of more stringent compiler warnings. Those compiler warnings are relatively specific to GCC, though, so let's try our best to translate them to the equivalent options to pass to MS Visual C++'s `cl.exe`. Signed-off-by: Johannes Schindelin --- compat/vcbuild/scripts/clink.pl | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/compat/vcbuild/scripts/clink.pl b/compat/vcbuild/scripts/clink.pl index 34af8f824557f0..4ccfc319d51fdf 100755 --- a/compat/vcbuild/scripts/clink.pl +++ b/compat/vcbuild/scripts/clink.pl @@ -57,6 +57,52 @@ push(@lflags, $arg); } elsif ("$arg" =~ /^-[Rl]/) { # eat + } elsif ("$arg" eq "-Werror") { + push(@cflags, "-WX"); + } elsif ("$arg" eq "-Wall") { + # cl.exe understands -Wall, but it is really overzealous + push(@cflags, "-W4"); + # disable the "signed/unsigned mismatch" warnings; our source code violates that + push(@cflags, "-wd4018"); + push(@cflags, "-wd4245"); + push(@cflags, "-wd4389"); + # disable the "unreferenced formal parameter" warning; our source code violates that + push(@cflags, "-wd4100"); + # disable the "conditional expression is constant" warning; our source code violates that + push(@cflags, "-wd4127"); + # disable the "const object should be initialized" warning; these warnings affect only objects that are `static` + push(@cflags, "-wd4132"); + # disable the "function/data pointer conversion in expression" warning; our source code violates that + push(@cflags, "-wd4152"); + # disable the "non-constant aggregate initializer" warning; our source code violates that + push(@cflags, "-wd4204"); + # disable the "cannot be initialized using address of automatic variable" warning; our source code violates that + push(@cflags, "-wd4221"); + # disable the "possible loss of data" warnings; our source code violates that + push(@cflags, "-wd4244"); + push(@cflags, "-wd4267"); + # disable the "array is too small to include a terminating null character" warning; we ab-use strings to initialize OIDs + push(@cflags, "-wd4295"); + # disable the "'<<': result of 32-bit shift implicitly converted to 64 bits" warning; our source code violates that + push(@cflags, "-wd4334"); + # disable the "declaration hides previous local declaration" warning; our source code violates that + push(@cflags, "-wd4456"); + # disable the "declaration hides function parameter" warning; our source code violates that + push(@cflags, "-wd4457"); + # disable the "declaration hides global declaration" warning; our source code violates that + push(@cflags, "-wd4459"); + # disable the "potentially uninitialized local variable '' used" warning; our source code violates that + push(@cflags, "-wd4701"); + # disable the "unreachable code" warning; our source code violates that + push(@cflags, "-wd4702"); + # disable the "potentially uninitialized local pointer variable used" warning; our source code violates that + push(@cflags, "-wd4703"); + # disable the "assignment within conditional expression" warning; our source code violates that + push(@cflags, "-wd4706"); + # disable the "'inet_ntoa': Use inet_ntop() or InetNtop() instead" warning; our source code violates that + push(@cflags, "-wd4996"); + } elsif ("$arg" =~ /^-W[a-z]/) { + # let's ignore those } else { push(@args, $arg); } From 5fe27bcbfbce2edcab3d1663acb0ad23f45b5ea2 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 4 Apr 2019 16:54:04 +0200 Subject: [PATCH 11/13] msvc: work around a bug in GetEnvironmentVariable() The return value of that function is 0 both for variables that are unset, as well as for variables whose values are empty. To discern those two cases, one has to call `GetLastError()`, whose return value is `ERROR_ENVVAR_NOT_FOUND` and `ERROR_SUCCESS`, respectively. Except that it is not actually set to `ERROR_SUCCESS` in the latter case, apparently, but the last error value seems to be simply unchanged. To work around this, let's just re-set the last error value just before inspecting the environment variable. This fixes a problem that triggers failures in t3301-notes.sh (where we try to override config settings by passing empty values for certain environment variables). This problem is hidden in the MINGW build by the fact that older MSVC runtimes (such as the one used by MINGW builds) have a `calloc()` that re-sets the last error value in case of success, while newer runtimes set the error value only if `NULL` is returned by that function. Signed-off-by: Johannes Schindelin --- compat/mingw.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compat/mingw.c b/compat/mingw.c index 3164814fc49d7f..e4583ace621af0 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -2072,6 +2072,8 @@ char *mingw_getenv(const char *name) if (!w_key) die("Out of memory, (tried to allocate %u wchar_t's)", len_key); xutftowcs(w_key, name, len_key); + /* GetEnvironmentVariableW() only sets the last error upon failure */ + SetLastError(ERROR_SUCCESS); len_value = GetEnvironmentVariableW(w_key, w_value, ARRAY_SIZE(w_value)); if (!len_value && GetLastError() == ERROR_ENVVAR_NOT_FOUND) { free(w_key); From 0c6ba3f4303594abbd72be5fcbdb51f113b6de31 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 3 Apr 2019 17:16:41 +0200 Subject: [PATCH 12/13] ci: really use shallow clones on Azure Pipelines This was a left-over from the previous YAML schema, and it no longer works. The problem was noticed while editing `azure-pipelines.yml` in VS Code with the very helpful "Azure Pipelines" extension (syntax highlighting and intellisense for `azure-pipelines.yml`...). Signed-off-by: Johannes Schindelin --- azure-pipelines.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c329b7218bb361..55ee23ad0f5a38 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,6 +1,5 @@ -resources: -- repo: self - fetchDepth: 1 +variables: + Agent.Source.Git.ShallowFetchDepth: 1 jobs: - job: windows_build From 2cd6754ce15601144376a913736e38b80cc84679 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 2 Apr 2019 14:28:11 +0200 Subject: [PATCH 13/13] ci: also test with MS Visual C on Azure Pipelines ... because we can, now. Signed-off-by: Johannes Schindelin --- Makefile | 4 ++ azure-pipelines.yml | 141 ++++++++++++++++++++++++++++++++++++++++++++ ci/lib.sh | 5 ++ 3 files changed, 150 insertions(+) diff --git a/Makefile b/Makefile index 3404a091c8120e..fbb71a28e81828 100644 --- a/Makefile +++ b/Makefile @@ -3000,6 +3000,10 @@ rpm:: @false .PHONY: rpm +ifneq ($(INCLUDE_DLLS_IN_ARTIFACTS),) +OTHER_PROGRAMS += $(shell echo *.dll t/helper/*.dll) +endif + artifacts-tar:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) \ GIT-BUILD-OPTIONS $(TEST_PROGRAMS) $(test_bindir_programs) \ $(NO_INSTALL) $(MOFILES) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 55ee23ad0f5a38..fe587ebd8d42d9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -130,6 +130,147 @@ jobs: PathtoPublish: t/failed-test-artifacts ArtifactName: failed-test-artifacts +- job: msvc_build + displayName: Windows (MSVC) Build + condition: succeeded() + pool: Hosted VS2017 + timeoutInMinutes: 240 + steps: + - powershell: | + if ("$GITFILESHAREPWD" -ne "" -and "$GITFILESHAREPWD" -ne "`$`(gitfileshare.pwd)") { + net use s: \\gitfileshare.file.core.windows.net\test-cache "$GITFILESHAREPWD" /user:AZURE\gitfileshare /persistent:no + cmd /c mklink /d "$(Build.SourcesDirectory)\test-cache" S:\ + } + displayName: 'Mount test-cache' + env: + GITFILESHAREPWD: $(gitfileshare.pwd) + - powershell: | + $urlbase = "https://dev.azure.com/git/git/_apis/build/builds" + $id = ((Invoke-WebRequest -UseBasicParsing "${urlbase}?definitions=9&statusFilter=completed&resultFilter=succeeded&`$top=1").content | ConvertFrom-JSON).value[0].id + $downloadUrl = ((Invoke-WebRequest -UseBasicParsing "${urlbase}/$id/artifacts").content | ConvertFrom-JSON).value[0].resource.downloadUrl + (New-Object Net.WebClient).DownloadFile($downloadUrl, "compat.zip") + Expand-Archive compat.zip -DestinationPath . -Force + Remove-Item compat.zip + displayName: 'Download vcpkg artifacts' + - powershell: | + $urlbase = "https://dev.azure.com/git-for-windows/git/_apis/build/builds" + $id = ((Invoke-WebRequest -UseBasicParsing "${urlbase}?definitions=22&statusFilter=completed&resultFilter=succeeded&`$top=1").content | ConvertFrom-JSON).value[0].id + $downloadUrl = ((Invoke-WebRequest -UseBasicParsing "${urlbase}/$id/artifacts").content | ConvertFrom-JSON).value[1].resource.downloadUrl + (New-Object Net.WebClient).DownloadFile($downloadUrl, "git-sdk-64-minimal.zip") + Expand-Archive git-sdk-64-minimal.zip -DestinationPath . -Force + Remove-Item git-sdk-64-minimal.zip + + # Let Git ignore the SDK and the test-cache + "/git-sdk-64-minimal/`n/test-cache/`n" | Out-File -NoNewLine -Encoding ascii -Append "$(Build.SourcesDirectory)\.git\info\exclude" + displayName: 'Download git-sdk-64-minimal' + - powershell: | + & compat\vcbuild\vcpkg_copy_dlls.bat release + if (!$?) { exit(1) } + & git-sdk-64-minimal\usr\bin\bash.exe -lc @" + INCLUDE_DLLS_IN_ARTIFACTS=YesPlease \ + ci/make-test-artifacts.sh artifacts + "@ + if (!$?) { exit(1) } + displayName: Build + env: + HOME: $(Build.SourcesDirectory) + MSYSTEM: MINGW64 + DEVELOPER: 1 + NO_PERL: 1 + MSVC: 1 + VCPKG_ROOT: $(Build.SourcesDirectory)\compat\vcbuild\vcpkg + - task: PublishPipelineArtifact@0 + displayName: 'Publish Pipeline Artifact: MSVC test artifacts' + inputs: + artifactName: 'msvc-artifacts' + targetPath: '$(Build.SourcesDirectory)\artifacts' + - task: PublishPipelineArtifact@0 + displayName: 'Publish Pipeline Artifact: git-sdk-64-min-msvc' + inputs: + artifactName: 'git-sdk-64-min-msvc' + targetPath: '$(Build.SourcesDirectory)\git-sdk-64-minimal' + - powershell: | + if ("$GITFILESHAREPWD" -ne "" -and "$GITFILESHAREPWD" -ne "`$`(gitfileshare.pwd)") { + cmd /c rmdir "$(Build.SourcesDirectory)\test-cache" + } + displayName: 'Unmount test-cache' + condition: true + env: + GITFILESHAREPWD: $(gitfileshare.pwd) + +- job: msvc_test + displayName: Windows (MSVC) Test + dependsOn: msvc_build + condition: succeeded() + pool: Hosted + timeoutInMinutes: 240 + strategy: + parallel: 10 + steps: + - powershell: | + if ("$GITFILESHAREPWD" -ne "" -and "$GITFILESHAREPWD" -ne "`$`(gitfileshare.pwd)") { + net use s: \\gitfileshare.file.core.windows.net\test-cache "$GITFILESHAREPWD" /user:AZURE\gitfileshare /persistent:no + cmd /c mklink /d "$(Build.SourcesDirectory)\test-cache" S:\ + } + displayName: 'Mount test-cache' + env: + GITFILESHAREPWD: $(gitfileshare.pwd) + - task: DownloadPipelineArtifact@0 + displayName: 'Download Pipeline Artifact: MSVC test artifacts' + inputs: + artifactName: 'msvc-artifacts' + targetPath: '$(Build.SourcesDirectory)' + - task: DownloadPipelineArtifact@0 + displayName: 'Download Pipeline Artifact: git-sdk-64-min-msvc' + inputs: + artifactName: 'git-sdk-64-min-msvc' + targetPath: '$(Build.SourcesDirectory)\git-sdk-64-minimal' + - powershell: | + & git-sdk-64-minimal\usr\bin\bash.exe -lc @" + test -f artifacts.tar.gz || { + echo No test artifacts found\; skipping >&2 + exit 0 + } + tar xf artifacts.tar.gz || exit 1 + + # Let Git ignore the SDK and the test-cache + printf '%s\n' /git-sdk-64-minimal/ /test-cache/ >>.git/info/exclude + + ci/run-test-slice.sh `$SYSTEM_JOBPOSITIONINPHASE `$SYSTEM_TOTALJOBSINPHASE || { + ci/print-test-failures.sh + exit 1 + } + "@ + if (!$?) { exit(1) } + displayName: 'Test (parallel)' + env: + HOME: $(Build.SourcesDirectory) + MSYSTEM: MINGW64 + NO_SVN_TESTS: 1 + GIT_TEST_SKIP_REBASE_P: 1 + - powershell: | + if ("$GITFILESHAREPWD" -ne "" -and "$GITFILESHAREPWD" -ne "`$`(gitfileshare.pwd)") { + cmd /c rmdir "$(Build.SourcesDirectory)\test-cache" + } + displayName: 'Unmount test-cache' + condition: true + env: + GITFILESHAREPWD: $(gitfileshare.pwd) + - task: PublishTestResults@2 + displayName: 'Publish Test Results **/TEST-*.xml' + inputs: + mergeTestResults: true + testRunTitle: 'msvc' + platform: Windows + publishRunAttachments: false + condition: succeededOrFailed() + - task: PublishBuildArtifacts@1 + displayName: 'Publish trash directories of failed tests' + condition: failed() + inputs: + PathtoPublish: t/failed-test-artifacts + ArtifactName: failed-msvc-test-artifacts + - job: linux_clang displayName: linux-clang condition: succeeded() diff --git a/ci/lib.sh b/ci/lib.sh index 288a5b3884ad82..93a5cba811d761 100755 --- a/ci/lib.sh +++ b/ci/lib.sh @@ -116,6 +116,11 @@ then CI_OS_NAME="$(echo "$AGENT_OS" | tr A-Z a-z)" test darwin != "$CI_OS_NAME" || CI_OS_NAME=osx CI_REPO_SLUG="$(expr "$BUILD_REPOSITORY_URI" : '.*/\([^/]*/[^/]*\)$')" + if test -n "$MSVC" + then + CC=compat/vcbuild/scripts/clink.pl + jobname=windows-msvc + fi CC="${CC:-gcc}" # use a subdirectory of the cache dir (because the file share is shared