@flun/nodejs-mobile-gyp 1.1.3 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/CHANGELOG.md +7 -25
  2. package/LICENSE +9 -4
  3. package/README.md +198 -132
  4. package/addon.gypi +1 -1
  5. package/bin/node-gyp.js +6 -5
  6. package/gyp/README.md +5 -3
  7. package/gyp/data/win/large-pdb-shim.cc +1 -1
  8. package/gyp/gyp +1 -1
  9. package/gyp/gyp.bat +1 -1
  10. package/gyp/gyp_main.py +1 -1
  11. package/gyp/pylib/gyp/MSVSNew.py +1 -1
  12. package/gyp/pylib/gyp/MSVSProject.py +1 -1
  13. package/gyp/pylib/gyp/MSVSSettings.py +1 -1
  14. package/gyp/pylib/gyp/MSVSToolFile.py +1 -1
  15. package/gyp/pylib/gyp/MSVSUserFile.py +1 -1
  16. package/gyp/pylib/gyp/MSVSUtil.py +1 -1
  17. package/gyp/pylib/gyp/MSVSVersion.py +1 -1
  18. package/gyp/pylib/gyp/__init__.py +1 -1
  19. package/gyp/pylib/gyp/common.py +1 -1
  20. package/gyp/pylib/gyp/easy_xml.py +1 -1
  21. package/gyp/pylib/gyp/flock_tool.py +1 -1
  22. package/gyp/pylib/gyp/generator/analyzer.py +1 -1
  23. package/gyp/pylib/gyp/generator/android.py +1 -1
  24. package/gyp/pylib/gyp/generator/cmake.py +1 -1
  25. package/gyp/pylib/gyp/generator/compile_commands_json.py +1 -1
  26. package/gyp/pylib/gyp/generator/dump_dependency_json.py +1 -1
  27. package/gyp/pylib/gyp/generator/eclipse.py +1 -1
  28. package/gyp/pylib/gyp/generator/gypd.py +1 -1
  29. package/gyp/pylib/gyp/generator/gypsh.py +1 -1
  30. package/gyp/pylib/gyp/generator/make.py +23 -12
  31. package/gyp/pylib/gyp/generator/msvs.py +3 -3
  32. package/gyp/pylib/gyp/generator/ninja.py +1 -1
  33. package/gyp/pylib/gyp/generator/xcode.py +1 -1
  34. package/gyp/pylib/gyp/input.py +1 -1
  35. package/gyp/pylib/gyp/mac_tool.py +1 -1
  36. package/gyp/pylib/gyp/msvs_emulation.py +1 -1
  37. package/gyp/pylib/gyp/ninja_syntax.py +1 -1
  38. package/gyp/pylib/gyp/simple_copy.py +1 -1
  39. package/gyp/pylib/gyp/win_tool.py +1 -1
  40. package/gyp/pylib/gyp/xcode_emulation.py +5 -5
  41. package/gyp/pylib/gyp/xcode_ninja.py +1 -1
  42. package/gyp/pylib/gyp/xcodeproj_file.py +1 -1
  43. package/gyp/pylib/gyp/xml_fix.py +1 -1
  44. package/gyp/pylib/packaging/LICENSE +1 -1
  45. package/gyp/pylib/packaging/LICENSE.APACHE +1 -1
  46. package/gyp/pylib/packaging/LICENSE.BSD +1 -1
  47. package/gyp/pylib/packaging/__init__.py +1 -1
  48. package/gyp/pylib/packaging/_elffile.py +1 -1
  49. package/gyp/pylib/packaging/_manylinux.py +1 -1
  50. package/gyp/pylib/packaging/_musllinux.py +1 -1
  51. package/gyp/pylib/packaging/_parser.py +1 -1
  52. package/gyp/pylib/packaging/_structures.py +1 -1
  53. package/gyp/pylib/packaging/_tokenizer.py +1 -1
  54. package/gyp/pylib/packaging/markers.py +1 -1
  55. package/gyp/pylib/packaging/metadata.py +1 -1
  56. package/gyp/pylib/packaging/requirements.py +1 -1
  57. package/gyp/pylib/packaging/specifiers.py +1 -1
  58. package/gyp/pylib/packaging/tags.py +1 -1
  59. package/gyp/pylib/packaging/utils.py +1 -1
  60. package/gyp/pylib/packaging/version.py +1 -1
  61. package/lib/Find-VisualStudio.cs +1 -1
  62. package/lib/build.js +16 -16
  63. package/lib/clean.js +2 -2
  64. package/lib/configure.js +20 -17
  65. package/lib/create-config-gypi.js +8 -8
  66. package/lib/download.js +3 -3
  67. package/lib/find-node-directory.js +9 -9
  68. package/lib/find-python.js +14 -14
  69. package/lib/find-visualstudio.js +19 -19
  70. package/lib/install.js +22 -21
  71. package/lib/list.js +1 -1
  72. package/lib/log.js +2 -2
  73. package/lib/node-gyp.js +7 -7
  74. package/lib/process-release.js +14 -14
  75. package/lib/rebuild.js +1 -1
  76. package/lib/remove.js +2 -2
  77. package/lib/util.js +5 -4
  78. package/package.json +1 -1
  79. package/src/win_delay_load_hook.cc +1 -1
package/CHANGELOG.md CHANGED
@@ -1,34 +1,16 @@
1
1
  # 变更日志
2
2
 
3
+ ## [1.1.4] - 2026-10-24 09:20
4
+ ### 优化
5
+ - 项目标点已改为以英文标点为主;
6
+ - 行宽改为以 123 为主,部分超宽表格改为了列表;
7
+
3
8
  ## [1.1.3] - 2026-10-20 13:55
4
9
  ### 修复
5
10
  - 一些细节优化
6
11
 
7
12
  ## [1.1.2] - 2026-09-28 21:49
8
-
9
13
  ### 修复
10
14
 
11
- - **action 目标的路径分隔符**:`make.py` 中 `self.output` 由 `ComputeOutput` 产出,Windows 上带反斜杠(如 `$(obj).target\../node-addon-api\foo.stamp`),导致 `sh` 把 `\.` 当转义、目录不存在。现统一转正斜杠;非 Windows 平台为 no-op。
12
-
13
- ## [1.1.1] - 2026-09-28 09:23
14
-
15
- ### 修复
16
-
17
- - **Windows 路径分隔符**:gyp 生成的 Makefile 中,`Absolutify` 与 `self.output` 产出的路径带 Windows 反斜杠(如 `src\bufferutil.o`),导致 `sh` / `sed` / `make` 解析失败。现在统一转成正斜杠;该改动在非 Windows 平台上是 no-op。
18
- - **`mkdir` 目标路径**:`mkdir -p "$(dir $@)"` 在 Windows 上因路径尾部反斜杠被 `sh` 当转义符,导致目录未创建、编译器无法写产物。新增 `slashpath` 辅助函数,把路径转正斜杠后再传给 `mkdir`。
19
- - **超长路径依赖**:Windows 下 Makefile 会因 gypi 依赖路径超过 260 字符而报 `No rule to make target`。现在过滤掉 `node_modules` 中的此类依赖——仅影响 Makefile 自动重新生成,不影响编译。
20
-
21
- ### 文档
22
-
23
- 全面核对并修正 README,消除前后矛盾、过时表述与硬编码:
24
-
25
- - **系统要求**:
26
- - iOS 构建前置工具从「Command Line Tools」修正为「**完整 Xcode**」——`xcodebuild` 必须完整 Xcode,CLT 单独不够;
27
- - Visual Studio 从「仅 VS2026」放宽为「**VS2019 / VS2022 / VS2026**」——VS2017 及更早受 Node 版本上限限制,故不在支持范围;VS2026 为已验证版本;
28
- - Android NDK 从「27.x」修正为「**23–27**」,与实测验证范围一致;
29
- - Git for Windows 的说明从「提供 `sh.exe` / `printf` / `xargs`」扩写为「**自带整套 MSYS2 POSIX 工具集**」,避免读者低估其必要性。
30
- - **自动探测**:
31
- - 「无需手动配置」改为「**无需手动指定路径**(前提:工具已安装)」,区分「必须安装」与「位置自动定位」;
32
- - 「POSIX shell(`sh.exe`)」项改为「**Git for Windows 的 `usr/bin` 目录**(以 `sh.exe` 是否存在作为判据)」,与实际探测逻辑一致。
33
- - **顶部引言**:适用范围从仅官方 `nodejs-mobile` 改为「官方及兼容的社区发行版(如 OpenFlun/nodejs-mobile)」。
34
- - 修正若干失效链接。
15
+ - **action 目标的路径分隔符**:`make.py` 中 `self.output` 由 `ComputeOutput` 产出,Windows 上带反斜杠(如
16
+ `$(obj).target\../node-addon-api\foo.stamp`),导致 `sh` 把 `\.` 当转义、目录不存在;现统一转正斜杠;非 Windows 平台为 no-op;
package/LICENSE CHANGED
@@ -1,12 +1,17 @@
1
1
  ISC 许可证 (ISC License)
2
2
 
3
- 版权所有 (c) 2026, flun <open@flun.top>
3
+ Copyright (c) 2026, flun <open@flun.top>
4
4
 
5
- 特此免费授予任何获得本软件及相关文档文件(“软件”)副本的人,不受限制地处理本软件的权利,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售本软件副本的权利,并允许向其提供本软件的人这样做,但须满足以下条件:
5
+ 特此免费授予任何获得本软件及相关文档文件("软件")副本的人,不受限制地处理本软件的权利,
6
+ 包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售本软件副本的权利,
7
+ 并允许向其提供本软件的人这样做,但须满足以下条件:
6
8
 
7
9
  上述版权声明和本许可声明应包含在本软件的所有副本或重要部分中;
8
10
 
9
- 本软件按“原样”提供,不作任何形式的明示或暗示的保证,包括但不限于适销性、特定用途的适用性和不侵权的保证;在任何情况下,作者或版权持有人均不对因本软件或本软件的使用或其他交易而产生的任何索赔、损害或其他责任负责,无论是合同之诉、侵权之诉还是其他行为之诉;
11
+ 本软件按"原样"提供,不作任何形式的明示或暗示的保证,
12
+ 包括但不限于适销性、特定用途的适用性和不侵权的保证;
13
+ 在任何情况下,作者或版权持有人均不对因本软件或本软件的使用或其它交易而产生的
14
+ 任何索赔、损害或其它责任负责,无论是合同之诉、侵权之诉还是其它行为之诉;
10
15
 
11
16
  ---
12
17
 
@@ -26,4 +31,4 @@ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
26
31
  ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
27
32
  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
28
33
  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
29
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
34
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -1,18 +1,22 @@
1
1
  # @flun/nodejs-mobile-gyp
2
2
 
3
- 移动端 Node.js 原生模块(Native Addon)的交叉编译工具。
3
+ 移动端 Node.js 原生模块(Native Addon)的交叉编译工具;
4
4
 
5
- 用于为 nodejs-mobile 环境编译 C/C++ 原生模块,支持 Android 与 iOS 的交叉编译。适用于官方 [nodejs-mobile](https://github.com/nodejs-mobile/nodejs-mobile) 及兼容的社区发行版(如 [OpenFlun/nodejs-mobile](https://github.com/OpenFlun/nodejs-mobile))。
5
+ 用于为 nodejs-mobile 环境编译 C/C++ 原生模块,支持 Android 与 iOS 的交叉编译;
6
+ 适用于官方 [nodejs-mobile](https://github.com/nodejs-mobile/nodejs-mobile) 及兼容的社区发行版
7
+ (如 [OpenFlun/nodejs-mobile](https://github.com/OpenFlun/nodejs-mobile));
6
8
 
7
- 宿主平台支持 **Windows** / **macOS** / **Linux**,各平台所需的环境与工具见「[支持的系统与配置要求](#支持的系统与配置要求)」。
9
+ 宿主平台支持 **Windows** / **macOS** / **Linux**,各平台所需的环境与工具见"[支持的系统与配置要求](#支持的系统与配置要求)";
8
10
 
9
- [`@flun/nodejs-mobile-react-native`](https://www.npmjs.com/package/@flun/nodejs-mobile-react-native) 在构建时会自动调用本包,无需手动安装。
11
+ [`@flun/nodejs-mobile-react-native`](https://www.npmjs.com/package/@flun/nodejs-mobile-react-native)
12
+ 在构建时会自动调用本包,无需手动安装;
10
13
 
11
- 本包是 [`nodejs-mobile-gyp`](https://github.com/nodejs-mobile/nodejs-mobile-gyp) 的 flun fork,后者又基于上游 [`node-gyp`](https://github.com/nodejs/node-gyp)。
14
+ 本包是 [`nodejs-mobile-gyp`](https://github.com/nodejs-mobile/nodejs-mobile-gyp) 的 flun fork,后者又基于上游
15
+ [`node-gyp`](https://github.com/nodejs/node-gyp);
12
16
 
13
- - GitHub:https://github.com/OpenFlun/nodejs-mobile-gyp
17
+ - GitHub:https://github.com/OpenFlun/nodejs-mobile-gyp
14
18
  - gitee: https://gitee.com/OpenFlun/nodejs-mobile-gyp
15
- - npm:https://www.npmjs.com/package/@flun/nodejs-mobile-gyp
19
+ - npm:https://www.npmjs.com/package/@flun/nodejs-mobile-gyp
16
20
 
17
21
  ## 项目结构
18
22
 
@@ -20,30 +24,30 @@
20
24
  @flun/nodejs-mobile-gyp/
21
25
  │
22
26
  ├── bin/
23
- │ └── node-gyp.js # CLI 入口(#!/usr/bin/env node),创建 Gyp 实例并依次执行命令队列
27
+ │ └── node-gyp.js # CLI 入口(#!/usr/bin/env node),创建 Gyp 实例并依次执行命令队列
24
28
  │
25
- ├── lib/ # 核心实现,全部为 ESM
26
- │ ├── node-gyp.js # Gyp 主类:参数解析、命令分发、usage 生成
27
- │ ├── build.js # build 命令:调用 make / msbuild 编译原生模块
28
- │ ├── clean.js # clean 命令:删除 build 目录
29
- │ ├── configure.js # configure 命令:下载 headers、生成 config.gypi 与工程文件
30
- │ ├── rebuild.js # rebuild 命令:依次执行 clean + configure + build
31
- │ ├── install.js # install 命令:下载并解压指定版本的 Node 开发文件
32
- │ ├── remove.js # remove 命令:删除指定版本的 Node 开发文件
33
- │ ├── list.js # list 命令:列出已安装的 Node 开发文件版本
34
- │ ├── create-config-gypi.js # 生成 config.gypi;Windows 上强制 MSVC 工具集、关闭 LTO
29
+ ├── lib/ # 核心实现,全部为 ESM
30
+ │ ├── node-gyp.js # Gyp 主类:参数解析、命令分发、usage 生成
31
+ │ ├── build.js # build 命令:调用 make / msbuild 编译原生模块
32
+ │ ├── clean.js # clean 命令:删除 build 目录
33
+ │ ├── configure.js # configure 命令:下载 headers、生成 config.gypi 与工程文件
34
+ │ ├── rebuild.js # rebuild 命令:依次执行 clean + configure + build
35
+ │ ├── install.js # install 命令:下载并解压指定版本的 Node 开发文件
36
+ │ ├── remove.js # remove 命令:删除指定版本的 Node 开发文件
37
+ │ ├── list.js # list 命令:列出已安装的 Node 开发文件版本
38
+ │ ├── create-config-gypi.js # 生成 config.gypi;Windows 上强制 MSVC 工具集、关闭 LTO
35
39
  │ ├── process-release.js # 解析下载 URL、本地目录名、headers 与 node.lib 地址
36
40
  │ ├── download.js # 基于 make-fetch-happen 的 HTTP 下载与 CA 读取
37
- │ ├── find-node-directory.js # 推断 Node 安装根目录(用于 AIX / zOS)
38
- │ ├── find-python.js # PythonFinder 类:动态定位 Python 3.6+(py 启动器 / 目录扫描)
39
- │ ├── find-visualstudio.js # VisualStudioFinder 类:定位可用的 VS 安装(VS2013+,含 VS2026)
40
- │ ├── Find-VisualStudio.cs # PowerShell 调用的 C# 脚本,枚举 VS 安装信息
41
- │ ├── log.js # Logger 类 + proc-log 包装,分级着色日志
42
- │ └── util.js # 通用工具:execFile 包装、注册表读取、候选文件查找
41
+ │ ├── find-node-directory.js # 推断 Node 安装根目录(用于 AIX / zOS)
42
+ │ ├── find-python.js # PythonFinder 类:动态定位 Python 3.6+(py 启动器 / 目录扫描)
43
+ │ ├── find-visualstudio.js # VisualStudioFinder 类:定位可用的 VS 安装(VS2013+,含 VS2026)
44
+ │ ├── Find-VisualStudio.cs # PowerShell 调用的 C# 脚本,枚举 VS 安装信息
45
+ │ ├── log.js # Logger 类 + proc-log 包装,分级着色日志
46
+ │ └── util.js # 通用工具:execFile 包装、注册表读取、候选文件查找
43
47
  │
44
- ├── gyp/ # 内置的 gyp 工具(Python)
45
- │ ├── gyp # Python 启动脚本(Unix)
46
- │ ├── gyp.bat # Python 启动脚本(Windows)
48
+ ├── gyp/ # 内置的 gyp 工具(Python)
49
+ │ ├── gyp # Python 启动脚本(Unix)
50
+ │ ├── gyp.bat # Python 启动脚本(Windows)
47
51
  │ ├── gyp_main.py # gyp 主入口
48
52
  │ ├── LICENSE # gyp 自身的许可证
49
53
  │ ├── pylib/gyp/ # gyp 核心 Python 模块
@@ -54,156 +58,185 @@
54
58
  │ │ ├── xcode*.py # Xcode 工程生成
55
59
  │ │ ├── mac_tool.py # macOS 工具链
56
60
  │ │ ├── win_tool.py # Windows 工具链
57
- │ │ └── generator/ # 各类生成器后端(make / msvs / ninja / xcode / cmake ...)
58
- │ ├── pylib/packaging/ # gyp 依赖的 Python packaging 库(vendored)
61
+ │ │ └── generator/ # 各类生成器后端(make / msvs / ninja / xcode / cmake ...)
62
+ │ ├── pylib/packaging/ # gyp 依赖的 Python packaging 库(vendored)
59
63
  │ └── data/win/
60
64
  │ └── large-pdb-shim.cc # Windows 大 PDB 兼容编译单元
61
65
  │
62
66
  ├── src/
63
- │ └── win_delay_load_hook.cc # Windows 加载延迟钩子(编译进每个原生模块)
67
+ │ └── win_delay_load_hook.cc # Windows 加载延迟钩子(编译进每个原生模块)
64
68
  │
65
69
  ├── addon.gypi # 所有原生模块共用的 gyp 配置
66
- ├── package.json # type: module,bin 命令名为 nodejs-mobile-gyp
67
- ├── LICENSE # 本包许可证(ISC)
70
+ ├── package.json # type: module,bin 命令名为 nodejs-mobile-gyp
71
+ ├── LICENSE # 本包许可证(ISC)
68
72
  ├── README.md # 本文件
69
73
  ├── CHANGELOG.md # 版本变更记录
70
74
  ├── .gitignore # Git 忽略规则
71
75
  ├── .npmignore # npm 发布排除规则
72
76
  ├── .gitattributes # Git 换行符 / 二进制标记
73
- └── macOS_Catalina_acid_test.sh # macOS Catalina 兼容性验证脚本(仅本地开发,不随包发布)
77
+ └── macOS_Catalina_acid_test.sh # macOS Catalina 兼容性验证脚本(仅本地开发,不随包发布)
74
78
  ```
75
79
 
76
80
  ## 本 fork 的改动
77
81
 
78
- 本 fork 在功能上与原版 `nodejs-mobile-gyp` 一致,做了以下改造。
82
+ 本 fork 在功能上与原版 `nodejs-mobile-gyp` 一致,做了以下改造;
79
83
 
80
84
  ### 代码风格
81
85
 
82
86
  | 项 | 原版 | 本 fork |
83
87
  | -------- | ----------------------- | --------------------------------------------- |
84
- | 模块系统 | CommonJS | **ESM**(`package.json` 的 `type: "module"`) |
88
+ | 模块系统 | CommonJS | **ESM**(`package.json` 的 `type: "module"`) |
85
89
  | 导出方式 | 文件内 `module.exports` | **末尾统一 `export { ... }`** |
86
- | 函数声明 | `async function xxx` | `const xxx = async () =>`(`class` 保留) |
90
+ | 函数声明 | `async function xxx` | `const xxx = async () =>`(`class` 保留) |
87
91
  | 注释 | 英文 | 中文 |
88
92
 
89
93
  ### 依赖升级
90
94
 
91
95
  | 包 | 原版 | 本 fork | 原因 |
92
96
  | ------------------- | ---------- | --------- | -------------------------------------------- |
93
- | `tar` | `^6.1.2` | `^7.5.22` | 上游 v6 停更,有安全公告 |
97
+ | `tar` | `^6.1.2` | `^7.5.22` | 上游 v6 停更,有安全公告 |
94
98
  | `glob` | `^10.3.10` | `^13.0.6` | 上游 v10 停更 |
95
- | `make-fetch-happen` | `^13.0.0` | `^16.0.1` | 连带升级 `cacache`,去掉 `tar@6` / `glob@10` |
99
+ | `make-fetch-happen` | `^13.0.0` | `^16.0.1` | 连带升级 `cacache`,去掉 `tar@6` / `glob@10` |
96
100
 
97
- 升级后依赖树干净,`npm audit` 0 vulnerabilities。
101
+ 升级后依赖树干净,`npm audit` 0 vulnerabilities;
98
102
 
99
103
  ### Windows 构建适配
100
104
 
101
- 原版 `nodejs-mobile-gyp` 在 Windows 上有若干问题,本 fork 逐一解决,涉及三方面。
105
+ 原版 `nodejs-mobile-gyp` 在 Windows 上有若干问题,本 fork 逐一解决,涉及三方面;
102
106
 
103
107
  #### 1. 工具集与 LTO
104
108
 
105
- 原版默认走 ClangCL 工具集,且继承 Node 官方二进制的 LTO 配置。Node.js 24+ 官方二进制由 ClangCL + ThinLTO 编译,其 `common.gypi` 会在 `clang==1` 时把 MSBuild 工具集设为 `ClangCL`,并在 `enable_lto==true` / `enable_thin_lto==true` 时向链接器传入 `-flto=thin`、`/opt:lldltojobs` 等 Clang 专用参数。若用户本机没装 ClangCL,或用的是传统 MSVC 工具链,会报:
109
+ 原版默认走 ClangCL 工具集,且继承 Node 官方二进制的 LTO 配置;Node.js 24+ 官方二进制由 ClangCL + ThinLTO 编译,其
110
+ `common.gypi` 会在 `clang==1` 时把 MSBuild 工具集设为 `ClangCL`,并在 `enable_lto==true` / `enable_thin_lto==true`
111
+ 时向链接器传入 `-flto=thin`、`/opt:lldltojobs` 等 Clang 专用参数;若用户本机没装 ClangCL,或用的是传统 MSVC 工具链,会报:
106
112
 
107
113
  - `MSB8020: 无法找到 ClangCL 的生成工具`
108
114
  - `LNK1117: 选项"opt:lldltojobs=2"中的语法错误`
109
115
 
110
- 本 fork 强制走 MSVC 工具集并关闭 LTO,避免上述报错。工具集版本从 `find-visualstudio` 的探测结果**动态获取**(`v140` / `v141` / `v142` / `v143` / `v145`...),不写死。
116
+ 本 fork 强制走 MSVC 工具集并关闭 LTO,避免上述报错;工具集版本从 `find-visualstudio` 的探测结果**动态获取**(`v140` / `v141`
117
+ / `v142` / `v143` / `v145`...),不写死;
111
118
 
112
119
  #### 2. GNU make 的 POSIX 环境
113
120
 
114
- Android 原生模块通过 GNU make 构建,其 Makefile 会调用 `printf`、`xargs`、`sed` 等 Unix 命令。GNU make 需要一个 POSIX shell(`sh.exe`)来执行它们;Windows 上若无,会直接报 `CreateProcess(NULL, printf ...) failed`。Git for Windows 自带整套 POSIX 工具集;本 fork 会自动定位其 `usr/bin` 并前置到 PATH,详见「[支持的系统与配置要求](#支持的系统与配置要求) → 自动探测」。
121
+ Android 原生模块通过 GNU make 构建,其 Makefile 会调用 `printf`、`xargs`、`sed` 等 Unix 命令;GNU make 需要一个 POSIX
122
+ shell(`sh.exe`)来执行它们;Windows 上若无,会直接报 `CreateProcess(NULL, printf ...) failed`;Git for Windows 自带整套 POSIX
123
+ 工具集;本 fork 会自动定位其 `usr/bin` 并前置到 PATH,详见"[支持的系统与配置要求](#支持的系统与配置要求) → 自动探测";
115
124
 
116
125
  #### 3. 路径分隔符
117
126
 
118
- gyp 生成的 Makefile 中,路径原本会带上 Windows 的反斜杠(如 `src\bufferutil.o`),导致 `sh` / `sed` / `make` 解析失败。本 fork 在 gyp 的路径生成环节统一转成正斜杠;该改动在非 Windows 平台上是 no-op。
127
+ gyp 生成的 Makefile 中,路径原本会带上 Windows 的反斜杠(如 `src\bufferutil.o`),导致 `sh` / `sed` / `make` 解析失败;本 fork
128
+ 在 gyp 的路径生成环节统一转成正斜杠;该改动在非 Windows 平台上是 no-op;
119
129
 
120
130
  ### 具体改动清单
121
131
 
122
132
  #### 构建工具链
123
133
 
124
- | 文件 | 改动 |
125
- | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
126
- | `lib/create-config-gypi.js` | 生成 `config.gypi` 时把 `clang` 置 0、`enable_lto` / `enable_thin_lto` 置 `'false'`、`lto_jobs` 置空,避免 `common.gypi` 切到 ClangCL 并向 MSVC 传 LTO 参数 |
127
- | `lib/configure.js` | 调用 gyp 时追加 `-Gmsvs_toolset=<探测到的 toolset>`,不再写死 `v145` |
128
- | `lib/find-visualstudio.js` | 支持 VS2013+,含最新 VS2026(版本号 18,`versionYear=2026`,toolset `v145`) |
129
- | `gyp/pylib/gyp/MSVSSettings.py` | 注册 `ExternalWarningLevel`(MSBuild 属性),供 `addon.gypi` 使用 |
130
- | `addon.gypi` | Windows 下追加 `/external:anglebrackets` + `ExternalWarningLevel: TurnOffAllWarnings`,只静音外部头(Node / V8)的警告 |
134
+ - `lib/create-config-gypi.js`
135
+ - 改动:生成 `config.gypi` 时把 `clang` 置 0、`enable_lto` / `enable_thin_lto` 置 `'false'`、
136
+ `lto_jobs` 置空,避免 `common.gypi` 切到 ClangCL 并向 MSVC 传 LTO 参数
137
+ - `lib/configure.js`
138
+ - 改动:调用 gyp 时追加 `-Gmsvs_toolset=<探测到的 toolset>`,不再写死 `v145`
139
+ - `lib/find-visualstudio.js`
140
+ - 改动:支持 VS2013+,含最新 VS2026(版本号 18,`versionYear=2026`,toolset `v145`)
141
+ - `gyp/pylib/gyp/MSVSSettings.py`
142
+ - 改动:注册 `ExternalWarningLevel`(MSBuild 属性),供 `addon.gypi` 使用
143
+ - `addon.gypi`
144
+ - 改动:Windows 下追加 `/external:anglebrackets` +
145
+ `ExternalWarningLevel: TurnOffAllWarnings`,只静音外部头(Node / V8)的警告
131
146
 
132
147
  #### 跨平台路径
133
148
 
134
- | 文件 | 改动 |
135
- | --------------------------------- | ----------------------------------------------------------------------------------------------------------- |
136
- | `gyp/pylib/gyp/common.py` | `RelativePath` 返回值统一转正斜杠 |
137
- | `gyp/pylib/gyp/generator/make.py` | `Absolutify` 返回正斜杠;新增 `slashpath` 供 `mkdir` 使用;Windows 下跳过 `node_modules` 中的超长 gypi 依赖 |
149
+ | 文件 | 改动
150
+ |
151
+ | --------------------------------- |
152
+ ----------------------------------------------------------------------------------------------------------- |
153
+ | `gyp/pylib/gyp/common.py` | `RelativePath` 返回值统一转正斜杠
154
+ |
155
+ | `gyp/pylib/gyp/generator/make.py` | `Absolutify` 返回正斜杠;新增 `slashpath` 供 `mkdir` 使用;Windows 下跳过
156
+ `node_modules` 中的超长 gypi 依赖 |
138
157
 
139
158
  #### Windows 运行时探测
140
159
 
141
- | 文件 | 改动 |
142
- | -------------------- | -------------------------------------------------------------------------------------------------------------- |
143
- | `lib/find-python.js` | 重写:移除硬编码版本列表,改为 `py.exe` 候选 + `py -0p` 枚举 + 目录扫描;`run()` 显式检查 `execFile` 的 err |
144
- | `lib/build.js` | 区分「宿主 Windows」与「Android 交叉编译」;自动探测 `sh.exe` 并前置到 PATH;为 Python 创建 `python3.cmd` shim |
160
+ | 文件 | 改动
161
+ |
162
+ | -------------------- |
163
+ -------------------------------------------------------------------------------------------------------------- |
164
+ | `lib/find-python.js` | 重写:移除硬编码版本列表,改为 `py.exe` 候选 + `py -0p` 枚举 + 目录扫描;`run()` 显式检查 `execFile`
165
+ 的 err |
166
+ | `lib/build.js` | 区分"宿主 Windows"与"Android 交叉编译";自动探测 `sh.exe` 并前置到 PATH;为 Python 创建
167
+ `python3.cmd` shim |
145
168
 
146
169
  #### 兼容性与健壮性
147
170
 
148
- - **`proc-log` 新版本兼容**:新版把日志级别函数与 `pause` / `resume` 挂在默认导出的 `log` 对象下。本 fork 已按此调整 `lib/log.js`,否则 `configure` 阶段会抛 `TypeError`。
149
- - **弃用 API 清理**:`lib/process-release.js` 不再用 `url.resolve()` / `url.parse()`,改用 WHATWG `URL`,消除 `DEP0169` 警告。
150
- - **依赖脚本放行**:`package.json` 显式声明 `allowScripts`,适配新版 npm 默认禁止依赖执行安装脚本的行为。
171
+ - **`proc-log` 新版本兼容**:新版把日志级别函数与 `pause` / `resume` 挂在默认导出的 `log` 对象下;本 fork 已按此调整
172
+ `lib/log.js`,否则 `configure` 阶段会抛 `TypeError`;
173
+ - **弃用 API 清理**:`lib/process-release.js` 不再用 `url.resolve()` / `url.parse()`,改用 WHATWG `URL`,消除 `DEP0169` 警告;
174
+ - **依赖脚本放行**:`package.json` 显式声明 `allowScripts`,适配新版 npm 默认禁止依赖执行安装脚本的行为;
151
175
 
152
176
 
153
177
  ### 迁移踩过的坑
154
178
 
155
- 1. **`graceful-fs` 是 CJS,命名导入会失败**
156
- 写成 `import gracefulFs from 'graceful-fs'`,再从 default 解构 `const { openSync, closeSync } = gracefulFs`。
179
+ 1. **`graceful-fs` 是 CJS,命名导入会失败**
180
+ 写成 `import gracefulFs from 'graceful-fs'`,再从 default 解构 `const { openSync, closeSync } = gracefulFs`;
157
181
 
158
182
  2. **`tar@7` 没有 default export**
159
- 写成 `import * as tar from 'tar'`。
183
+ 写成 `import * as tar from 'tar'`;
160
184
 
161
185
  3. **`proc-log` 的解构**
162
- `import procLog from 'proc-log'`,再把需要的函数从 default 里解构后统一导出。
186
+ `import procLog from 'proc-log'`,再把需要的函数从 default 里解构后统一导出;
163
187
 
164
188
  4. **PowerShell 写文件会加 BOM**
165
- `Set-Content -Encoding UTF8` 会写入 `\uFEFF`,导致 gyp 的 `eval()` 报 `SyntaxError: invalid non-printable character U+FEFF`。写 `binding.gyp` 等交给 Python eval 的文件时,用 `[System.IO.File]::WriteAllText` + `New-Object System.Text.UTF8Encoding $false`。
189
+ `Set-Content -Encoding UTF8` 会写入 `\uFEFF`,导致 gyp 的 `eval()` 报
190
+ `SyntaxError: invalid non-printable character U+FEFF`;写 `binding.gyp` 等交给 Python eval 的文件时,用
191
+ `[System.IO.File]::WriteAllText` + `New-Object System.Text.UTF8Encoding $false`;
166
192
 
167
193
  5. **ESM 不支持动态 `require('./' + command)`**
168
- `lib/node-gyp.js` 原本用 `require('./' + command)` 动态加载命令模块,ESM 下改为在顶部静态 import 所有命令,再用静态映射表组装 `this.commands`。
194
+ `lib/node-gyp.js` 原本用 `require('./' + command)` 动态加载命令模块,ESM 下改为在顶部静态 import 所有命令,
195
+ 再用静态映射表组装 `this.commands`;
169
196
 
170
197
  6. **`__dirname` / `__filename` 在 ESM 中不存在**
171
- 用 `fileURLToPath(import.meta.url)` 重建。
198
+ 用 `fileURLToPath(import.meta.url)` 重建;
172
199
 
173
200
  7. **非 Windows 平台不引入 `find-visualstudio.js`**
174
- 该模块依赖 Windows 专属的 `path.win32` 和注册表操作,保持原版的"仅在 Windows 上条件加载"逻辑。
201
+ 该模块依赖 Windows 专属的 `path.win32` 和注册表操作,保持原版的"仅在 Windows 上条件加载"逻辑;
175
202
 
176
203
  ## 支持的系统与配置要求
177
204
 
178
- 本包面向 **Android / iOS 交叉编译**,宿主平台支持情况:
205
+ 本包面向 **Android / iOS 交叉编译**,宿主平台支持情况:
179
206
 
180
- | 宿主平台 | 目标:Android | 目标:iOS |
207
+ | 宿主平台 | 目标:Android | 目标:iOS |
181
208
  | -------- | ------------- | ---------- |
182
209
  | Windows | ✅ 完整支持 | ❌ 需 macOS |
183
210
  | macOS | ✅ 完整支持 | ✅ 完整支持 |
184
211
  | Linux | ✅ 完整支持 | ❌ 需 macOS |
185
212
 
186
- 各平台所需的构建环境如下。
213
+ 各平台所需的构建环境如下;
187
214
 
188
215
  ### 通用要求
189
216
 
190
- - **Node.js**:最低版本见 `package.json` 的 `engines.node` 字段
191
- - **Python 3.6+**:gyp 本身是 Python 程序,构建时必需
192
- - **目标平台 SDK**:
193
- - Android:Android NDK(**23–27 已验证**)
194
- - iOS:完整 Xcode(仅 macOS;Command Line Tools 单独不够)
217
+ - **Node.js**:最低版本见 `package.json` 的 `engines.node` 字段
218
+ - **Python 3.6+**:gyp 本身是 Python 程序,构建时必需
219
+ - **目标平台 SDK**:
220
+ - Android:Android NDK(**23–27 已验证**)
221
+ - iOS:完整 Xcode(仅 macOS;Command Line Tools 单独不够)
195
222
 
196
223
  ### Windows
197
224
 
198
225
  | 组件 | 要求 | 说明 |
199
226
  | --------------- | --------------------------------------- | ----------------------------------------------------------- |
200
227
  | Node.js | 见 `engines.node` | |
201
- | Python | 3.6+ | 支持任意安装位置,见下方「自动探测」 |
202
- | Visual Studio | **VS2019 / VS2022 / VS2026**(2026 已验证) | 需勾选「使用 C++ 的桌面开发」工作负载,含 Windows SDK;VS2017 及更早受 Node 版本上限限制 |
203
- | Android NDK | **23–27**(已验证) | 由 `@flun/nodejs-mobile-react-native` 自动定位 |
204
- | Git for Windows | 任意近期版本 | 自带**整套 MSYS2 POSIX 工具集**(`sh.exe`、`printf`、`xargs`、`sed`、`rm`、`mkdir` 等数十个命令),GNU make 执行 Makefile 所依赖的 Unix 命令均由它提供;位置自动探测(见下方) |
205
-
206
- > **为什么需要 Git for Windows?** Android 原生模块通过 GNU make 构建,Makefile 中会调用 `printf`、`xargs`、`sed` 等 Unix 命令。这些命令并非 Windows 自带,GNU make 需要一个 POSIX 环境来执行它们。Git for Windows 自带**整套 MSYS2 POSIX 工具集**(`sh.exe`、`printf`、`xargs`、`sed`、`rm`、`mkdir` 等数十个命令),无需额外安装 MSYS2 或 Cygwin。
228
+ | Python | 3.6+ | 支持任意安装位置,见下方"自动探测" |
229
+ | Visual Studio | **VS2019 / VS2022 / VS2026**(2026 已验证) | 需勾选"使用 C++ 的桌面开发"工作负载,含 Windows SDK;VS2017
230
+ 及更早受 Node 版本上限限制 |
231
+ | Android NDK | **23–27**(已验证) | 由 `@flun/nodejs-mobile-react-native` 自动定位
232
+ |
233
+ | Git for Windows | 任意近期版本 | 自带**整套 MSYS2 POSIX 工具集**(`sh.exe`、`printf`、`xargs`、
234
+ `sed`、`rm`、`mkdir` 等数十个命令),GNU make 执行 Makefile 所依赖的 Unix 命令均由它提供;位置自动探测(见下方) |
235
+
236
+ > **为什么需要 Git for Windows?** Android 原生模块通过 GNU make 构建,Makefile 中会调用 `printf`、`xargs`、`sed` 等 Unix
237
+ 命令;这些命令并非 Windows 自带,GNU make 需要一个 POSIX 环境来执行它们;Git for Windows
238
+ 自带**整套 MSYS2 POSIX 工具集**(`sh.exe`、`printf`、`xargs`、`sed`、`rm`、`mkdir` 等数十个命令),无需额外安装 MSYS2 或
239
+ Cygwin;
207
240
 
208
241
  ### macOS
209
242
 
@@ -211,7 +244,7 @@ gyp 生成的 Makefile 中,路径原本会带上 Windows 的反斜杠(如 `s
211
244
  | ----------- | -------------------------------- |
212
245
  | Node.js | 见 `engines.node` |
213
246
  | Python | 3.6+ |
214
- | Xcode | 完整 Xcode(必须,CLT 单独不够) |
247
+ | Xcode | 完整 Xcode(必须,CLT 单独不够) |
215
248
  | Android NDK | 仅构建 Android 目标时需 23–27 |
216
249
 
217
250
  ### Linux
@@ -220,31 +253,34 @@ gyp 生成的 Makefile 中,路径原本会带上 Windows 的反斜杠(如 `s
220
253
  | ----------- | ------------------------------------------------------ |
221
254
  | Node.js | 见 `engines.node` |
222
255
  | Python | 3.6+ |
223
- | 构建工具 | `make`、`g++`(`apt install build-essential python3`) |
256
+ | 构建工具 | `make`、`g++`(`apt install build-essential python3`) |
224
257
  | Android NDK | 仅构建 Android 目标时需 23–27 |
225
258
 
226
- ### 自动探测(Windows)
259
+ ### 自动探测(Windows)
227
260
 
228
- 以下工具的**安装位置**由本包动态探测,**无需手动指定路径**(前提:工具已安装):
261
+ 以下工具的**安装位置**由本包动态探测,**无需手动指定路径**(前提:工具已安装):
229
262
 
230
- - **Python**,依次尝试:
263
+ - **Python**,依次尝试:
231
264
  1. `NODE_GYP_FORCE_PYTHON` 环境变量
232
265
  2. 命令行 `--python=`
233
266
  3. `PYTHON` 环境变量
234
- 4. `py.exe` 启动器(PATH 中、`%SystemRoot%\py.exe`、`%SystemRoot%\System32\py.exe`)
267
+ 4. `py.exe` 启动器(PATH 中、`%SystemRoot%\py.exe`、`%SystemRoot%\System32\py.exe`)
235
268
  5. `py -0p` 枚举所有已注册 Python
236
269
  6. `python3` / `python` 命令
237
270
  7. 扫描 `%LOCALAPPDATA%\Programs\Python\Python*` 与 `%ProgramFiles%\Python*`
238
271
 
239
- - **Git for Windows 的 `usr/bin` 目录**(POSIX 工具集所在处,以 `sh.exe` 是否存在作为判据),依次尝试:
272
+ - **Git for Windows 的 `usr/bin` 目录**(POSIX 工具集所在处,以 `sh.exe` 是否存在作为判据),依次尝试:
240
273
  1. 注册表 `HKLM\SOFTWARE\GitForWindows` 的 `InstallPath`
241
274
  2. `which git` 反推 `../usr/bin`
242
275
  3. `PATH` 中的 `git.exe` 反推 `../usr/bin`
243
276
  4. 常见安装位置兜底
244
277
 
245
- - **Android NDK**:由 `@flun/nodejs-mobile-react-native` 通过 `android.ndkDirectory` 定位,并注入 `make.exe`、`clang` 等工具路径。
278
+ - **Android NDK**:由 `@flun/nodejs-mobile-react-native` 通过 `android.ndkDirectory` 定位,并注入 `make.exe`、`clang`
279
+ 等工具路径;
246
280
 
247
- > 本包不依赖任何随包分发的硬编码配置文件。上述探测均为运行时动态完成;仅 Visual Studio 的「版本号 → 版本年份 → toolset」对照表以常量形式内联在 `lib/find-visualstudio.js` 中——这类信息由微软固定发布,无枚举接口,且随 VS 版本发布而更新,不适合做成外部资源。
281
+ > 本包不依赖任何随包分发的硬编码配置文件;上述探测均为运行时动态完成;仅 Visual Studio 的"版本号 → 版本年份 →
282
+ toolset"对照表以常量形式内联在 `lib/find-visualstudio.js` 中--这类信息由微软固定发布,无枚举接口,且随 VS 版本发布而更新,
283
+ 不适合做成外部资源;
248
284
 
249
285
 
250
286
  ## 安装
@@ -253,9 +289,12 @@ gyp 生成的 Makefile 中,路径原本会带上 Windows 的反斜杠(如 `s
253
289
  npm i @flun/nodejs-mobile-gyp
254
290
  ```
255
291
 
256
- 通常你不需要手动安装本包——它由 [`@flun/nodejs-mobile-react-native`](https://www.npmjs.com/package/@flun/nodejs-mobile-react-native) 在编译原生模块时自动调用。
292
+ 通常你不需要手动安装本包--它由 [`@flun/nodejs-mobile-react-native`](https://www.npmjs.
293
+ com/package/@flun/nodejs-mobile-react-native) 在编译原生模块时自动调用;
257
294
 
258
- > **Node 版本要求**:本 fork 的依赖链(`make-fetch-happen`、`nopt`、`proc-log`、`which` 等)已升级到较新版本,要求比原版 `nodejs-mobile-gyp` 更高的 Node。具体最低版本见 `package.json` 的 `engines.node` 字段。若你的项目仍在使用较旧的 Node,请改用原版 `nodejs-mobile-gyp`。
295
+ > **Node 版本要求**:本 fork 的依赖链(`make-fetch-happen`、`nopt`、`proc-log`、`which` 等)已升级到较新版本,要求比原版
296
+ `nodejs-mobile-gyp` 更高的 Node;具体最低版本见 `package.json` 的 `engines.node` 字段;若你的项目仍在使用较旧的 Node,
297
+ 请改用原版 `nodejs-mobile-gyp`;
259
298
 
260
299
  ## 使用
261
300
 
@@ -265,7 +304,7 @@ npm i @flun/nodejs-mobile-gyp
265
304
  npx @flun/nodejs-mobile-gyp <command> [options]
266
305
  ```
267
306
 
268
- 或在 `package.json` 的 `scripts` 中调用:
307
+ 或在 `package.json` 的 `scripts` 中调用:
269
308
 
270
309
  ```json
271
310
  {
@@ -277,7 +316,8 @@ npx @flun/nodejs-mobile-gyp <command> [options]
277
316
 
278
317
  ### 从 Node.js 代码调用
279
318
 
280
- 本包主要作为 CLI 工具使用,推荐通过 spawn / execFile 调用其命令行入口。包本身也导出了 Gyp 类,但属于内部实现,接口可能随版本变化,不建议直接在代码中依赖。
319
+ 本包主要作为 CLI 工具使用,推荐通过 spawn / execFile 调用其命令行入口;包本身也导出了 Gyp 类,但属于内部实现,
320
+ 接口可能随版本变化,不建议直接在代码中依赖;
281
321
 
282
322
  ## 命令
283
323
 
@@ -285,7 +325,7 @@ npx @flun/nodejs-mobile-gyp <command> [options]
285
325
  | ----------- | ---------------------------------------- |
286
326
  | `help` | 显示帮助 |
287
327
  | `build` | 调用 `make` / `msbuild.exe` 编译原生模块 |
288
- | `clean` | 删除 `build` 目录(若存在) |
328
+ | `clean` | 删除 `build` 目录(若存在) |
289
329
  | `configure` | 为当前平台生成工程构建文件 |
290
330
  | `rebuild` | 依次执行 `clean` → `configure` → `build` |
291
331
  | `install` | 为指定版本安装 Node.js 头文件 |
@@ -294,64 +334,90 @@ npx @flun/nodejs-mobile-gyp <command> [options]
294
334
 
295
335
  ## 命令选项
296
336
 
297
- | 选项 | 说明 |
298
- | --------------------------------- | -------------------------------------------------------------------------------------------- |
299
- | `-v`, `--version` | 打印本包版本号 |
300
- | `-j n`, `--jobs n` | 并行运行 `make`;`max` 表示使用所有 CPU 核心 |
301
- | `--target=v6.2.1` | 目标 Node.js 版本(默认 `process.version`) |
302
- | `--silly`, `--loglevel=silly` | 输出全部进度日志 |
303
- | `--verbose`, `--loglevel=verbose` | 输出大部分进度日志 |
304
- | `--silent`, `--loglevel=silent` | 不输出任何日志 |
305
- | `debug`, `--debug` | 生成 Debug 构建(默认 Release) |
306
- | `--release`, `--no-debug` | 生成 Release 构建 |
307
- | `-C $dir`, `--directory=$dir` | 在指定目录运行命令 |
308
- | `--make=$make` | 覆盖 `make` 命令(如 `gmake`) |
309
- | `--thin=yes` | 启用 thin 静态库 |
310
- | `--arch=$arch` | 目标架构(如 `ia32`) |
311
- | `--tarball=$path` | 从本地 tarball 获取头文件 |
312
- | `--devdir=$path` | SDK 下载目录(默认为系统缓存目录) |
313
- | `--ensure` | 已存在的头文件不重装 |
314
- | `--dist-url=$url` | 从自定义 URL 下载头文件 tarball |
315
- | `--proxy=$url` | 下载时使用 HTTP(S) 代理 |
316
- | `--noproxy=$urls` | 下载时忽略代理的 URL 列表 |
317
- | `--cafile=$cafile` | 覆盖默认 CA 链(用于下载 tarball) |
318
- | `--nodedir=$path` | 指定 Node 源码路径 |
319
- | `--python=$path` | 指定 Python 二进制路径 |
320
- | `--msvs_version=$version` | 指定 Visual Studio 版本或安装路径(仅 Windows;可填 `2022` / `2026` 或 `C:\...\BuildTools`) |
321
- | `--solution=$solution` | 指定 Visual Studio Solution 版本(仅 Windows) |
322
- | `--force-process-config` | 强制用运行时的 `process.config` 生成 `config.gypi` |
337
+ | 选项 | 说明
338
+ |
339
+ | --------------------------------- |
340
+ -------------------------------------------------------------------------------------------- |
341
+ | `-v`, `--version` | 打印本包版本号
342
+ |
343
+ | `-j n`, `--jobs n` | 并行运行 `make`;`max` 表示使用所有 CPU 核心
344
+ |
345
+ | `--target=v6.2.1` | 目标 Node.js 版本(默认 `process.version`)
346
+ |
347
+ | `--silly`, `--loglevel=silly` | 输出全部进度日志
348
+ |
349
+ | `--verbose`, `--loglevel=verbose` | 输出大部分进度日志
350
+ |
351
+ | `--silent`, `--loglevel=silent` | 不输出任何日志
352
+ |
353
+ | `debug`, `--debug` | 生成 Debug 构建(默认 Release)
354
+ |
355
+ | `--release`, `--no-debug` | 生成 Release 构建
356
+ |
357
+ | `-C $dir`, `--directory=$dir` | 在指定目录运行命令
358
+ |
359
+ | `--make=$make` | 覆盖 `make` 命令(如 `gmake`)
360
+ |
361
+ | `--thin=yes` | 启用 thin 静态库
362
+ |
363
+ | `--arch=$arch` | 目标架构(如 `ia32`)
364
+ |
365
+ | `--tarball=$path` | 从本地 tarball 获取头文件
366
+ |
367
+ | `--devdir=$path` | SDK 下载目录(默认为系统缓存目录)
368
+ |
369
+ | `--ensure` | 已存在的头文件不重装
370
+ |
371
+ | `--dist-url=$url` | 从自定义 URL 下载头文件 tarball
372
+ |
373
+ | `--proxy=$url` | 下载时使用 HTTP(S) 代理
374
+ |
375
+ | `--noproxy=$urls` | 下载时忽略代理的 URL 列表
376
+ |
377
+ | `--cafile=$cafile` | 覆盖默认 CA 链(用于下载 tarball)
378
+ |
379
+ | `--nodedir=$path` | 指定 Node 源码路径
380
+ |
381
+ | `--python=$path` | 指定 Python 二进制路径
382
+ |
383
+ | `--msvs_version=$version` | 指定 Visual Studio 版本或安装路径(仅 Windows;可填 `2022` / `2026` 或
384
+ `C:\...\BuildTools`) |
385
+ | `--solution=$solution` | 指定 Visual Studio Solution 版本(仅 Windows)
386
+ |
387
+ | `--force-process-config` | 强制用运行时的 `process.config` 生成 `config.gypi`
388
+ |
323
389
 
324
390
  ## 配置
325
391
 
326
392
  ### 环境变量
327
393
 
328
- 上表中的所有命令选项,都可以用 `npm_config_OPTION_NAME` 形式的**环境变量**来设置(选项名中的 `-` 替换为 `_`)。
394
+ 上表中的所有命令选项,都可以用 `npm_config_OPTION_NAME` 形式的**环境变量**来设置(选项名中的 `-` 替换为 `_`);
329
395
 
330
- 例如,把 `devdir` 设为 `/tmp/.gyp`:
396
+ 例如,把 `devdir` 设为 `/tmp/.gyp`:
331
397
 
332
- Unix:
398
+ Unix:
333
399
  ```bash
334
400
  export npm_config_devdir=/tmp/.gyp
335
401
  ```
336
402
 
337
- Windows:
403
+ Windows:
338
404
  ```console
339
405
  set npm_config_devdir=c:\temp\.gyp
340
406
  ```
341
407
 
342
- ### npm 配置(npm v9 之前)
408
+ ### npm 配置(npm v9 之前)
343
409
 
344
- 用 `OPTION_NAME` 形式:
410
+ 用 `OPTION_NAME` 形式:
345
411
 
346
412
  ```bash
347
413
  npm config set [--global] devdir /tmp/.gyp
348
414
  ```
349
415
 
350
- **注意**:通过 `npm config` 设置的配置,只在本包 **由 npm 调用时**生效,直接运行 `nodejs-mobile-gyp` 不生效。
416
+ **注意**:通过 `npm config` 设置的配置,只在本包 **由 npm 调用时**生效,直接运行 `nodejs-mobile-gyp` 不生效;
351
417
 
352
418
  ## 上游参考
353
419
 
354
- 本包是 `node-gyp` 的 fork。上游完整文档(含更多高级用法、`binding.gyp` 语法、跨平台细节)请见:
420
+ 本包是 `node-gyp` 的 fork;上游完整文档(含更多高级用法、`binding.gyp` 语法、跨平台细节)请见:
355
421
 
356
422
  - [nodejs/node-gyp README](https://github.com/nodejs/node-gyp#readme)
357
423
  - [gyp 用户文档](https://gyp.gsrc.io/docs/UserDocumentation.md)