Skip to content

Commit 0fa38ba

Browse files
committed
Use existing pkg-config builds and pre-built contents for packages
1 parent f2c131a commit 0fa38ba

File tree

14 files changed

+157
-145
lines changed

14 files changed

+157
-145
lines changed

config/lib.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
"watcher"
2020
]
2121
},
22+
"pkg-config": {
23+
"type": "package",
24+
"source": "pkg-config",
25+
"bin-unix": [
26+
"pkg-config"
27+
]
28+
},
2229
"micro": {
2330
"type": "target",
2431
"source": "micro"

config/pkg.json

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,35 @@
7171
"type": "custom"
7272
},
7373
"pkg-config-x86_64-linux": {
74-
"type": "custom"
74+
"type": "ghrel",
75+
"repo": "static-php/static-php-cli-hosted",
76+
"match": "pkg-config-x86_64-linux-musl-1.2.5.txz",
77+
"extract-files": {
78+
"bin/pkg-config": "{pkg_root_path}/bin/pkg-config"
79+
}
7580
},
7681
"pkg-config-aarch64-linux": {
77-
"type": "custom"
82+
"type": "ghrel",
83+
"repo": "static-php/static-php-cli-hosted",
84+
"match": "pkg-config-aarch64-linux-musl-1.2.5.txz",
85+
"extract-files": {
86+
"bin/pkg-config": "{pkg_root_path}/bin/pkg-config"
87+
}
7888
},
7989
"pkg-config-x86_64-macos": {
80-
"type": "custom"
90+
"type": "ghrel",
91+
"repo": "static-php/static-php-cli-hosted",
92+
"match": "pkg-config-x86_64-darwin.txz",
93+
"extract-files": {
94+
"bin/pkg-config": "{pkg_root_path}/bin/pkg-config"
95+
}
8196
},
8297
"pkg-config-aarch64-macos": {
83-
"type": "custom"
98+
"type": "ghrel",
99+
"repo": "static-php/static-php-cli-hosted",
100+
"match": "pkg-config-aarch64-darwin.txz",
101+
"extract-files": {
102+
"bin/pkg-config": "{pkg_root_path}/bin/pkg-config"
103+
}
84104
}
85105
}

config/source.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
},
88
"alt": false
99
},
10+
"pkg-config": {
11+
"type": "url",
12+
"url": "https://dl.static-php.dev/static-php-cli/deps/pkg-config/pkg-config-0.29.2.tar.gz",
13+
"provide-pre-built": true,
14+
"license": {
15+
"type": "file",
16+
"path": "COPYING"
17+
}
18+
},
1019
"amqp": {
1120
"type": "url",
1221
"url": "https://pecl.php.net/get/amqp",

src/SPC/builder/freebsd/BSDBuilder.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use SPC\builder\unix\UnixBuilderBase;
88
use SPC\exception\WrongUsageException;
99
use SPC\store\FileSystem;
10-
use SPC\store\pkg\PkgConfig;
1110
use SPC\store\SourcePatcher;
1211

1312
class BSDBuilder extends UnixBuilderBase
@@ -26,10 +25,6 @@ public function __construct(array $options = [])
2625
f_putenv('CXX=' . $this->getOption('cxx', 'clang++'));
2726
// set PATH
2827
f_putenv('PATH=' . BUILD_ROOT_PATH . '/bin:' . getenv('PATH'));
29-
// set PKG_CONFIG
30-
f_putenv('PKG_CONFIG=' . PkgConfig::getEnvironment()['PATH'] . '/bin/pkg-config');
31-
// set PKG_CONFIG_PATH
32-
f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig/');
3328

3429
// set arch (default: current)
3530
$this->setOptionIfNotExist('arch', php_uname('m'));
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\freebsd\library;
6+
7+
/**
8+
* gmp is a template library class for unix
9+
*/
10+
class pkgconfig extends BSDLibraryBase
11+
{
12+
use \SPC\builder\unix\library\pkgconfig;
13+
14+
public const NAME = 'pkg-config';
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\linux\library;
6+
7+
/**
8+
* gmp is a template library class for unix
9+
*/
10+
class pkgconfig extends LinuxLibraryBase
11+
{
12+
use \SPC\builder\unix\library\pkgconfig;
13+
14+
public const NAME = 'pkg-config';
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\macos\library;
6+
7+
/**
8+
* gmp is a template library class for unix
9+
*/
10+
class pkgconfig extends MacOSLibraryBase
11+
{
12+
use \SPC\builder\unix\library\pkgconfig;
13+
14+
public const NAME = 'pkg-config';
15+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\unix\library;
6+
7+
use SPC\util\executor\UnixAutoconfExecutor;
8+
use SPC\util\SPCTarget;
9+
10+
trait pkgconfig
11+
{
12+
protected function build(): void
13+
{
14+
UnixAutoconfExecutor::create($this)
15+
->appendEnv([
16+
'CFLAGS' => '-Wimplicit-function-declaration -Wno-int-conversion',
17+
'LDFLAGS' => SPCTarget::isStatic() ? '--static' : '',
18+
])
19+
->configure(
20+
'--with-internal-glib',
21+
'--disable-host-tool',
22+
'--without-sysroot',
23+
'--without-system-include-path',
24+
'--without-system-library-path',
25+
'--without-pc-path',
26+
)
27+
->make(with_install: 'install-exec');
28+
29+
shell()->exec('strip ' . BUILD_ROOT_PATH . '/bin/pkg-config');
30+
}
31+
}

src/SPC/doctor/item/PkgConfigCheck.php

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use SPC\doctor\CheckResult;
1010
use SPC\doctor\OptionalCheck;
1111
use SPC\store\PackageManager;
12-
use SPC\store\pkg\PkgConfig;
12+
use SPC\util\PkgConfigUtil;
1313

1414
#[OptionalCheck([self::class, 'optionalCheck'])]
1515
class PkgConfigCheck
@@ -20,26 +20,19 @@ public static function optionalCheck(): bool
2020
}
2121

2222
/** @noinspection PhpUnused */
23-
#[AsCheckItem('if pkg-config is installed', level: 800)]
23+
#[AsCheckItem('if pkg-config is installed or built', level: 800)]
2424
public function checkPkgConfig(): CheckResult
2525
{
26-
if (PkgConfig::isInstalled()) {
27-
return CheckResult::ok();
26+
if (!($pkgconf = PkgConfigUtil::findPkgConfig())) {
27+
return CheckResult::fail('pkg-config is not installed', 'install-pkgconfig');
2828
}
29-
return CheckResult::fail('pkg-config is not installed', 'install-pkgconfig');
29+
return CheckResult::ok($pkgconf);
3030
}
3131

3232
#[AsFixItem('install-pkgconfig')]
3333
public function installPkgConfig(): bool
3434
{
35-
$arch = arch2gnu(php_uname('m'));
36-
$os = match (PHP_OS_FAMILY) {
37-
'Windows' => 'win',
38-
'Darwin' => 'macos',
39-
'BSD' => 'freebsd',
40-
default => 'linux',
41-
};
42-
PackageManager::installPackage("pkg-config-{$arch}-{$os}");
43-
return PkgConfig::isInstalled();
35+
PackageManager::installPackage('pkg-config');
36+
return true;
4437
}
4538
}

src/SPC/store/pkg/PkgConfig.php

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)