mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 12:54:52 +08:00
Merge pull request #622 from DubbleClick/libacl
bring back pr for libacl
This commit is contained in:
commit
58eafe5100
2
.github/workflows/build-unix.yml
vendored
2
.github/workflows/build-unix.yml
vendored
@ -15,7 +15,7 @@ on:
|
|||||||
php-version:
|
php-version:
|
||||||
required: true
|
required: true
|
||||||
description: PHP version to compile
|
description: PHP version to compile
|
||||||
default: '8.3'
|
default: '8.4'
|
||||||
type: choice
|
type: choice
|
||||||
options:
|
options:
|
||||||
- '8.4'
|
- '8.4'
|
||||||
|
|||||||
@ -137,4 +137,4 @@ echo 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm -lresolv -lutil -lrt"'
|
|||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
# shellcheck disable=SC2090
|
# shellcheck disable=SC2090
|
||||||
|
|
||||||
$DOCKER_EXECUTABLE run --rm $INTERACT -e SPC_FIX_DEPLOY_ROOT="$(pwd)" --env-file /tmp/spc-gnu-docker.env $MOUNT_LIST cwcc-spc-gnu-$SPC_USE_ARCH # bin/spc $@
|
$DOCKER_EXECUTABLE run --rm $INTERACT -e SPC_FIX_DEPLOY_ROOT="$(pwd)" --env-file /tmp/spc-gnu-docker.env $MOUNT_LIST cwcc-spc-gnu-$SPC_USE_ARCH bin/spc $@
|
||||||
|
|||||||
@ -35,7 +35,6 @@
|
|||||||
; SPC_LINUX_DEFAULT_CC: the default compiler for linux. (For alpine linux: `gcc`, default: `$GNU_ARCH-linux-musl-gcc`)
|
; SPC_LINUX_DEFAULT_CC: the default compiler for linux. (For alpine linux: `gcc`, default: `$GNU_ARCH-linux-musl-gcc`)
|
||||||
; SPC_LINUX_DEFAULT_CXX: the default c++ compiler for linux. (For alpine linux: `g++`, default: `$GNU_ARCH-linux-musl-g++`)
|
; SPC_LINUX_DEFAULT_CXX: the default c++ compiler for linux. (For alpine linux: `g++`, default: `$GNU_ARCH-linux-musl-g++`)
|
||||||
; SPC_LINUX_DEFAULT_AR: the default archiver for linux. (For alpine linux: `ar`, default: `$GNU_ARCH-linux-musl-ar`)
|
; SPC_LINUX_DEFAULT_AR: the default archiver for linux. (For alpine linux: `ar`, default: `$GNU_ARCH-linux-musl-ar`)
|
||||||
; SPC_PHP_DEFAULT_LD_LIBRARY_PATH_CMD: the default LD_LIBRARY_PATH for php. (linux: `LD_LIBRARY_PATH=/usr/local/musl/$GNU_ARCH-linux-musl/lib`, default: empty)
|
|
||||||
|
|
||||||
|
|
||||||
[global]
|
[global]
|
||||||
@ -45,6 +44,14 @@ SPC_CONCURRENCY=${CPU_COUNT}
|
|||||||
SPC_SKIP_PHP_VERSION_CHECK="no"
|
SPC_SKIP_PHP_VERSION_CHECK="no"
|
||||||
; Ignore some check item for bin/spc doctor command, comma separated (e.g. SPC_SKIP_DOCTOR_CHECK_ITEMS="if homebrew has installed")
|
; Ignore some check item for bin/spc doctor command, comma separated (e.g. SPC_SKIP_DOCTOR_CHECK_ITEMS="if homebrew has installed")
|
||||||
SPC_SKIP_DOCTOR_CHECK_ITEMS=""
|
SPC_SKIP_DOCTOR_CHECK_ITEMS=""
|
||||||
|
; EXTENSION_DIR where the built php will look for extension when a .ini instructs to load them
|
||||||
|
; only useful for builds targeting glibc --libc=glibc
|
||||||
|
; default paths
|
||||||
|
; Ubuntu/Debian: /usr/lib/php/{PHP_VERSION}/
|
||||||
|
; RHEL: /usr/lib64/php/modules
|
||||||
|
; Alpine: /usr/lib/php{PHP_VERSION}/modules
|
||||||
|
; where {PHP_VERSION} is 84 for php 8.4
|
||||||
|
EXTENSION_DIR=
|
||||||
|
|
||||||
[windows]
|
[windows]
|
||||||
; php-sdk-binary-tools path
|
; php-sdk-binary-tools path
|
||||||
@ -63,7 +70,7 @@ CXX=${SPC_LINUX_DEFAULT_CXX}
|
|||||||
AR=${SPC_LINUX_DEFAULT_AR}
|
AR=${SPC_LINUX_DEFAULT_AR}
|
||||||
LD=ld.gold
|
LD=ld.gold
|
||||||
; default compiler flags, used in CMake toolchain file, openssl and pkg-config build
|
; default compiler flags, used in CMake toolchain file, openssl and pkg-config build
|
||||||
SPC_DEFAULT_C_FLAGS=
|
SPC_DEFAULT_C_FLAGS="-fPIC"
|
||||||
SPC_DEFAULT_CXX_FLAGS=
|
SPC_DEFAULT_CXX_FLAGS=
|
||||||
; extra libs for building php executable, used in `make` command for building php (this value may changed by extension build process, space separated)
|
; extra libs for building php executable, used in `make` command for building php (this value may changed by extension build process, space separated)
|
||||||
SPC_EXTRA_LIBS=
|
SPC_EXTRA_LIBS=
|
||||||
@ -76,7 +83,7 @@ SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime
|
|||||||
; buildconf command
|
; buildconf command
|
||||||
SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force"
|
SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force"
|
||||||
; configure command
|
; configure command
|
||||||
SPC_CMD_PREFIX_PHP_CONFIGURE="${SPC_PHP_DEFAULT_LD_LIBRARY_PATH_CMD} ./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg --with-pic"
|
SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg --with-pic"
|
||||||
; make command
|
; make command
|
||||||
SPC_CMD_PREFIX_PHP_MAKE="make -j${CPU_COUNT}"
|
SPC_CMD_PREFIX_PHP_MAKE="make -j${CPU_COUNT}"
|
||||||
; embed type for php, static (libphp.a) or shared (libphp.so)
|
; embed type for php, static (libphp.a) or shared (libphp.so)
|
||||||
@ -117,8 +124,6 @@ SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force"
|
|||||||
SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg"
|
SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg"
|
||||||
; make command
|
; make command
|
||||||
SPC_CMD_PREFIX_PHP_MAKE="make -j${CPU_COUNT}"
|
SPC_CMD_PREFIX_PHP_MAKE="make -j${CPU_COUNT}"
|
||||||
; embed type for php, static or shared
|
|
||||||
SPC_CMD_VAR_PHP_EMBED_TYPE="static"
|
|
||||||
|
|
||||||
; *** default build vars for building php ***
|
; *** default build vars for building php ***
|
||||||
; CFLAGS for configuring php
|
; CFLAGS for configuring php
|
||||||
@ -131,6 +136,8 @@ SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH}"
|
|||||||
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="${SPC_PHP_DEFAULT_OPTIMIZE_CFLAGS}"
|
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="${SPC_PHP_DEFAULT_OPTIMIZE_CFLAGS}"
|
||||||
; EXTRA_LIBS for `make` php
|
; EXTRA_LIBS for `make` php
|
||||||
SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-lresolv"
|
SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-lresolv"
|
||||||
|
; embed type for php, static (libphp.a) or shared (libphp.dylib)
|
||||||
|
SPC_CMD_VAR_PHP_EMBED_TYPE="static"
|
||||||
|
|
||||||
[freebsd]
|
[freebsd]
|
||||||
; compiler environments
|
; compiler environments
|
||||||
|
|||||||
@ -9,8 +9,13 @@
|
|||||||
"type": "root",
|
"type": "root",
|
||||||
"source": "php-src",
|
"source": "php-src",
|
||||||
"lib-depends": [
|
"lib-depends": [
|
||||||
"micro",
|
"lib-base",
|
||||||
"lib-base"
|
"micro"
|
||||||
|
],
|
||||||
|
"lib-depends-linux": [
|
||||||
|
"lib-base",
|
||||||
|
"libacl",
|
||||||
|
"micro"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"micro": {
|
"micro": {
|
||||||
@ -24,6 +29,12 @@
|
|||||||
"pkg-config"
|
"pkg-config"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"attr": {
|
||||||
|
"source": "attr",
|
||||||
|
"static-libs-unix": [
|
||||||
|
"libattr.a"
|
||||||
|
]
|
||||||
|
},
|
||||||
"brotli": {
|
"brotli": {
|
||||||
"source": "brotli",
|
"source": "brotli",
|
||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
@ -234,6 +245,15 @@
|
|||||||
"libsodium"
|
"libsodium"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"libacl": {
|
||||||
|
"source": "libacl",
|
||||||
|
"static-libs-unix": [
|
||||||
|
"libacl.a"
|
||||||
|
],
|
||||||
|
"lib-depends": [
|
||||||
|
"attr"
|
||||||
|
]
|
||||||
|
},
|
||||||
"libaom": {
|
"libaom": {
|
||||||
"source": "libaom",
|
"source": "libaom",
|
||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
|
|||||||
@ -36,6 +36,16 @@
|
|||||||
"path": "LICENSE"
|
"path": "LICENSE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"attr": {
|
||||||
|
"type": "git",
|
||||||
|
"rev": "v2.5.2",
|
||||||
|
"url": "https://git.savannah.nongnu.org/git/attr.git",
|
||||||
|
"provide-pre-built": true,
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "doc/COPYING"
|
||||||
|
}
|
||||||
|
},
|
||||||
"brotli": {
|
"brotli": {
|
||||||
"type": "ghtar",
|
"type": "ghtar",
|
||||||
"repo": "google/brotli",
|
"repo": "google/brotli",
|
||||||
@ -323,6 +333,16 @@
|
|||||||
"path": "LICENSE"
|
"path": "LICENSE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"libacl": {
|
||||||
|
"type": "git",
|
||||||
|
"rev": "v2.3.2",
|
||||||
|
"url": "https://git.savannah.nongnu.org/git/acl.git",
|
||||||
|
"provide-pre-built": true,
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "doc/COPYING"
|
||||||
|
}
|
||||||
|
},
|
||||||
"libaom": {
|
"libaom": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"rev": "main",
|
"rev": "main",
|
||||||
|
|||||||
@ -139,7 +139,8 @@ class Extension
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Patch code before ./buildconf
|
* Patch code before ./buildconf
|
||||||
* If you need to patch some code, overwrite this and return true
|
* If you need to patch some code, overwrite this
|
||||||
|
* return true if you patched something, false if not
|
||||||
*/
|
*/
|
||||||
public function patchBeforeBuildconf(): bool
|
public function patchBeforeBuildconf(): bool
|
||||||
{
|
{
|
||||||
@ -148,7 +149,8 @@ class Extension
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Patch code before ./configure
|
* Patch code before ./configure
|
||||||
* If you need to patch some code, overwrite this and return true
|
* If you need to patch some code, overwrite this
|
||||||
|
* return true if you patched something, false if not
|
||||||
*/
|
*/
|
||||||
public function patchBeforeConfigure(): bool
|
public function patchBeforeConfigure(): bool
|
||||||
{
|
{
|
||||||
@ -157,7 +159,8 @@ class Extension
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Patch code before make
|
* Patch code before make
|
||||||
* If you need to patch some code, overwrite this and return true
|
* If you need to patch some code, overwrite this
|
||||||
|
* return true if you patched something, false if not
|
||||||
*/
|
*/
|
||||||
public function patchBeforeMake(): bool
|
public function patchBeforeMake(): bool
|
||||||
{
|
{
|
||||||
|
|||||||
@ -113,7 +113,7 @@ abstract class LibraryBase
|
|||||||
/*
|
/*
|
||||||
Rules:
|
Rules:
|
||||||
If it is a Windows system, try the following dependencies in order: lib-depends-windows, lib-depends-win, lib-depends.
|
If it is a Windows system, try the following dependencies in order: lib-depends-windows, lib-depends-win, lib-depends.
|
||||||
If it is a macOS system, try the following dependencies in order: lib-depends-darwin, lib-depends-unix, lib-depends.
|
If it is a macOS system, try the following dependencies in order: lib-depends-macos, lib-depends-unix, lib-depends.
|
||||||
If it is a Linux system, try the following dependencies in order: lib-depends-linux, lib-depends-unix, lib-depends.
|
If it is a Linux system, try the following dependencies in order: lib-depends-linux, lib-depends-unix, lib-depends.
|
||||||
*/
|
*/
|
||||||
foreach (Config::getLib(static::NAME, 'lib-depends', []) as $dep_name) {
|
foreach (Config::getLib(static::NAME, 'lib-depends', []) as $dep_name) {
|
||||||
@ -261,14 +261,6 @@ abstract class LibraryBase
|
|||||||
return LIB_STATUS_ALREADY;
|
return LIB_STATUS_ALREADY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Patch before build, overwrite this and return true to patch libs.
|
|
||||||
*/
|
|
||||||
public function patchBeforeBuild(): bool
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function validate(): void
|
public function validate(): void
|
||||||
{
|
{
|
||||||
// do nothing, just throw wrong usage exception if not valid
|
// do nothing, just throw wrong usage exception if not valid
|
||||||
@ -294,6 +286,46 @@ abstract class LibraryBase
|
|||||||
// do something before pack, default do nothing. overwrite this method to do something (e.g. modify pkg-config file)
|
// do something before pack, default do nothing. overwrite this method to do something (e.g. modify pkg-config file)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Patch code before build
|
||||||
|
* If you need to patch some code, overwrite this
|
||||||
|
* return true if you patched something, false if not
|
||||||
|
*/
|
||||||
|
public function patchBeforeBuild(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Patch code before ./buildconf
|
||||||
|
* If you need to patch some code, overwrite this
|
||||||
|
* return true if you patched something, false if not
|
||||||
|
*/
|
||||||
|
public function patchBeforeBuildconf(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Patch code before ./configure
|
||||||
|
* If you need to patch some code, overwrite this
|
||||||
|
* return true if you patched something, false if not
|
||||||
|
*/
|
||||||
|
public function patchBeforeConfigure(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Patch code before make
|
||||||
|
* If you need to patch some code, overwrite this
|
||||||
|
* return true if you patched something, false if not
|
||||||
|
*/
|
||||||
|
public function patchBeforeMake(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build this library.
|
* Build this library.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -37,9 +37,13 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
GlobalEnvManager::init($this);
|
GlobalEnvManager::init($this);
|
||||||
|
|
||||||
// set library path, some libraries need it. (We cannot use `putenv` here, because cmake will be confused)
|
// set library path, some libraries need it. (We cannot use `putenv` here, because cmake will be confused)
|
||||||
if (!filter_var(getenv('SPC_NO_MUSL_PATH'), FILTER_VALIDATE_BOOLEAN)) {
|
if (!filter_var(getenv('SPC_NO_MUSL_PATH'), FILTER_VALIDATE_BOOLEAN) && $this->libc !== LIBC_GLIBC) {
|
||||||
$this->setOptionIfNotExist('library_path', "LIBRARY_PATH=\"/usr/local/musl/{$arch}-linux-musl/lib\"");
|
$this->setOptionIfNotExist('library_path', "LIBRARY_PATH=\"/usr/local/musl/{$arch}-linux-musl/lib\"");
|
||||||
$this->setOptionIfNotExist('ld_library_path', "LD_LIBRARY_PATH=\"/usr/local/musl/{$arch}-linux-musl/lib\"");
|
$this->setOptionIfNotExist('ld_library_path', "LD_LIBRARY_PATH=\"/usr/local/musl/{$arch}-linux-musl/lib\"");
|
||||||
|
GlobalEnvManager::putenv("PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . getenv('PATH'));
|
||||||
|
$configure = getenv('SPC_CMD_PREFIX_PHP_CONFIGURE');
|
||||||
|
$configure = "LD_LIBRARY_PATH=\"/usr/local/musl/{$arch}-linux-musl/lib\" " . $configure;
|
||||||
|
GlobalEnvManager::putenv("SPC_CMD_PREFIX_PHP_CONFIGURE={$configure}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str_ends_with(getenv('CC'), 'linux-musl-gcc') && !file_exists("/usr/local/musl/bin/{$arch}-linux-musl-gcc") && (getenv('SPC_NO_MUSL_PATH') !== 'yes')) {
|
if (str_ends_with(getenv('CC'), 'linux-musl-gcc') && !file_exists("/usr/local/musl/bin/{$arch}-linux-musl-gcc") && (getenv('SPC_NO_MUSL_PATH') !== 'yes')) {
|
||||||
@ -174,7 +178,7 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
->exec(
|
->exec(
|
||||||
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
|
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
|
||||||
($enable_cli ? '--enable-cli ' : '--disable-cli ') .
|
($enable_cli ? '--enable-cli ' : '--disable-cli ') .
|
||||||
($enable_fpm ? '--enable-fpm ' : '--disable-fpm ') .
|
($enable_fpm ? '--enable-fpm ' . ($this->getLib('libacl') !== null ? '--with-fpm-acl ' : '') : '--disable-fpm ') .
|
||||||
($enable_embed ? "--enable-embed={$embed_type} " : '--disable-embed ') .
|
($enable_embed ? "--enable-embed={$embed_type} " : '--disable-embed ') .
|
||||||
($enable_micro ? '--enable-micro=all-static ' : '--disable-micro ') .
|
($enable_micro ? '--enable-micro=all-static ' : '--disable-micro ') .
|
||||||
$config_file_path .
|
$config_file_path .
|
||||||
|
|||||||
12
src/SPC/builder/linux/library/attr.php
Normal file
12
src/SPC/builder/linux/library/attr.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\linux\library;
|
||||||
|
|
||||||
|
class attr extends LinuxLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\attr;
|
||||||
|
|
||||||
|
public const NAME = 'attr';
|
||||||
|
}
|
||||||
12
src/SPC/builder/linux/library/libacl.php
Normal file
12
src/SPC/builder/linux/library/libacl.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\linux\library;
|
||||||
|
|
||||||
|
class libacl extends LinuxLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\libacl;
|
||||||
|
|
||||||
|
public const NAME = 'libacl';
|
||||||
|
}
|
||||||
@ -44,7 +44,11 @@ class libpng extends LinuxLibraryBase
|
|||||||
shell()->cd($this->source_dir)
|
shell()->cd($this->source_dir)
|
||||||
->exec('chmod +x ./configure')
|
->exec('chmod +x ./configure')
|
||||||
->exec('chmod +x ./install-sh')
|
->exec('chmod +x ./install-sh')
|
||||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
->setEnv([
|
||||||
|
'CFLAGS' => trim($this->getLibExtraCFlags() . ' ' . $this->builder->arch_c_flags),
|
||||||
|
'LDFLAGS' => $this->getLibExtraLdFlags(),
|
||||||
|
'LIBS' => $this->getLibExtraLibs(),
|
||||||
|
])
|
||||||
->execWithEnv(
|
->execWithEnv(
|
||||||
'LDFLAGS="-L' . BUILD_LIB_PATH . '" ' .
|
'LDFLAGS="-L' . BUILD_LIB_PATH . '" ' .
|
||||||
'./configure ' .
|
'./configure ' .
|
||||||
|
|||||||
28
src/SPC/builder/unix/library/attr.php
Normal file
28
src/SPC/builder/unix/library/attr.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\unix\library;
|
||||||
|
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
|
|
||||||
|
trait attr
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
protected function build(): void
|
||||||
|
{
|
||||||
|
shell()->cd($this->source_dir)
|
||||||
|
->setEnv([
|
||||||
|
'CFLAGS' => trim('-I' . BUILD_INCLUDE_PATH . ' ' . $this->getLibExtraCFlags()),
|
||||||
|
'LDFLAGS' => trim('-L' . BUILD_LIB_PATH . ' ' . $this->getLibExtraLdFlags()),
|
||||||
|
'LIBS' => $this->getLibExtraLibs(),
|
||||||
|
])->execWithEnv('./autogen.sh')
|
||||||
|
->execWithEnv('./configure --prefix= --enable-static --disable-shared')
|
||||||
|
->execWithEnv("make -j {$this->builder->concurrency}")
|
||||||
|
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||||
|
|
||||||
|
$this->patchPkgconfPrefix(['libattr.pc'], PKGCONF_PATCH_PREFIX);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace SPC\builder\unix\library;
|
namespace SPC\builder\unix\library;
|
||||||
|
|
||||||
|
use SPC\builder\linux\library\LinuxLibraryBase;
|
||||||
use SPC\exception\FileSystemException;
|
use SPC\exception\FileSystemException;
|
||||||
use SPC\exception\RuntimeException;
|
use SPC\exception\RuntimeException;
|
||||||
use SPC\store\FileSystem;
|
use SPC\store\FileSystem;
|
||||||
@ -52,9 +53,14 @@ trait curl
|
|||||||
|
|
||||||
FileSystem::resetDir($this->source_dir . '/build');
|
FileSystem::resetDir($this->source_dir . '/build');
|
||||||
|
|
||||||
|
$cflags = $this instanceof LinuxLibraryBase && $this->builder->libc === 'glibc' ? '-fPIC' : '';
|
||||||
// compile!
|
// compile!
|
||||||
shell()->cd($this->source_dir . '/build')
|
shell()->cd($this->source_dir . '/build')
|
||||||
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
|
->setEnv([
|
||||||
|
'CFLAGS' => trim($this->getLibExtraCFlags() . ' ' . $cflags),
|
||||||
|
'LDFLAGS' => $this->getLibExtraLdFlags(),
|
||||||
|
'LIBS' => $this->getLibExtraLibs(),
|
||||||
|
])
|
||||||
->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ../CMakeLists.txt')
|
->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ../CMakeLists.txt')
|
||||||
->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF -DBUILD_LIBCURL_DOCS=OFF {$extra} ..")
|
->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF -DBUILD_LIBCURL_DOCS=OFF {$extra} ..")
|
||||||
->execWithEnv("make -j{$this->builder->concurrency}")
|
->execWithEnv("make -j{$this->builder->concurrency}")
|
||||||
|
|||||||
45
src/SPC/builder/unix/library/libacl.php
Normal file
45
src/SPC/builder/unix/library/libacl.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\unix\library;
|
||||||
|
|
||||||
|
use SPC\exception\FileSystemException;
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
|
||||||
|
trait libacl
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @throws FileSystemException
|
||||||
|
*/
|
||||||
|
public function patchBeforeMake(): bool
|
||||||
|
{
|
||||||
|
$file_path = SOURCE_PATH . '/php-src/Makefile';
|
||||||
|
$file_content = FileSystem::readFile($file_path);
|
||||||
|
if (!preg_match('/FPM_EXTRA_LIBS =(.*)-lacl/', $file_content)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/Makefile', '/FPM_EXTRA_LIBS =(.*)-lacl ?(.*)/', 'FPM_EXTRA_LIBS =$1$2');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RuntimeException
|
||||||
|
*/
|
||||||
|
protected function build(): void
|
||||||
|
{
|
||||||
|
shell()->cd($this->source_dir)
|
||||||
|
->setEnv([
|
||||||
|
'CFLAGS' => trim('-I' . BUILD_INCLUDE_PATH . ' ' . $this->getLibExtraCFlags()),
|
||||||
|
'LDFLAGS' => trim('-L' . BUILD_LIB_PATH . ' ' . $this->getLibExtraLdFlags()),
|
||||||
|
'LIBS' => $this->getLibExtraLibs(),
|
||||||
|
])
|
||||||
|
->execWithEnv('./autogen.sh')
|
||||||
|
->execWithEnv('./configure --prefix= --enable-static --disable-shared --disable-tests --disable-nls')
|
||||||
|
->execWithEnv("make -j {$this->builder->concurrency}")
|
||||||
|
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
|
||||||
|
|
||||||
|
$this->patchPkgconfPrefix(['libacl.pc'], PKGCONF_PATCH_PREFIX);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -10,7 +10,7 @@ trait pkgconfig
|
|||||||
{
|
{
|
||||||
protected function build(): void
|
protected function build(): void
|
||||||
{
|
{
|
||||||
$cflags = PHP_OS_FAMILY !== 'Linux' ? '-Wimplicit-function-declaration -Wno-int-conversion' : '';
|
$cflags = PHP_OS_FAMILY !== 'Linux' ? "{$this->builder->arch_c_flags} -Wimplicit-function-declaration -Wno-int-conversion" : '';
|
||||||
$ldflags = !($this instanceof LinuxLibraryBase) || $this->builder->libc === 'glibc' ? '' : '--static';
|
$ldflags = !($this instanceof LinuxLibraryBase) || $this->builder->libc === 'glibc' ? '' : '--static';
|
||||||
|
|
||||||
shell()->cd($this->source_dir)
|
shell()->cd($this->source_dir)
|
||||||
|
|||||||
@ -108,6 +108,9 @@ class BuildCliCommand extends BuildCommand
|
|||||||
$include_suggest_ext = $this->getOption('with-suggested-exts');
|
$include_suggest_ext = $this->getOption('with-suggested-exts');
|
||||||
$include_suggest_lib = $this->getOption('with-suggested-libs');
|
$include_suggest_lib = $this->getOption('with-suggested-libs');
|
||||||
[$extensions, $libraries, $not_included] = DependencyUtil::getExtsAndLibs($extensions, $libraries, $include_suggest_ext, $include_suggest_lib);
|
[$extensions, $libraries, $not_included] = DependencyUtil::getExtsAndLibs($extensions, $libraries, $include_suggest_ext, $include_suggest_lib);
|
||||||
|
if (PHP_OS_FAMILY !== 'Linux' || !($rule & BUILD_TARGET_FPM)) {
|
||||||
|
$libraries = array_filter($libraries, fn ($lib) => !in_array($lib, ['attr', 'libacl']));
|
||||||
|
}
|
||||||
$display_libs = array_filter($libraries, fn ($lib) => in_array(Config::getLib($lib, 'type', 'lib'), ['lib', 'package']));
|
$display_libs = array_filter($libraries, fn ($lib) => in_array(Config::getLib($lib, 'type', 'lib'), ['lib', 'package']));
|
||||||
|
|
||||||
// print info
|
// print info
|
||||||
|
|||||||
@ -17,7 +17,7 @@ class LinuxToolCheckList
|
|||||||
|
|
||||||
public const TOOLS_ALPINE = [
|
public const TOOLS_ALPINE = [
|
||||||
'make', 'bison', 'flex',
|
'make', 'bison', 'flex',
|
||||||
'git', 'autoconf', 'automake',
|
'git', 'autoconf', 'automake', 'gettext-dev',
|
||||||
'tar', 'unzip', 'gzip',
|
'tar', 'unzip', 'gzip',
|
||||||
'bzip2', 'cmake', 'gcc',
|
'bzip2', 'cmake', 'gcc',
|
||||||
'g++', 'patch', 'binutils-gold',
|
'g++', 'patch', 'binutils-gold',
|
||||||
@ -26,7 +26,7 @@ class LinuxToolCheckList
|
|||||||
|
|
||||||
public const TOOLS_DEBIAN = [
|
public const TOOLS_DEBIAN = [
|
||||||
'make', 'bison', 'flex',
|
'make', 'bison', 'flex',
|
||||||
'git', 'autoconf', 'automake',
|
'git', 'autoconf', 'automake', 'autopoint',
|
||||||
'tar', 'unzip', 'gzip',
|
'tar', 'unzip', 'gzip',
|
||||||
'bzip2', 'cmake', 'patch',
|
'bzip2', 'cmake', 'patch',
|
||||||
'xz', 'libtoolize',
|
'xz', 'libtoolize',
|
||||||
|
|||||||
@ -29,6 +29,7 @@ class SourcePatcher
|
|||||||
FileSystem::addSourceExtractHook('php-src', [SourcePatcher::class, 'patchImapLicense']);
|
FileSystem::addSourceExtractHook('php-src', [SourcePatcher::class, 'patchImapLicense']);
|
||||||
FileSystem::addSourceExtractHook('ext-imagick', [SourcePatcher::class, 'patchImagickWith84']);
|
FileSystem::addSourceExtractHook('ext-imagick', [SourcePatcher::class, 'patchImagickWith84']);
|
||||||
FileSystem::addSourceExtractHook('libaom', [SourcePatcher::class, 'patchLibaomForAlpine']);
|
FileSystem::addSourceExtractHook('libaom', [SourcePatcher::class, 'patchLibaomForAlpine']);
|
||||||
|
FileSystem::addSourceExtractHook('attr', [SourcePatcher::class, 'patchAttrForAlpine']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,6 +47,11 @@ class SourcePatcher
|
|||||||
logger()->info('Extension [' . $ext->getName() . '] patched before buildconf');
|
logger()->info('Extension [' . $ext->getName() . '] patched before buildconf');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
foreach ($builder->getLibs() as $lib) {
|
||||||
|
if ($lib->patchBeforeBuildconf() === true) {
|
||||||
|
logger()->info('Library [' . $lib->getName() . '] patched before buildconf');
|
||||||
|
}
|
||||||
|
}
|
||||||
// patch windows php 8.1 bug
|
// patch windows php 8.1 bug
|
||||||
if (PHP_OS_FAMILY === 'Windows' && $builder->getPHPVersionID() >= 80100 && $builder->getPHPVersionID() < 80200) {
|
if (PHP_OS_FAMILY === 'Windows' && $builder->getPHPVersionID() >= 80100 && $builder->getPHPVersionID() < 80200) {
|
||||||
logger()->info('Patching PHP 8.1 windows Fiber bug');
|
logger()->info('Patching PHP 8.1 windows Fiber bug');
|
||||||
@ -84,6 +90,11 @@ class SourcePatcher
|
|||||||
logger()->info('Extension [' . $ext->getName() . '] patched before configure');
|
logger()->info('Extension [' . $ext->getName() . '] patched before configure');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
foreach ($builder->getLibs() as $lib) {
|
||||||
|
if ($lib->patchBeforeConfigure() === true) {
|
||||||
|
logger()->info('Library [' . $lib->getName() . '] patched before configure');
|
||||||
|
}
|
||||||
|
}
|
||||||
// patch capstone
|
// patch capstone
|
||||||
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/have_capstone="yes"/', 'have_capstone="no"');
|
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/have_capstone="yes"/', 'have_capstone="no"');
|
||||||
if ($builder instanceof LinuxBuilder && $builder->libc === 'glibc') {
|
if ($builder instanceof LinuxBuilder && $builder->libc === 'glibc') {
|
||||||
@ -246,6 +257,11 @@ class SourcePatcher
|
|||||||
logger()->info('Extension [' . $ext->getName() . '] patched before make');
|
logger()->info('Extension [' . $ext->getName() . '] patched before make');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
foreach ($builder->getLibs() as $lib) {
|
||||||
|
if ($lib->patchBeforeMake() === true) {
|
||||||
|
logger()->info('Library [' . $lib->getName() . '] patched before make');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -407,6 +423,15 @@ class SourcePatcher
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function patchAttrForAlpine(): bool
|
||||||
|
{
|
||||||
|
if (PHP_OS_FAMILY === 'Linux' && SystemUtil::isMuslDist() || PHP_OS_FAMILY === 'Darwin') {
|
||||||
|
SourcePatcher::patchFile('attr_alpine_gethostname.patch', SOURCE_PATH . '/attr');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Patch cli SAPI Makefile for Windows.
|
* Patch cli SAPI Makefile for Windows.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -108,11 +108,6 @@ class GlobalEnvManager
|
|||||||
'BSD' => self::applyConfig($ini['freebsd']),
|
'BSD' => self::applyConfig($ini['freebsd']),
|
||||||
default => null,
|
default => null,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (PHP_OS_FAMILY === 'Linux' && !filter_var(getenv('SPC_NO_MUSL_PATH'), FILTER_VALIDATE_BOOLEAN)) {
|
|
||||||
self::putenv("SPC_PHP_DEFAULT_LD_LIBRARY_PATH_CMD=LD_LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib");
|
|
||||||
self::putenv("PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . getenv('PATH'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function putenv(string $val): void
|
public static function putenv(string $val): void
|
||||||
|
|||||||
11
src/globals/patch/attr_alpine_gethostname.patch
Normal file
11
src/globals/patch/attr_alpine_gethostname.patch
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
diff --git a/tools/attr.c b/tools/attr.c
|
||||||
|
index 312aef1..8e82810 100644
|
||||||
|
--- a/tools/attr.c
|
||||||
|
+++ b/tools/attr.c
|
||||||
|
@@ -28,6 +28,7 @@
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <locale.h>
|
||||||
|
+#include <libgen.h>
|
||||||
|
|
||||||
|
#include <attr/attributes.h>
|
||||||
Loading…
x
Reference in New Issue
Block a user