# PyBuildKit **Repository Path**: skb666/PyBuildKit ## Basic Information - **Project Name**: PyBuildKit - **Description**: 一个强大的 C/C++ SDK 编译框架,基于 CMake 和 Kconfig,结合了 Python 脚本进行项目管理。 - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2023-07-14 - **Last Updated**: 2025-02-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # PyBuildKit 一个强大的 C/C++ SDK 编译框架,基于 CMake 和 Kconfig,结合了 Python 脚本进行项目管理。 基于 [Neutree](https://github.com/Neutree) 的代码构建框架: [c_cpp_project_framework](./framework.md); 在此基础上引入对 [vcpkg](https://github.com/microsoft/vcpkg/blob/master/README_zh_CN.md) 的支持,方便在做跨平台开发时能够快速在宿主机做一些三方库的功能验证与 demo 利用 cmake 对 vcpkg 的良好支持,我们可以通过 vcpkg.json 实现库自动安装与版本控制; 此外,你可以通过使用 `Visual Studio Code` + `CMake Tools (>=1.13.40)` 获得较好的 [UI 支持](https://github.com/Neutree/c_cpp_project_framework/issues/4)。 ## 安装 **curl 安装** ```bash # 仅安装 PyBuildKit curl -fsSL https://raw.githubusercontent.com/skb666/PyBuildKit/master/install.sh | bash # 安装 PyBuildKit 和 vcpkg curl -fsSL https://raw.githubusercontent.com/skb666/PyBuildKit/master/install.sh | bash -s -- -w ``` **wget 安装** ```bash # 仅安装 PyBuildKit wget -qO- https://raw.githubusercontent.com/skb666/PyBuildKit/master/install.sh | bash # 安装 PyBuildKit 和 vcpkg wget -qO- https://raw.githubusercontent.com/skb666/PyBuildKit/master/install.sh | bash -s -- -w ``` **通过源码安装** ```bash git clone https://github.com/skb666/PyBuildKit.git --recursive cd PyBuildKit chmod +x ./install.sh # 仅安装 PyBuildKit ./install.sh -d $HOME/.mysdk # 安装 PyBuildKit 和 vcpkg ./install.sh -w -d $HOME/.mysdk ``` **安装完成后,你可以通过执行 `. $HOME/.mysdk/env` 以临时配置编译环境;或者将 `. $HOME/.mysdk/env` 写入 `~/.profile`、`~/.bashrc`、`~/.zshenv` 等文件后重新登入 shell 以使环境配置永久生效。** > 若提示 *"Please run as root"*,请使用 `sudo` 以管理员身份重新执行脚本,使其可以自动安装必须的一些软件包; > 若提示 *"[warning] You should ensure 'xxx' is already installed."*,请根据提示,确保系统已安装软件包 'xxx'; > 你也可以手动安装这些软件包后重新运行安装脚本:`git` `python3` `cmake` `build-essential` `pkg-config` `curl` `wget` `zip` `unzip` `tar` ## 编译、运行测试 ### template/test_sample ```bash # 切换到项目目录 cd template/test_sample # 编译 python project.py build # 运行 python project.py run ``` ### template/test_vcpkg ```bash # 切换到项目目录 cd template/test_vcpkg # 配置 vcpkg 子模块(只需要执行一次,自动生成 .config.mk) python project.py config --toolchain ${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake # 查看、更改配置控制选项 python project.py menuconfig # 编译 python project.py build # 运行 python project.py run ``` ## 添加项目 + 新建项目,目录结构参照 `template` + 普通 `c/c++` 的应用参考 `template/test_sample` + 使用 `vcpkg` 的应用参考 `template/test_vcpkg` + 在 `/main` 中放应用代码文件 + 在 `/main/CMakeLists.txt` 中添加要编译的源码及其他 + 在 `/main/Kconfig` 中添加 `menuconfig` 控制选项 + 在 `/compile/priority.conf` 中设置依赖组件的编译顺序 + 在 `/compile/compile_flags.cmake` 中设置编译器编译参数 + 在 `/compile/gen_binary.cmake` 中添加编译后自定义命令 + 在 `/config_defaults.mk` 或 `/.config.mk` 中设置控制选项的值 + 在 `/vcpkg.json` 配置 `vcpkg` 项目依赖的包,参考 [vcpkg-json](https://learn.microsoft.com/zh-cn/vcpkg/reference/vcpkg-json) ## 添加组件 + 全局组件:参考 [template.md](components/template.md) + 项目共享组件:参考 `template/components/event` + 应用私有组件:与 `/main` 同级