{\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匹配当前 OSnamed-configs arg1 arg2 ...构建所有配置name是一个词组
交叉汇编
本模块支持从Linux到macOS和Windows的交叉编译,给出了正确的工具链设置. 有一种基于 CLang 7 为 Windows 和 macOS 设置的交叉工具链容器,可能在 CI 中使用.