Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix configure buglet; verify bit-for-bit identical installs; enhance junit output; add Linux/bsd/mac builders #500

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open
72 changes: 72 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
upload_junit_template: &UPLOAD_JUNIT
always:
junit_artifacts:
path: "btmp/*-junit.xml"
type: text/xml
format: junit

check_docker_task:
matrix:
- name: "ubu1404"
container:
dockerfile: ci/cirrus/ubu1404/Dockerfile # remove 2022/4
- name: "ubu1604"
container:
dockerfile: ci/cirrus/ubu1604/Dockerfile # remove 2024/4
- name: "ubu1804"
container:
dockerfile: ci/cirrus/ubu1804/Dockerfile # remove 2028/4
- name: "ubu2004"
container:
dockerfile: ci/cirrus/ubu2004/Dockerfile
- name: "ubu2010"
container:
dockerfile: ci/cirrus/ubu2010/Dockerfile # remove 2021/7
- name: "debian8"
container:
dockerfile: ci/cirrus/debian8/Dockerfile # remove 2020/7
- name: "debian9"
container:
dockerfile: ci/cirrus/debian9/Dockerfile # remove 2022/7
- name: "debian10"
container:
dockerfile: ci/cirrus/debian10/Dockerfile
- name: "fedora31"
container:
dockerfile: ci/cirrus/fedora31/Dockerfile # remove 2020/11
- name: "fedora32"
container:
dockerfile: ci/cirrus/fedora32/Dockerfile # remove 2021/5
test_script:
- sh ci/test-cmake.sh && sh ci/pkgcheck.sh
<< : *UPLOAD_JUNIT

check_mac_task:
osx_instance:
image: catalina-xcode
install_script:
- brew install ninja
test_script:
- sh ci/test-cmake.sh && sh ci/pkgcheck.sh
<< : *UPLOAD_JUNIT

check_bsd_task:
freebsd_instance:
image_family: freebsd-12-1
install_script:
- pkg install -y gcc cmake ninja
test_script:
- sh ci/test-cmake.sh && sh ci/pkgcheck.sh
<< : *UPLOAD_JUNIT

check_win_task:
windows_container:
image: cirrusci/windowsservercore:cmake
install_script:
- choco install -y --no-progress ninja
test_script:
- cmake --version
- ninja --version
- echo "Setting compiler to MSVC rather than the default (GCC from chocolatey)"
- call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat" && where cl && set CC=cl && mkdir btmp && cd btmp && cmake -G Ninja .. && ninja && ctest -V
<< : *UPLOAD_JUNIT
101 changes: 84 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,31 @@ set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)

project(zlib C)

# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION
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})
# FIXME: parse VERSION from ZLIB_FULL_VERSION
set(VERSION "1.2.11.1")

option(ASM686 "Enable building i686 assembly implementation")
option(AMD64 "Enable building amd64 assembly implementation")
option(JUNIT "Enable junit output when testing")

set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages")
set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
set(INSTALL_PKGCONFIG_DIR "${INSTALL_LIB_DIR}/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")

# Set a default build type if none was specified
set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

include(CheckTypeSize)
include(CheckFunctionExists)
Expand All @@ -21,8 +36,35 @@ include(CheckCSourceCompiles)
enable_testing()

check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(stdarg.h HAVE_STDARG_H)
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(stddef.h HAVE_STDDEF_H)
check_include_file(unistd.h HAVE_UNISTD_H)

#
# Match configure's zconf.h exactly
#
if (HAVE_STDARG_H)
SET(ZCONF_STDARG_LINE "#if 1 /* was set to #if 1 by ./configure */")
else()
SET(ZCONF_STDARG_LINE "#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */")
endif()
if (HAVE_UNISTD_H)
SET(ZCONF_UNISTD_LINE "#if 1 /* was set to #if 1 by ./configure */")
else()
SET(ZCONF_UNISTD_LINE "#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */")
endif()

#
# Check to see if compiler supports __attribute__((visibility ("hidden")))
#
check_c_source_compiles(
"int __attribute__((visibility (\"hidden\"))) foo; int main() { return foo; }"
HAVE_HIDDEN
)
if(HAVE_HIDDEN)
add_definitions(-DHAVE_HIDDEN)
endif()

#
# Check to see if we have large file support
Expand Down Expand Up @@ -57,7 +99,7 @@ endif()
#
# Check for unistd.h
#
check_include_file(unistd.h Z_HAVE_UNISTD_H)
check_include_file(unistd.h HAVE_UNISTD_H)

if(MSVC)
set(CMAKE_DEBUG_POSTFIX "d")
Expand All @@ -78,6 +120,19 @@ if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
endif()
endif()

# Refer to prefix symbolically to ease relocation by end user,
# and match Makefile-generate .pc file exactly.
if(INSTALL_INC_DIR STREQUAL "${CMAKE_INSTALL_PREFIX}/include")
set(PC_INSTALL_INC_DIR "\${prefix}/include")
else()
set(PC_INSTALL_INC_DIR "${INSTALL_INC_DIR}")
endif()
if(INSTALL_LIB_DIR STREQUAL "${CMAKE_INSTALL_PREFIX}/lib")
set(PC_INSTALL_LIB_DIR "\${exec_prefix}/lib")
else()
set(PC_INSTALL_LIB_DIR "${INSTALL_LIB_DIR}")
endif()

set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
${ZLIB_PC} @ONLY)
Expand Down Expand Up @@ -105,22 +160,27 @@ set(ZLIB_PRIVATE_HDRS
trees.h
zutil.h
)

# Note: keep these in the same order as in Makefile.in
# This allows libz.so to be identical between the two build systems.
set(ZLIB_SRCS
# Makefile.in: PIC_OBJZ
adler32.c
compress.c
crc32.c
deflate.c
gzclose.c
gzlib.c
gzread.c
gzwrite.c
inflate.c
infback.c
inftrees.c
inffast.c
inflate.c
inftrees.c
trees.c
uncompr.c
zutil.c
# Makefile.in: PIC_OBJG
compress.c
uncompr.c
gzclose.c
gzlib.c
gzread.c
gzwrite.c
)

if(NOT MINGW)
Expand Down Expand Up @@ -162,11 +222,6 @@ if(MSVC)
endif()
endif()

# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION
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)
# This gets us DLL resource information when compiling on MinGW.
if(NOT CMAKE_RC_COMPILER)
Expand Down Expand Up @@ -204,6 +259,9 @@ if(UNIX)
set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
if(NOT APPLE)
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
# Makefile.in uses -lc...
set(LDSHAREDLIBC -lc)
target_link_libraries(zlib ${LDSHAREDLIBC})
endif()
elseif(BUILD_SHARED_LIBS AND WIN32)
# Creates zlib1.dll when building shared library version
Expand Down Expand Up @@ -232,7 +290,12 @@ endif()

add_executable(example test/example.c)
target_link_libraries(example zlib)
add_test(example example)
if(JUNIT)
add_test(example example --junit ${CMAKE_CURRENT_BINARY_DIR}/example-junit.xml)
else()
add_test(example example)
endif()


add_executable(minigzip test/minigzip.c)
target_link_libraries(minigzip zlib)
Expand All @@ -241,7 +304,11 @@ if(HAVE_OFF64_T)
add_executable(example64 test/example.c)
target_link_libraries(example64 zlib)
set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
add_test(example64 example64)
if(JUNIT)
add_test(example64 example64 --junit ${CMAKE_CURRENT_BINARY_DIR}/example64-junit.xml)
else()
add_test(example64 example64)
endif()

add_executable(minigzip64 test/minigzip.c)
target_link_libraries(minigzip64 zlib)
Expand Down
11 changes: 9 additions & 2 deletions README → README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
ZLIB DATA COMPRESSION LIBRARY

[![AppVeyor CI status][appveyor-shield]][appveyor-link][![Cirrus CI status][cirrus-shield]][cirrus-link]

zlib 1.2.11.1 is a general purpose data compression library. All the code is
thread safe. The data format used by the zlib library is described by RFCs
(Request for Comments) 1950 to 1952 in the files
Expand Down Expand Up @@ -102,8 +104,7 @@ Copyright notice:
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.

Jean-loup Gailly Mark Adler
jloup@gzip.org madler@alumni.caltech.edu
Jean-loup Gailly (jloup@gzip.org) & Mark Adler (madler@alumni.caltech.edu)

If you use the zlib library in a product, we would appreciate *not* receiving
lengthy legal documents to sign. The sources are provided for free but without
Expand All @@ -116,3 +117,9 @@ any third parties.
If you redistribute modified sources, we would appreciate that you include in
the file ChangeLog history information documenting your changes. Please read
the FAQ for more information on the distribution of modified source versions.

<!-- fix following four lines when merging -->
[appveyor-shield]: https://ci.appveyor.com/api/projects/status/h80iqyhbe09p29n0/branch/develop?svg=true
[appveyor-link]: https://ci.appveyor.com/project/dankegel/zlib/branch/develop
[cirrus-shield]: https://api.cirrus-ci.com/github/dankegel/zlib.svg?branch=develop
[cirrus-link]: https://cirrus-ci.com/github/dankegel/zlib/develop
33 changes: 33 additions & 0 deletions ci/appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: 1.2.11.1.{build}

pull_requests:
do_not_increment_build_number: true

shallow_clone: true

image:
- Visual Studio 2019

before_build:
- cmd: cmake -DJUNIT=ON .

build:
project: "zlib.sln"

platform:
- x64
configuration:
- Debug
- Release

test_script:
- ps: |
&"ctest" -V
$testError = $LastExitCode
$wc = New-Object 'System.Net.WebClient'
$jurl = "https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)"
$wc.UploadFile($jurl, (Resolve-Path "$($env:APPVEYOR_BUILD_FOLDER)\example-junit.xml"))
if ($testError -ne 0)
{
throw $testError
}
5 changes: 5 additions & 0 deletions ci/cirrus/debian10/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM debian:10

RUN apt-get update && \
apt-get install --no-install-recommends -y cmake gcc libc6-dev ninja-build make && \
apt-get clean
5 changes: 5 additions & 0 deletions ci/cirrus/debian8/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM debian:8

RUN apt-get update && \
apt-get install --no-install-recommends -y cmake gcc libc6-dev ninja-build make && \
apt-get clean
5 changes: 5 additions & 0 deletions ci/cirrus/debian9/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM debian:9

RUN apt-get update && \
apt-get install --no-install-recommends -y cmake gcc libc6-dev ninja-build make && \
apt-get clean
12 changes: 12 additions & 0 deletions ci/cirrus/fedora31/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM fedora:31

RUN dnf -y update && dnf clean all

RUN dnf makecache \
&& dnf -y install \
gcc \
cmake \
diffutils \
make \
ninja-build \
&& dnf clean all
12 changes: 12 additions & 0 deletions ci/cirrus/fedora32/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM fedora:32

RUN dnf -y update && dnf clean all

RUN dnf makecache \
&& dnf -y install \
gcc \
cmake \
diffutils \
make \
ninja-build \
&& dnf clean all
5 changes: 5 additions & 0 deletions ci/cirrus/ubu1404/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ubuntu:14.04

RUN apt-get update && \
apt-get install --no-install-recommends -y cmake gcc libc6-dev ninja-build make && \
apt-get clean
5 changes: 5 additions & 0 deletions ci/cirrus/ubu1604/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ubuntu:16.04

RUN apt-get update && \
apt-get install --no-install-recommends -y cmake gcc libc6-dev ninja-build make && \
apt-get clean
5 changes: 5 additions & 0 deletions ci/cirrus/ubu1804/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ubuntu:18.04

RUN apt-get update && \
apt-get install --no-install-recommends -y cmake gcc libc6-dev ninja-build make && \
apt-get clean
5 changes: 5 additions & 0 deletions ci/cirrus/ubu2004/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ubuntu:20.04

RUN apt-get update && \
apt-get install --no-install-recommends -y cmake gcc libc6-dev ninja-build make && \
apt-get clean
5 changes: 5 additions & 0 deletions ci/cirrus/ubu2010/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ubuntu:20.10

RUN apt-get update && \
apt-get install --no-install-recommends -y cmake gcc libc6-dev ninja-build make && \
apt-get clean
Loading