Skip to content

Commit 2d7aabd

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 2d7aabd

File tree

11 files changed

+262
-538
lines changed

11 files changed

+262
-538
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: 11 additions & 3 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)
@@ -181,7 +185,7 @@ if(MINGW)
181185
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
182186
-i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
183187
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
184-
endif(MINGW)
188+
endif()
185189

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

ci/appveyor/build.bat

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@ECHO ON
2+
SETLOCAL EnableDelayedExpansion
3+
CALL ci\appveyor\env.bat
4+
5+
:: Create the build directory
6+
MKDIR %BUILDDIR% || EXIT /B
7+
CD %BUILDDIR%
8+
9+
cmake --version
10+
11+
::IF "%WRAPPER:~0,6%" == "cygwin" (
12+
:: Run the cygwin cmake build in a cygwin bash shell
13+
:: bash.exe -c "cmake !CYGSRCDIR! %DASHG% -DCMAKE_INSTALL_PREFIX=!CYGINSTDIR! && cmake --build . --target install --config %CMAKE_BUILD_TYPE%" || EXIT /B
14+
::) ELSE (
15+
cmake "%SRCDIR%" %DASHG% -DCMAKE_INSTALL_PREFIX=%INSTDIR% || EXIT /B
16+
cmake --build . --target install --config %CMAKE_BUILD_TYPE% || EXIT /B
17+
::)
18+
19+
DIR /S %INSTDIR%

ci/appveyor/env.bat

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
::
2+
:: Environment Variables
3+
::
4+
:: In:
5+
:: ADDPATH contains path directories that are prepended to the path (optional)
6+
:: CMAKE_BUILD_TYPE sets the build configuration (required)
7+
:: GENERATOR is the cmake generator to use (optional)
8+
:: WRAPPER is the build type wrapper to use
9+
::
10+
:: Out:
11+
:: BUILDDIR is the directory to do the build in
12+
:: INSTDIR is the directory to put the install target files into
13+
:: SRCDIR is the directory containing the project
14+
::
15+
:: CYGDIR is the home of cygwin, whichever flavor is being used
16+
:: CYGSETUP is the path to the setup executable for instlaling things
17+
:: CYGINSTDIR is INSTDIR translated to cygwin's /cygdrive/... path syntax
18+
:: CYGSRCDIR is SRCDIR translated to cygwin's /cygdrive/... path syntax
19+
::
20+
:: DASHG is the cmake -G"<generator>" argument content
21+
::
22+
23+
SET BUILDDIR=C:\temp\build
24+
SET INSTDIR=C:\temp\install
25+
SET SRCDIR=%CD%
26+
27+
SET PATH=%ADDPATH%%PATH%
28+
29+
IF "%WRAPPER%" == "cygwin" (
30+
SET CYGDIR=C:\cygwin
31+
SET CYGSETUP=C:\cygwin\setup-x86.exe
32+
For /F "Tokens=1" %%I in (C:\cygwin\bin\cygpath -u "%SRCDIR%") Do Set CYGSRCDIR=%%I
33+
For /F "Tokens=1" %%I in (C:\cygwin\bin\cygpath -u "%INSTDIR%") Do Set CYGINSTDIR=%%I
34+
) ELSE IF "%WRAPPER%" == "cygwin64" (
35+
SET CYGDIR=C:\cygwin64
36+
SET CYGSETUP=C:\cygwin\setup-x86_64.exe
37+
For /F "Tokens=1" %%I in (C:\cygwin64\bin\cygpath -u "%SRCDIR%") Do Set CYGSRCDIR=%%I
38+
For /F "Tokens=1" %%I in (C:\cygwin64\bin\cygpath -u "%INSTDIR%") Do Set CYGINSTDIR=%%I
39+
)

ci/appveyor/install.bat

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@ECHO ON
2+
SETLOCAL EnableDelayedExpansion
3+
CALL ci\appveyor\env.bat
4+
5+
:: Move sh.exe out of the path for MinGW builds to work
6+
IF "%WRAPPER:~0,5%" == "mingw" (
7+
REN "C:\Program Files\Git\usr\bin\sh.exe" "sh.exx"
8+
)
9+
10+
:: Install missing cygwin packages
11+
:: cmake and make are obvious; cygwin is to ensure the command "cygpath" is there
12+
IF "%WRAPPER:~0,6%" == "cygwin" (
13+
%CYGSETUP% -B -q -n -N -d -l %CYGDIR%/var/cache/setup -R %CYGDIR% -s http://mirror.rit.edu -P cmake cygwin make
14+
)
15+
16+
CALL ci\appveyor\build.bat

ci/appveyor/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+
CALL ci\appveyor\env.bat
4+
5+
CD %BUILDDIR% || EXIT /B
6+
ctest -D ExperimentalTest || EXIT /B
7+
8+
IF EXISTS %CMAKE_BUILD_TYPE% (
9+
CD %CMAKE_BUILD_TYPE% || EXIT /B
10+
)
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

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

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)