From 282e99b6b0b09958464ccfbb618d01b75e4f0e7f Mon Sep 17 00:00:00 2001 From: clanmills Date: Mon, 7 Jan 2019 17:02:54 +0000 Subject: [PATCH 1/3] Fix #610 (cherry picked from commit 54367e18ed0bf8bae6d8449341a6f82779f6d3c7) --- src/futils.cpp | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/src/futils.cpp b/src/futils.cpp index 8049c3db..2de5dc00 100644 --- a/src/futils.cpp +++ b/src/futils.cpp @@ -17,12 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. */ -/* - File: futils.cpp - Author(s): Andreas Huggel (ahu) - History: 08-Dec-03, ahu: created - 02-Apr-05, ahu: moved to Exiv2 namespace - */ // ***************************************************************************** // included header files #include "config.h" @@ -33,25 +27,26 @@ // + standard includes #include #include - -#ifdef _MSC_VER - #include - # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) - #include // For access to GetModuleFileNameEx -#elif defined(__APPLE__) - #include -#endif - -#ifdef EXV_HAVE_UNISTD_H - # include // for stat() -#endif - #include #include #include #include #include #include +#ifdef EXV_HAVE_UNISTD_H +#include // for stat() +#endif + +#if defined(WIN32) +#include +#include // For access to GetModuleFileNameEx +#endif + +#if defined(_MSC_VER) +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#elif defined(__APPLE__) +#include +#endif namespace Exiv2 { const char* ENVARDEF[] = {"/exiv2.php", "40"}; //!< @brief default URL for http exiv2 handler and time-out @@ -471,7 +466,7 @@ namespace Exiv2 { if (proc_pidpath (pid, pathbuf, sizeof(pathbuf)) > 0) { ret = pathbuf; } - #elif defined(__linux__) || defined(__CYGWIN__) || defined(__MINGW__) + #elif defined(__linux__) || defined(__CYGWIN__) || defined(__MSYS__) // http://stackoverflow.com/questions/606041/how-do-i-get-the-path-of-a-process-in-unix-linux char proc[100]; char path[500]; @@ -482,11 +477,8 @@ namespace Exiv2 { ret = path; } #endif - #if defined(WIN32) - const size_t idxLastSeparator = ret.find_last_of('\\'); - #else - const size_t idxLastSeparator = ret.find_last_of('/'); - #endif + + const size_t idxLastSeparator = ret.find_last_of(EXV_SEPARATOR_STR); return ret.substr(0, idxLastSeparator); } } // namespace Exiv2 From eb107da08f90f7a09c3c4708c18e507b27ca1a01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= Date: Sat, 9 Feb 2019 11:23:59 +0100 Subject: [PATCH 2/3] [ci] Refactor ci/test_build.py to allow customizations of the build matrix (cherry picked from commit ee6f1de028534019d8ecfd18de9b77b9b4208cbe) --- ci/test_build.py | 168 +++++++++++++++++++++++++++++++---------------- 1 file changed, 112 insertions(+), 56 deletions(-) diff --git a/ci/test_build.py b/ci/test_build.py index 73bb5d2c..84e68c52 100644 --- a/ci/test_build.py +++ b/ci/test_build.py @@ -8,24 +8,6 @@ import shlex import subprocess import sys -#: -DEXIV2_BUILD_SHARED_LIBS options -SHARED_LIBS = ["ON", "OFF"] - -#: C & C++ compiler as tuples -CCS = ["gcc", "clang"] - -#: -DCMAKE_BUILD_TYPE options -BUILD_TYPES = ["Debug", "Release"] - -#: Additional parameters for cmake -CMAKE_OPTIONS = os.getenv("CMAKE_OPTIONS") or \ - "-DEXIV2_TEAM_EXTRA_WARNINGS=ON -DEXIV2_ENABLE_VIDEO=ON "\ - "-DEXIV2_ENABLE_WEBREADY=ON -DEXIV2_BUILD_UNIT_TESTS=ON "\ - "-DBUILD_WITH_CCACHE=ON " - -#: cpu count -NCPUS = multiprocessing.cpu_count() - def call_wrapper(*args, **kwargs): """ @@ -37,41 +19,115 @@ def call_wrapper(*args, **kwargs): sys.exit(return_code) -# create build directory -os.mkdir("build") - -root_dir = os.path.abspath(os.getcwd()) - -for params in itertools.product(SHARED_LIBS, CCS, BUILD_TYPES): - - lib_type, cc, build_type = params - - cxx = {"gcc": "g++", "clang": "clang++"}[cc] - - cwd = os.path.abspath(os.path.join("build", "_".join(params))) - os.mkdir(cwd) - - cmake = "cmake {!s} -DCMAKE_BUILD_TYPE={build_type} "\ - "-DBUILD_SHARED_LIBS={lib_type} ../.."\ - .format(CMAKE_OPTIONS, build_type=build_type, lib_type=lib_type) - make = "make -j " + str(NCPUS) - make_tests = "make tests" - unit_tests = os.path.join(cwd, "bin", "unit_tests") - - # set up environment - env_copy = os.environ.copy() - env_copy["CC"] = cc - env_copy["CXX"] = cxx - - # location of the binaries for the new test suite: - env_copy["EXIV2_BINDIR"] = os.path.join(cwd, "bin") - - kwargs = {"env": env_copy, "cwd": cwd} - - def run(cmd): - call_wrapper(shlex.split(cmd), **kwargs) - - run(cmake) - run(make) - run(make_tests) - run(unit_tests) +def matrix_build(shared_libs, ccs, build_types, cmake_bin, cmake_options, + tests=True): + + NCPUS = multiprocessing.cpu_count() + + os.mkdir("build") + + for params in itertools.product(shared_libs, ccs, build_types): + + lib_type, cc, build_type = params + + cwd = os.path.abspath( + os.path.join( + "build", + "_".join( + map(lambda p: str(p) if p is not None else "", params) + ) + ) + ) + os.mkdir(cwd) + + cmake = "{cmake_bin} {!s} -DCMAKE_BUILD_TYPE={build_type} " \ + "-DBUILD_SHARED_LIBS={lib_type} -DEXIV2_BUILD_UNIT_TESTS={tests} "\ + "../..".format( + cmake_options, cmake_bin=cmake_bin, build_type=build_type, + lib_type=lib_type, tests="ON" if tests else "OFF" + ) + make = "make -j " + str(NCPUS) + make_tests = "make tests" + unit_test_binary = os.path.join(cwd, "bin", "unit_tests") + + # set compiler via environment only when requested + env_copy = os.environ.copy() + if cc is not None: + cxx = {"gcc": "g++", "clang": "clang++"}[cc] + env_copy["CC"] = cc + env_copy["CXX"] = cxx + + # location of the binaries for the new test suite: + env_copy["EXIV2_BINDIR"] = os.path.join(cwd, "bin") + + kwargs = {"env": env_copy, "cwd": cwd} + + def run(cmd): + call_wrapper(shlex.split(cmd), **kwargs) + + run(cmake) + run(make) + if tests: + run(make_tests) + run(unit_test_binary) + + +if __name__ == '__main__': + import argparse + + parser = argparse.ArgumentParser( + description="Build and test exiv2 using a matrix of build switches") + parser.add_argument( + "--compilers", + help="Compilers to be used to build exiv2 (when none ore specified, " + "then the default compiler will be used)", + nargs='*', + default=["gcc", "clang"], + type=str + ) + parser.add_argument( + "--shared-libs", + help="Values for the -DBUILD_SHARED_LIBS option", + nargs='+', + default=["ON", "OFF"], + type=str + ) + parser.add_argument( + "--build-types", + help="Values for the -DCMAKE_BUILD_TYPE option", + nargs='+', + default=["Debug", "Release"], + type=str + ) + parser.add_argument( + "--cmake-executable", + help="alternative name or path for the cmake executable", + nargs=1, + default=['cmake'], + type=str + ) + parser.add_argument( + "--without-tests", + help="Skip building and running tests", + action='store_true' + ) + parser.add_argument( + "--cmake-options", + help="Additional flags for cmake", + type=str, + nargs='?', + default="-DEXIV2_TEAM_EXTRA_WARNINGS=ON -DEXIV2_ENABLE_VIDEO=ON " + "-DEXIV2_ENABLE_WEBREADY=ON -DEXIV2_BUILD_UNIT_TESTS=ON " + "-DBUILD_WITH_CCACHE=ON -DEXIV2_ENABLE_CURL=ON" + ) + + args = parser.parse_args() + + if len(args.compilers) == 0: + args.compilers = [None] + + matrix_build( + args.shared_libs, args.compilers, args.build_types, + args.cmake_executable[0], args.cmake_options, + not args.without_tests + ) From 43c5f29e9721eee4ac95cc160693fd2bbe7e95e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= Date: Sat, 9 Feb 2019 11:24:37 +0100 Subject: [PATCH 3/3] [ci] Add Fedora cross compilation build job with MinGW (cherry picked from commit b0e93c24d89d35cce0b38d09383cd5807370bfce) --- .gitlab-ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 396113b6..4b6ff25b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,6 +36,14 @@ Fedora: <<: *default_config <<: *distro_build +Fedora_MinGW: + image: fedora:29 + before_script: + - dnf -y upgrade + - dnf -y install mingw64-gcc-c++ mingw64-filesystem mingw64-expat mingw64-zlib cmake make + script: + - python3 ci/test_build.py --without-tests --cmake-executable "mingw64-cmake" --cmake-options "-DEXIV2_TEAM_EXTRA_WARNINGS=ON -DEXIV2_ENABLE_VIDEO=ON -DEXIV2_ENABLE_WEBREADY=ON -DEXIV2_ENABLE_WIN_UNICODE=ON " --compilers --shared-libs OFF + Debian: image: debian:9 <<: *default_config