File: compile

package info (click to toggle)
composer 2.9.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,476 kB
  • sloc: php: 82,636; makefile: 59; xml: 39
file content (44 lines) | stat: -rwxr-xr-x 1,499 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env php
<?php

$cwd = getcwd();
assert(is_string($cwd));
chdir(__DIR__.'/../');
$ts = rtrim(exec('git rev-list --no-commit-header -n1 --format=%ct HEAD'));
if (!is_numeric($ts)) {
    echo 'Could not detect date using "git rev-list --no-commit-header -n1 --format=%ct HEAD"'.PHP_EOL;
    exit(1);
}
// Install with the current version to force it having the right ClassLoader version
// Install without dev packages to clean up the included classmap from phpunit classes
exec('php bin/composer config autoloader-suffix ComposerPhar' . $ts, $output, $result);
if (0 !== $result) {
    echo 'Could not set the autoloader suffix, make sure exec is allowed and php can be found in your PATH';
    exit(1);
}
exec('php bin/composer install -q --no-dev', $output, $result);
if (0 !== $result) {
    echo 'Could not remove dev deps, make sure exec is allowed and php can be found in your PATH';
    exit(1);
}
exec('php bin/composer config autoloader-suffix --unset', $output, $result);
if (0 !== $result) {
    echo 'Could not remove the autoloader suffix, make sure exec is allowed and php can be found in your PATH';
    exit(1);
}
chdir($cwd);

require __DIR__.'/../src/bootstrap.php';

use Composer\Compiler;

error_reporting(-1);
ini_set('display_errors', '1');

try {
    $compiler = new Compiler();
    $compiler->compile();
} catch (\Exception $e) {
    echo 'Failed to compile phar: ['.get_class($e).'] '.$e->getMessage().' at '.$e->getFile().':'.$e->getLine().PHP_EOL;
    exit(1);
}