Skip to content

Commit f933258

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 f933258

11 files changed

Lines changed: 265 additions & 538 deletions

File tree

.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: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
version: 0.0.{build}-{branch}
2+
3+
shallow_clone: true
4+
5+
branches:
6+
only:
7+
- master
8+
9+
# this a not a .NET project in all cases - we will build during install phase
10+
build: false
11+
12+
install:
13+
- ci\appveyor\env.bat
14+
- ci\appveyor\install.bat
15+
16+
test_script:
17+
- ci\appveyor\test.bat
18+
19+
matrix:
20+
allow_failures:
21+
- MAYFAIL: true
22+
23+
environment:
24+
global:
25+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
26+
CMAKE_BUILD_TYPE: Release
27+
28+
matrix:
29+
# Cygwin
30+
- ADDPATH: C:\cygwin\bin;
31+
WRAPPER: cygwin
32+
33+
# Cygwin64
34+
- ADDPATH: C:\cygwin64\bin;
35+
WRAPPER: cygwin64
36+
37+
# MinGW
38+
- ADDPATH: C:\mingw\bin;
39+
GENERATOR: MinGW Makefiles
40+
WRAPPER: mingw
41+
42+
# MinGW-w64
43+
- ADDPATH: C:\mingw64\bin;
44+
GENERATOR: MinGW Makefiles
45+
WRAPPER: mingw
46+
47+
# MSYS2
48+
- ADDPATH: C:\msys64\usr\bin;
49+
GENERATOR: MSYS Makefiles
50+
51+
# Visual Studio 2010
52+
- GENERATOR: Visual Studio 10 2010
53+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
54+
55+
# Visual Studio 2015 Win64 Debug
56+
- GENERATOR: Visual Studio 14 2015 Win64
57+
CMAKE_BUILD_TYPE: Debug
58+
59+
# Visual Studio 2015 Win64 RelWithDebInfo
60+
- GENERATOR: Visual Studio 14 2015 Win64
61+
CMAKE_BUILD_TYPE: RelWithDebInfo
62+
63+
# Visual Studio 2015 Win64 Release
64+
- GENERATOR: Visual Studio 14 2015 Win64

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: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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 (optional) [mingw, cygwin, cygwin64]
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+
@ECHO ON
24+
25+
SET BUILDDIR=C:\temp\build
26+
SET INSTDIR=C:\temp\install
27+
SET SRCDIR=%CD%
28+
29+
SET PATH=%ADDPATH%%PATH%
30+
31+
IF "%WRAPPER%" == "cygwin" (
32+
SET CYGDIR=C:\cygwin
33+
SET CYGSETUP=C:\cygwin\setup-x86.exe
34+
For /F "Tokens=1" %%I in (C:\cygwin\bin\cygpath -u "%SRCDIR%") Do Set CYGSRCDIR=%%I
35+
For /F "Tokens=1" %%I in (C:\cygwin\bin\cygpath -u "%INSTDIR%") Do Set CYGINSTDIR=%%I
36+
) ELSE IF "%WRAPPER%" == "cygwin64" (
37+
SET CYGDIR=C:\cygwin64
38+
SET CYGSETUP=C:\cygwin\setup-x86_64.exe
39+
For /F "Tokens=1" %%I in (C:\cygwin64\bin\cygpath -u "%SRCDIR%") Do Set CYGSRCDIR=%%I
40+
For /F "Tokens=1" %%I in (C:\cygwin64\bin\cygpath -u "%INSTDIR%") Do Set CYGINSTDIR=%%I
41+
)
42+
43+
IF DEFINED GENERATOR (
44+
SET DASHG="-G%GENERATOR%"
45+
)

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/cygwin -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 EXIST %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)