Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: e2f5bc9c93
Fetching contributors…

Cannot retrieve contributors at this time

executable file 207 lines (187 sloc) 8.644 kB
#!/usr/bin/env php
<?php
// Compiles Simo into one big PHP file (images and CSS served by Silex directly)
// Can be used on the web and the CLI
use Symfony\Component\ClassLoader\ClassCollectionLoader;
use Symfony\Component\Finder\Finder;
require_once __DIR__.'/vendor/autoload.php';
@mkdir(__DIR__.'/build', 0777, true);
@unlink(__DIR__.'/build/sismo.php');
$classes = array (
'Twig_Environment',
'Twig_Error_Loader',
'Twig_Error_Runtime',
'Twig_Error_Syntax',
'Twig_Extension',
'Twig_Extension_Core',
'Twig_Extension_Escaper',
'Twig_Extension_Optimizer',
'Twig_Filter',
'Twig_Filter_Function',
'Twig_Filter_Method',
'Twig_Function',
'Twig_Function_Function',
'Twig_Function_Method',
'Twig_LoaderInterface',
'Twig_Markup',
'Twig_Template',
'Symfony\Component\Console\Helper\Helper',
'Symfony\Component\Console\Helper\HelperSet',
'Symfony\Component\Console\Helper\DialogHelper',
'Symfony\Component\Console\Helper\FormatterHelper',
'Symfony\Component\Console\Command\Command',
'Symfony\Component\Console\Command\HelpCommand',
'Symfony\Component\Console\Command\ListCommand',
'Symfony\Component\Console\Formatter\OutputFormatter',
'Symfony\Component\Console\Formatter\OutputFormatterStyle',
'Symfony\Component\Console\Formatter\OutputFormatterStyleStack',
'Symfony\Component\Console\Input\Input',
'Symfony\Component\Console\Input\ArgvInput',
'Symfony\Component\Console\Input\ArrayInput',
'Symfony\Component\Console\Input\InputArgument',
'Symfony\Component\Console\Input\InputDefinition',
'Symfony\Component\Console\Input\InputOption',
'Symfony\Component\Console\Input\StringInput',
'Symfony\Component\Console\Output\Output',
'Symfony\Component\Console\Output\StreamOutput',
'Symfony\Component\Console\Output\ConsoleOutput',
'Symfony\Component\Console\Output\NullOutput',
'Symfony\Component\Console\Shell',
'Symfony\Component\Console\Application',
'Symfony\Component\EventDispatcher\Event',
'Symfony\Component\EventDispatcher\EventDispatcher',
'Symfony\Component\HttpFoundation\ParameterBag',
'Symfony\Component\HttpFoundation\Cookie',
'Symfony\Component\HttpFoundation\FileBag',
'Symfony\Component\HttpFoundation\HeaderBag',
'Symfony\Component\HttpFoundation\RedirectResponse',
'Symfony\Component\HttpFoundation\Request',
'Symfony\Component\HttpFoundation\Response',
'Symfony\Component\HttpFoundation\ResponseHeaderBag',
'Symfony\Component\HttpFoundation\ServerBag',
'Symfony\Component\HttpKernel\Controller\ControllerResolver',
'Symfony\Component\HttpKernel\EventListener\LocaleListener',
'Symfony\Component\HttpKernel\EventListener\RouterListener',
'Symfony\Component\HttpKernel\EventListener\RouterListener',
'Symfony\Component\HttpKernel\EventListener\ResponseListener',
'Symfony\Component\HttpKernel\Event\FilterControllerEvent',
'Symfony\Component\HttpKernel\Event\FilterResponseEvent',
'Symfony\Component\HttpKernel\Event\GetResponseEvent',
'Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent',
'Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent',
'Symfony\Component\HttpKernel\Event\KernelEvent',
'Symfony\Component\HttpKernel\Event\PostResponseEvent',
'Symfony\Component\HttpKernel\Exception\HttpException',
'Symfony\Component\HttpKernel\Exception\NotFoundHttpException',
'Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException',
'Symfony\Component\HttpKernel\HttpKernel',
'Symfony\Component\HttpKernel\KernelEvents',
'Symfony\Component\Process\ProcessBuilder',
'Symfony\Component\Process\Process',
'Symfony\Component\Routing\Exception\InvalidParameterException',
'Symfony\Component\Routing\Exception\MethodNotAllowedException',
'Symfony\Component\Routing\Exception\MissingMandatoryParametersException',
'Symfony\Component\Routing\Exception\ResourceNotFoundException',
'Symfony\Component\Routing\Exception\RouteNotFoundException',
'Symfony\Component\Routing\Generator\UrlGenerator',
'Symfony\Component\Routing\Matcher\RedirectableUrlMatcher',
'Symfony\Component\Routing\RequestContext',
'Symfony\Component\Routing\Route',
'Symfony\Component\Routing\CompiledRoute',
'Symfony\Component\Routing\RouteCollection',
'Symfony\Component\Routing\RouteCompiler',
'Symfony\Bridge\Twig\Extension\RoutingExtension',
'Pimple',
'Silex\Application',
'Silex\Controller',
'Silex\ControllerCollection',
'Silex\ControllerResolver',
'Silex\ExceptionHandler',
'Silex\Exception\ControllerFrozenException',
'Silex\LazyUrlMatcher',
'Silex\Provider\TwigCoreExtension',
'Silex\Provider\TwigServiceProvider',
'Silex\Provider\UrlGeneratorServiceProvider',
'Silex\RedirectableUrlMatcher',
'Silex\SilexEvents',
'Silex\Route',
'Sismo\AnsiEscapeSequencesConverter',
'Sismo\Builder',
'Sismo\BuildException',
'Sismo\Commit',
'Sismo\Contrib\XmppNotifier',
'Sismo\Contrib\GoogleTalkNotifier',
'Sismo\Notifier\DBusNotifier',
'Sismo\Notifier\GrowlNotifier',
'Sismo\Notifier\Notifier',
'Sismo\Project',
'Sismo\GithubProject',
'Sismo\SSHProject',
'Sismo\Sismo',
'Sismo\Storage\Storage',
);
$ccl = new ClassCollectionLoader();
$ccl->load($classes, __DIR__.'/build', 'sismo', false);
$classes = str_replace('<?php', '', file_get_contents(__DIR__.'/build/sismo.php'));
$app = 'namespace {'.str_replace('<?php', '', file_get_contents(__DIR__.'/src/app.php')).'}';
$app = str_replace('return $app;', '', $app);
$base = __DIR__.'/src/templates';
$app .= <<<EOF
namespace {
class FakeTwigLoader implements Twig_LoaderInterface
{
public function getSource(\$name) {}
public function getCacheKey(\$name)
{
static \$templates = array(
'ccmonitor.twig.xml' => '$base/ccmonitor.twig.xml',
'error.twig' => '$base/error.twig',
'layout.twig' => '$base/layout.twig',
'project.twig' => '$base/project.twig',
'projects.twig' => '$base/projects.twig',
);
return \$templates[\$name];
}
public function isFresh(\$name, \$time) { return true; }
}
\$app['twig.loader'] = \$app->share(function () { return new FakeTwigLoader(); });
}
EOF;
$templates = '';
$twig = new Twig_Environment(new Twig_Loader_Filesystem(__DIR__.'/src/templates'), array('cache' => sys_get_temp_dir()));
$twig->addExtension(new Symfony\Bridge\Twig\Extension\RoutingExtension(new Symfony\Component\Routing\Generator\UrlGenerator(new Symfony\Component\Routing\RouteCollection(), new Symfony\Component\Routing\RequestContext())));
foreach (array('ccmonitor.twig.xml', 'error.twig', 'layout.twig', 'project.twig', 'projects.twig') as $name) {
$templates .= str_replace('<?php', '', $twig->compileSource($twig->getLoader()->getSource($name), $name));
}
$templates = 'namespace {'.str_replace('basepath', 'baseurl', $templates).'}';
$cli = 'namespace {'.str_replace('<?php', '', file_get_contents(__DIR__.'/src/console.php')).'}';
$cli = str_replace('return $console;', '', $cli);
$controllers = 'namespace {'.str_replace('<?php', '', file_get_contents(__DIR__.'/src/controllers.php')).'}';
$controllers = str_replace('return $app;', '', $controllers);
$assets = sprintf('$app->get(\'/css/sismo.css\', function() { return new Response(\'%s\', 200, array(\'Content-Type\' => \'text/css\')); });', str_replace("'", "\\'", file_get_contents(__DIR__.'/web/css/sismo.css')));
foreach (array('failed.png', 'header.png', 'hr.png', 'nobuild.png', 'success.png', 'sensio-labs-product.png') as $image) {
$assets .= sprintf('$app->get(\'/images/%s\', function() { return new Response(base64_decode(\'%s\'), 200, array(\'Content-Type\' => \'image/png\')); });', $image, base64_encode(file_get_contents(__DIR__.'/web/images/'.$image)));
}
$assets = 'namespace { use Symfony\Component\HttpFoundation\Response; '.$assets.'}';
$content = "<?php
$classes
$app
$templates
$cli
$assets
$controllers
namespace {
if ('cli' === php_sapi_name()) {
\$console->run();
} else {
\$app->run();
}
}
";
// remove require_once calls
$content = preg_replace('#require_once[^;]+?;#', '', $content);
file_put_contents(__DIR__.'/build/sismo.php', $content);
file_put_contents(__DIR__.'/build/sismo.php',
"<?php \n/*".file_get_contents(__DIR__.'/LICENSE')."\n*/\n".
str_replace('<?php', '', php_strip_whitespace(__DIR__.'/build/sismo.php'))
);
Jump to Line
Something went wrong with that request. Please try again.