From f2a3b020402943f90957552a884788e70ece6cd7 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 8 Jun 2017 20:46:10 +0000 Subject: [PATCH] * .travis.yml, build/travis-ci: new files from 0001-ci-Add-Travis-support-for-Linux-builds-with-Autoconf.patch by Roger Leigh (sent to mailing list on 2017-06-08) This patch adds support for the Travis-CI service. * .appveyor.yml: new file from 0002-ci-Add-AppVeyor-support.patch by Roger Leigh (sent to mailing list on 2017-06-08) This patch adds a .appveyor.yml file to the top-level. This allows one to opt in to having a branch built on Windows with Cygwin, MinGW and MSVC automatically when a branch is pushed to GitHub, GitLab, BitBucket or any other supported git hosting service. * CMakeLists.txt, test/CMakeLists.txt, test/TiffTestCommon.cmake: apply patch 0001-cmake-Improve-Cygwin-and-MingGW-test-support.patch from Roger Leigh (sent to mailing list on 2017-06-08) This patch makes the CMake build system support running the tests with MinGW or Cygwin. --- .appveyor.yml | 103 ++++++++++++++++++++++++++++++++++++++ .travis.yml | 31 ++++++++++++ CMakeLists.txt | 2 +- ChangeLog | 21 ++++++++ build/travis-ci | 90 +++++++++++++++++++++++++++++++++ test/CMakeLists.txt | 29 ++++++----- test/TiffTestCommon.cmake | 5 ++ 7 files changed, 268 insertions(+), 13 deletions(-) create mode 100644 .appveyor.yml create mode 100644 .travis.yml create mode 100644 build/travis-ci diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 00000000..fb534236 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,103 @@ +environment: + AV_PROJECTS: 'c:\projects' + AV_TIFF_DOWNLOAD: 'c:\projects\download' + AV_TIFF_SOURCE: 'c:\projects\libtiff' + AV_TIFF_BUILD: 'c:\projects\build' + AV_TIFF_INSTALL: 'c:\projects\install' + + matrix: + - compiler: cygwin-cmake + generator: Unix Makefiles + shared: ON + - compiler: cygwin-cmake + generator: Unix Makefiles + shared: OFF + - compiler: mingw64-cmake + generator: Unix Makefiles + shared: ON + - compiler: mingw64-cmake + generator: Unix Makefiles + shared: OFF + - compiler: vc14-cmake + generator: Visual Studio 14 2015 Win64 + shared: ON + - compiler: vc14-cmake + generator: Visual Studio 14 2015 Win64 + shared: OFF + - compiler: vc14-nmake + +cache: + - 'c:\projects\download -> appveyor.yml' + +# Operating system (build VM template) +os: 'Visual Studio 2015' + +# clone directory +clone_folder: 'c:\projects\libtiff' +clone_depth: 5 + +platform: x64 +configuration: Release + +init: + - git config --global core.autocrlf input + - 'FOR /F "tokens=* USEBACKQ" %%F IN (`C:\cygwin64\bin\cygpath -u %AV_TIFF_SOURCE%`) DO SET AV_TIFF_CYG_SOURCE=%%F' + - 'FOR /F "tokens=* USEBACKQ" %%F IN (`C:\cygwin64\bin\cygpath -u %AV_TIFF_INSTALL%`) DO SET AV_TIFF_CYG_INSTALL=%%F' + - 'if %compiler%==cygwin-cmake C:\Cygwin64\setup-x86_64 -q -R C:\Cygwin64 -s http://cygwin.mirror.constant.com -l %AV_TIFF_DOWNLOAD%\cygwin -P cmake,libjpeg-devel,zlib-devel' + - 'if %compiler%==cygwin-cmake set "PATH=C:\Cygwin64\bin;%PATH%"' + - 'if %compiler%==mingw64-cmake set "PATH=C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;%PATH%"' + - set "AV_CMAKE_ARGS=-DBUILD_SHARED_LIBS:BOOL=%shared%" + - 'if %compiler%==mingw64-cmake set "PATH=C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;%PATH%"' + - 'if %compiler%==mingw64-cmake set "AV_CMAKE_ARGS=%AV_CMAKE_ARGS% -DCMAKE_MAKE_PROGRAM=C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin\mingw32-make"' + - set "AV_TIFF_CMAKE_SOURCE=%AV_TIFF_SOURCE%" + - set "AV_TIFF_CMAKE_INSTALL=%AV_TIFF_INSTALL%" + - 'if %compiler%==cygwin-cmake set "AV_TIFF_CMAKE_SOURCE=%AV_TIFF_CYG_SOURCE%' + - 'if %compiler%==cygwin-cmake set "AV_TIFF_CMAKE_INSTALL=%AV_TIFF_CYG_INSTALL%' + - 'if %compiler%==vc14-nmake call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" %platform%' + +before_build: + - mkdir %AV_TIFF_BUILD% + - cd %AV_TIFF_BUILD% + - if NOT %compiler%==vc14-nmake echo Running cmake -G "%generator%" -DCMAKE_INSTALL_PREFIX=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_TIFF_CMAKE_SOURCE% + - 'if %compiler%==cygwin-cmake bash -c "cmake -G \"%generator%\" -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%"' + - 'if %compiler%==mingw64-cmake cmake -G "%generator%" -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%' + - 'if %compiler%==vc14-cmake cmake -G "%generator%" -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%' + +build_script: + - if NOT %compiler%==vc14-nmake cd %AV_TIFF_BUILD% + - if %compiler%==vc14-nmake cd %AV_TIFF_SOURCE% + - 'if %compiler%==cygwin-cmake bash -c "cmake --build . --config %configuration% --target install"' + - 'if %compiler%==mingw64-cmake cmake --build . --config %configuration% --target install' + - 'if %compiler%==vc14-cmake cmake --build . --config %configuration% --target install' + - 'if %compiler%==vc14-nmake nmake /f Makefile.vc EXTRAFLAGS=/DHAVE_SNPRINTF=1' + - 'if %compiler%==vc14-nmake mkdir %AV_TIFF_INSTALL%' + - 'if %compiler%==vc14-nmake mkdir %AV_TIFF_INSTALL%\bin' + - 'if %compiler%==vc14-nmake mkdir %AV_TIFF_INSTALL%\lib' + - 'if %compiler%==vc14-nmake mkdir %AV_TIFF_INSTALL%\include' + - 'if %compiler%==vc14-nmake copy tools\*.exe %AV_TIFF_INSTALL%\bin' + - 'if %compiler%==vc14-nmake copy port\*.lib %AV_TIFF_INSTALL%\lib' + - 'if %compiler%==vc14-nmake copy libtiff\tiff.h %AV_TIFF_INSTALL%\include' + - 'if %compiler%==vc14-nmake copy libtiff\tiffio.h %AV_TIFF_INSTALL%\include' + - 'if %compiler%==vc14-nmake copy libtiff\tiffvers.h %AV_TIFF_INSTALL%\include' + - 'if %compiler%==vc14-nmake copy libtiff\tiffconf.h %AV_TIFF_INSTALL%\include' + - 'if %compiler%==vc14-nmake copy libtiff\tiffio.hxx %AV_TIFF_INSTALL%\include' + +# scripts to run after build +after_build: + - cd %AV_TIFF_BUILD% + - '7z a %AV_TIFF_SOURCE%\libtiff-build.zip * -tzip' + - cd %AV_TIFF_INSTALL% + - '7z a %AV_TIFF_SOURCE%\libtiff.zip * -tzip' + +before_test: + - cd %AV_TIFF_BUILD% + - 'if %compiler%==cygwin-cmake bash -c "ctest -V -C %configuration%"' + - 'if %compiler%==mingw64-cmake ctest -V -C %configuration%' + - 'if %compiler%==vc14-cmake ctest -V -C %configuration%' +# vc14-nmake does not support unit tests + +artifacts: + - path: libtiff.zip + name: libtiff.zip + - path: libtiff-build.zip + name: libtiff-build.zip diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..9b371162 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,31 @@ +language: c + +sudo: false +dist: trusty + +cache: + directories: + - download + +addons: + apt_packages: + - libjpeg8-dev + - libjbig-dev + - liblzma-dev + - zlib1g-dev + +compiler: + - gcc + - clang + +env: + matrix: + - BUILD=autoconf + - BUILD=cmake TOOL="Unix Makefiles" TYPE=Release + - BUILD=cmake TOOL="Ninja" TYPE=Release + +matrix: + fast_finish: true + +script: + - ./build/travis-ci "$BUILD" "$TOOL" "$TYPE" diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ee6fd46..52b5ae99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -467,7 +467,7 @@ report_values(CMAKE_HOST_SYSTEM_PROCESSOR HOST_FILLORDER HOST_BIG_ENDIAN HAVE_IEEEFP) # Large file support -if (UNIX) +if (UNIX OR MINGW) # This might not catch every possibility catered for by # AC_SYS_LARGEFILE. add_definitions(-D_FILE_OFFSET_BITS=64) diff --git a/ChangeLog b/ChangeLog index 70d3ee0d..ac5ebbf5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2017-06-08 Even Rouault + + * .travis.yml, build/travis-ci: new files from + 0001-ci-Add-Travis-support-for-Linux-builds-with-Autoconf.patch by + Roger Leigh (sent to mailing list on 2017-06-08) + This patch adds support for the Travis-CI service. + + * .appveyor.yml: new file from + 0002-ci-Add-AppVeyor-support.patch by Roger Leigh (sent to mailing + list on 2017-06-08) + This patch adds a .appveyor.yml file to the top-level. This allows + one to opt in to having a branch built on Windows with Cygwin, + MinGW and MSVC automatically when a branch is pushed to GitHub, + GitLab, BitBucket or any other supported git hosting service. + + * CMakeLists.txt, test/CMakeLists.txt, test/TiffTestCommon.cmake: apply + patch 0001-cmake-Improve-Cygwin-and-MingGW-test-support.patch from Roger + Leigh (sent to mailing list on 2017-06-08) + This patch makes the CMake build system support running the tests + with MinGW or Cygwin. + 2017-06-08 Even Rouault * libtiff/tif_swab.c: if DISABLE_CHECK_TIFFSWABMACROS is defined, do not do diff --git a/build/travis-ci b/build/travis-ci new file mode 100644 index 00000000..c34791a1 --- /dev/null +++ b/build/travis-ci @@ -0,0 +1,90 @@ +#!/bin/sh +# This script is used for testing the build, primarily for use +# with travis, but may be used by hand as well. + +set -e +set -x + +# Test autoconf build +autoconf_build() +{ + mkdir autoconf-build + cd autoconf-build + ../configure --prefix=$(readlink -f ../autoconf-install) + make + make install + make check +} + +# Install needed tools +cmake_deps() +{ + mkdir -p download + mkdir -p tools + + cmake_file="cmake-3.8.2-Linux-x86_64.tar.gz" + cmake_url="https://cmake.org/files/v3.8/${cmake_file}" + cmake_hash="574673d3f37b0be6a0813b894a8bce9c4af08c13f1ec25c030a69f42e0e4b349e0192385ef20c8a9271055b7c3b24c5b20fb5009762131a3fba3d17576e641f1" + + ninja_file="ninja-linux.zip" + ninja_url="https://github.com/ninja-build/ninja/releases/download/v1.7.2/${ninja_file}" + ninja_hash="2dddc52750c5e6f841acd0d978b894c9a6562f12ddb4ba9e5118a213f54265f065682ffe1bc7bc2ac6146760145d17800a4b7373791cd1fbbaf0836faf050e19" + + ( + cd download + if [ ! -f "$cmake_file" ] || [ "$(sha512sum "$cmake_file")" != "$cmake_hash $cmake_file" ]; then + wget "$cmake_url" + if [ "$(sha512sum "$cmake_file")" != "$cmake_hash $cmake_file" ]; then + echo "Error: cmake download hash mismatch" >&2 + exit 1 + fi + fi + tar xf "$cmake_file" + cp -a ${cmake_file%.tar.gz}/* ../tools + + if [ "$1" = "Ninja" ]; then + if [ ! -f "$ninja_file" ] || [ "$(sha512sum "$ninja_file")" != "$ninja_hash $ninja_file" ]; then + wget "$ninja_url" + if [ "$(sha512sum "$ninja_file")" != "$ninja_hash $ninja_file" ]; then + echo "Error: ninja download hash mismatch" >&2 + exit 1 + fi + fi + unzip "$ninja_file" + mv ninja ../tools/bin + fi + ) +} + +# Test autoconf build +cmake_build() +{ + PATH="$(pwd)/tools/bin:$PATH" + mkdir cmake-build + cd cmake-build + cmake -G "$1" -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../autoconf-install .. + cmake --build . + cmake --build . --target install + ctest -V +} + +build=$1 +shift + +case $build in + autoconf) + echo "Testing Autoconf build" + autoconf_build "$@" + ;; + cmake) + echo "Testing CMake build" + cmake_deps "$@" + cmake_build "$@" + ;; + *) + echo "Invalid argument: \"$arg\"" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b9e373f9..731aa806 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -185,6 +185,18 @@ target_link_libraries(custom_dir tiff port) set(TEST_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output") file(MAKE_DIRECTORY "${TEST_OUTPUT}") +set(tiff_test_extra_args + "-DTIFFCP=$" + "-DTIFFINFO=$" + "-DTIFFSPLIT=$" + "-DLIBTIFF=$") +if(WIN32) + list(APPEND tiff_test_extra_args "-DWIN32=${WIN32}") +endif() +if(CYGWIN) + list(APPEND tiff_test_extra_args "-DCYGWIN=${CYGWIN}") +endif() + macro(tiff_test_convert name command1 command2 command3 infile outfile validate) add_test(NAME "${name}" COMMAND "${CMAKE_COMMAND}" @@ -193,9 +205,8 @@ macro(tiff_test_convert name command1 command2 command3 infile outfile validate) "-DCONVERT_COMMAND3=${command3}" "-DINFILE=${infile}" "-DOUTFILE=${outfile}" - "-DTIFFINFO=$" - "-DLIBTIFF=$" "-DVALIDATE=${validate}" + ${tiff_test_extra_args} -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffTest.cmake") endmacro() @@ -205,8 +216,7 @@ macro(tiff_test_stdout name command infile outfile) "-DSTDOUT_COMMAND=${command}" "-DINFILE=${infile}" "-DOUTFILE=${outfile}" - "-DTIFFINFO=$" - "-DLIBTIFF=$" + ${tiff_test_extra_args} -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffTest.cmake") endmacro() @@ -215,8 +225,7 @@ macro(tiff_test_reader name command infile) COMMAND "${CMAKE_COMMAND}" "-DREADER_COMMAND=${command}" "-DINFILE=${infile}" - "-DTIFFINFO=$" - "-DLIBTIFF=$" + ${tiff_test_extra_args} -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffTest.cmake") endmacro() @@ -344,9 +353,7 @@ add_test(NAME "tiffcp-split" "-DTESTFILES=${ESCAPED_UNCOMPRESSED}" "-DCONJOINED=${TEST_OUTPUT}/tiffcp-split-conjoined.tif" "-DSPLITFILE=${TEST_OUTPUT}/tiffcp-split-split-" - "-DTIFFCP=$" - "-DTIFFSPLIT=$" - "-DLIBTIFF=$" + ${tiff_test_extra_args} -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffSplitTest.cmake") add_test(NAME "tiffcp-split-join" COMMAND "${CMAKE_COMMAND}" @@ -354,9 +361,7 @@ add_test(NAME "tiffcp-split-join" "-DCONJOINED=${TEST_OUTPUT}/tiffcp-split-join-conjoined.tif" "-DSPLITFILE=${TEST_OUTPUT}/tiffcp-split-join-split-" "-DRECONJOINED=${TEST_OUTPUT}/tiffcp-split-join-reconjoined.tif" - "-DTIFFCP=$" - "-DTIFFSPLIT=$" - "-DLIBTIFF=$" + ${tiff_test_extra_args} -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffSplitTest.cmake") # PDF diff --git a/test/TiffTestCommon.cmake b/test/TiffTestCommon.cmake index 50a4c34a..a0db6782 100644 --- a/test/TiffTestCommon.cmake +++ b/test/TiffTestCommon.cmake @@ -101,3 +101,8 @@ if(WIN32) file(TO_NATIVE_PATH "${LIBTIFF_DIR}" LIBTIFF_DIR) set(ENV{PATH} "${LIBTIFF_DIR};$ENV{PATH}") endif() +if(CYGWIN) + get_filename_component(LIBTIFF_DIR "${LIBTIFF}" DIRECTORY) + file(TO_NATIVE_PATH "${LIBTIFF_DIR}" LIBTIFF_DIR) + set(ENV{PATH} "${LIBTIFF_DIR}:$ENV{PATH}") +endif()