From 1e0265e67391d2fe6975f237d53fb36d0a999cf3 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 21 Dec 2023 14:02:32 +0800 Subject: [PATCH] add sqlsrv support --- config/ext.json | 11 +++++++ config/lib.json | 11 +++++++ config/source.json | 18 ++++++++++++ src/SPC/builder/linux/LinuxBuilder.php | 1 + src/SPC/builder/linux/library/unixodbc.php | 12 ++++++++ src/SPC/builder/macos/MacOSBuilder.php | 1 + src/SPC/builder/macos/library/unixodbc.php | 12 ++++++++ src/SPC/builder/unix/library/unixodbc.php | 34 ++++++++++++++++++++++ 8 files changed, 100 insertions(+) create mode 100644 src/SPC/builder/linux/library/unixodbc.php create mode 100644 src/SPC/builder/macos/library/unixodbc.php create mode 100644 src/SPC/builder/unix/library/unixodbc.php diff --git a/config/ext.json b/config/ext.json index 8a75b502..26bb9e94 100644 --- a/config/ext.json +++ b/config/ext.json @@ -391,6 +391,17 @@ "sqlite" ] }, + "sqlsrv": { + "type": "external", + "source": "sqlsrv", + "lib-depends": [ + "unixodbc" + ], + "cpp-extension": true, + "ext-depends-linux": [ + "pcntl" + ] + }, "ssh2": { "type": "external", "source": "ext-ssh2", diff --git a/config/lib.json b/config/lib.json index 14d66130..73c5aee2 100644 --- a/config/lib.json +++ b/config/lib.json @@ -496,6 +496,17 @@ "libtidy.a" ] }, + "unixodbc": { + "source": "unixodbc", + "static-libs-unix": [ + "libodbc.a", + "libodbccr.a", + "libodbcinst.a" + ], + "lib-depends": [ + "libiconv" + ] + }, "xz": { "source": "xz", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index 09cd2064..d9cd69dd 100644 --- a/config/source.json +++ b/config/source.json @@ -457,6 +457,16 @@ "text": "The author disclaims copyright to this source code. In place of\na legal notice, here is a blessing:\n\n * May you do good and not evil.\n * May you find forgiveness for yourself and forgive others.\n * May you share freely, never taking more than you give." } }, + "sqlsrv": { + "type": "url", + "url": "https://pecl.php.net/get/sqlsrv", + "path": "php-src/ext/sqlsrv", + "filename": "sqlsrv.tgz", + "license": { + "type": "text", + "text": "TODO" + } + }, "swoole": { "type": "ghtar", "path": "php-src/ext/swoole", @@ -486,6 +496,14 @@ "path": "README/LICENSE.md" } }, + "unixodbc": { + "type": "url", + "url": "https://www.unixodbc.org/unixODBC-2.3.12.tar.gz", + "license": { + "type": "text", + "text": "TODO" + } + }, "xlswriter": { "type": "url", "url": "https://pecl.php.net/get/xlswriter", diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index da7f793d..a757c661 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -144,6 +144,7 @@ class LinuxBuilder extends BuilderBase // prepare build php envs $envs_build_php = SystemUtil::makeEnvVarString([ 'CFLAGS' => $cflags, + 'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, 'LIBS' => '-ldl -lpthread', ]); diff --git a/src/SPC/builder/linux/library/unixodbc.php b/src/SPC/builder/linux/library/unixodbc.php new file mode 100644 index 00000000..0741d264 --- /dev/null +++ b/src/SPC/builder/linux/library/unixodbc.php @@ -0,0 +1,12 @@ +arch_c_flags} -Werror=unknown-warning-option' " . + "CPPFLAGS='-I" . BUILD_INCLUDE_PATH . "' " . '--disable-all ' . '--disable-cgi ' . '--disable-phpdbg ' . diff --git a/src/SPC/builder/macos/library/unixodbc.php b/src/SPC/builder/macos/library/unixodbc.php new file mode 100644 index 00000000..35ac965e --- /dev/null +++ b/src/SPC/builder/macos/library/unixodbc.php @@ -0,0 +1,12 @@ +cd($this->source_dir) + ->exec( + './configure ' . + '--enable-static --disable-shared ' . + '--disable-debug ' . + '--disable-dependency-tracking ' . + '--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' . + '--enable-gui=no ' . + '--prefix=' + ) + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency}") + ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + $this->patchPkgconfPrefix(['odbc.pc', 'odbccr.pc', 'odbcinst.pc']); + $this->cleanLaFiles(); + } +}