diff --git a/config/pkg/ext/ext-decimal.yml b/config/pkg/ext/ext-decimal.yml new file mode 100644 index 00000000..da541911 --- /dev/null +++ b/config/pkg/ext/ext-decimal.yml @@ -0,0 +1,16 @@ +ext-decimal: + type: php-extension + artifact: + source: + type: ghtagtar + repo: php-decimal/ext-decimal + match: 'v2\.\d.*' + extract: php-src/ext/decimal + metadata: + license-files: [LICENSE] + license: MIT + depends: + - libmpdec + php-extension: + arg-type@unix: '--enable-decimal --with-libmpdec-path=@build_root_path@' + arg-type@windows: '--with-decimal' diff --git a/config/pkg/lib/libmpdec.yml b/config/pkg/lib/libmpdec.yml new file mode 100644 index 00000000..adb9e531 --- /dev/null +++ b/config/pkg/lib/libmpdec.yml @@ -0,0 +1,15 @@ +libmpdec: + type: library + artifact: + source: + type: url + url: 'https://www.bytereef.org/software/mpdecimal/releases/mpdecimal-4.0.1.tar.gz' + metadata: + license-files: [COPYRIGHT.txt] + license: BSD-2-Clause + headers: + - mpdecimal.h + static-libs@unix: + - libmpdec.a + static-libs@windows: + - libmpdec_a.lib diff --git a/src/Package/Extension/decimal.php b/src/Package/Extension/decimal.php new file mode 100644 index 00000000..147f7388 --- /dev/null +++ b/src/Package/Extension/decimal.php @@ -0,0 +1,29 @@ +getSourceDir() . '/php_decimal.c', + 'zend_module_entry decimal_module_entry', + 'zend_module_entry php_decimal_module_entry' + ); + } +} diff --git a/src/Package/Library/libmpdec.php b/src/Package/Library/libmpdec.php new file mode 100644 index 00000000..05b2df04 --- /dev/null +++ b/src/Package/Library/libmpdec.php @@ -0,0 +1,46 @@ +configure('--disable-cxx --disable-shared --enable-static') + ->make(); + } + + #[BuildFor('Windows')] + public function buildWin(LibraryPackage $lib): void + { + $makefileDir = $lib->getSourceDir() . DIRECTORY_SEPARATOR . 'libmpdec'; + + cmd()->cd($makefileDir) + ->exec('copy /y Makefile.vc Makefile') + ->exec('nmake /nologo clean') + ->exec('nmake /nologo MACHINE=x64'); + + // Copy static lib (rename from versioned name to libmpdec_a.lib) + $libs = glob($makefileDir . DIRECTORY_SEPARATOR . 'libmpdec-*.lib'); + foreach ($libs as $libFile) { + if (!str_contains($libFile, '.dll.')) { + FileSystem::copy($libFile, $lib->getLibDir() . DIRECTORY_SEPARATOR . 'libmpdec_a.lib'); + break; + } + } + + FileSystem::copy($makefileDir . DIRECTORY_SEPARATOR . 'mpdecimal.h', $lib->getIncludeDir() . DIRECTORY_SEPARATOR . 'mpdecimal.h'); + } +} diff --git a/src/globals/ext-tests/decimal.php b/src/globals/ext-tests/decimal.php new file mode 100644 index 00000000..54f660fb --- /dev/null +++ b/src/globals/ext-tests/decimal.php @@ -0,0 +1,10 @@ +