Skip to content

一个强大的 C/C++ SDK 编译框架,基于 CMake 和 Kconfig,结合了 Python 脚本进行项目管理。

License

Notifications You must be signed in to change notification settings

skb666/PyBuildKit

Repository files navigation

PyBuildKit

一个强大的 C/C++ SDK 编译框架,基于 CMake 和 Kconfig,结合了 Python 脚本进行项目管理。

基于 Neutree 的代码构建框架: c_cpp_project_framework
在此基础上引入对 vcpkg 的支持,方便在做跨平台开发时能够快速在宿主机做一些三方库的功能验证与 demo
利用 cmake 对 vcpkg 的良好支持,我们可以通过 vcpkg.json 实现库自动安装与版本控制;
此外,你可以通过使用 Visual Studio Code + CMake Tools (>=1.13.40) 获得较好的 UI 支持

安装

curl 安装

# 仅安装 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 安装

# 仅安装 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

通过源码安装

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

# 切换到项目目录
cd template/test_sample
# 编译
python project.py build
# 运行
python project.py run

template/test_vcpkg

# 切换到项目目录
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
  • <application>/main 中放应用代码文件
  • <application>/main/CMakeLists.txt 中添加要编译的源码及其他
  • <application>/main/Kconfig 中添加 menuconfig 控制选项
  • <application>/compile/priority.conf 中设置依赖组件的编译顺序
  • <application>/compile/compile_flags.cmake 中设置编译器编译参数
  • <application>/compile/gen_binary.cmake 中添加编译后自定义命令
  • <application>/config_defaults.mk<application>/.config.mk 中设置控制选项的值
  • <application>/vcpkg.json 配置 vcpkg 项目依赖的包,参考 vcpkg-json

添加组件

  • 全局组件:参考 template.md
  • 项目共享组件:参考 template/components/event
  • 应用私有组件:与 <application>/main 同级

About

一个强大的 C/C++ SDK 编译框架,基于 CMake 和 Kconfig,结合了 Python 脚本进行项目管理。

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published