Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 337 lines (316 sloc) 13.782 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\UniversalClassLoader;
use Symfony\Component\ClassLoader\ClassCollectionLoader;
use Symfony\Component\Finder\Finder;
require_once __DIR__.'/vendor/silex/autoload.php';
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
'Sismo' => __DIR__.'/src',
'Symfony' => __DIR__.'/vendor',
));
$loader->registerPrefixes(array(
'Twig_' => __DIR__.'/vendor/silex/vendor/twig/lib',
));
$loader->register();
@mkdir(__DIR__.'/build', 0777, true);
@unlink(__DIR__.'/build/sismo.php');
$classes = array (
'Twig_Compiler',
'Twig_CompilerInterface',
'Twig_Environment',
'Twig_Error',
'Twig_Error_Loader',
'Twig_Error_Runtime',
'Twig_Error_Syntax',
'Twig_ExpressionParser',
'Twig_Extension',
'Twig_ExtensionInterface',
'Twig_Extension_Core',
'Twig_Extension_Escaper',
'Twig_Extension_Optimizer',
'Twig_Filter',
'Twig_FilterInterface',
'Twig_Filter_Function',
'Twig_Filter_Method',
'Twig_Function',
'Twig_FunctionInterface',
'Twig_Function_Function',
'Twig_Function_Method',
'Twig_Lexer',
'Twig_LexerInterface',
'Twig_LoaderInterface',
'Twig_Loader_Array',
'Twig_Loader_Chain',
'Twig_Loader_Filesystem',
'Twig_Markup',
'Twig_Node',
'Twig_NodeInterface',
'Twig_NodeOutputInterface',
'Twig_NodeTraverser',
'Twig_NodeVisitorInterface',
'Twig_NodeVisitor_Escaper',
'Twig_NodeVisitor_Optimizer',
'Twig_NodeVisitor_SafeAnalysis',
'Twig_Node_AutoEscape',
'Twig_Node_Block',
'Twig_Node_BlockReference',
'Twig_Node_Expression',
'Twig_Node_Expression_Name',
'Twig_Node_Expression_Array',
'Twig_Node_Expression_AssignName',
'Twig_Node_Expression_BlockReference',
'Twig_Node_Expression_Conditional',
'Twig_Node_Expression_Constant',
'Twig_Node_Expression_Filter',
'Twig_Node_Expression_Function',
'Twig_Node_Expression_GetAttr',
'Twig_Node_Expression_Parent',
'Twig_Node_Expression_Test',
'Twig_Node_Expression_Unary',
'Twig_Node_Expression_Unary_Not',
'Twig_Node_For',
'Twig_Node_If',
'Twig_Node_Import',
'Twig_Node_Include',
'Twig_Node_Macro',
'Twig_Node_Module',
'Twig_Node_Print',
'Twig_Node_Set',
'Twig_Node_Spaceless',
'Twig_Node_Text',
'Twig_Parser',
'Twig_ParserInterface',
'Twig_Template',
'Twig_TemplateInterface',
'Twig_TestInterface',
'Twig_Test_Function',
'Twig_Token',
'Twig_TokenParser',
'Twig_TokenParserBroker',
'Twig_TokenParserBrokerInterface',
'Twig_TokenParserInterface',
'Twig_TokenParser_AutoEscape',
'Twig_TokenParser_Block',
'Twig_TokenParser_Extends',
'Twig_TokenParser_Filter',
'Twig_TokenParser_For',
'Twig_TokenParser_From',
'Twig_TokenParser_If',
'Twig_TokenParser_Import',
'Twig_TokenParser_Include',
'Twig_TokenParser_Macro',
'Twig_TokenParser_Set',
'Twig_TokenParser_Spaceless',
'Twig_TokenParser_Use',
'Twig_TokenStream',
'Symfony\Component\ClassLoader\UniversalClassLoader',
'Symfony\Component\Console\Helper\HelperInterface',
'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\OutputFormatterInterface',
'Symfony\Component\Console\Formatter\OutputFormatter',
'Symfony\Component\Console\Formatter\OutputFormatterStyleInterface',
'Symfony\Component\Console\Formatter\OutputFormatterStyle',
'Symfony\Component\Console\Input\InputInterface',
'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\OutputInterface',
'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\Tester\ApplicationTester',
'Symfony\Component\Console\Tester\CommandTester',
'Symfony\Component\Console\Application',
'Symfony\Component\EventDispatcher\EventDispatcherInterface',
'Symfony\Component\EventDispatcher\EventSubscriberInterface',
'Symfony\Component\EventDispatcher\Event',
'Symfony\Component\EventDispatcher\EventDispatcher',
'Symfony\Component\HttpFoundation\Cookie',
'Symfony\Component\HttpFoundation\FileBag',
'Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException',
'Symfony\Component\HttpFoundation\File\Exception\FileException',
'Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException',
'Symfony\Component\HttpFoundation\File\File',
'Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface',
'Symfony\Component\HttpFoundation\File\Mimetype\ExtensionGuesserInterface',
'Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser',
'Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser',
'Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser',
'Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser',
'Symfony\Component\HttpFoundation\File\UploadedFile',
'Symfony\Component\HttpFoundation\HeaderBag',
'Symfony\Component\HttpFoundation\ParameterBag',
'Symfony\Component\HttpFoundation\RedirectResponse',
'Symfony\Component\HttpFoundation\Request',
'Symfony\Component\HttpFoundation\Response',
'Symfony\Component\HttpFoundation\ResponseHeaderBag',
'Symfony\Component\HttpFoundation\ServerBag',
'Symfony\Component\HttpFoundation\Session',
'Symfony\Component\HttpFoundation\SessionStorage\SessionStorageInterface',
'Symfony\Component\HttpKernel\Controller\ControllerResolverInterface',
'Symfony\Component\HttpKernel\Controller\ControllerResolver',
'Symfony\Component\HttpKernel\Debug\ExceptionHandler',
'Symfony\Component\HttpKernel\EventListener\ResponseListener',
'Symfony\Component\HttpKernel\EventListener\RouterListener',
'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\Exception\FlattenException',
'Symfony\Component\HttpKernel\Exception\HttpExceptionInterface',
'Symfony\Component\HttpKernel\Exception\HttpException',
'Symfony\Component\HttpKernel\Exception\NotFoundHttpException',
'Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException',
'Symfony\Component\HttpKernel\HttpKernelInterface',
'Symfony\Component\HttpKernel\HttpKernel',
'Symfony\Component\HttpKernel\KernelEvents',
'Symfony\Component\HttpKernel\Log\LoggerInterface',
'Symfony\Component\Process\Process',
'Symfony\Component\Routing\Exception\ExceptionInterface',
'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\UrlGeneratorInterface',
'Symfony\Component\Routing\Generator\UrlGenerator',
'Symfony\Component\Routing\Matcher\UrlMatcherInterface',
'Symfony\Component\Routing\Matcher\UrlMatcher',
'Symfony\Component\Routing\Matcher\RedirectableUrlMatcherInterface',
'Symfony\Component\Routing\Matcher\RedirectableUrlMatcher',
'Symfony\Component\Routing\RequestContextAwareInterface',
'Symfony\Component\Routing\RequestContext',
'Symfony\Component\Routing\Route',
'Symfony\Component\Routing\CompiledRoute',
'Symfony\Component\Routing\RouteCollection',
'Symfony\Component\Routing\RouteCompilerInterface',
'Symfony\Component\Routing\RouteCompiler',
'Symfony\Bridge\Twig\Extension\FormExtension',
'Symfony\Bridge\Twig\Extension\RoutingExtension',
'Symfony\Bridge\Twig\Extension\TranslationExtension',
'Symfony\Bridge\Twig\NodeVisitor\TranslationNodeVisitor',
'Symfony\Bridge\Twig\Node\FormThemeNode',
'Symfony\Bridge\Twig\Node\TransNode',
'Symfony\Bridge\Twig\TokenParser\TransTokenParser',
'Symfony\Bridge\Twig\TokenParser\FormThemeTokenParser',
'Symfony\Bridge\Twig\TokenParser\TransChoiceTokenParser',
'Pimple',
'Silex\Application',
'Silex\Controller',
'Silex\ControllerProviderInterface',
'Silex\ControllerCollection',
'Silex\ControllerResolver',
'Silex\ExceptionHandler',
'Silex\Exception\ControllerFrozenException',
'Silex\GetResponseForErrorEvent',
'Silex\LazyUrlMatcher',
'Silex\ServiceProviderInterface',
'Silex\Provider\SymfonyBridgesServiceProvider',
'Silex\Provider\TwigCoreExtension',
'Silex\Provider\TwigServiceProvider',
'Silex\Provider\UrlGeneratorServiceProvider',
'Silex\RedirectableUrlMatcher',
'Silex\SilexEvents',
'Silex\StringResponseConverter',
'Sismo\AnsiEscapeSequencesConverter',
'Sismo\Builder',
'Sismo\Project',
'Sismo\HTTPProject',
'Sismo\GithubProject',
'Sismo\Notifier',
'Sismo\GrowlNotifier',
'Sismo\BuildException',
'Sismo\Commit',
'Sismo\Contrib\XmppNotifier',
'Sismo\Contrib\GoogleTalkNotifier',
'Sismo\DBusNotifier',
'Sismo\GithubProject',
'Sismo\GrowlNotifier',
'Sismo\Notifier',
'Sismo\Project',
'Sismo\Sismo',
'Sismo\Storage',
);
@unlink(__DIR__.'/build/sismo.php');
$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.