Skip to content

Commit

Permalink
[gmime] Update to 3.2.15, use official build system (microsoft#42959)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg0yt authored Dec 30, 2024
1 parent a54ecb2 commit 8a3beb3
Show file tree
Hide file tree
Showing 12 changed files with 227 additions and 90 deletions.
58 changes: 0 additions & 58 deletions ports/gmime/CMakeLists.txt

This file was deleted.

33 changes: 33 additions & 0 deletions ports/gmime/msvc-ssize_t.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
diff --git a/configure.ac b/configure.ac
index 9d368e0..c534a09 100644
--- a/configure.ac
+++ b/configure.ac
@@ -168,6 +168,13 @@ AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
+AH_BOTTOM([
+#ifdef _MSC_VER
+#undef ssize_t;
+#include <BaseTsd.h>
+typedef SSIZE_T ssize_t;
+#endif
+])
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINT8_T
diff --git a/gmime/gmime.h b/gmime/gmime.h
index ef6b93e..d3696ac 100644
--- a/gmime/gmime.h
+++ b/gmime/gmime.h
@@ -22,6 +22,10 @@
#ifndef __GMIME_H__
#define __GMIME_H__

+#ifdef _MSC_VER
+#include <BaseTsd.h>
+typedef SSIZE_T ssize_t;
+#endif
#include <glib.h>
#include <gmime/gmime-version.h>
#include <gmime/gmime-error.h>
77 changes: 55 additions & 22 deletions ports/gmime/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,38 +1,71 @@
set(LIB_NAME gmime)
set(LIB_VERSION 3.2.6)

set(LIB_FILENAME ${LIB_NAME}-${LIB_VERSION}.tar.xz)

vcpkg_download_distfile(ARCHIVE
URLS "https://download.gnome.org/sources/gmime/3.2/${LIB_FILENAME}"
FILENAME "${LIB_FILENAME}"
SHA512 a60d3f9f1aa8490865c22cd9539544e9c9f3ceb4037b9749cf9e5c279f97aa88fc4cd077bf2aff314ba0db2a1b7bbe76f9b1ca5a17fffcbd6315ecebc5414a3d
URLS https://github.com/jstedfast/gmime/releases/download/${VERSION}/gmime-${VERSION}.tar.xz
FILENAME "gmime-${VERSION}.tar.xz"
SHA512 cafb89854b2441508bf940fd6f991739d30fb137b8928ad33e8e4d2a0293a6460e4d1318e73c3ee9e5a964b692f36e7a4eb5f2930c6998698bd9edf866629655
)

vcpkg_extract_source_archive(
SOURCE_PATH
ARCHIVE "${ARCHIVE}"
SOURCE_BASE "${LIB_VERSION}"
PATCHES
subdirs.diff
msvc-ssize_t.diff
)

file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
set(ENV{ACLOCAL} "aclocal -I \"${CURRENT_INSTALLED_DIR}/share/aclocal/\"") # for glib
set(ENV{GTKDOCIZE} true)

vcpkg_list(SET options)
set(iconv_detect_h "${CURRENT_HOST_INSTALLED_DIR}/share/${PORT}/iconv-detect-${VCPKG_CMAKE_SYSTEM_NAME}.h")
if(EXISTS "${iconv_detect_h}")
vcpkg_list(APPEND options "ac_cv_have_iconv_detect_h=yes")
elseif(VCPKG_CROSSCOMPILING)
vcpkg_list(APPEND options "ac_cv_have_iconv_detect_h=no")
endif()

# We can use file supplied with original sources
configure_file("${SOURCE_PATH}/build/vs2017/unistd.h" "${SOURCE_PATH}" COPYONLY)
configure_file("${SOURCE_PATH}/build/vs2017/config.h" "${SOURCE_PATH}" COPYONLY)
configure_file("${SOURCE_PATH}/build/vs2017/gmime.def" "${SOURCE_PATH}" COPYONLY)
vcpkg_find_acquire_program(PKGCONFIG)
vcpkg_cmake_configure(
if("crypto" IN_LIST FEATURES)
vcpkg_list(APPEND options "--enable-crypto")
else()
vcpkg_list(APPEND options "--disable-crypto")
endif()

vcpkg_configure_make(
SOURCE_PATH "${SOURCE_PATH}"
AUTOCONFIG
ADD_BIN_TO_PATH # for iconv-detect
OPTIONS
"-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}"
${options}
--disable-crypto
--disable-glibtest
--disable-introspection
--disable-vala
)

vcpkg_cmake_install()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
if(EXISTS "${iconv_detect_h}")
file(COPY_FILE "${iconv_detect_h}" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/iconv-detect.h")
if(NOT VCPKG_BUILD_TYPE)
file(COPY_FILE "${iconv_detect_h}" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/iconv-detect.h")
endif()
endif()

# License and man
file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${LIB_NAME}" RENAME copyright)
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
file(COPY "${SOURCE_PATH}/build/vs2017/unistd.h" DESTINATION "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel")
if(NOT VCPKG_BUILD_TYPE)
file(COPY "${SOURCE_PATH}/build/vs2017/unistd.h" DESTINATION "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg")
endif()
endif()

vcpkg_install_make()
vcpkg_copy_pdbs()
vcpkg_fixup_pkgconfig()

if(NOT VCPKG_CROSSCOMPILING)
file(INSTALL "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/iconv-detect.h"
DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}"
RENAME "iconv-detect-${VCPKG_CMAKE_SYSTEM_NAME}.h"
)
endif()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING")
16 changes: 16 additions & 0 deletions ports/gmime/subdirs.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/Makefile.am b/Makefile.am
index c004167..0fafe72 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,10 +2,9 @@

ACLOCAL_AMFLAGS = -I m4

-SUBDIRS = m4 build util gmime tests docs
+SUBDIRS = m4 build util gmime

if !PLATFORM_WIN32
-SUBDIRS += examples
endif

SUBDIRS += tools .
26 changes: 18 additions & 8 deletions ports/gmime/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
{
"name": "gmime",
"version": "3.2.6",
"port-version": 6,
"version": "3.2.15",
"description": "GMime is a C/C++ library which may be used for the creation and parsing of messages using the Multipurpose Internet Mail Extension (MIME).",
"homepage": "https://developer.gnome.org/gmime/",
"homepage": "https://github.com/jstedfast/gmime",
"license": "LGPL-2.1-or-later",
"supports": "windows & !xbox",
"supports": "!xbox",
"dependencies": [
"glib",
"libiconv",
"libidn2",
{
"name": "vcpkg-cmake",
"name": "gmime",
"host": true
},
"libiconv",
"libidn2",
"zlib"
]
],
"features": {
"crypto": {
"description": "PGP and S/MIME support",
"dependencies": [
{
"name": "gpgme",
"default-features": false
}
]
}
}
}
15 changes: 15 additions & 0 deletions ports/gmime/win32_ssize_t.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/gmime/gmime.h b/gmime/gmime.h
index ef6b93e..d3696ac 100644
--- a/gmime/gmime.h
+++ b/gmime/gmime.h
@@ -22,6 +22,10 @@
#ifndef __GMIME_H__
#define __GMIME_H__

+#ifdef _MSC_VER
+#include <BaseTsd.h>
+typedef SSIZE_T ssize_t;
+#endif
#include <glib.h>
#include <gmime/gmime-version.h>
#include <gmime/gmime-error.h>
11 changes: 11 additions & 0 deletions scripts/test_ports/vcpkg-ci-gmime/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
SET(VCPKG_POLICY_EMPTY_PACKAGE enabled)

vcpkg_find_acquire_program(PKGCONFIG)

vcpkg_cmake_configure(
SOURCE_PATH "${CURRENT_PORT_DIR}/project"
OPTIONS
"-DFEATURES=${FEATURES}"
"-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}"
)
vcpkg_cmake_build()
15 changes: 15 additions & 0 deletions scripts/test_ports/vcpkg-ci-gmime/project/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.10)

project(vcpkg-ci-gmime C)

set(CMAKE_C_STANDARD 11)

find_package(PkgConfig REQUIRED)
pkg_check_modules(gmime REQUIRED IMPORTED_TARGET gmime-3.0)

add_executable(main main.c)
target_link_libraries(main PRIVATE PkgConfig::gmime)

if("crypto" IN_LIST FEATURES)
target_compile_definitions(main PRIVATE ENABLE_CRYPTO)
endif()
26 changes: 26 additions & 0 deletions scripts/test_ports/vcpkg-ci-gmime/project/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <glib.h>
#include <gmime/gmime.h>

void verify_callback(GMimeObject *parent, GMimeObject *part, gpointer user_data)
{
#ifdef ENABLE_CRYPTO
if (GMIME_IS_MULTIPART_SIGNED(part))
{
GMimeMultipartSigned *mps = (GMimeMultipartSigned *)part;
GError *err = NULL;
GMimeSignatureList *signatures = g_mime_multipart_signed_verify(mps, GMIME_VERIFY_NONE, &err);
g_object_unref(signatures);
}
#endif
}

int main()
{
g_mime_init();
GMimeParser *parser = g_mime_parser_new();
GMimeMessage *message = g_mime_parser_construct_message(parser, NULL);
g_mime_message_foreach(message, verify_callback, NULL);
g_object_unref(message);
g_object_unref(parser);
return 0;
}
31 changes: 31 additions & 0 deletions scripts/test_ports/vcpkg-ci-gmime/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "vcpkg-ci-gmime",
"version-string": "ci",
"description": "Validates gmime",
"dependencies": [
"gmime",
{
"name": "vcpkg-cmake",
"host": true
}
],
"default-features": [
{
"name": "crypto",
"platform": "!windows | mingw"
}
],
"features": {
"crypto": {
"description": "gmime[crypo]",
"dependencies": [
{
"name": "gmime",
"features": [
"crypto"
]
}
]
}
}
}
4 changes: 2 additions & 2 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -3193,8 +3193,8 @@
"port-version": 4
},
"gmime": {
"baseline": "3.2.6",
"port-version": 6
"baseline": "3.2.15",
"port-version": 0
},
"gmmlib": {
"baseline": "22.5.2",
Expand Down
5 changes: 5 additions & 0 deletions versions/g-/gmime.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "0317c90380341a0639221bed8e70dbf37de46b0c",
"version": "3.2.15",
"port-version": 0
},
{
"git-tree": "93e8b6f02474e1edb7e99db85020d864ee071ce0",
"version": "3.2.6",
Expand Down

0 comments on commit 8a3beb3

Please sign in to comment.