Skip to content

Commit ebe6e80

Browse files
committed
MORE
1 parent 259805c commit ebe6e80

4 files changed

Lines changed: 73 additions & 40 deletions

File tree

.github/workflows/continuous-integration.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ jobs:
5959
run: |
6060
sudo apt-get update
6161
sudo apt-get install -y --no-install-recommends \
62+
g++ gcc make autoconf libtool bison re2c pkg-config unzip \
6263
libcurl4-openssl-dev \
6364
liblmdb-dev \
6465
libdb-dev \
@@ -82,6 +83,8 @@ jobs:
8283
libtidy-dev \
8384
libxslt1-dev \
8485
libsasl2-dev \
86+
libpq-dev \
87+
libsqlite3-dev \
8588
libzip-dev
8689
- name: Setup PHP
8790
uses: shivammathur/setup-php@v2

src/Building/UnixBuild.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Php\Pie\Building;
66

7+
use Php\Pie\ComposerIntegration\BundledPhpExtensionsRepository;
78
use Php\Pie\Downloading\DownloadedPackage;
89
use Php\Pie\File\BinaryFile;
910
use Php\Pie\Platform\TargetPhp\PhpizePath;
@@ -15,7 +16,6 @@
1516
use function count;
1617
use function file_exists;
1718
use function implode;
18-
use function realpath;
1919
use function rename;
2020
use function sprintf;
2121

@@ -175,9 +175,10 @@ private function make(
175175
$makeCommand[] = sprintf('-j%d', $targetPlatform->makeParallelJobs);
176176
}
177177

178-
if ($downloadedPackage->package->addBundledPhpSrcCflags()) {
179-
$makeCommand[] = 'EXTRA_CFLAGS=-I' . realpath($downloadedPackage->extractedSourcePath . '/../..');
180-
}
178+
$makeCommand = BundledPhpExtensionsRepository::augmentMakeCommandForPhpBundledExtensions(
179+
$makeCommand,
180+
$downloadedPackage,
181+
);
181182

182183
if ($output->isVerbose()) {
183184
$output->writeln('<comment>Running make step with: ' . implode(' ', $makeCommand) . '</comment>');

src/ComposerIntegration/BundledPhpExtensionsRepository.php

Lines changed: 65 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,20 @@
99
use Composer\Package\Package;
1010
use Composer\Package\Version\VersionParser;
1111
use Composer\Repository\ArrayRepository;
12+
use Php\Pie\Downloading\DownloadedPackage;
1213
use Php\Pie\ExtensionType;
1314
use Php\Pie\Platform\OperatingSystemFamily;
1415
use Php\Pie\Platform\TargetPlatform;
16+
use Php\Pie\Util\Process;
17+
use RuntimeException;
18+
use Symfony\Component\Process\Exception\ProcessFailedException;
1519

1620
use function array_combine;
1721
use function array_key_exists;
1822
use function array_keys;
1923
use function array_map;
24+
use function in_array;
25+
use function realpath;
2026
use function sprintf;
2127

2228
class BundledPhpExtensionsRepository extends ArrayRepository
@@ -28,7 +34,6 @@ class BundledPhpExtensionsRepository extends ArrayRepository
2834
* os-families?: non-empty-list<OperatingSystemFamily>,
2935
* type?: ExtensionType,
3036
* priority?: int,
31-
* add-bundled-php-src-cflags?: bool,
3237
* }>
3338
*/
3439
private static array $bundledPhpExtensions = [
@@ -86,32 +91,39 @@ class BundledPhpExtensionsRepository extends ArrayRepository
8691
'ext-mysqlnd' => '*',
8792
],
8893
],
89-
// ['name' => 'odbc'], // build failure - cp: cannot stat '/usr/local/lib/odbclib.a': No such file or directory configure: error: ODBC header file '/usr/local/incl/sqlext.h' not found!
9094
[
9195
'name' => 'opcache',
9296
'type' => ExtensionType::ZendExtension,
9397
'require' => ['php' => '>= 5.5.0'],
9498
],
9599
// ['name' => 'openssl'], // Not building in CI
96100
['name' => 'pcntl'],
97-
// ['name' => 'pdo', 'require' => ['php' => '>= 5.1.0']], // build failure - make: *** [Makefile:206: /home/james/.config/pie/php8.4_64f029c38a947437b5385bfed58650fb/vendor/php/pdo/ext/pdo/pdo_sql_parser.c] Error 127
98-
// ['name' => 'pdo_dblib', 'require' => ['php' => '>= 5.1.0']], // build failure - configure: error: Cannot find FreeTDS in known installation directories.
99-
// ['name' => 'pdo_firebird', 'require' => ['php' => '>= 5.1.0']], // build failure - configure: error: libfbclient not found.
100-
// [
101-
// 'name' => 'pdo_mysql',
102-
// 'require' => ['php' => '>= 5.1.0'],
103-
// ], // Not building in CI
104-
// ['name' => 'pdo_odbc', 'require' => ['php' => '>= 5.1.0']], // build failure - configure: error: Unknown ODBC flavour yes
105-
// [
106-
// 'name' => 'pdo_pgsql',
107-
// 'require' => ['php' => '>= 5.1.0'],
108-
// ], // Not building in CI
109-
// [
110-
// 'name' => 'pdo_sqlite',
111-
// 'require' => ['php' => '>= 5.1.0'],
112-
// ], // Not building in CI
101+
[
102+
'name' => 'pdo',
103+
'require' => ['php' => '>= 5.1.0'],
104+
],
105+
[
106+
'name' => 'pdo_mysql',
107+
'require' => [
108+
'php' => '>= 5.1.0',
109+
'ext-pdo' => '*',
110+
],
111+
],
112+
[
113+
'name' => 'pdo_pgsql',
114+
'require' => [
115+
'php' => '>= 5.1.0',
116+
'ext-pdo' => '*',
117+
],
118+
],
119+
[
120+
'name' => 'pdo_sqlite',
121+
'require' => [
122+
'php' => '>= 5.1.0',
123+
'ext-pdo' => '*',
124+
],
125+
],
113126
['name' => 'pgsql'],
114-
// ['name' => 'phar', 'require' => ['php' => '>= 5.3.0']], // build failure - config.status: error: cannot find input file: '/phar.1.in'
115127
['name' => 'posix'],
116128
['name' => 'readline'],
117129
['name' => 'session'],
@@ -144,7 +156,6 @@ class BundledPhpExtensionsRepository extends ArrayRepository
144156
['name' => 'sysvsem'],
145157
['name' => 'sysvshm'],
146158
['name' => 'tidy'],
147-
// ['name' => 'tokenizer'], // build failure - make: *** No rule to make target '/home/james/workspace/oss/php-src/ext/tokenizer/Zend/zend_language_parser.y', needed by '/home/james/workspace/oss/php-src/ext/tokenizer/Zend/zend_language_parser.c'. Stop.
148159
[
149160
'name' => 'xml',
150161
'require' => [
@@ -159,7 +170,6 @@ class BundledPhpExtensionsRepository extends ArrayRepository
159170
'ext-libxml' => '*',
160171
'ext-dom' => '*',
161172
],
162-
'add-bundled-php-src-cflags' => true,
163173
],
164174
[
165175
'name' => 'xmlwriter',
@@ -232,16 +242,45 @@ static function (string $target, string $constraint) use ($extension, $versionPa
232242
$phpExt['priority'] = $extension['priority'];
233243
}
234244

235-
if (array_key_exists('add-bundled-php-src-cflags', $extension)) {
236-
$phpExt['add-bundled-php-src-cflags'] = $extension['add-bundled-php-src-cflags'];
237-
}
238-
239-
/** @psalm-suppress InvalidArgument */
240245
$package->setPhpExt($phpExt);
241246

242247
return $package;
243248
},
244249
self::$bundledPhpExtensions,
245250
));
246251
}
252+
253+
private static function findRe2c(): string
254+
{
255+
try {
256+
return Process::run(['which', 're2c']);
257+
} catch (ProcessFailedException $processFailed) {
258+
throw new RuntimeException('Unable to find re2c on the system', previous: $processFailed);
259+
}
260+
}
261+
262+
/**
263+
* @param list<string> $makeCommand
264+
*
265+
* @return list<string>
266+
*/
267+
public static function augmentMakeCommandForPhpBundledExtensions(array $makeCommand, DownloadedPackage $downloadedPackage): array
268+
{
269+
if ($downloadedPackage->package->name() === 'php/xmlreader') {
270+
$makeCommand[] = 'EXTRA_CFLAGS=-I' . realpath($downloadedPackage->extractedSourcePath . '/../..');
271+
}
272+
273+
if (
274+
in_array($downloadedPackage->package->name(), [
275+
'php/pdo',
276+
'php/pdo_mysql',
277+
'php/pdo_pgsql',
278+
'php/pdo_sqlite',
279+
])
280+
) {
281+
$makeCommand[] = 'RE2C=' . self::findRe2c();
282+
}
283+
284+
return $makeCommand;
285+
}
247286
}

src/DependencyResolver/Package.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ final class Package
4343
private bool $supportZts = true;
4444
private bool $supportNts = true;
4545
private DownloadUrlMethod|null $downloadUrlMethod = null;
46-
private bool $addBundledPhpSrcCflags = false;
4746

4847
public function __construct(
4948
private readonly CompletePackageInterface $composerPackage,
@@ -95,10 +94,6 @@ public static function fromComposerCompletePackage(CompletePackageInterface $com
9594
$package->downloadUrlMethod = DownloadUrlMethod::tryFrom($phpExtOptions['download-url-method']);
9695
}
9796

98-
if ($phpExtOptions !== null && array_key_exists('add-bundled-php-src-cflags', $phpExtOptions)) {
99-
$package->addBundledPhpSrcCflags = (bool) $phpExtOptions['add-bundled-php-src-cflags'];
100-
}
101-
10297
return $package;
10398
}
10499

@@ -225,9 +220,4 @@ public function downloadUrlMethod(): DownloadUrlMethod|null
225220
{
226221
return $this->downloadUrlMethod;
227222
}
228-
229-
public function addBundledPhpSrcCflags(): bool
230-
{
231-
return $this->addBundledPhpSrcCflags;
232-
}
233223
}

0 commit comments

Comments
 (0)