diff --git a/mingw-w64-adbc/PKGBUILD b/mingw-w64-adbc/PKGBUILD new file mode 100644 index 0000000000000..c97f6b3078731 --- /dev/null +++ b/mingw-w64-adbc/PKGBUILD @@ -0,0 +1,65 @@ +# Maintainer: Taozuhong + +_realname=adbc +pkgbase=mingw-w64-${_realname} +pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}" +pkgver=15.0.0 +pkgrel=1 +pkgdesc="ADBC libraries for Arrow-native access to databases.(mingw-w64)" +arch=('any') +mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64') +url="https://github.com/apache/arrow-adbc" +license=('Apache-2.0') +depends=("${MINGW_PACKAGE_PREFIX}-arrow" + "${MINGW_PACKAGE_PREFIX}-nanoarrow") +makedepends=("${MINGW_PACKAGE_PREFIX}-cc" + "${MINGW_PACKAGE_PREFIX}-go" + "git" + "${MINGW_PACKAGE_PREFIX}-cmake" + "${MINGW_PACKAGE_PREFIX}-ninja" + "${MINGW_PACKAGE_PREFIX}-pkgconf") +options=('staticlibs' 'strip' 'emptydirs') +# source=("https://github.com/apache/arrow-adbc/releases/download//apache-arrow-${_realname}-${pkgver:0:2}/apache-arrow-${_realname}-${pkgver:0:2}.tar.gz") +source=("git+https://github.com/apache/arrow-adbc.git#commit=e6bb104" + "adbc-001.patch") +sha256sums=('SKIP' + '6d1747345b48fe2878c2c368af7768d7096908ded002fe485bd38b00b083654f') + + +build() { + cd "${srcdir}/arrow-adbc" + + patch -p1 -i "${srcdir}"/adbc-001.patch + + # Update Go compiler path + export GOROOT=${MINGW_PREFIX}/lib/go + + [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST} + mkdir -p ${srcdir}/build-${MINGW_CHOST} && cd ${srcdir}/build-${MINGW_CHOST} + + declare -a _extra_config + if check_option "debug" "n"; then + _extra_config+=("-DCMAKE_BUILD_TYPE=Release") + else + _extra_config+=("-DCMAKE_BUILD_TYPE=Debug") + fi + + MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \ + "${MINGW_PREFIX}"/bin/cmake.exe \ + -GNinja \ + -DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \ + -DADBC_DRIVER_MANAGER=ON \ + -DADBC_DRIVER_SQLITE=ON \ + -DADBC_DRIVER_FLIGHTSQL=ON \ + -DADBC_DRIVER_POSTGRESQL=ON \ + "${_extra_config[@]}" \ + ../arrow-adbc/c + + "${MINGW_PREFIX}"/bin/cmake.exe --build . +} + +package() { + # ADBC Core + cd "${srcdir}/build-${MINGW_CHOST}" + DESTDIR="${pkgdir}" "${MINGW_PREFIX}"/bin/cmake.exe --install . +} diff --git a/mingw-w64-adbc/adbc-001.patch b/mingw-w64-adbc/adbc-001.patch new file mode 100644 index 0000000000000..e0581abd8ff64 --- /dev/null +++ b/mingw-w64-adbc/adbc-001.patch @@ -0,0 +1,212 @@ +From 088df0850ca62365219b45ef5255f71b59de507e Mon Sep 17 00:00:00 2001 +From: taozuhong +Date: Sat, 7 Dec 2024 19:21:35 +0800 +Subject: [PATCH] Fixed compile issue + +--- + c/driver/sqlite/statement_reader.h | 2 +- + c/include/arrow-adbc/adbc.h | 41 ++++++++++++++++++----------- + go/adbc/drivermgr/arrow-adbc/adbc.h | 41 ++++++++++++++++++----------- + 3 files changed, 53 insertions(+), 31 deletions(-) + +diff --git a/c/driver/sqlite/statement_reader.h b/c/driver/sqlite/statement_reader.h +index 2e6b19086c..48123ed844 100644 +--- a/c/driver/sqlite/statement_reader.h ++++ b/c/driver/sqlite/statement_reader.h +@@ -28,7 +28,7 @@ extern "C" { + #endif + + /// \brief Helper to manage binding data to a SQLite statement. +-struct ADBC_EXPORT AdbcSqliteBinder { ++struct ADBC_EXPORT_STRUCT AdbcSqliteBinder { + // State + struct ArrowSchema schema; + struct ArrowArrayStream params; +diff --git a/c/include/arrow-adbc/adbc.h b/c/include/arrow-adbc/adbc.h +index b965672e6f..e73bed2e33 100644 +--- a/c/include/arrow-adbc/adbc.h ++++ b/c/include/arrow-adbc/adbc.h +@@ -152,15 +152,26 @@ struct ArrowArrayStream { + // Storage class macros for Windows + // Allow overriding/aliasing with application-defined macros + #if !defined(ADBC_EXPORT) +-#if defined(_WIN32) +-#if defined(ADBC_EXPORTING) +-#define ADBC_EXPORT __declspec(dllexport) +-#else +-#define ADBC_EXPORT __declspec(dllimport) +-#endif // defined(ADBC_EXPORTING) +-#else +-#define ADBC_EXPORT +-#endif // defined(_WIN32) ++ #if defined(_WIN32) ++ #if defined(ADBC_EXPORTING) ++ #define ADBC_EXPORT __declspec(dllexport) ++ #else ++ #define ADBC_EXPORT __declspec(dllimport) ++ #endif // defined(ADBC_EXPORTING) ++ ++ #if defined(__cplusplus) ++ #if defined(ADBC_EXPORTING) ++ #define ADBC_EXPORT_STRUCT __declspec(dllexport) ++ #else ++ #define ADBC_EXPORT_STRUCT __declspec(dllimport) ++ #endif // defined(ADBC_EXPORTING) ++ #else ++ #define ADBC_EXPORT_STRUCT ++ #endif // defined(__cplusplus) ++ #else ++ #define ADBC_EXPORT ++ #define ADBC_EXPORT_STRUCT ++ #endif // defined(_WIN32) + #endif // !defined(ADBC_EXPORT) + + /// \defgroup adbc-error-handling Error Handling +@@ -266,7 +277,7 @@ typedef uint8_t AdbcStatusCode; + /// ADBC_ERROR_VENDOR_CODE_PRIVATE_DATA. Clients are required to initialize + /// this struct to avoid the possibility of uninitialized values confusing the + /// driver. +-struct ADBC_EXPORT AdbcError { ++struct ADBC_EXPORT_STRUCT AdbcError { + /// \brief The error message. + char* message; + +@@ -347,7 +358,7 @@ struct ADBC_EXPORT AdbcError { + /// called. + /// + /// \since ADBC API revision 1.1.0 +-struct ADBC_EXPORT AdbcErrorDetail { ++struct ADBC_EXPORT_STRUCT AdbcErrorDetail { + /// \brief The metadata key. + const char* key; + /// \brief The binary metadata value. +@@ -805,7 +816,7 @@ const struct AdbcError* AdbcErrorFromArrayStream(struct ArrowArrayStream* stream + /// \brief An instance of a database. + /// + /// Must be kept alive as long as any connections exist. +-struct ADBC_EXPORT AdbcDatabase { ++struct ADBC_EXPORT_STRUCT AdbcDatabase { + /// \brief Opaque implementation-defined state. + /// This field is NULLPTR iff the connection is unintialized/freed. + void* private_data; +@@ -828,7 +839,7 @@ struct ADBC_EXPORT AdbcDatabase { + /// Connections are not required to be thread-safe, but they can be + /// used from multiple threads so long as clients take care to + /// serialize accesses to a connection. +-struct ADBC_EXPORT AdbcConnection { ++struct ADBC_EXPORT_STRUCT AdbcConnection { + /// \brief Opaque implementation-defined state. + /// This field is NULLPTR iff the connection is unintialized/freed. + void* private_data; +@@ -866,7 +877,7 @@ struct ADBC_EXPORT AdbcConnection { + /// Statements are not required to be thread-safe, but they can be + /// used from multiple threads so long as clients take care to + /// serialize accesses to a statement. +-struct ADBC_EXPORT AdbcStatement { ++struct ADBC_EXPORT_STRUCT AdbcStatement { + /// \brief Opaque implementation-defined state. + /// This field is NULLPTR iff the connection is unintialized/freed. + void* private_data; +@@ -933,7 +944,7 @@ struct AdbcPartitions { + /// initialization routines. Drivers should populate this struct, and + /// applications can call ADBC functions through this struct, without + /// worrying about multiple definitions of the same symbol. +-struct ADBC_EXPORT AdbcDriver { ++struct ADBC_EXPORT_STRUCT AdbcDriver { + /// \brief Opaque driver-defined state. + /// This field is NULL if the driver is unintialized/freed (but + /// it need not have a value even if the driver is initialized). +diff --git a/go/adbc/drivermgr/arrow-adbc/adbc.h b/go/adbc/drivermgr/arrow-adbc/adbc.h +index b965672e6f..e73bed2e33 100644 +--- a/go/adbc/drivermgr/arrow-adbc/adbc.h ++++ b/go/adbc/drivermgr/arrow-adbc/adbc.h +@@ -152,15 +152,26 @@ struct ArrowArrayStream { + // Storage class macros for Windows + // Allow overriding/aliasing with application-defined macros + #if !defined(ADBC_EXPORT) +-#if defined(_WIN32) +-#if defined(ADBC_EXPORTING) +-#define ADBC_EXPORT __declspec(dllexport) +-#else +-#define ADBC_EXPORT __declspec(dllimport) +-#endif // defined(ADBC_EXPORTING) +-#else +-#define ADBC_EXPORT +-#endif // defined(_WIN32) ++ #if defined(_WIN32) ++ #if defined(ADBC_EXPORTING) ++ #define ADBC_EXPORT __declspec(dllexport) ++ #else ++ #define ADBC_EXPORT __declspec(dllimport) ++ #endif // defined(ADBC_EXPORTING) ++ ++ #if defined(__cplusplus) ++ #if defined(ADBC_EXPORTING) ++ #define ADBC_EXPORT_STRUCT __declspec(dllexport) ++ #else ++ #define ADBC_EXPORT_STRUCT __declspec(dllimport) ++ #endif // defined(ADBC_EXPORTING) ++ #else ++ #define ADBC_EXPORT_STRUCT ++ #endif // defined(__cplusplus) ++ #else ++ #define ADBC_EXPORT ++ #define ADBC_EXPORT_STRUCT ++ #endif // defined(_WIN32) + #endif // !defined(ADBC_EXPORT) + + /// \defgroup adbc-error-handling Error Handling +@@ -266,7 +277,7 @@ typedef uint8_t AdbcStatusCode; + /// ADBC_ERROR_VENDOR_CODE_PRIVATE_DATA. Clients are required to initialize + /// this struct to avoid the possibility of uninitialized values confusing the + /// driver. +-struct ADBC_EXPORT AdbcError { ++struct ADBC_EXPORT_STRUCT AdbcError { + /// \brief The error message. + char* message; + +@@ -347,7 +358,7 @@ struct ADBC_EXPORT AdbcError { + /// called. + /// + /// \since ADBC API revision 1.1.0 +-struct ADBC_EXPORT AdbcErrorDetail { ++struct ADBC_EXPORT_STRUCT AdbcErrorDetail { + /// \brief The metadata key. + const char* key; + /// \brief The binary metadata value. +@@ -805,7 +816,7 @@ const struct AdbcError* AdbcErrorFromArrayStream(struct ArrowArrayStream* stream + /// \brief An instance of a database. + /// + /// Must be kept alive as long as any connections exist. +-struct ADBC_EXPORT AdbcDatabase { ++struct ADBC_EXPORT_STRUCT AdbcDatabase { + /// \brief Opaque implementation-defined state. + /// This field is NULLPTR iff the connection is unintialized/freed. + void* private_data; +@@ -828,7 +839,7 @@ struct ADBC_EXPORT AdbcDatabase { + /// Connections are not required to be thread-safe, but they can be + /// used from multiple threads so long as clients take care to + /// serialize accesses to a connection. +-struct ADBC_EXPORT AdbcConnection { ++struct ADBC_EXPORT_STRUCT AdbcConnection { + /// \brief Opaque implementation-defined state. + /// This field is NULLPTR iff the connection is unintialized/freed. + void* private_data; +@@ -866,7 +877,7 @@ struct ADBC_EXPORT AdbcConnection { + /// Statements are not required to be thread-safe, but they can be + /// used from multiple threads so long as clients take care to + /// serialize accesses to a statement. +-struct ADBC_EXPORT AdbcStatement { ++struct ADBC_EXPORT_STRUCT AdbcStatement { + /// \brief Opaque implementation-defined state. + /// This field is NULLPTR iff the connection is unintialized/freed. + void* private_data; +@@ -933,7 +944,7 @@ struct AdbcPartitions { + /// initialization routines. Drivers should populate this struct, and + /// applications can call ADBC functions through this struct, without + /// worrying about multiple definitions of the same symbol. +-struct ADBC_EXPORT AdbcDriver { ++struct ADBC_EXPORT_STRUCT AdbcDriver { + /// \brief Opaque driver-defined state. + /// This field is NULL if the driver is unintialized/freed (but + /// it need not have a value even if the driver is initialized).