Commit 959482e104261286ea31f261d6694424b330938b

Edward Thomson 2015-03-09T09:18:37

Merge pull request #2946 from tkelman/appveyor-mingw RFC: add mingw to appveyor matrix

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c63107b..1948fc8 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)
diff --git a/appveyor.yml b/appveyor.yml
index d155485..c6a9f1d 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -11,11 +11,32 @@ environment:
     ARCH: 32
   - GENERATOR: "Visual Studio 11 Win64"
     ARCH: 64
+  - GENERATOR: "MSYS Makefiles"
+    ARCH: 32
+  - GENERATOR: "MSYS Makefiles"
+    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
 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
-    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
+    }
+- 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
new file mode 100755
index 0000000..48e0bad
--- /dev/null
+++ b/script/appveyor-mingw.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+set -e
+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
diff --git a/script/cibuild.sh b/script/cibuild.sh
index 8983dcc..82cf725 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 347922b..3eb57ce 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 c2e0162..ad6a7b4 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
diff --git a/src/win32/mingw-compat.h b/src/win32/mingw-compat.h
index feedfec..a4a5a31 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__ */
diff --git a/src/win32/msvc-compat.h b/src/win32/msvc-compat.h
index 4789d63..8004bc1 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 9ac7843..4bc6bfe 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);
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c
index b8b4f43..544b1eb 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. */