Skip to content

Commit

Permalink
Add libtiff support (#361)
Browse files Browse the repository at this point in the history
* add libtiff support

* fix command option not working on *nix

* fix test with libs ext test
  • Loading branch information
crazywhalecc committed Mar 1, 2024
1 parent b46655e commit 9664709
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 11 deletions.
9 changes: 8 additions & 1 deletion config/lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@
"libpng",
"libjpeg",
"libwebp",
"freetype"
"freetype",
"libtiff"
],
"lib-suggests": [
"zstd",
Expand Down Expand Up @@ -330,6 +331,12 @@
"zlib"
]
},
"libtiff": {
"source": "libtiff",
"static-libs-unix": [
"libtiff.a"
]
},
"libuv": {
"source": "libuv",
"static-libs-unix": [
Expand Down
9 changes: 9 additions & 0 deletions config/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,15 @@
"path": "COPYING"
}
},
"libtiff": {
"type": "filelist",
"url": "https://download.osgeo.org/libtiff/",
"regex": "/href=\"(?<file>tiff-(?<version>[^\"]+)\\.tar\\.xz)\"/",
"license": {
"type": "file",
"path": "LICENSE.md"
}
},
"libuv": {
"type": "ghtar",
"repo": "libuv/libuv",
Expand Down
12 changes: 12 additions & 0 deletions src/SPC/builder/linux/library/libtiff.php
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 libtiff extends LinuxLibraryBase
{
use \SPC\builder\unix\library\libtiff;

public const NAME = 'libtiff';
}
12 changes: 12 additions & 0 deletions src/SPC/builder/macos/library/libtiff.php
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 libtiff extends MacOSLibraryBase
{
use \SPC\builder\unix\library\libtiff;

public const NAME = 'libtiff';
}
30 changes: 30 additions & 0 deletions src/SPC/builder/unix/library/libtiff.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace SPC\builder\unix\library;

use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;

trait libtiff
{
/**
* @throws FileSystemException
* @throws RuntimeException
*/
protected function build(): void
{
shell()->cd($this->source_dir)
->exec(
'./configure ' .
'--enable-static --disable-shared ' .
'--disable-cxx ' .
'--prefix='
)
->exec('make clean')
->exec("make -j{$this->builder->concurrency}")
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
$this->patchPkgconfPrefix(['libtiff-4.pc']);
}
}
6 changes: 1 addition & 5 deletions src/SPC/command/BuildCliCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,8 @@ public function configure(): void
$this->addOption('with-suggested-exts', 'E', null, 'Build with suggested extensions for selected exts');
$this->addOption('with-added-patch', 'P', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Inject patch script outside');
$this->addOption('without-micro-ext-test', null, null, 'Disable phpmicro with extension test code');

$this->addOption('with-upx-pack', null, null, 'Compress / pack binary using UPX tool (linux/windows only)');

if (PHP_OS_FAMILY === 'Windows') {
$this->addOption('with-micro-logo', null, InputOption::VALUE_REQUIRED, 'Use custom .ico for micro.sfx');
}
$this->addOption('with-micro-logo', null, InputOption::VALUE_REQUIRED, 'Use custom .ico for micro.sfx (windows only)');
}

public function handle(): int
Expand Down
11 changes: 6 additions & 5 deletions src/globals/test-extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@

// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
$extensions = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'pgsql,pdo_pgsql',
'Linux', 'Darwin' => 'imagick,zstd,bz2,zip,xml,dom',
'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi',
};

// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).
$with_libs = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => '',
'Linux', 'Darwin' => 'xz',
'Windows' => '',
};

// Please change your test base combination. We recommend testing with `common`.
// You can use `common`, `bulk`, `minimal` or `none`.
// note: combination is only available for *nix platform. Windows must use `none` combination
$base_combination = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'common',
'Linux', 'Darwin' => 'minimal',
'Windows' => 'none',
};

Expand Down Expand Up @@ -62,14 +62,15 @@ function _getCombination(string $type = 'common'): string

if (PHP_OS_FAMILY === 'Windows') {
$final_extensions_cmd = '"' . $final_extensions . '"';
$final_libs = $final_libs === '' ? '' : ('"' . $final_libs . '"');
} else {
$final_extensions_cmd = $final_extensions;
}

echo match ($argv[1]) {
'extensions' => $final_extensions,
'libs' => $final_libs,
'libs_cmd' => ($final_libs === '' ? '' : (' --with-libs="' . $final_libs . '"')),
'cmd' => $final_extensions_cmd . ($final_libs === '' ? '' : (' --with-libs="' . $final_libs . '"')),
'libs_cmd' => ($final_libs === '' ? '' : (' --with-libs=' . $final_libs)),
'cmd' => $final_extensions_cmd . ($final_libs === '' ? '' : (' --with-libs=' . $final_libs)),
default => '',
};

0 comments on commit 9664709

Please sign in to comment.