Merge pull request #728 from Exiv2/mingw-gitlab-0.27

Mingw gitlab 0.27
v0.27.3
Luis Díaz Más 6 years ago committed by GitHub
commit 89a42bcc98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

@ -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
)

@ -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) <ahuggel@gmx.net>
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 <sys/types.h>
#include <sys/stat.h>
#ifdef _MSC_VER
#include <Windows.h>
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#include <psapi.h> // For access to GetModuleFileNameEx
#elif defined(__APPLE__)
#include <libproc.h>
#endif
#ifdef EXV_HAVE_UNISTD_H
# include <unistd.h> // for stat()
#endif
#include <cstdio>
#include <cerrno>
#include <sstream>
#include <cstring>
#include <algorithm>
#include <stdexcept>
#ifdef EXV_HAVE_UNISTD_H
#include <unistd.h> // for stat()
#endif
#if defined(WIN32)
#include <windows.h>
#include <psapi.h> // For access to GetModuleFileNameEx
#endif
#if defined(_MSC_VER)
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#elif defined(__APPLE__)
#include <libproc.h>
#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

Loading…
Cancel
Save