Some fixes for MINGW (#828)

* Enable webpng on MINGW

* Detect GD version using cmake language

* Use _aligned_malloc instead of posix_memalign on Windows

* Include missing "errno.h"

* Fix finding WEBP on MINGW

* Fix finding XPM on MINGW

* Use PkgConfig to find packages on MINGW

* CI: Enable more options  for MINGW
master
مهدي شينون (Mehdi Chinoune) 2022-04-15 09:34:24 +01:00 committed by GitHub
parent 03495a4f95
commit 7efcf4f935
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 43 additions and 43 deletions

View File

@ -21,16 +21,14 @@ jobs:
fail-fast: false
matrix:
include:
- { icon: '⬛', sys: mingw32, env: i686 }
- { icon: '🟦', sys: mingw64, env: x86_64 }
- { icon: '🟨', sys: ucrt64, env: ucrt-x86_64 } # Experimental!
# - { icon: '🟧', sys: clang64, env: clang-x86_64 } # Experimental!
- { icon: '⬛', sys: MINGW32 }
- { icon: '🟦', sys: MINGW64 }
- { icon: '🟨', sys: UCRT64 } # Experimental!
- { icon: '🟧', sys: CLANG64 } # Experimental!
name: 🚧${{ matrix.icon }}-${{ matrix.sys }}
defaults:
run:
shell: msys2 {0}
env:
MINGW_ARCH: ${{ matrix.sys }}
steps:
- name: '⚙️ git config'
@ -51,24 +49,26 @@ jobs:
git
base-devel
tree
mingw-w64-${{ matrix.env }}-toolchain
mingw-w64-${{ matrix.env }}-libpng
mingw-w64-${{ matrix.env }}-libjpeg-turbo
mingw-w64-${{ matrix.env }}-freetype
mingw-w64-${{ matrix.env }}-libtiff
mingw-w64-${{ matrix.env }}-libwebp
mingw-w64-${{ matrix.env }}-libheif
mingw-w64-${{ matrix.env }}-libraqm
mingw-w64-${{ matrix.env }}-libimagequant
mingw-w64-${{ matrix.env }}-libavif
mingw-w64-${{ matrix.env }}-cmake
pacboy: >
toolchain:p
libpng:p
libjpeg-turbo:p
freetype:p
libtiff:p
libwebp:p
libheif:p
libraqm:p
libavif:p
xpm-nox:p
cmake:p
ninja:p
- name: '🚧 Cmake Configure'
run: |
MSYSTEM=MINGW64 cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DENABLE_PNG=1 -DENABLE_FREETYPE=1 -DENABLE_XPM=0 -DENABLE_JPEG=1 -DENABLE_WEBP=0 -DENABLE_TIFF=1 -DENABLE_XPM=0 -DENABLE_GD_FORMATS=1 -DENABLE_HEIF=1 -DENABLE_RAQM=1 -DBUILD_TEST=1 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -B.
cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_PNG=1 -DENABLE_FREETYPE=1 -DENABLE_XPM=1 -DENABLE_JPEG=1 -DENABLE_WEBP=1 -DENABLE_TIFF=1 -DENABLE_GD_FORMATS=1 -DENABLE_HEIF=1 -DENABLE_RAQM=1 -DENABLE_ICONV=1 -DENABLE_CPP=1 -DBUILD_TEST=1 -B.
- name: Build
run: cmake --build . --config ${{env.BUILD_TYPE}} --parallel 4
run: cmake --build .
- name: Run tests
working-directory: ${{github.workspace}}
@ -76,4 +76,4 @@ jobs:
mkdir tmp
export TMP=${{github.workspace}}\\tmp
export CTEST_OUTPUT_ON_FAILURE=1
ctest -C ${{env.BUILD_TYPE}}
ctest

View File

@ -86,10 +86,10 @@ if (USE_EXT_GD)
else (USE_EXT_GD)
MACRO(GV VER VAR)
execute_process(
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config/getver.sh ${VER}
OUTPUT_VARIABLE ${VAR}
)
file (STRINGS "src/gd.h" _VERSION_LINE REGEX "define[ ]+GD_${VER}_VERSION")
if ( _VERSION_LINE )
string ( REGEX REPLACE ".*define[ ]+GD_${VER}_VERSION[ ]+\"?([^ \"]*)\"?[ ]+.*" "\\1" ${VAR} "${_VERSION_LINE}" )
endif ()
ENDMACRO(GV)
GV(MAJOR GDLIB_MAJOR)

View File

@ -37,11 +37,11 @@ endif ( FONTCONFIG_INCLUDE_DIR AND FONTCONFIG_LIBRARY )
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
if( NOT WIN32 )
if( NOT MSVC )
find_package(PkgConfig)
pkg_check_modules(FONTCONFIG_PKG QUIET fontconfig)
endif( NOT WIN32 )
endif( NOT MSVC )
FIND_PATH(FONTCONFIG_INCLUDE_DIR NAMES fontconfig/fontconfig.h
PATHS

View File

@ -41,10 +41,10 @@ SET(HEIF_FOUND "NO")
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
if( NOT WIN32 )
if( NOT MSVC )
find_package(PkgConfig)
pkg_check_modules(HEIF_PKG libheif>=1.7.0 QUIET)
endif( NOT WIN32 )
endif( NOT MSVC )
FIND_PATH(HEIF_INCLUDE_DIR NAMES libheif/heif.h
PATHS

View File

@ -37,11 +37,10 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
include(FindZLIB)
find_path(WEBP_INCLUDE_DIR decode.h
/usr/local/include/webp
/usr/include/webp
find_path(WEBP_INCLUDE_DIR
NAMES decode.h
PATHS /usr/local/include /usr/include
PATH_SUFFIXES webp
)
set(WEBP_NAMES ${WEBP_NAMES} webp)

View File

@ -40,9 +40,10 @@
SET(XPM_FOUND "NO")
FIND_PATH(XPM_XPM_INCLUDE_DIR xpm.h
/usr/local/include/X11
/usr/include/X11
FIND_PATH(XPM_XPM_INCLUDE_DIR
NAMES xpm.h
PATHS /usr/local/include /usr/include
PATH_SUFFIXES X11
)
SET(XPM_NAMES ${XPM_NAMES} Xpm libXpm)

View File

@ -132,9 +132,9 @@ set(GD_PROGRAMS gdcmpgif)
if (PNG_FOUND)
set(GD_PROGRAMS ${GD_PROGRAMS} gdtopng pngtogd)
if (NOT WIN32)
if (NOT MSVC)
set(GD_PROGRAMS ${GD_PROGRAMS} webpng)
endif (NOT WIN32)
endif (NOT MSVC)
if (ZLIB_FOUND)
set(GD_PROGRAMS ${GD_PROGRAMS} gdparttopng gd2topng pngtogd2)
endif()
@ -152,11 +152,6 @@ endif()
foreach(program ${GD_PROGRAMS})
add_executable(${program} ${program}.c)
if (WIN32)
list(REMOVE_ITEM program webpng.c annotate.c)
list(REMOVE_ITEM GD_PROGRAMS webpng)
list(REMOVE_ITEM GD_PROGRAMS annotate)
endif (WIN32)
if (BUILD_SHARED_LIBS)
target_link_libraries(${program} ${GD_LIB})

View File

@ -1527,8 +1527,12 @@ static void free_truecolor_image_data(gdImagePtr oim)
/* liq requires 16 byte aligned heap memory */
static void *malloc16(size_t size)
{
#ifndef _WIN32
void *p;
return posix_memalign(&p, 16, size) == 0 ? p : NULL;
#else
return _aligned_malloc(16, size);
#endif
}
#endif

View File

@ -9,6 +9,7 @@
#include <math.h>
#include <limits.h>
#include <time.h>
#include <errno.h>
#ifdef HAVE_DIRENT_H
#include <dirent.h>