-
-
Notifications
You must be signed in to change notification settings - Fork 382
feat: add gmagick extension and GraphicsMagick library support #1090
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ed659cc
feat: add gmagick extension and GraphicsMagick library support
superdav42 b92699c
fix: patch out OpenMP check in gmagick for static builds
superdav42 cd9f898
test: add gmagick extension sanity test
superdav42 e837397
refactor: use ac_cv_func var instead of patching config.m4 for OMP
superdav42 0b63d99
Update config/source.json
henderkes a628054
Add libxml2 dep for graphicsmagick, add tests and patches
crazywhalecc f7b69d9
zts
crazywhalecc d023c25
fix: patch config.m4 directly to remove OMP check for static builds
superdav42 6fef646
Merge branch 'main' into feat/gmagick-extension
superdav42 d26a081
fix: exclude HEIF/JXL from GraphicsMagick static build
superdav42 2006d70
fix: patch PHP 8.4.x opcache reset races (php/php-src#21778)
superdav42 e42b29f
build: pin OpenSSL to 3.5.0 for PHP 8.4 compatibility
superdav42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace SPC\builder\extension; | ||
|
|
||
| use SPC\builder\Extension; | ||
| use SPC\store\FileSystem; | ||
| use SPC\util\CustomExt; | ||
|
|
||
| #[CustomExt('gmagick')] | ||
| class gmagick extends Extension | ||
| { | ||
| public function patchBeforeBuildconf(): bool | ||
| { | ||
| // PHP 8.5 removed zend_exception_get_default(), use zend_ce_exception instead | ||
| FileSystem::replaceFileStr($this->source_dir . '/gmagick.c', 'zend_exception_get_default()', 'zend_ce_exception'); | ||
|
|
||
| // Remove the entire OpenMP check block from config.m4 to avoid linking | ||
| // against libgomp in static builds. gmagick's config.m4 uses PHP_CHECK_FUNC | ||
| // which does not honour ac_cv cache variables, so we must patch the source. | ||
| FileSystem::replaceFileRegex( | ||
| SOURCE_PATH . '/php-src/ext/gmagick/config.m4', | ||
| '/AC_MSG_CHECKING\(omp_pause_resource_all usability\).*?AC_MSG_RESULT\(no\)\n\t\t\]\)/s', | ||
| 'dnl OMP check removed for static build' | ||
| ); | ||
| return true; | ||
| } | ||
|
|
||
| public function getUnixConfigureArg(bool $shared = false): string | ||
| { | ||
| return '--with-gmagick=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace SPC\builder\linux\library; | ||
|
|
||
| class graphicsmagick extends LinuxLibraryBase | ||
| { | ||
| use \SPC\builder\unix\library\graphicsmagick; | ||
|
|
||
| public const NAME = 'graphicsmagick'; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace SPC\builder\macos\library; | ||
|
|
||
| class graphicsmagick extends MacOSLibraryBase | ||
| { | ||
| use \SPC\builder\unix\library\graphicsmagick; | ||
|
|
||
| public const NAME = 'graphicsmagick'; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace SPC\builder\unix\library; | ||
|
|
||
| use SPC\util\executor\UnixAutoconfExecutor; | ||
| use SPC\util\SPCTarget; | ||
|
|
||
| trait graphicsmagick | ||
| { | ||
| protected function build(): void | ||
| { | ||
| $ac = UnixAutoconfExecutor::create($this) | ||
| ->optionalLib('zlib', ...ac_with_args('zlib')) | ||
| ->optionalLib('libpng', ...ac_with_args('png')) | ||
| ->optionalLib('libjpeg', ...ac_with_args('jpeg')) | ||
| ->optionalLib('libwebp', ...ac_with_args('webp')) | ||
| ->optionalLib('libtiff', ...ac_with_args('tiff')) | ||
| ->optionalLib('freetype', ...ac_with_args('ttf')) | ||
| ->optionalLib('bzip2', ...ac_with_args('bzlib')) | ||
| ->addConfigureArgs( | ||
| '--disable-openmp', | ||
| '--without-x', | ||
| '--without-perl', | ||
| '--enable-shared=no', | ||
| '--enable-static=yes', | ||
| ); | ||
|
|
||
| // special: linux-static target needs `-static` | ||
| $ldflags = SPCTarget::isStatic() ? '-static -ldl' : '-ldl'; | ||
|
|
||
| // special: macOS needs -liconv | ||
| $libs = SPCTarget::getTargetOS() === 'Darwin' ? '-liconv' : ''; | ||
|
|
||
| $ac->appendEnv([ | ||
| 'LDFLAGS' => $ldflags, | ||
| 'LIBS' => $libs, | ||
| 'PKG_CONFIG' => '$PKG_CONFIG --static', | ||
| ]); | ||
|
|
||
| $ac->configure()->make(); | ||
|
|
||
| $this->patchPkgconfPrefix(['GraphicsMagick.pc', 'GraphicsMagick++.pc', 'GraphicsMagickWand.pc']); | ||
| $this->patchLaDependencyPrefix(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| assert(class_exists('Gmagick')); | ||
| assert(in_array('JPEG', (new Gmagick())->queryformats())); | ||
| assert(in_array('PNG', (new Gmagick())->queryformats())); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.