Skip to content

Commit

Permalink
Add continuous integration support for GitHub
Browse files Browse the repository at this point in the history
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
  • Loading branch information
James E. King, III committed Nov 23, 2017
1 parent cacf7f1 commit 7b8aa04
Show file tree
Hide file tree
Showing 11 changed files with 261 additions and 538 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@
/configure.log

.DS_Store

.vs/
55 changes: 55 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
sudo: false
dist: trusty
language: c

branches:
only:
- master

script:
- ci/build.sh

compiler:
# - clang
- gcc

os:
- linux
# - osx

env:
- CMAKE_BUILD_TYPE=Debug
- CMAKE_BUILD_TYPE=RelWithDebInfo
- CMAKE_BUILD_TYPE=Release
- CONFIGURE=

matrix:
include:
- os: linux
compiler: clang
env:
- CMAKE_BUILD_TYPE=debug
- CTEST_DASHBOARD=ExperimentalMemCheck
addons:
apt:
packages:
- valgrind
- os: linux
compiler: gcc
env:
- COMMENT=UBSAN
- CMAKE_BUILD_TYPE=debug
- CMAKE_C_COMPILER=gcc-7
- CFLAGS='-fno-omit-frame-pointer -fsanitize=undefined'
- LDFLAGS='-fsanitize=undefined'
addons:
apt:
packages:
- g++-7
sources:
- ubuntu-toolchain-r-test

notifications:
email:
false

14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ include(CheckTypeSize)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CheckCSourceCompiles)
enable_testing()
if(UNIX)
find_program( MEMORYCHECK_COMMAND valgrind )
set( MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --leak-check=full" )
endif()
include(CTest)

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

if(MINGW)
if(MINGW OR CYGWIN)
# This gets us DLL resource information when compiling on MinGW.
if(NOT CMAKE_RC_COMPILER)
set(CMAKE_RC_COMPILER windres.exe)
Expand All @@ -181,7 +185,7 @@ if(MINGW)
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
-i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
endif(MINGW)
endif()

add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
Expand Down Expand Up @@ -234,6 +238,10 @@ add_executable(example test/example.c)
target_link_libraries(example zlib)
add_test(example example)

add_executable(infcover test/infcover.c)
target_link_libraries(infcover zlibstatic)
add_test(infcover infcover)

add_executable(minigzip test/minigzip.c)
target_link_libraries(minigzip zlib)

Expand Down
71 changes: 71 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
version: 0.0.{build}-{branch}

shallow_clone: true

branches:
only:
- master

install:
- ci\appveyor\env.bat
- ci\appveyor\install.bat

build: ci\appveyor\build.bat

test_script: ci\appveyor\test.bat

matrix:
allow_failures:
- MAYFAIL: true

environment:
global:
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
CMAKE_BUILD_TYPE: Release

matrix:
# MinGW
- ADDPATH: C:\mingw\bin;
GENERATOR: MinGW Makefiles

# MinGW-w64
- ADDPATH: C:\mingw64\bin;
GENERATOR: MinGW Makefiles

- GENERATOR: Visual Studio 10 2010
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013

# - GENERATOR: Visual Studio 11 2012
# APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013

# - GENERATOR: Visual Studio 12 2013
# APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013

- GENERATOR: Visual Studio 14 2015 Win64

- GENERATOR: Visual Studio 14 2015 Win64
CMAKE_BUILD_TYPE: RelWithDebInfo

- GENERATOR: Visual Studio 14 2015 Win64
CMAKE_BUILD_TYPE: Debug

# - GENERATOR: Visual Studio 15 2017 Win64

# Cygwin
- ADDPATH: C:\cygwin\bin;
MAYFAIL: true
WHYFAIL: https://github.com/madler/zlib/issues/268
WRAPPER: cygwin

# Cygwin64
- ADDPATH: C:\cygwin64\bin;
MAYFAIL: true
WHYFAIL: https://github.com/madler/zlib/issues/268
WRAPPER: cygwin64

# MSYS2
- ADDPATH: C:\msys64\usr\bin;
GENERATOR: MSYS Makefiles
MAYFAIL: true
WHYFAIL: https://github.com/madler/zlib/issues/268

18 changes: 18 additions & 0 deletions ci/appveyor/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@ECHO ON
SETLOCAL EnableDelayedExpansion

:: Create the build directory
MKDIR %BUILDDIR% || EXIT /B
CD %BUILDDIR%

cmake --version

::IF "%WRAPPER:~0,6%" == "cygwin" (
:: Run the cygwin cmake build in a cygwin bash shell
:: bash.exe -c "cmake !CYGSRCDIR! %DASHG% -DCMAKE_INSTALL_PREFIX=!CYGINSTDIR! && cmake --build . --target install --config %CMAKE_BUILD_TYPE%" || EXIT /B
::) ELSE (
cmake "%SRCDIR%" %DASHG% -DCMAKE_INSTALL_PREFIX=%INSTDIR% || EXIT /B
cmake --build . --target install --config %CMAKE_BUILD_TYPE% || EXIT /B
::)

DIR /S %INSTDIR%
39 changes: 39 additions & 0 deletions ci/appveyor/env.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
::
:: Environment Variables
::
:: In:
:: ADDPATH contains path directories that are prepended to the path (optional)
:: CMAKE_BUILD_TYPE sets the build configuration (required)
:: GENERATOR is the cmake generator to use (optional)
:: WRAPPER is the build type wrapper to use
::
:: Out:
:: BUILDDIR is the directory to do the build in
:: INSTDIR is the directory to put the install target files into
:: SRCDIR is the directory containing the project
::
:: CYGDIR is the home of cygwin, whichever flavor is being used
:: CYGSETUP is the path to the setup executable for instlaling things
:: CYGINSTDIR is INSTDIR translated to cygwin's /cygdrive/... path syntax
:: CYGSRCDIR is SRCDIR translated to cygwin's /cygdrive/... path syntax
::
:: DASHG is the cmake -G"<generator>" argument content
::

SET BUILDDIR=C:\temp\build
SET INSTDIR=C:\temp\install
SET SRCDIR=%CD%

SET PATH=%ADDPATH%%PATH%

IF "%WRAPPER%" == "cygwin" (
SET CYGDIR=C:\cygwin
SET CYGSETUP=C:\cygwin\setup-x86.exe
For /F "Tokens=1" %%I in (C:\cygwin\bin\cygpath -u "%SRCDIR%") Do Set CYGSRCDIR=%%I
For /F "Tokens=1" %%I in (C:\cygwin\bin\cygpath -u "%INSTDIR%") Do Set CYGINSTDIR=%%I
) ELSE IF "%WRAPPER%" == "cygwin64" (
SET CYGDIR=C:\cygwin64
SET CYGSETUP=C:\cygwin\setup-x86_64.exe
For /F "Tokens=1" %%I in (C:\cygwin64\bin\cygpath -u "%SRCDIR%") Do Set CYGSRCDIR=%%I
For /F "Tokens=1" %%I in (C:\cygwin64\bin\cygpath -u "%INSTDIR%") Do Set CYGINSTDIR=%%I
)
13 changes: 13 additions & 0 deletions ci/appveyor/install.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@ECHO ON
SETLOCAL EnableDelayedExpansion

:: Move sh.exe out of the path for MinGW builds to work
IF "%WRAPPER:~0,5%" == "mingw" (
REN "C:\Program Files\Git\usr\bin\sh.exe" "sh.exx"
)

:: Install missing cygwin packages
:: cmake and make are obvious; cygwin is to ensure the command "cygpath" is there
IF "%WRAPPER:~0,6%" == "cygwin" (
%CYGSETUP% -B -q -n -N -d -l %CYGDIR%/var/cache/setup -R %CYGDIR% -s http://mirror.rit.edu -P cmake cygwin make
)
15 changes: 15 additions & 0 deletions ci/appveyor/test.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@ECHO ON
SETLOCAL

CD %BUILDDIR% || EXIT /B
ctest -D ExperimentalTest || EXIT /B

IF EXISTS %CMAKE_BUILD_TYPE% (
CD %CMAKE_BUILD_TYPE% || EXIT /B
)
COPY example.exe example.exe.orig || EXIT /B
minigzip -3 example.exe || EXIT /B
minigzip -9 example.exe.gz || EXIT /B
minigzip -d example.exe.gz.gz || EXIT /B
minigzip -d example.exe.gz || EXIT /B
fc /B example.exe example.exe.orig > nul
36 changes: 36 additions & 0 deletions ci/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
#
# Environment Variables
#
# CMAKE_BUILD_TYPE sets the cmake variable by that name (default if not set: use ./configure)
# CMAKE_C_COMPILER sets the cmake variable by that name (default if not set: $CC)
# CTEST_DASHBOARD sets the dashboard suite to run (default if not set: ExperimentalTest)
#

set -ex

SRCDIR=`pwd`
if [[ "${CTEST_BASHBOARD}" == "ExperimentalMemCheck" ]]; then
RUNNER=valgrind
fi
mkdir /tmp/build
cd /tmp/build

if [[ ! -z "$CMAKE_BUILD_TYPE" ]]; then
cmake $SRCDIR -DCMAKE_INSTALL_PREFIX=/tmp/install \
-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER:-$CC}
VERBOSE=1 cmake --build . --target install
ctest -D ${CTEST_DASHBOARD:-ExperimentalTest}
ls -lsR /tmp/install
else
$SRCDIR/configure $CONFIGURE --prefix=/tmp/install
make -j2 install
make test
ls -lsR /tmp/install
fi

cp libz.a libz.a.orig
$RUNNER ./minigzip64 -9 libz.a
$RUNNER ./minigzip64 -d libz.a.gz
cmp libz.a libz.a.orig
2 changes: 1 addition & 1 deletion gzguts.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
# include <io.h>
#endif

#if defined(_WIN32) || defined(__CYGWIN__)
#if defined(_WIN32)
# define WIDECHAR
#endif

Expand Down
Loading

0 comments on commit 7b8aa04

Please sign in to comment.