一个小型C/C++ Builder
bbee的Python项目详细描述
bbee
非常简单的C-C++Builder
我写了这个小脚本来帮助我用C或C++代码。它基本上对源代码进行爬网,编译对象并将其链接到可执行二进制文件或静态库。(我喜欢静态库)
有时我不想花时间编写makefile脚本
因此,在向ppl发送一些示例代码时,我包括了这个。
这有一个小小的约定,只要你遵守约定,事情就会成功地建立起来。
请注意,我没有为大而复杂的项目写这个小脚本,如果你打算写复杂的东西,请坚持使用cmake或autotools。
除此之外,此脚本还可以为您完成工作;
快速启动
简单地运行下面的命令来创建一个空的c项目。这将创建一个空目录树,其中包含includes、build和source目录以及已经配置的capul.json文件。您可以在源目录中创建main.c,然后从调用bbee命令开始编译和运行。
bbee --create
或运行下面的命令创建一个空C++项目
bbee --create++
参数:
Field Name | Option | Type | Description | Example |
---|---|---|---|---|
name | str | Name of the project | "sample" | |
builder | str | Builder command | "gcc" or "/usr/bin/gcc-7" | |
sources | list | List of sources (directory or files) | ["./source", "main.c"] | |
includes | list | List of includes (dir or files) | ["./include", "/usr/local/includes"] | |
libraries | list | List of libraries to link | ["pthread", "GL", "m"] | |
frameworks | list | List of frameworks to link (MacOS) | ["OpenGL", "GLUT"] | |
library_search_paths | list | List of library directories | ["./libs", "/usr/local/lib"] | |
output | library / binary | str | Output format, binary exec. or a lib | "binary" |
output_dir | str | Where to put the output file(s) | "build" | |
output_name | str | Output file name | "hello_world" or "libmylib.a" | |
cflags | str | gcc extra flags | "-std=gnu99 -Wall -Werror -O3 -g" | |
debug | true / false | bool | BBee Debug Mode on / off | false |
source_extension | str | Extension to crawl for compiling | ".c" | |
run_after_build | bool | Run the binary output file after | false | |
install | list | List of installation directives | See below at "how to make install" |
如何进行安装
创建安装指令非常简单,只需告诉要复制的内容和复制的位置。
如果目标目录名以开头!然后将使用“mkdir-p”命令创建它
# This example will copy build/hello_world to /usr/local/bin
[
["build/hello_world", "/usr/local/bin"]
]
# This example will try to copy build/hello_world to first directory it can verify
# if the directory does not exists, it will try the next directory in the list
[
["build/hello_world", ["/usr/local/bin", "/usr/bin"]]
]
# This will copy the headers include folder to includes and copy the library to libs
[
["./includes", "!/usr/local/includes/mylib"],
["build/libmylib.a", ["/usr/local/lib", "/usr/lib"]]
]
下面是capul.json文件示例
{
"name": "Hello World",
"builder": "gcc",
"sources": [
"./src"
],
"includes": [
"./include"
],
"libraries": [
"pthread"
],
"library_search_paths": [
"/usr/local/lib"
],
"frameworks": [
"OpenGL",
"GLUT"
],
"output": "binary",
"output_dir": "build",
"output_name": "hello_world",
"cflags": "",
"debug": true,
"source_extension": ".c",
"run_after_build": False
}
注意:只有“源”、“输出”字段是必需的,其他字段是可选的。
如果您想参与,请将代码保存为单个文件,pep8应无错误或警告地传递 是的。