From 42084f2563b0a367bcb646b4038f44c5b446799d Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Mon, 15 Oct 2018 09:20:46 +0100 Subject: [PATCH] Add support for MinGW/msys2 in 32 bits + Updates in buildserver --- README.md | 42 +++++++---- cmake/compilerFlags.cmake | 6 +- cmake/config.h.cmake | 6 -- cmake/findDependencies.cmake | 9 +-- cmake/packaging.cmake | 4 +- contrib/buildserver/build.sh | 138 +++++++++++++++++++++++------------ src/CMakeLists.txt | 19 ++--- src/version.cpp | 4 +- 8 files changed, 135 insertions(+), 93 deletions(-) diff --git a/README.md b/README.md index 7c77e1bb..6a78d2af 100644 --- a/README.md +++ b/README.md @@ -21,14 +21,13 @@ 4. [Platform Notes](#4) 1. [Linux](#4-1) 2. [MacOS-X](#4-2) - 3. [Cygwin](#4-3) - 4. [MinGW msys/2](#4-4) + 3. [MinGW/msys2](#4-3) + 4. [Cygwin](#4-3) 5. [Microsoft Visual C++](#4-5) 5. [Test Suit](#5) 1. [Running tests on a UNIX-like system](#5-1) 2. [Running tests on Visual Studio builds](#5-2) - # Welcome to Exiv2 @@ -293,33 +292,46 @@ You should build and install CMake from source. [TOC](#TOC) -### 4.3 MinGW msys/2 64 +### 4.3 MinGW/msys2 + +Support for MinGW/msys1.0 32 bit build was provided for Exiv2 v0.26. +#### MSYS 64 bit https://www.msys2.org Download: http://repo.msys2.org/distrib/x86_64/msys2-x86_64-20180531.exe -#### msys64.bat - I use this batch file to start the MinGW bash shell from the Dos Command Prompt (cmd.exe) ``` $ cat msys64.bat setlocal set "PATH=c:\msys64\usr\bin;c:\msys64\usr\local\bin;c:\msys64\mingw64\bin;" -set "PS1=\! \u@\h:\w \$ " +set "PS1=\! \u@\h-64:\w \$ " bash.exe -norc $ ``` -#### Install MinGW Dependencies +#### MSYS 32 bit +http://repo.msys2.org/distrib/i686/msys2-i686-20180531.exe -$ pacman -S base-devel +I use this batch file to start the MinGW bash shell from the Dos Command Prompt (cmd.exe) ``` -$ for i in libtre git coreutils mingw-w64-x86_64-gcc mingw-w64-x86_64-gdb mingw-w64-x86_64-make mingw-w64-x86_64-pkg-config mingw-w64-x86_64-cmake; do (echo y|pacman -S $i); done +$ cat msys32.bat +setlocal +set "PATH=c:\msys32\usr\bin;c:\msys32\usr\local\bin;c:\msys32\mingw64\bin;" +set "PS1=\! \u@\h-32:\w \$ " +bash.exe -norc +$ ``` -#### Download exiv2 from github and build. +#### Install MinGW Dependencies + +``` +for i in base-devel git cmake coreutils python3 man gcc gdb make dos2unix diffutils zlib-devel libexpat-devel libiconv-devel; do (echo y|pacman -S $i); done +``` + +#### Download exiv2 from github and build ``` $ mkdir -p ~/gnu/github/exiv2 @@ -329,6 +341,11 @@ $ mkdir build ; cd build ; $ cmake .. -G "Unix Makefiles" $ make ``` + +#### MinGW and Regex + +The exiv2 command line program provides a `--grep` option which filters output. The implementation requires the header file `` and supporting library to be available during the build. When not available, the option degenerates to a substring match. Because there are multiple versions of `` available on the MinGW platform, detection of Regex is always disabled on this platform. + [TOC](#TOC) @@ -345,7 +362,6 @@ https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz Download and build cmake from source because I can't get the cygwin installed cmake 3.6.2 to work To build cmake from source (for 3.11+), you need libncurses. - [TOC](#TOC) @@ -391,7 +407,7 @@ rmills@rmillsmbp-w7 ~/gnu/github/exiv2/exiv2/test $ env EXIV2_BINDIR=${PWD}/../b ### 5.2 Running tests on Visual Studio builds -Use the bash interpreter for MinGW/msys/2 to run the test suite. +Use the bash interpreter for MinGW/msys2 to run the test suite. $ cd ...../build/../test $ export EXIV2_EXT=.exe diff --git a/cmake/compilerFlags.cmake b/cmake/compilerFlags.cmake index 6519eff8..b697b537 100644 --- a/cmake/compilerFlags.cmake +++ b/cmake/compilerFlags.cmake @@ -1,6 +1,6 @@ # These flags applies to exiv2lib, the applications, and to the xmp code -if ( MINGW OR UNIX ) # MINGW, Linux, APPLE, CYGWIN +if ( MINGW OR UNIX OR MSYS ) # MINGW, Linux, APPLE, CYGWIN if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU) set(COMPILER_IS_GCC ON) elseif (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") @@ -59,7 +59,7 @@ if ( MINGW OR UNIX ) # MINGW, Linux, APPLE, CYGWIN endif() # sorry, ASAN does not work on Windows - if ( NOT CYGWIN AND NOT MINGW ) + if ( NOT CYGWIN AND NOT MINGW AND NOT MSYS ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_FLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZER_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SANITIZER_FLAGS}") @@ -157,7 +157,7 @@ if(MSVC) set(CMAKE_CXX_COMPILER ${CLCACHE}) endif() endif() - + set(variables CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_MINSIZEREL diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 9434a1a7..10352d05 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -50,12 +50,6 @@ // Define if you have the header file. #cmakedefine EXV_HAVE_STDINT_H -#ifndef EXV_HAVE_STDINT_H -#if defined(__MINGW32__) || defined(__MINGW64__) -#define EXV_HAVE_STDINT_H -#endif -#endif - // Define if you have the header file. #cmakedefine EXV_HAVE_STRINGS_H diff --git a/cmake/findDependencies.cmake b/cmake/findDependencies.cmake index 18a45afb..c86857d8 100644 --- a/cmake/findDependencies.cmake +++ b/cmake/findDependencies.cmake @@ -10,13 +10,6 @@ endif() find_package(Threads REQUIRED) -if(MINGW) - find_package(Regex REQUIRED) - if(REGEX_FOUND) - include_directories(${REGEX_INCLUDE_DIRS}) - endif() -endif() - if( EXIV2_ENABLE_PNG ) find_package( ZLIB REQUIRED ) include_directories( ${ZLIB_INCLUDE_DIR} ) @@ -84,7 +77,7 @@ if (EXIV2_BUILD_UNIT_TESTS) endif() # On Windows we are interested in placing the DLLs together to the binaries in the install/bin -# folder, at the installation step. On other platforms we do not care about that, since the +# folder, at the installation step. On other platforms we do not care about that, since the # RPATHs will point the locations where the libraries where found. if (USING_CONAN AND WIN32) install(DIRECTORY ${PROJECT_BINARY_DIR}/conanDlls/ DESTINATION bin) diff --git a/cmake/packaging.cmake b/cmake/packaging.cmake index 1f9a9978..9a360d35 100644 --- a/cmake/packaging.cmake +++ b/cmake/packaging.cmake @@ -7,7 +7,7 @@ set(CPACK_SOURCE_IGNORE_FILES "build.*;\.git/;\.DS_Store/;test;third-party;") ## ----------------------------------------------- ## TODO: Luis will rewrite this ----------------- -if ( MINGW ) +if ( MINGW OR MSYS ) set (PACKNAME MinGW) elseif ( MSVC ) set (PACKNAME msvc) @@ -15,7 +15,7 @@ else() set (PACKNAME ${CMAKE_SYSTEM_NAME}) # Darwin or Linux or CYGWIN endif() -if ( CYGWIN OR MINGW ) +if ( CYGWIN OR MINGW OR MSYS ) set(CPACK_GENERATOR TGZ) # MinGW/Cygwin use .tar.gz elseif ( MSVC ) set(CPACK_GENERATOR ZIP) # use .zip - less likely to damage bin/exiv2.dll permissions diff --git a/contrib/buildserver/build.sh b/contrib/buildserver/build.sh index 60b5ce09..5a06162f 100755 --- a/contrib/buildserver/build.sh +++ b/contrib/buildserver/build.sh @@ -1,8 +1,10 @@ #!/bin/bash syntax() { - echo "usage: $0 { --help | -? | -h | platform }+ " + echo "usage: $0 { --help | -? | -h | platform | option | switch }+ " echo "platform: all | cygwin | linux | macosx | mingw | msvc " + echo "switch: --32 | --64 | --2015 | --2017 --publish | --verbose | --static " + echo "option: --branch x | --server x | --user x" } announce() @@ -12,6 +14,55 @@ announce() echo ++++++++++++++++++++++++++++++++ } +bomb() { + echo "*** $1 requires an argument ***" >&2 + exit 1 +} + +unixBuild() +{ +announce $1 $2 +! ssh $1 ${command} <&2; help=1; ;; esac if [ "$#" != "0" ]; then shift ; fi @@ -41,66 +114,39 @@ if [ $help == 1 ]; then exit 0; fi +if [ "$b64" == "0" -a "$b32" == "0" ]; then b64=1; fi +if [ "$b64" == "1" -a "$b32" == "1" ]; then + echo "*** can't specify --64 && --32 ***" >&2 + exit 1 +fi + if [ $linux == 1 ]; then -me=Linux -server=rmills@rmillsmm-ubuntu command='' cd=/home/rmills/gnu/github/exiv2/ +unixBuild ${user}@${server}-ubuntu Linux fi if [ $macosx == 1 ]; then -me=MacOS-X -server=rmills@rmillsmm -cd=/Users/rmills/gnu/github/exiv2/ -command='' + cd=/Users/rmills/gnu/github/exiv2/ + command='' + unixBuild ${user}@${server} MacOSX fi if [ $mingw == 1 ]; then -me=MinGW -server=rmills@rmillsmm-w7 -command='msys64' -cd=/home/rmills/gnu/github/exiv2/ + command='msys64' + if [ $b32 == 1 ]; then command='msys32' ; fi + cd=/home/rmills/gnu/github/exiv2/ + unixBuild ${user}@${server}-w7 MinGW fi if [ $cygwin == 1 ]; then -me=Cygwin -server=rmills@rmillsmm-w7 -command='c:\\cygwin64\\bin\\bash.exe' -fi - -if [ ! -z $server ]; then -announce $me -! ssh ${server} ${command} < $ @@ -262,30 +262,27 @@ if (EXIV2_ENABLE_WEBREADY) endif() -if ( MSVC ) +if ( MSVC OR CYGWIN OR MINGW OR MSYS) target_compile_definitions(exiv2lib PRIVATE PSAPI_VERSION=1 # to be compatible with <= WinVista (#905) ) +endif() +if ( MSVC ) source_group("Header Files" FILES ${LIBEXIV2_HDR} ) source_group("Header Files" FILES ${LIBCURL_HDR} ) source_group("Header Files" FILES ${SSH_HDR} ) target_link_libraries( exiv2lib PRIVATE ${CURL_LIBRARIES} ${SSH_LIBRARIES}) else() - # TODO: Check if this is really needed. if ( UNIX AND NOT FREEBSD ) target_link_libraries( exiv2lib PRIVATE ${CMAKE_DL_LIBS}) # -ldl = dynamic loader used by src/version.cpp endif() - if (CYGWIN OR MINGW) + if (CYGWIN OR MINGW OR MSYS) target_link_libraries( exiv2lib PRIVATE psapi ws2_32 ) endif() - if (MINGW) - target_link_libraries( exiv2lib PRIVATE ${REGEX_LIBRARIES} ) - endif() - target_link_libraries( exiv2lib PRIVATE Threads::Threads) endif() @@ -340,13 +337,7 @@ if(EXIV2_BUILD_EXIV2_COMMAND) target_compile_definitions(exiv2 PRIVATE EXV_HAVE_DLL ) endif() - if (MINGW) - target_link_libraries( exiv2 PRIVATE ${REGEX_LIBRARIES} ) - endif() - # modify source lists to suit environment - - # TODO This should not be needed here! we need to fix the previous TODO target_include_directories(exiv2 PRIVATE ${CMAKE_SOURCE_DIR}/include/) # Copy DLLs from conan packages to the bin folder diff --git a/src/version.cpp b/src/version.cpp index 7c7d1ee0..eb308518 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -222,7 +222,9 @@ void Exiv2::dumpLibraryInfo(std::ostream& os,const exv_grep_keys_t& keys) #endif const char* platform = -#if defined(__CYGWIN__) +#if defined(__MSYS__) + "msys"; +#elif defined(__CYGWIN__) "cygwin"; #elif defined(_MSC_VER) "windows";