refactor(php): 简化配置项读取逻辑

- 移除对下划线格式配置键的支持,统一使用中横线格式
- 更新 cxx-flags 配置项读取方式
- 更新 cxx-std 配置项读取方式
- 更新 ld-flags 配置项读取方式
- 更新 link-libs 配置项读取方式
- 更新 link-paths 配置项读取方式
- 更新 cpp-compiler 配置项读取方式
pull/3/head
韩天峰 2 months ago
parent 02a91bba95
commit 8f3f3e73eb
  1. 24
      src/Php/Translator.php

@ -1865,8 +1865,8 @@ CODE;
$list = $this->getFilesFromDir($projectDir); $list = $this->getFilesFromDir($projectDir);
} }
// 读取 cxx-flags(支持中横线和下划线) // 读取 cxx-flags
$cxxFlags = $cfg['cxx-flags'] ?? $cfg['cxxflags'] ?? null; $cxxFlags = $cfg['cxx-flags'] ?? null;
if (!empty($cxxFlags)) { if (!empty($cxxFlags)) {
if (is_array($cxxFlags)) { if (is_array($cxxFlags)) {
$this->cxxFlags = implode(' ', $cxxFlags); $this->cxxFlags = implode(' ', $cxxFlags);
@ -1875,14 +1875,14 @@ CODE;
} }
} }
// 读取 C++ 标准版本(支持中横线和下划线) // 读取 cxx-std
$cxxStd = $cfg['cxx-std'] ?? $cfg['cxx_std'] ?? null; $cxxStd = $cfg['cxx-std'] ?? null;
if (!empty($cxxStd)) { if (!empty($cxxStd)) {
$this->cxxStd = $cxxStd; $this->cxxStd = $cxxStd;
} }
// 读取 ldflags(支持中横线和下划线) // 读取 ld-flags
$ldflags = $cfg['ld-flags'] ?? $cfg['ldflags'] ?? null; $ldflags = $cfg['ld-flags'] ?? null;
if (!empty($ldflags)) { if (!empty($ldflags)) {
if (is_array($ldflags)) { if (is_array($ldflags)) {
$this->ldflags = implode(' ', $ldflags); $this->ldflags = implode(' ', $ldflags);
@ -1891,16 +1891,16 @@ CODE;
} }
} }
// 读取 link-libs(支持中横线和下划线) // 读取 link-libs
$linkLibs = $cfg['link-libs'] ?? $cfg['link_libs'] ?? null; $linkLibs = $cfg['link-libs'] ?? null;
if (!empty($linkLibs) && is_array($linkLibs)) { if (!empty($linkLibs) && is_array($linkLibs)) {
foreach ($linkLibs as $lib) { foreach ($linkLibs as $lib) {
$this->linkLibs[] = (string)$lib; $this->linkLibs[] = (string)$lib;
} }
} }
// 读取 link-paths(支持中横线和下划线) // 读取 link-paths
$linkPaths = $cfg['link-paths'] ?? $cfg['link_paths'] ?? null; $linkPaths = $cfg['link-paths'] ?? null;
if (!empty($linkPaths) && is_array($linkPaths)) { if (!empty($linkPaths) && is_array($linkPaths)) {
foreach ($linkPaths as $path) { foreach ($linkPaths as $path) {
$this->linkPaths[] = (string)$path; $this->linkPaths[] = (string)$path;
@ -1912,8 +1912,8 @@ CODE;
$this->setTargetName($cfg['name']); $this->setTargetName($cfg['name']);
} }
// 读取 cpp-compiler(支持中横线和下划线) // 读取 cpp-compiler
$cppCompiler = $cfg['cpp-compiler'] ?? $cfg['cpp_compiler'] ?? null; $cppCompiler = $cfg['cpp-compiler'] ?? null;
if (!empty($cppCompiler)) { if (!empty($cppCompiler)) {
$this->setCppCompiler($cppCompiler); $this->setCppCompiler($cppCompiler);
} }

Loading…
Cancel
Save