File: phing.php

package info (click to toggle)
phing 3.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,368 kB
  • sloc: php: 59,821; xml: 9,767; sql: 78; makefile: 39; sh: 14
file content (69 lines) | stat: -rw-r--r-- 2,095 bytes parent folder | download | duplicates (2)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php

/**
 * This is the Phing command line launcher. It starts up the system evironment
 * tests for all important paths and properties and kicks of the main command-
 * line entry point of phing located in phing.Phing
 */

// Use composers autoload.php if available
use Phing\Exception\ConfigurationException;
use Phing\Phing;

require_once __DIR__ . '/autoload.php';

// Set any INI options for PHP
// ---------------------------

/* set include paths */
set_include_path(
            realpath(__DIR__ . '/Phing') .
            PATH_SEPARATOR .
            get_include_path()
        );

/**
* Code from Symfony/Component/Console/Output/StreamOutput.php
*/
function hasColorSupport()
{
    if (DIRECTORY_SEPARATOR == '\\') {
        return 0 >= version_compare('10.0.10586', PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD)
        || false !== getenv('ANSICON')
        || 'ON' === getenv('ConEmuANSI')
        || 'xterm' === getenv('TERM');
    }
    return function_exists('posix_isatty') && @posix_isatty(STDOUT);
}

// default logger
if (!in_array('-logger', $argv) && hasColorSupport()) {
    array_splice($argv, 1, 0, ['-logger', 'Phing\Listener\AnsiColorLogger']);
}

try {

    /* Setup Phing environment */
    Phing::startup();

    // Set phing.home property to the value from environment
    // (this may be NULL, but that's not a big problem.)
    Phing::setProperty('phing.home', getenv('PHING_HOME'));
    // Grab and clean up the CLI arguments
    $args = isset($argv) ? $argv : $_SERVER['argv']; // $_SERVER['argv'] seems to not work (sometimes?) when argv is registered
    array_shift($args); // 1st arg is script name, so drop it

    // Invoke the commandline entry point
    Phing::fire($args);
} catch (ConfigurationException $x) {
    Phing::shutdown();
    Phing::printMessage($x);
    exit(-1); // This was convention previously for configuration errors.
} catch (Exception $x) {
    Phing::shutdown();

    // Assume the message was already printed as part of the build and
    // exit with non-0 error code.

    exit(1);
}