From 1158931d918fbfcd357bd2085e3c38ccf0f17ef2 Mon Sep 17 00:00:00 2001 From: Marcel Pociot Date: Fri, 2 Jun 2023 11:47:11 +0200 Subject: [PATCH 1/4] Add intl/ICU support --- config/lib.json | 13 +++++++++++++ config/source.json | 8 ++++++++ src/SPC/builder/linux/LinuxBuilder.php | 2 +- src/SPC/builder/linux/library/icu.php | 20 ++++++++++++++++++++ src/SPC/builder/macos/MacOSBuilder.php | 2 +- src/SPC/builder/macos/library/icu.php | 20 ++++++++++++++++++++ src/globals/tests/intl.php | 5 +++++ 7 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 src/SPC/builder/linux/library/icu.php create mode 100644 src/SPC/builder/macos/library/icu.php create mode 100644 src/globals/tests/intl.php diff --git a/config/lib.json b/config/lib.json index bfe6ec6c9..16ea45c8f 100644 --- a/config/lib.json +++ b/config/lib.json @@ -460,5 +460,18 @@ "static-libs-unix": [ "libsodium.a" ] + }, + "icu": { + "source": "icu", + "static-libs-unix": [ + "libicudata.a", + "libicui18n.a", + "libicuio.a", + "libicutu.a", + "libicuuc.a" + ], + "headers": [ + + ] } } \ No newline at end of file diff --git a/config/source.json b/config/source.json index d74fd4963..89238e393 100644 --- a/config/source.json +++ b/config/source.json @@ -419,5 +419,13 @@ "type": "file", "path": "LICENSE" } + }, + "icu": { + "type": "url", + "url": "https://github.com/unicode-org/icu/releases/download/release-73-1/icu4c-73_1-src.tgz", + "license": { + "type": "file", + "path": "LICENSE" + } } } \ No newline at end of file diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index b8d8757de..8aee51ce7 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -139,7 +139,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE, bool $with_clean ) ); } - if ($this->getExt('swoole')) { + if ($this->getExt('swoole') || $this->getExt('intl')) { $extra_libs .= ' -lstdc++'; } if ($this->getExt('imagick')) { diff --git a/src/SPC/builder/linux/library/icu.php b/src/SPC/builder/linux/library/icu.php new file mode 100644 index 000000000..4e061dfc7 --- /dev/null +++ b/src/SPC/builder/linux/library/icu.php @@ -0,0 +1,20 @@ +cd($this->source_dir . '/source') + ->exec("{$this->builder->configure_env} ./runConfigureICU Linux --enable-static --disable-shared --prefix={$root}") + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency}") + ->exec('make install'); + } +} diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index cb7f9f562..65b1a7f6b 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -123,7 +123,7 @@ public function getFrameworks(bool $asString = false): array|string */ public function buildPHP(int $build_target = BUILD_TARGET_NONE, bool $bloat = false): void { - $extra_libs = $this->getFrameworks(true) . ' ' . ($this->getExt('swoole') ? '-lc++ ' : ''); + $extra_libs = $this->getFrameworks(true) . ' ' . ($this->getExt('swoole') || $this->getExt('intl') ? '-lc++ ' : ''); if (!$bloat) { $extra_libs .= implode(' ', $this->getAllStaticLibFiles()); } else { diff --git a/src/SPC/builder/macos/library/icu.php b/src/SPC/builder/macos/library/icu.php new file mode 100644 index 000000000..dd7967a17 --- /dev/null +++ b/src/SPC/builder/macos/library/icu.php @@ -0,0 +1,20 @@ +cd($this->source_dir . '/source') + ->exec("{$this->builder->configure_env} ./runConfigureICU MacOSX --enable-static --disable-shared --prefix={$root}") + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency}") + ->exec('make install'); + } +} diff --git a/src/globals/tests/intl.php b/src/globals/tests/intl.php new file mode 100644 index 000000000..32ccd5680 --- /dev/null +++ b/src/globals/tests/intl.php @@ -0,0 +1,5 @@ + Date: Fri, 2 Jun 2023 11:52:27 +0200 Subject: [PATCH 2/4] Remove empty headers array --- config/lib.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/config/lib.json b/config/lib.json index 16ea45c8f..b69d53bd5 100644 --- a/config/lib.json +++ b/config/lib.json @@ -469,9 +469,6 @@ "libicuio.a", "libicutu.a", "libicuuc.a" - ], - "headers": [ - ] } } \ No newline at end of file From 1398086c38c717fc55f96738c733a00eeac86c02 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 2 Jun 2023 20:26:19 +0800 Subject: [PATCH 3/4] add icu configure options for linux --- src/SPC/builder/linux/library/icu.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/linux/library/icu.php b/src/SPC/builder/linux/library/icu.php index 4e061dfc7..c6ef6c375 100644 --- a/src/SPC/builder/linux/library/icu.php +++ b/src/SPC/builder/linux/library/icu.php @@ -11,8 +11,22 @@ class icu extends LinuxLibraryBase protected function build() { $root = BUILD_ROOT_PATH; + $cppflag = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1"'; shell()->cd($this->source_dir . '/source') - ->exec("{$this->builder->configure_env} ./runConfigureICU Linux --enable-static --disable-shared --prefix={$root}") + ->exec( + "{$this->builder->configure_env} {$cppflag} ./runConfigureICU Linux " . + '--enable-static ' . + '--disable-shared ' . + '--with-data-packaging=static ' . + '--enable-release=yes ' . + '--enable-extras=yes ' . + '--enable-icuio=yes ' . + '--enable-dyload=no ' . + '--enable-tools=yes ' . + '--enable-tests=no ' . + '--enable-samples=no ' . + "--prefix={$root}" + ) ->exec('make clean') ->exec("make -j{$this->builder->concurrency}") ->exec('make install'); From 874e104570f966d04401ca62c96b15cd70b3605d Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 2 Jun 2023 20:27:25 +0800 Subject: [PATCH 4/4] sort config and change icu libs order --- config/lib.json | 31 +++++++++++++++---------------- config/source.json | 32 ++++++++++++++++---------------- 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/config/lib.json b/config/lib.json index b69d53bd5..18f712446 100644 --- a/config/lib.json +++ b/config/lib.json @@ -96,6 +96,15 @@ "gmp.h" ] }, + "icu": { + "source": "icu", + "static-libs-unix": [ + "libicui18n.a", + "libicuio.a", + "libicuuc.a", + "libicudata.a" + ] + }, "imagemagick": { "source": "imagemagick", "static-libs-unix": [ @@ -200,6 +209,12 @@ "zlib" ] }, + "libsodium": { + "source": "libsodium", + "static-libs-unix": [ + "libsodium.a" + ] + }, "libssh2": { "source": "libssh2", "static-libs-unix": [ @@ -454,21 +469,5 @@ "zstd.h", "zstd_errors.h" ] - }, - "libsodium": { - "source": "libsodium", - "static-libs-unix": [ - "libsodium.a" - ] - }, - "icu": { - "source": "icu", - "static-libs-unix": [ - "libicudata.a", - "libicui18n.a", - "libicuio.a", - "libicutu.a", - "libicuuc.a" - ] } } \ No newline at end of file diff --git a/config/source.json b/config/source.json index 89238e393..a5ede6209 100644 --- a/config/source.json +++ b/config/source.json @@ -99,6 +99,14 @@ "text": "Since version 6, GMP is distributed under the dual licenses, GNU LGPL v3 and GNU GPL v2. These licenses make the library free to use, share, and improve, and allow you to pass on the result. The GNU licenses give freedoms, but also set firm restrictions on the use with non-free programs." } }, + "icu": { + "type": "url", + "url": "https://github.com/unicode-org/icu/releases/download/release-73-1/icu4c-73_1-src.tgz", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "imagemagick": { "type": "ghtar", "repo": "ImageMagick/ImageMagick", @@ -186,6 +194,14 @@ "path": "COPYING" } }, + "libsodium": { + "type": "url", + "url": "https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "libssh2": { "type": "ghrel", "repo": "libssh2/libssh2", @@ -411,21 +427,5 @@ "type": "file", "path": "LICENSE" } - }, - "libsodium": { - "type": "url", - "url": "https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz", - "license": { - "type": "file", - "path": "LICENSE" - } - }, - "icu": { - "type": "url", - "url": "https://github.com/unicode-org/icu/releases/download/release-73-1/icu4c-73_1-src.tgz", - "license": { - "type": "file", - "path": "LICENSE" - } } } \ No newline at end of file