我如何用巴泽尔建立这个简单的例子
How do I build this simple example with Bazel?
假设我有一个这样的项目:
$ tree .
├── WORKSPACE
├── include
│ └── header.hpp
└── main.cpp
└── BUILD.bazel
和main.cpp
看起来像这样:
#include "header.hpp"
int main() {
return 0;
}
我的BUILD.bazel
文件应该是什么样的?
我目前的尝试:
cc_binary(
name = "app",
srcs = [
"main.cpp",
"include/header.hpp",
],
)
编辑:忘了提及我的WORKSPACE
文件
编辑:找到了一个工作,但我认为它不是很优雅:
cc_library(
name = "app-hdrs",
hdrs = [
"include/header.hpp",
],
srcs = [
"include/header.hpp",
],
strip_include_prefix = "include",
)
cc_binary(
name = "app",
srcs = [
"main.cpp",
],
deps = [
":app-hdrs",
],
)
您需要一个在项目文件夹中称为 WORKSPACE
的文件:
$ tree .
├── include
│ └── header.hpp
└── main.cpp
└── BUILD.bazel
└── WORKSPACE
然后,您可以使用以下commmand构建应用程序:
bazel build //:app
,还指定了copts
-Flag中的Incluble路径:
cc_binary(
name = "app",
srcs = [
"main.cpp",
"include/header.hpp",
],
copts = ["-Iinclude", "-Wall", "-Werror"],
)
cc_binary(
name = "app",
includes = [ "include" ],
srcs = [
"main.cpp",
"include/header.hpp",
],
copts = [ "-Wall", "-Werror" ],
)
相关文章:
- 在c++中用vector填充一个简单的动态数组
- (C++)分析树以计算返回错误值的简单算术表达式
- 我的简单if-else语句是如何无法访问的代码
- 使用简单类型列表实现的指数编译时间.为什么
- 如何在BST的这个简单递归实现中消除警告
- 如何建立使用模板函数的lambda函数的尾部返回类型
- 一种在C++中读取TXT配置文件的简单方法
- 关于简单C++函数(is_palindrome)的逻辑的问题
- 显示错误输出的简单数组排序程序
- 如何在c++中从git建立外部库
- 当无法使用模板和宏时,生成类型变体C++代码的最简单方法是什么?
- 退出简单while循环时出现问题
- 为什么简单的算术减法在"if"条件下不起作用?
- 无法在C++中建立与MySQL数据库的连接
- C++-字符串是否包含一个带有简单循环的单词
- 关于 c++ 函数中指针赋值的简单问题
- 从函数返回任意简单类型的数据
- 如何在没有函数的情况下编写此代码并使C++更简单?
- NAS(使用 qt/linux)- 无法建立简单的音频服务器连接测试
- 我如何用巴泽尔建立这个简单的例子