Fix windows issues

pull/41/head
韩天峰 4 weeks ago
parent 2a1a11d1b5
commit b9ba0e84d5
  1. 2
      .gitignore
  2. 4
      src/Backend/Msvc.php
  3. 4
      src/Generator/ClosureGenerator.php
  4. 31
      src/Platform/Windows.php
  5. 6
      src/Transform/ConstantExpressionValidator.php
  6. 4
      src/compiler.php

2
.gitignore vendored

@ -18,6 +18,8 @@
*.exe
*.obj
*.pdb
*.lib
*.exp
*.class
/swoole_compiler
/tpc

@ -38,7 +38,7 @@ class Msvc extends CompilerBackend
{
$cmd = '';
$cmd .= ' /DZEND_WIN32 /DPHP_WIN32 /DZEND_DEBUG=0';
$cmd .= ' /utf-8 /DZEND_WIN32 /DPHP_WIN32 /DZEND_DEBUG=0 /DENABLE_INTSAFE_SIGNED_FUNCTIONS';
if (!empty($config['is_zts'])) {
$cmd .= ' /DZTS';
@ -288,7 +288,7 @@ class Msvc extends CompilerBackend
$cmd = '';
// 平台宏定义
$cmd .= ' /DZEND_WIN32 /DPHP_WIN32 /DZEND_DEBUG=0';
$cmd .= ' /utf-8 /DZEND_WIN32 /DPHP_WIN32 /DZEND_DEBUG=0 /DENABLE_INTSAFE_SIGNED_FUNCTIONS';
// ZTS
if ($this->platform instanceof Windows && $this->platform->isZts()) {

@ -174,7 +174,7 @@ trait ClosureGenerator
$this->addArgument($var, Type::VAR);
}
if ($this->methodDef) {
if ($this->methodDef && !$expr->static) {
$this->addArgument('this_', Type::OBJECT);
}
@ -211,7 +211,7 @@ trait ClosureGenerator
$this->context = $oriContext;
$this->context->beforeStmtLines[] = $code;
if ($this->methodDef) {
if ($this->methodDef && !$expr->static) {
return 'php::newClosure(' . $tmpVar . ', { ' . implode(', ', $useVars) . ' }, this_)';
} else {
return 'php::newClosure(' . $tmpVar . ', { ' . implode(', ', $useVars) . ' })';

@ -177,10 +177,6 @@ class Windows extends PlatformBase
public function getBuildLibraryWarnings(string $phpDir, string $phpxDir, string $buildMode): array
{
if ($buildMode !== 'bin' && $buildMode !== 'lib') {
return [];
}
$warnings = [];
$phpDirs = [
$phpDir . '\SDK\lib',
@ -201,10 +197,30 @@ class Windows extends PlatformBase
];
}
if (!is_file($phpxDir . '\lib\phpx.lib') && !is_file($phpxDir . '\lib\phpx.dll')) {
$phpxLibPath = $phpxDir . '\lib\phpx.lib';
if (!is_file($phpxLibPath)) {
$warnings[] = [
'warning' => 'The PHPX import library was not found at: ' . $phpxLibPath,
'info' => 'Create the PHPX lib directory, reconfigure CMake if needed, then rebuild the phpx target',
];
}
$phpxDllPaths = [
$phpxDir . '\build\phpx.dll',
$phpxDir . '\lib\phpx.dll',
$phpxDir . '\phpx.dll',
];
$hasPhpxDll = false;
foreach ($phpxDllPaths as $phpxDllPath) {
if (is_file($phpxDllPath)) {
$hasPhpxDll = true;
break;
}
}
if (!$hasPhpxDll) {
$warnings[] = [
'warning' => 'The `phpx.lib` or `phpx.dll` is not found in PHX directory',
'info' => 'Note: If you are building an extension (-m ext), this is OK. For binary mode, please run `make` to build it',
'warning' => 'The PHPX runtime library `phpx.dll` was not found under: ' . $phpxDir,
'info' => 'Reconfigure CMake if needed, then rebuild the phpx target',
];
}
@ -292,6 +308,7 @@ class Windows extends PlatformBase
$phpDirs = [
$phpDir . '\\SDK\\lib',
$phpDir . '\\lib',
$phpDir,
];
$embedLibPath = '';

@ -321,11 +321,7 @@ final class ConstantExpressionValidator
private function tryEvaluate(Expr $expression): array
{
try {
$value = (new ConstExprEvaluator(
static function (): never {
throw new \LogicException('Expression is not statically known');
},
))->evaluateDirectly($expression);
$value = (new ConstExprEvaluator())->evaluateDirectly($expression);
return [true, $value];
} catch (\Throwable) {
return [false, null];

@ -3,6 +3,10 @@ use TypePhp\Translator;
function main(int $argc, array $argv): void
{
// Compiling a complete project keeps the parsed AST and generated sources in
// memory. The default CLI limit (commonly 128M) is too small for larger builds.
ini_set('memory_limit', '-1');
if (!defined('ROOT_PATH')) {
define("ROOT_PATH", getcwd());
}

Loading…
Cancel
Save