@aminya/cmake-ts

中文文档
0.3.0-aminya.7发布于 2024/10/23MITTypeScriptCommonJS近 30 天下载 2万

cmake-js 重写为打字符以支持高级构建配置

中文使用文档
文档目录3 节
  1. 配置
  2. 工作流程
  3. 交叉汇编

{\fn黑体\fs22\bord1\shad0\3ahbe\4ah00\fscx67\fscy66\2chffffff\3ch808080}你觉得呢

一个基于CMake的建构系统,用于本土的NodeJS和Electron加通.

这个项目的灵感很松散 鸡尾酒 但试图弥补一些设计缺陷.

它旨在为不同版本的NodeJS和Electron预建附加物并运送一款二进制版本.

配置

配置完全通过 package.json。可以在 cmake-ts 键 :

"cmake-ts": {
  "nodeAPI": "node-addon-api" // Specify the node API package such as `node-addon-api`, `nan`, or the path to a directory that has the nodeAPI header. Default is `node-addon-api`, a warning is emitted if nan is used
  "configurations": [
    {
      "name": "win-x64", // name for named-configs mode
      "os": "win32", // win32, linux and darwin are supported
      "arch": "x64", // x64, x86 should work
      "runtime": "electron", // node or electron
      "runtimeVersion": "4.0.1", // Version of the runtime which it is built
      "toolchainFile": "/windows.cmake", // CMake Toolchain file to use for crosscompiling
      "CMakeOptions": [ //Same syntax as for the globalCMakeOptions
        {
          "name": "MY_CMAKE_OPTION",
          "value": "my_value",
        }
      ],
      "addonSubdirectory": "avx2-generic" // if you build addons for multiple architectures in high performance scenarios, you can put the addon inside another subdirectory
    }, // more build configurations...
    {
      "dev": true, // whether this configuration is eligible to be used in a dev test build
      "os": "linux", // win32, linux and darwin are supported
      "arch": "x64", // x64, x86 should work
      "runtime": "node", // node or electron
      "runtimeVersion": "10.3.0", // Version of the runtime which it is built
    } // more build configurations ...
  ],
  "targetDirectory": "build", // where to build your project
  "buildType": "Release", // Debug or Release build, most likely set it to Release
  "projectName": "addon" // The name of your CMake project.
  "globalCMakeOptions": [{ // this might be omitted of no further options should be passed to CMake
    "name": "CMAKE_CXX_FLAGS",
    "value": "-Og"
  }, {
    "name": "CMAKE_CXX_FLAGS",
    "value": "-I$ROOT$/include", // $ROOT$ will be replaced by the package.json directory
  }, {
      "name": "CMAKE_EXPORT_COMPILE_COMMANDS",
      "value": "1"
  }]
}

工作流程

虽然在CI环境中进行完整的构建(所有配置)是可取的,但长时间的构建会阻碍本地软件包的开发. 因此 CMake-ts 知道多个构建模式 :

  • 开始 nativeonly - > (中文) 构建本地代码 仅限 用于运行时的 cmake- ts 正在运行,而忽略了所有先前指定的配置。 如果您想对编译的代码进行一些单位测试,这个是有用的. 运行时 cmake-ts nativeonly, cmake-ts将决定运行时间, ABI, 以及来自环境的平台, 并且只构建在这个平台上运行所需的配置.
    • 使用以上配置的示例
    • 你跑开 cmake-ts nativeonly 打开 MacOS上的节点JS 11.7, (中文(简体) ), cmake-ts 将 忽略 上方的所有指定配置,并构建本地加成 MacOS上的节点JS 11.7
  • 开始 osonly - > (中文) 为所有符合当前操作系统的配置构建本地代码。 这对那些开发电子加通,想用电子测试其密码的人来说是有用的. 在这种情况下,您会在配置中指定多个平台的电子和节点JS运行时间,您可以使用 cmake-ts osonly 来构建您可以在应用程序中安装的本地软件包.
    • 使用以上配置的示例
    • 你跑开 cmake-ts osonly 打开 Linux 上的节点JS 11.7, (中文(简体) ), cmake-ts 将 忽略 上方的所有配置 os != linux 并建造土生土长的 全部 剩余配置,在此情况下,将构建用于 Linux 上的节点JS 10.3。 。 。 .
  • 开始 汉特: 两者 osonly 财务报告和审定财务报表 nativeonly中,指定的 CMake Toolchain 文件被忽略了,因为我猜你已经正确设置了您的工具链 拥有 操作系统.
  • 无/ 关闭: 构建所有配置
  • dev-os-only 构建第一个配置 dev == true 财务报告和审定财务报表 os 匹配当前 OS
  • named-configs arg1 arg2 ... 构建所有配置 name 是一个词组

交叉汇编

本模块支持从Linux到macOS和Windows的交叉编译,给出了正确的工具链设置. 有一种基于 CLang 7 为 Windows 和 macOS 设置的交叉工具链容器,可能在 CI 中使用.

Docker 图像

版本与发布记录

@aminya/cmake-ts 共发布 7 个版本,首次发布于 2024/10/23;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.3.0-aminya.7latest2024/10/232 年前
0.3.0-aminya.62024/10/232 年前
0.3.0-aminya.52024/10/232 年前
0.3.0-aminya.42024/10/232 年前
0.3.0-aminya.32024/10/232 年前
0.3.0-aminya.22024/10/232 年前

关于 @aminya/cmake-ts 的常见问题

@aminya/cmake-ts 是什么?

cmake-js 重写为打字符以支持高级构建配置

如何安装 @aminya/cmake-ts?

在项目目录运行 npm install @aminya/cmake-ts,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 cmake-ts,可以用 npx cmake-ts 直接运行。

@aminya/cmake-ts 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@aminya/cmake-ts 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@aminya/cmake-ts 可以商用吗?

@aminya/cmake-ts 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@aminya/cmake-ts 的下载量有多少?

根据 npm 官方下载统计,@aminya/cmake-ts 在 2026/10/06 – 2026/11/04 这 30 天内被下载 19,617 次,日均约 654 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@aminya/cmake-ts 还在维护吗?

最新版本 0.3.0-aminya.7 发布于 2024/10/23(2 年前);至今共发布 7 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/10/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。