2014-01-21 12:56:43 -04:00
|
|
|
#!/usr/bin/env php
|
2013-11-22 16:20:49 -04:00
|
|
|
<?php
|
|
|
|
|
|
2014-01-21 12:56:43 -04:00
|
|
|
/*
|
|
|
|
|
* Script o build vendors that requires make some builds and copy some files to a determined path
|
|
|
|
|
*
|
|
|
|
|
* @license Colosa Inc.
|
|
|
|
|
* @author Erik Amaru Ortiz
|
|
|
|
|
*/
|
|
|
|
|
|
2014-01-29 21:04:12 -04:00
|
|
|
$config = @parse_ini_file("workflow/engine/config/env.ini");
|
|
|
|
|
|
|
|
|
|
$debug = !empty($config) && isset($config['debug']) ? $config['debug'] : 0;
|
|
|
|
|
|
2013-11-22 16:20:49 -04:00
|
|
|
define('DS', DIRECTORY_SEPARATOR);
|
2014-01-21 12:56:43 -04:00
|
|
|
|
2013-11-22 16:20:49 -04:00
|
|
|
// --no-ansi wins over --ansi
|
|
|
|
|
if (in_array('--no-ansi', $argv)) {
|
|
|
|
|
define('USE_ANSI', false);
|
|
|
|
|
} elseif (in_array('--ansi', $argv)) {
|
|
|
|
|
define('USE_ANSI', true);
|
|
|
|
|
} else {
|
|
|
|
|
// On Windows, default to no ANSI, except in ANSICON and ConEmu.
|
|
|
|
|
// Everywhere else, default to ANSI if stdout is a terminal.
|
|
|
|
|
define('USE_ANSI',
|
2014-01-24 11:33:25 -04:00
|
|
|
(DIRECTORY_SEPARATOR == '\\')
|
|
|
|
|
? (false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI'))
|
|
|
|
|
: (function_exists('posix_isatty') && posix_isatty(1))
|
2013-11-22 16:20:49 -04:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$vendorDir = dirname(__FILE__) . DS . 'vendor';
|
|
|
|
|
|
|
|
|
|
if (! is_dir($vendorDir )) {
|
|
|
|
|
echo "Vendor directory is missing!" . PHP_EOL;
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$projects = array(
|
2014-01-23 17:41:52 -04:00
|
|
|
'colosa/MichelangeloFE',
|
|
|
|
|
'colosa/pmUI'
|
2013-11-22 16:20:49 -04:00
|
|
|
);
|
|
|
|
|
|
2014-02-25 11:54:56 -05:00
|
|
|
out("build-vendor.php", 'purple');
|
|
|
|
|
|
|
|
|
|
out("generating files for ", 'purple', false);
|
|
|
|
|
out( $debug ? 'debug' : 'production', 'success', false);
|
|
|
|
|
out(" mode", 'purple');
|
|
|
|
|
|
2013-11-22 16:20:49 -04:00
|
|
|
foreach ($projects as $project) {
|
|
|
|
|
echo PHP_EOL;
|
2014-01-21 12:56:43 -04:00
|
|
|
out("=> Building project: ", 'info', false);
|
|
|
|
|
echo $project.' '.PHP_EOL;
|
2013-11-22 16:20:49 -04:00
|
|
|
chdir($vendorDir.DS.$project);
|
2014-02-25 11:54:56 -05:00
|
|
|
if ($debug) {
|
|
|
|
|
exec ('rake pmBuildDebug', $output, $exitCode );
|
|
|
|
|
} else {
|
|
|
|
|
exec ('rake pmBuild', $output, $exitCode );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($exitCode) {
|
|
|
|
|
out("$project executed with errors!", 'error');
|
|
|
|
|
foreach ($output as $line) {
|
|
|
|
|
print "$line\n";
|
|
|
|
|
}
|
|
|
|
|
echo PHP_EOL;
|
|
|
|
|
die;
|
|
|
|
|
} else {
|
|
|
|
|
foreach ($output as $line) {
|
|
|
|
|
print "$line\n";
|
|
|
|
|
}
|
|
|
|
|
out("$project completed", 'success');
|
|
|
|
|
echo PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-22 16:20:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo PHP_EOL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////
|
|
|
|
|
|
2014-01-21 12:56:43 -04:00
|
|
|
|
2013-11-22 16:20:49 -04:00
|
|
|
/**
|
|
|
|
|
* colorize output
|
|
|
|
|
*/
|
|
|
|
|
function out($text, $color = null, $newLine = true)
|
|
|
|
|
{
|
|
|
|
|
$styles = array(
|
2014-01-21 12:56:43 -04:00
|
|
|
'success' => "\033[0;35;32m%s\033[0m",
|
2014-02-25 11:54:56 -05:00
|
|
|
'error' => "\033[0;35;31m%s\033[0m",
|
|
|
|
|
'purple' => "\033[0;35;35m%s\033[0m",
|
|
|
|
|
'info' => "\033[1;33;34m%s\033[0m"
|
2013-11-22 16:20:49 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$format = '%s';
|
|
|
|
|
|
2014-01-21 12:56:43 -04:00
|
|
|
if (isset($styles[$color])) {
|
2013-11-22 16:20:49 -04:00
|
|
|
$format = $styles[$color];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($newLine) {
|
|
|
|
|
$format .= PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf($format, $text);
|
2014-02-25 11:54:56 -05:00
|
|
|
}
|