Skip to main content

批量构建CMake工程的Python工具,支持build.json配置和命令行批量编译

Project description

pycmakebuild

Python CMake 批量构建与自动化工具,支持通过 build.json 配置文件和命令行批量编译多个 CMake 项目,适用于跨平台 C++/第三方库工程的自动化批量编译。

功能特性

  • 支持 build.json 配置批量管理和编译多个 CMake 项目
  • 支持 Debug/Release 等多种构建类型,支持自定义 CMakeLists.txt 子目录
  • 支持命令行一键初始化环境、生成模板、批量构建
  • 自动推断 CMake 构建参数,兼容 Windows/Linux/Mac
  • 支持通过 python -m pycmakebuildpycmakebuild 命令行调用

快速开始

1. 安装

pip install pycmakebuild

2. 初始化环境和模板

python -m pycmakebuild --init

将在当前目录生成 .env 和 build.json 模板。

3. 编辑 build.json

示例:

{
  "sources": [
    {
      "path": "../Log4Qt",
      "name": "log4qt",
      "build_types": ["Debug", "Release"],
      "cmakelists_subpath": ".",
      "update_source": false,
      "other_build_params": ["-DCUSTOM_OPTION=ON"]
    }
  ]
}
  • path: CMake 项目源码路径
  • name: 目标名称(安装目录名)
  • build_types: 构建类型数组(如 Debug/Release)
  • cmakelists_subpath: CMakeLists.txt 所在子目录(可选,默认".")
  • update_source: 是否自动更新源码 git clean/pull(可选,默认 false)
  • other_build_params: 传递给 cmake 的额外参数列表(如 ["-DCUSTOM_OPTION=ON"],可选)
  • "update_source" 字段已废弃,如需清理请用 --clean 命令

4. 批量构建

python -m pycmakebuild --build

或直接

python -m pycmakebuild

会自动检测当前目录下 build.json 并批量构建所有配置项目,支持自定义 cmake 参数。

5. 批量清理源码和安装目录

python -m pycmakebuild --clean

自动清理更新源码

命令行参数

  • --init 初始化环境和 build.json 模板
  • --build 强制根据 build.json 批量构建
  • --clean 批根据 build.json 更新源码

依赖

  • python-dotenv:环境变量管理
  • cmake:Python CMake 封装

典型应用场景

  • 本地一键环境初始化默认构建环境与批量编译CMake三方库

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycmakebuild-0.2.7.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycmakebuild-0.2.7-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file pycmakebuild-0.2.7.tar.gz.

File metadata

  • Download URL: pycmakebuild-0.2.7.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for pycmakebuild-0.2.7.tar.gz
Algorithm Hash digest
SHA256 9fa03ffff0e2b690020f0bc9bb67af64eeb9fd891a719cf98457bcab6f8c1588
MD5 d0a9e58ac13ed5693f7ff08f1d537789
BLAKE2b-256 ebc603e509db3dcf9845a7a8d98de7b2c2a4024427e81d5eeb52602b7c11a08d

See more details on using hashes here.

File details

Details for the file pycmakebuild-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: pycmakebuild-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for pycmakebuild-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 bcfb521e88c0c3f2ddc17c1d74f30ba4f5c501787afdec76f1a871e9fd3b4d57
MD5 2e16fe0bbb787bab2ed1affdb29f1cd8
BLAKE2b-256 982d7f5c4ed49931055aef1017dc812cbb959645c2c9672d6060f9ec375d7fee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page