Skip to content
Permalink
Browse files

Compile everything into one PHP file

  • Loading branch information...
apeschar committed Sep 25, 2019
1 parent d16dbc0 commit e961ec1b5b4e3ff6d3e1e879916ee86e8984c021
@@ -1,3 +1,5 @@
/build
/dist
/docker/*.image
/node_modules
/vendor
@@ -2,7 +2,7 @@ PHP56 = docker run -it -v $(shell pwd):/data -w /data $(shell cat docker/php56.i
PHP56MIN = docker run -it -v $(shell pwd):/data -w /data $(shell cat docker/php56-min.image)


.PHONY : all test test-local update docker dist clean
.PHONY : all test test-local dist build clean


all : vendor/autoload.php
@@ -14,14 +14,20 @@ test : all docker/php56.image docker/php56-min.image
test-local : all
vendor/bin/phpunit

update : all
composer update

dist : all
bin/package

build : build/phast.php build/cacert.pem

build/phast.php : vendor/autoload.php
mkdir -p $(dir $@)
bin/compile > $@

build/cacert.pem : src/HTTP/cacert.pem
cp $< $@

clean :
rm -f docker/*.image
rm -rf build


vendor/autoload.php : composer.json composer.lock
@@ -0,0 +1,10 @@
#!/usr/bin/env php
<?php
require_once __DIR__ . '/../vendor/autoload.php';
if (!chdir(__DIR__ . '/..')) {
throw new RuntimeException("Could not change dir into project root");
}
echo (new Kibo\Phast\Build\Compiler())->run();
@@ -3,7 +3,7 @@
set -euo pipefail
cd "$(dirname "$0")/.."

file="certificates/mozilla-cacert.pem"
file="src/HTTP/cacert.pem"

wget -O "$file~" "https://curl.haxx.se/ca/cacert.pem"
mv "$file~" "$file"
@@ -5,13 +5,14 @@
"license": "AGPL-3.0-or-later",
"require": {
"php": ">=5.6",
"mrclay/jsmin-php": "2.3.2",
"mrclay/jsmin-php": "^2.3.2",
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "5.7.*",
"facebook/webdriver": "^1.5",
"ext-dom": "*"
"ext-dom": "*",
"nikic/php-parser": "^3.1"
},
"autoload": {
"psr-4": {

Some generated files are not rendered by default. Learn more.

@@ -0,0 +1,5 @@
{
"dependencies": {
"uglify-js": "^3.6.0"
}
}
@@ -0,0 +1,27 @@
<?php
namespace Kibo\Phast\Build;
use PhpParser\PrettyPrinter;
class ASCIIPrettyPrinter extends PrettyPrinter\Standard {
protected function escapeString($string, $quote) {
if (null === $quote) {
// For doc strings, don't escape newlines
$escaped = addcslashes($string, "\t\f\v$\\");
} else {
$escaped = addcslashes($string, "\n\r\t\f\v$" . $quote . "\\");
}
// Escape other control characters
return preg_replace_callback('/([^\x20-\x7F])(?=([0-7]?))/', function ($matches) {
$oct = decoct(ord($matches[1]));
if ($matches[2] !== '') {
// If there is a trailing digit, use the full three character form
return '\\' . str_pad($oct, 3, '0', STR_PAD_LEFT);
}
return '\\' . $oct;
}, $escaped);
}
}

0 comments on commit e961ec1

Please sign in to comment.
You can’t perform that action at this time.