refactor: 按目标名称区分函数与全局变量声明头文件

pull/1/head
韩天峰 3 months ago
parent 8a423d225e
commit af758ef130
  1. 2
      src/Php/CompilerBase.php
  2. 9
      src/Php/Translator.php

@ -155,8 +155,6 @@ class CompilerBase extends \PhpAot\Core\Translator
'phpx.h', 'phpx.h',
'phpx_helper.h', 'phpx_helper.h',
'phpx_func.h', 'phpx_func.h',
'php_func_decl.h',
'php_global_var_decl.h',
'php_aot_helper.h', 'php_aot_helper.h',
]; ];
protected array $localHeaders = []; protected array $localHeaders = [];

@ -779,8 +779,8 @@ CODE;
$job = $this->maxJob; $job = $this->maxJob;
// 生成所有函数声明、全局变量声明的头文件 // 生成所有函数声明、全局变量声明的头文件
$this->genFunctionDeclaration($this->getIncludeDir() . '/php_func_decl.h'); $this->genFunctionDeclaration($this->getIncludeDir() . "/php_{$this->targetName}_func_decl.h");
$this->genExternGlobalVars($this->getIncludeDir() . '/php_global_var_decl.h'); $this->genExternGlobalVars($this->getIncludeDir() . "/php_{$this->targetName}_global_var_decl.h");
// 生成扩展模块的源文件 // 生成扩展模块的源文件
$sourceFiles[] = $this->genExtension(); $sourceFiles[] = $this->genExtension();
@ -1133,7 +1133,10 @@ CODE;
public function genIncludeHeaderFiles(): string public function genIncludeHeaderFiles(): string
{ {
$headers = array_merge($this->globalHeaders, $this->localHeaders); $headers = array_merge($this->globalHeaders, [
"php_{$this->targetName}_func_decl.h",
"php_{$this->targetName}_global_var_decl.h",
], $this->localHeaders);
$lines = []; $lines = [];
foreach ($headers as $header) { foreach ($headers as $header) {
$lines[] = '#include <' . $header . '>'; $lines[] = '#include <' . $header . '>';

Loading…
Cancel
Save