程序员谈创业郭志敏的程序员书屋程序员

使用BLADE构建c++工程管理

2015-06-27  本文已影响6732人  skywalker

一. c++工程依赖管理

之前在百度一直使用comake2构建c++项目,十分方便。免去了手写Makefile的痛苦,很多项目都不需要从零开始,其中的一个配置类似如下:

WORKROOT('../../../')
CopyUsingHardLink(True)
CPPFLAGS('-D_GNU_SOURCE -D__STDC_LIMIT_MACROS -DVERSION=\"1.9.8.7\"')
CFLAGS('-g -pipe -W -Wall -fPIC')
CXXFLAGS('-g -pipe -W -Wall -fPIC')
INCPATHS('. ./include ./output ./output/include')
CONFIGS('lib2-64/dict@dict_3-1-15-0_PD_BL')
CONFIGS('lib2-64/ullib@ullib_3-1-41-0_PD_BL')
CONFIGS('public/configure@configure_1-2-1-0_PD_BL')
CONFIGS('public/ependingpool@ependingpool_1-0-6-0_PD_BL')
Application('test',Sources(user_sources))
StaticLibrary('test',Sources(user_sources),HeaderFiles(user_headers))
SharedLibrary('test',Sources(user_sources),HeaderFiles(user_headers))

基本思路是:新的项目相当于代码树的叶子节点,它可以依赖现有代码树上有权限的任意的一个字节点代码。comake2生成Makefile文件进行编译。

WORKROOT: 指定了这颗代码树的根节点的相对位置
CONFIGS:指定了你要依赖的库的位置,以及具体的版本,如果不指定则依赖trunk的代码,这个和maven的snapshot版本等概念类似。
Application: 输出二进制可运行
StaticLibrary:输出静态库
SharedLibrary:输出动态库

很可惜comake2一直没有开源。
类似的工具在其他的语言已经有了很好的解决方案
nodejs - npm
php - composer
python - pip
java - maven

二. BLADE - from 腾讯

blade@github
一个结合第三方lib和thrift的示例

libs display library search paths
reloc display relocation processing
files display progress for input file
symbols display symbol table processing
bindings display information about symbol binding
versions display version dependencies
scopes display scope information
all all previous options combined
statistics display relocation statistics
unused determined unused DSOs
help display this help message and exit

三. 好消息-google开源了多语言,多平台构建的工具-Bazel

Bazel@github
Bazel主页

上一篇 下一篇

猜你喜欢

热点阅读