Skip to content

Commit 30179d1

Browse files
committed
Merge branch '1.4.x' into merge-up-binary-pkg-configure-options-fix
2 parents 2dcdebf + b197d28 commit 30179d1

3 files changed

Lines changed: 65 additions & 0 deletions

File tree

docs/usage.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,11 @@ pie install example/some-extension --with-some-library-name=/path/to/the/lib
313313
pie install example/some-extension --with-some-library-name=/path/to/the/lib --enable-some-functionality
314314
```
315315

316+
> [!TIP]
317+
> If you specify configure options for a package that uses the
318+
> `pre-packaged-binary` download method, PIE will fall back to compiling the
319+
> extension using the configure options you have specified.
320+
316321
### Build tools check
317322

318323
PIE will attempt to check the presence of build tools (such as gcc, make, etc.)

src/ComposerIntegration/Listeners/OverrideDownloadUrlInstallListener.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ function (OperationInterface $operation): void {
8080
foreach ($downloadUrlMethods as $downloadUrlMethod) {
8181
$this->io->write('Trying to download using: ' . $downloadUrlMethod->value, verbosity: IOInterface::VERY_VERBOSE);
8282

83+
if ($downloadUrlMethod === DownloadUrlMethod::PrePackagedBinary && $this->composerRequest->configureOptions !== []) {
84+
$configureOptionsConflictMessage = 'Cannot use pre-packaged-binary download method, as configure options were passed.';
85+
86+
$downloadMethodFailures[$downloadUrlMethod->value] = $configureOptionsConflictMessage;
87+
$this->io->write($configureOptionsConflictMessage, verbosity: IOInterface::VERBOSE);
88+
89+
continue;
90+
}
91+
8392
// Exit early if we should just use Composer's normal download
8493
if ($downloadUrlMethod === DownloadUrlMethod::ComposerDefaultDownload) {
8594
$selectedDownloadUrlMethod = $downloadUrlMethod;

test/unit/ComposerIntegration/Listeners/OverrideDownloadUrlInstallListenerTest.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,57 @@ public function testDistUrlIsUpdatedForPrePackagedTgzBinaryWhenBinaryIsNotFound(
500500
self::assertSame('zip', $composerPackage->getDistType());
501501
}
502502

503+
public function testPrePackagedBinaryMethodIsIgnoredWhenConfigureOptionsArePassed(): void
504+
{
505+
$composerPackage = new CompletePackage('foo/bar', '1.2.3.0', '1.2.3');
506+
$composerPackage->setDistType('zip');
507+
$composerPackage->setDistUrl('https://example.com/git-archive-zip-url');
508+
$composerPackage->setPhpExt([
509+
'extension-name' => 'foobar',
510+
'download-url-method' => ['pre-packaged-binary'],
511+
]);
512+
513+
$installerEvent = new InstallerEvent(
514+
InstallerEvents::PRE_OPERATIONS_EXEC,
515+
$this->composer,
516+
$this->io,
517+
false,
518+
true,
519+
new Transaction([], [$composerPackage]),
520+
);
521+
522+
$this->container
523+
->expects(self::never())
524+
->method('get');
525+
526+
$listener = new OverrideDownloadUrlInstallListener(
527+
$this->composer,
528+
$this->io,
529+
$this->container,
530+
new PieComposerRequest(
531+
$this->createMock(IOInterface::class),
532+
new TargetPlatform(
533+
OperatingSystem::NonWindows,
534+
OperatingSystemFamily::Linux,
535+
PhpBinaryPath::fromCurrentProcess(),
536+
Architecture::x86_64,
537+
ThreadSafetyMode::NonThreadSafe,
538+
1,
539+
WindowsCompiler::VC15,
540+
null,
541+
),
542+
new RequestedPackageAndVersion('foo/bar', '^1.1'),
543+
PieOperation::Install,
544+
['--with-foo'],
545+
false,
546+
),
547+
);
548+
549+
$this->expectException(CouldNotDetermineDownloadUrlMethod::class);
550+
$this->expectExceptionMessage('Could not download foo/bar using pre-packaged-binary method: Cannot use pre-packaged-binary download method, as configure options were passed.');
551+
$listener($installerEvent);
552+
}
553+
503554
public function testNoSelectedDownloadUrlMethodWillThrowException(): void
504555
{
505556
$composerPackage = new CompletePackage('foo/bar', '1.2.3.0', '1.2.3');

0 commit comments

Comments
 (0)