TypePHP 编译器 https://swoole.com/aot/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

24 lines
644 B

#!/usr/bin/env php
<?php
require __DIR__ . '/bootstrap.php';
use PhpAot\Php\Translator;
if (empty($argv[1])) {
die("php compiler.php [file]\n");
}
$file = $argv[1];
$translator = new Translator(ROOT_PATH);
$translator->setIndent(' ');
$code = $translator->convert($file);
$info = pathinfo($file);
$cppFile = $info['dirname'] . '/' . $info['filename'] . '.cc';
$translator->save($code, $cppFile);
$translator->compileFile($cppFile);
$objectFile = $info['dirname'] . '/' . $info['filename'] . '.cc.o';
if (!is_file($objectFile)) {
throw new Exception("compile error");
}
$translator->compileBinary($info['filename'], $objectFile);