From ac5fad2780a381a2d60fb00e4104c713faa301ec Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Tue, 3 Mar 2015 10:53:26 -0800 Subject: [PATCH 1/9] add mingw to appveyor matrix use MSYS makefiles generator add bash script for running mingw on appveyor add --login and fix run paths use msys style path to appveyor-mingw.sh add mingw path to /etc/fstab --- appveyor.yml | 10 ++++++++-- script/appveyor-mingw.sh | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100755 script/appveyor-mingw.sh diff --git a/appveyor.yml b/appveyor.yml index d155485fd..00a2fd2f5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,11 +11,17 @@ environment: ARCH: 32 - GENERATOR: "Visual Studio 11 Win64" ARCH: 64 + - GENERATOR: "MSYS Makefiles" + ARCH: 32 build_script: - ps: | mkdir build cd build - cmake -D ENABLE_TRACE=ON -D BUILD_CLAR=ON .. -G"$env:GENERATOR" - cmake --build . --config RelWithDebInfo + if ($env:GENERATOR -ne "MSYS Makefiles") { + cmake -D ENABLE_TRACE=ON -D BUILD_CLAR=ON .. -G"$env:GENERATOR" + cmake --build . --config RelWithDebInfo + } else { + C:\MinGW\msys\1.0\bin\sh --login /c/projects/libgit2/script/appveyor-mingw.sh + } test_script: - ps: ctest -V . diff --git a/script/appveyor-mingw.sh b/script/appveyor-mingw.sh new file mode 100755 index 000000000..aaafa4903 --- /dev/null +++ b/script/appveyor-mingw.sh @@ -0,0 +1,6 @@ +#!/bin/sh +set -e +cd `dirname "$0"`/../build +echo 'C:\MinGW\ /MinGW' > /etc/fstab +cmake -D ENABLE_TRACE=ON -D BUILD_CLAR=ON .. -G"$GENERATOR" +cmake --build . --config RelWithDebInfo From 8008ab6a4158416d095212c9782fa1622ef994a5 Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Tue, 3 Mar 2015 17:03:07 -0800 Subject: [PATCH 2/9] add fast-fail feature for pending builds in PR's --- appveyor.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 00a2fd2f5..5358becb0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,6 +15,10 @@ environment: ARCH: 32 build_script: - ps: | + if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod ` + https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | ` + Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { ` + throw "There are newer queued builds for this pull request, failing early." } mkdir build cd build if ($env:GENERATOR -ne "MSYS Makefiles") { From ba6c53b91b1d9c9dc49b7c0d8e8efbd9842c31dc Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Tue, 3 Mar 2015 21:07:12 -0800 Subject: [PATCH 3/9] Implement fail-fast for Travis as well --- script/cibuild.sh | 10 ++++++++++ script/install-deps-linux.sh | 2 +- script/install-deps-osx.sh | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/script/cibuild.sh b/script/cibuild.sh index 8983dcce0..82cf72553 100755 --- a/script/cibuild.sh +++ b/script/cibuild.sh @@ -1,5 +1,15 @@ #!/bin/sh +# Fail fast for superseded builds to PR's +if ! [ "$TRAVIS_PULL_REQUEST" = "false" ]; then + if ! [ \"$TRAVIS_BUILD_NUMBER\" = $(curl -H "Accept: application/vnd.travis-ci.2+json" \ + https://api.travis-ci.org/repos/libgit2/libgit2/builds?event_type=pull_request | \ + jq ".builds | map(select(.pull_request_number == $TRAVIS_PULL_REQUEST))[0].number") ]; then + echo "There are newer queued builds for this pull request, failing early." + exit 1 + fi +fi + if [ -n "$COVERITY" ]; then ./script/coverity.sh; diff --git a/script/install-deps-linux.sh b/script/install-deps-linux.sh index 347922b89..3eb57ce1a 100755 --- a/script/install-deps-linux.sh +++ b/script/install-deps-linux.sh @@ -3,4 +3,4 @@ set -x sudo apt-get -qq update && -sudo apt-get -qq install cmake libssh2-1-dev openssh-client openssh-server +sudo apt-get -qq install cmake libssh2-1-dev openssh-client openssh-server jq diff --git a/script/install-deps-osx.sh b/script/install-deps-osx.sh index c2e0162d8..ad6a7b41d 100755 --- a/script/install-deps-osx.sh +++ b/script/install-deps-osx.sh @@ -2,4 +2,4 @@ set -x -brew install libssh2 cmake +brew install libssh2 cmake jq From 4c88fd7ce6a385fa313e93d4e1f594f29ccf1a36 Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Wed, 4 Mar 2015 11:31:24 -0800 Subject: [PATCH 4/9] Add MinGW-w64 to matrix cache mingw-w64 downloads quiet curl and 7zip run appveyor steps in cmd for mingw --- appveyor.yml | 11 +++++++++-- script/appveyor-mingw.sh | 21 +++++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 5358becb0..647ef16b5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,6 +13,13 @@ environment: ARCH: 64 - GENERATOR: "MSYS Makefiles" ARCH: 32 + - GENERATOR: "MSYS Makefiles" + ARCH: i686 # this is for 32-bit MinGW-w64 + - GENERATOR: "MSYS Makefiles" + ARCH: 64 +cache: +- i686-4.9.2-release-win32-sjlj-rt_v3-rev1.7z +- x86_64-4.9.2-release-win32-seh-rt_v3-rev1.7z build_script: - ps: | if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod ` @@ -24,8 +31,8 @@ build_script: if ($env:GENERATOR -ne "MSYS Makefiles") { cmake -D ENABLE_TRACE=ON -D BUILD_CLAR=ON .. -G"$env:GENERATOR" cmake --build . --config RelWithDebInfo - } else { - C:\MinGW\msys\1.0\bin\sh --login /c/projects/libgit2/script/appveyor-mingw.sh } +- cmd: | + if "%GENERATOR%"=="MSYS Makefiles" (C:\MinGW\msys\1.0\bin\sh --login /c/projects/libgit2/script/appveyor-mingw.sh) test_script: - ps: ctest -V . diff --git a/script/appveyor-mingw.sh b/script/appveyor-mingw.sh index aaafa4903..48e0bad0a 100755 --- a/script/appveyor-mingw.sh +++ b/script/appveyor-mingw.sh @@ -1,6 +1,23 @@ #!/bin/sh set -e -cd `dirname "$0"`/../build -echo 'C:\MinGW\ /MinGW' > /etc/fstab +cd `dirname "$0"`/.. +if [ "$ARCH" = "32" ]; then + echo 'C:\MinGW\ /MinGW' > /etc/fstab +elif [ "$ARCH" = "i686" ]; then + f=i686-4.9.2-release-win32-sjlj-rt_v3-rev1.7z + if ! [ -e $f ]; then + curl -LsSO http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.2/threads-win32/sjlj/$f + fi + 7z x $f > /dev/null + mv mingw32 /MinGW +else + f=x86_64-4.9.2-release-win32-seh-rt_v3-rev1.7z + if ! [ -e $f ]; then + curl -LsSO http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.2/threads-win32/seh/$f + fi + 7z x $f > /dev/null + mv mingw64 /MinGW +fi +cd build cmake -D ENABLE_TRACE=ON -D BUILD_CLAR=ON .. -G"$GENERATOR" cmake --build . --config RelWithDebInfo From 063532825cb9f736b7c2ed65c8f3269540df1ccc Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Thu, 5 Mar 2015 15:48:08 -0800 Subject: [PATCH 5/9] Only run -ionline tests IF (WINHTTP OR OPENSSL_FOUND) --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c63107bf0..1948fc88b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -493,7 +493,11 @@ IF (BUILD_CLAR) ENDIF () ENABLE_TESTING() - ADD_TEST(libgit2_clar libgit2_clar -ionline) + IF (WINHTTP OR OPENSSL_FOUND) + ADD_TEST(libgit2_clar libgit2_clar -ionline) + ELSE () + ADD_TEST(libgit2_clar libgit2_clar -v) + ENDIF () ENDIF () IF (TAGS) From 2326ea68b50756e44917e21142f22ac9baac63f6 Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Thu, 5 Mar 2015 16:14:17 -0800 Subject: [PATCH 6/9] Allow failures on mingw for now --- appveyor.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 647ef16b5..c6a9f1d71 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -17,6 +17,10 @@ environment: ARCH: i686 # this is for 32-bit MinGW-w64 - GENERATOR: "MSYS Makefiles" ARCH: 64 +matrix: + allow_failures: + - GENERATOR: "MSYS Makefiles" + ARCH: 32 cache: - i686-4.9.2-release-win32-sjlj-rt_v3-rev1.7z - x86_64-4.9.2-release-win32-seh-rt_v3-rev1.7z From 1a7ea63d228d42dc0ec1bed3a295d3dfe9392d74 Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Thu, 5 Mar 2015 17:11:17 -0800 Subject: [PATCH 7/9] Move definitions of strcasecmp and strncasecmp to msvc-compat.h should cut down on compiler warnings with mingw --- src/win32/msvc-compat.h | 3 +++ src/win32/posix.h | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/win32/msvc-compat.h b/src/win32/msvc-compat.h index 4789d63df..8004bc1f8 100644 --- a/src/win32/msvc-compat.h +++ b/src/win32/msvc-compat.h @@ -15,6 +15,9 @@ typedef unsigned short mode_t; typedef SSIZE_T ssize_t; +#define strcasecmp(s1, s2) _stricmp(s1, s2) +#define strncasecmp(s1, s2, c) _strnicmp(s1, s2, c) + #endif #define GIT_STDLIB_CALL __cdecl diff --git a/src/win32/posix.h b/src/win32/posix.h index 9ac78430b..4bc6bfe2e 100644 --- a/src/win32/posix.h +++ b/src/win32/posix.h @@ -32,8 +32,6 @@ extern int p_recv(GIT_SOCKET socket, void *buffer, size_t length, int flags); extern int p_send(GIT_SOCKET socket, const void *buffer, size_t length, int flags); extern int p_inet_pton(int af, const char* src, void* dst); -#define strcasecmp(s1, s2) _stricmp(s1, s2) -#define strncasecmp(s1, s2, c) _strnicmp(s1, s2, c) extern int p_vsnprintf(char *buffer, size_t count, const char *format, va_list argptr); extern int p_snprintf(char *buffer, size_t count, const char *format, ...) GIT_FORMAT_PRINTF(3, 4); extern int p_mkstemp(char *tmp_path); From 04c5a9c0838a9c44b55afb427169318ec4a44ec2 Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Thu, 5 Mar 2015 19:42:54 -0800 Subject: [PATCH 8/9] Add some missing definitions for mingw.org these shouldn't be necessary if _WIN32_WINNT >= _WIN32_WINNT_VISTA --- src/win32/mingw-compat.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/win32/mingw-compat.h b/src/win32/mingw-compat.h index feedfecf4..a4a5a31c7 100644 --- a/src/win32/mingw-compat.h +++ b/src/win32/mingw-compat.h @@ -17,6 +17,13 @@ #define stat _stati64 #endif +#if _WIN32_WINNT < 0x0600 && !defined(__MINGW64_VERSION_MAJOR) +#undef MemoryBarrier +void __mingworg_MemoryBarrier(void); +#define MemoryBarrier __mingworg_MemoryBarrier +#define VOLUME_NAME_DOS 0x0 +#endif + #endif #endif /* INCLUDE_mingw_compat__ */ From 78c34af016dc69e7553e671ad3795ffb9dbb93ef Mon Sep 17 00:00:00 2001 From: Matti Virolainen Date: Fri, 6 Mar 2015 12:23:14 +0200 Subject: [PATCH 9/9] Use secure API if available. --- src/win32/posix_w32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c index b8b4f43f8..544b1ebd5 100644 --- a/src/win32/posix_w32.c +++ b/src/win32/posix_w32.c @@ -55,7 +55,7 @@ int p_ftruncate(int fd, git_off_t size) return -1; } -#if !defined(__MINGW32__) +#if !defined(__MINGW32__) || defined(MINGW_HAS_SECURE_API) return ((_chsize_s(fd, size) == 0) ? 0 : -1); #else /* TODO MINGW32 Find a replacement for _chsize() that handles big files. */