Skip to content

Commit 0534ac6

Browse files
author
James E. King, III
committed
Add continuous integration support for GitHub
pull requests through Travis CI and Appveyor. Fix cygwin build issues. Recommend everyone use cmake to generate build environments, and consider checked-in projects or makefiles to be deprecated. The generated build will always be correct, and proven by CI. This fixes madler#162 This fixes madler#238 This fixes madler#307
1 parent cacf7f1 commit 0534ac6

File tree

9 files changed

+233
-537
lines changed

9 files changed

+233
-537
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@
2424
/configure.log
2525

2626
.DS_Store
27+
28+
.vs/

.travis.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
sudo: false
2+
dist: trusty
3+
language: c
4+
5+
branches:
6+
only:
7+
- master
8+
9+
script:
10+
- ci/build.sh
11+
12+
compiler:
13+
# - clang
14+
- gcc
15+
16+
os:
17+
- linux
18+
# - osx
19+
20+
env:
21+
- CMAKE_BUILD_TYPE=Debug
22+
- CMAKE_BUILD_TYPE=RelWithDebInfo
23+
- CMAKE_BUILD_TYPE=Release
24+
- CONFIGURE=
25+
26+
matrix:
27+
include:
28+
- os: linux
29+
compiler: clang
30+
env:
31+
- CMAKE_BUILD_TYPE=debug
32+
- CTEST_DASHBOARD=ExperimentalMemCheck
33+
addons:
34+
apt:
35+
packages:
36+
- valgrind
37+
- os: linux
38+
compiler: gcc
39+
env:
40+
- COMMENT=UBSAN
41+
- CMAKE_BUILD_TYPE=debug
42+
- CMAKE_C_COMPILER=gcc-7
43+
- CFLAGS='-fno-omit-frame-pointer -fsanitize=undefined'
44+
- LDFLAGS='-fsanitize=undefined'
45+
addons:
46+
apt:
47+
packages:
48+
- g++-7
49+
sources:
50+
- ubuntu-toolchain-r-test
51+
52+
notifications:
53+
email:
54+
false
55+

CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ include(CheckTypeSize)
1818
include(CheckFunctionExists)
1919
include(CheckIncludeFile)
2020
include(CheckCSourceCompiles)
21-
enable_testing()
21+
if(UNIX)
22+
find_program( MEMORYCHECK_COMMAND valgrind )
23+
set( MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --leak-check=full" )
24+
endif()
25+
include(CTest)
2226

2327
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
2428
check_include_file(stdint.h HAVE_STDINT_H)
@@ -167,7 +171,7 @@ file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
167171
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
168172
"\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
169173

170-
if(MINGW)
174+
if(MINGW OR CYGWIN)
171175
# This gets us DLL resource information when compiling on MinGW.
172176
if(NOT CMAKE_RC_COMPILER)
173177
set(CMAKE_RC_COMPILER windres.exe)
@@ -234,6 +238,10 @@ add_executable(example test/example.c)
234238
target_link_libraries(example zlib)
235239
add_test(example example)
236240

241+
add_executable(infcover test/infcover.c)
242+
target_link_libraries(infcover zlibstatic)
243+
add_test(infcover infcover)
244+
237245
add_executable(minigzip test/minigzip.c)
238246
target_link_libraries(minigzip zlib)
239247

appveyor.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
version: 0.0.{build}-{branch}
2+
3+
shallow_clone: true
4+
5+
branches:
6+
only:
7+
- master
8+
9+
matrix:
10+
allow_failures:
11+
- MAYFAIL: true
12+
13+
environment:
14+
global:
15+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
16+
CMAKE_BUILD_TYPE: Release
17+
18+
matrix:
19+
# MinGW
20+
- ADDPATH: C:\mingw\bin;
21+
GENERATOR: MinGW Makefiles
22+
23+
# MinGW-w64
24+
- ADDPATH: C:\mingw64\bin;
25+
GENERATOR: MinGW Makefiles
26+
27+
- GENERATOR: Visual Studio 10 2010
28+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
29+
30+
# - GENERATOR: Visual Studio 11 2012
31+
# APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
32+
33+
# - GENERATOR: Visual Studio 12 2013
34+
# APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
35+
36+
- GENERATOR: Visual Studio 14 2015 Win64
37+
38+
- GENERATOR: Visual Studio 14 2015 Win64
39+
CMAKE_BUILD_TYPE: RelWithDebInfo
40+
41+
- GENERATOR: Visual Studio 14 2015 Win64
42+
CMAKE_BUILD_TYPE: Debug
43+
44+
# - GENERATOR: Visual Studio 15 2017 Win64
45+
46+
# Cygwin
47+
- ADDPATH: C:\cygwin\bin;
48+
MAYFAIL: true
49+
WHYFAIL: https://github.com/madler/zlib/issues/268
50+
WRAPPER: cygwin
51+
52+
# Cygwin64
53+
- ADDPATH: C:\cygwin64\bin;
54+
MAYFAIL: true
55+
WHYFAIL: https://github.com/madler/zlib/issues/268
56+
WRAPPER: cygwin64
57+
58+
# MSYS2
59+
- ADDPATH: C:\msys64\usr\bin;
60+
GENERATOR: MSYS Makefiles
61+
MAYFAIL: true
62+
WHYFAIL: https://github.com/madler/zlib/issues/268
63+
64+
install:
65+
- ci\build.bat
66+
67+
# Not a .NET project - we build in the install phase
68+
build: false
69+
70+
test_script:
71+
- ci\test.bat

ci/build.bat

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
::
2+
:: Environment Variables
3+
::
4+
:: CMAKE_BUILD_TYPE sets the build configuration
5+
::
6+
7+
@ECHO ON
8+
SETLOCAL EnableDelayedExpansion
9+
10+
SET BUILDDIR=C:\TEMP\BUILD
11+
SET INSTDIR=C:\TEMP\INSTALL
12+
SET SRCDIR=%CD%
13+
14+
SET PATH=%ADDPATH%%PATH%
15+
16+
::
17+
:: Move sh.exe out of the path for MinGW builds to work
18+
::
19+
20+
REN "C:\Program Files\Git\usr\bin\sh.exe" "sh.exx"
21+
22+
MKDIR %BUILDDIR%
23+
CD %BUILDDIR%
24+
25+
IF DEFINED GENERATOR (SET DASHG=-G"%GENERATOR%")
26+
27+
IF "%WRAPPER%" == "cygwin" (
28+
c:\cygwin\setup-x86.exe -B -q -n -N -d -l C:/cygwin/var/cache/setup -R c:\cygwin -s http://cygwin.mirror.constant.com -P cmake make
29+
For /F "Tokens=1" %%I in (C:\cygwin\bin\cygpath -u "%SRCDIR%") Do Set UNIXSRCDIR=%%I
30+
For /F "Tokens=1" %%I in (C:\cygwin\bin\cygpath -u "%INSTDIR%") Do Set UNIXINSTDIR=%%I
31+
bash.exe -c "cmake --version && cmake !UNIXSRCDIR! %DASHG% -DCMAKE_INSTALL_PREFIX=!UNIXINSTDIR! && cmake --build . --target install --config %CMAKE_BUILD_TYPE%" || EXIT /B
32+
) ELSE IF "%WRAPPER%" == "cygwin64" (
33+
c:\cygwin64\setup-x86_64.exe -B -q -n -N -d -l C:/cygwin64/var/cache/setup -R c:\cygwin64 -s http://cygwin.mirror.constant.com -P cmake make
34+
For /F "Tokens=1" %%I in (C:\cygwin64\bin\cygpath -u "%SRCDIR%") Do Set UNIXSRCDIR=%%I
35+
For /F "Tokens=1" %%I in (C:\cygwin64\bin\cygpath -u "%INSTDIR%") Do Set UNIXINSTDIR=%%I
36+
bash.exe -c "cmake --version && cmake !UNIXSRCDIR! %DASHG% -DCMAKE_INSTALL_PREFIX=!UNIXINSTDIR! && cmake --build . --target install --config %CMAKE_BUILD_TYPE%" || EXIT /B
37+
) ELSE (
38+
cmake "%SRCDIR%" %DASHG% -DCMAKE_INSTALL_PREFIX=%INSTDIR% || EXIT /B
39+
cmake --build . --target install --config %CMAKE_BUILD_TYPE% || EXIT /B
40+
)
41+
42+
DIR /S C:\TEMP\INSTALL

ci/build.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
#
3+
# Environment Variables
4+
#
5+
# CMAKE_BUILD_TYPE sets the cmake variable by that name (default if not set: use ./configure)
6+
# CMAKE_C_COMPILER sets the cmake variable by that name (default if not set: $CC)
7+
# CTEST_DASHBOARD sets the dashboard suite to run (default if not set: ExperimentalTest)
8+
#
9+
10+
set -ex
11+
12+
SRCDIR=`pwd`
13+
if [[ "${CTEST_BASHBOARD}" == "ExperimentalMemCheck" ]]; then
14+
RUNNER=valgrind
15+
fi
16+
mkdir /tmp/build
17+
cd /tmp/build
18+
19+
if [[ ! -z "$CMAKE_BUILD_TYPE" ]]; then
20+
cmake $SRCDIR -DCMAKE_INSTALL_PREFIX=/tmp/install \
21+
-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
22+
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER:-$CC}
23+
VERBOSE=1 cmake --build . --target install
24+
ctest -D ${CTEST_DASHBOARD:-ExperimentalTest}
25+
ls -lsR /tmp/install
26+
else
27+
$SRCDIR/configure $CONFIGURE --prefix=/tmp/install
28+
make -j2 install
29+
make test
30+
ls -lsR /tmp/install
31+
fi
32+
33+
cp libz.a libz.a.orig
34+
$RUNNER ./minigzip64 -9 libz.a
35+
$RUNNER ./minigzip64 -d libz.a.gz
36+
cmp libz.a libz.a.orig

ci/test.bat

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@ECHO ON
2+
SETLOCAL
3+
4+
SET SRCDIR=%CD%
5+
SET PATH=%ADDPATH%%PATH%
6+
7+
CD C:\TEMP\BUILD || EXIT /B
8+
ctest -D ExperimentalTest || EXIT /B
9+
10+
CD %CMAKE_BUILD_TYPE% || EXIT /B
11+
COPY example.exe example.exe.orig || EXIT /B
12+
minigzip -3 example.exe || EXIT /B
13+
minigzip -9 example.exe.gz || EXIT /B
14+
minigzip -d example.exe.gz.gz || EXIT /B
15+
minigzip -d example.exe.gz || EXIT /B
16+
fc /B example.exe example.exe.orig > nul || EXIT /B

gzguts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
# include <io.h>
4040
#endif
4141

42-
#if defined(_WIN32) || defined(__CYGWIN__)
42+
#if defined(_WIN32)
4343
# define WIDECHAR
4444
#endif
4545

0 commit comments

Comments
 (0)