aboutsummaryrefslogtreecommitdiffhomepage
path: root/site
diff options
context:
space:
mode:
authorGravatar Kristina Chodorow <kchodorow@google.com>2015-10-08 14:58:34 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2015-10-09 14:39:58 +0000
commitc97ee9c33285b36926ed560e4c089b6bc28f4a25 (patch)
treef31318ad25da46b8e82db7ff6ea0e21f8b69d83c /site
parent88bd33adf7c07098c7f3f9bf00426399d08a807b (diff)
Recommend copts for external include paths, as it's less infectious than includes=[]
includes=[] is inherited by all rules that depend on it, which makes resolving ordering issues more difficult. -- MOS_MIGRATED_REVID=104961784
Diffstat (limited to 'site')
-rw-r--r--site/docs/cpp.md21
1 files changed, 11 insertions, 10 deletions
diff --git a/site/docs/cpp.md b/site/docs/cpp.md
index db0a1b753d..3566dc9f3a 100644
--- a/site/docs/cpp.md
+++ b/site/docs/cpp.md
@@ -145,7 +145,7 @@ cc_library(
name = "some_lib",
srcs = ["some_lib.cc"],
hdrs = ["some_lib.h"],
- includes = ["."],
+ copts = ["-Ithird_party/some_lib"],
)
```
@@ -176,9 +176,9 @@ more complicated:
`gtest-1.7.0/src/`, so we need to exclude it from the compile or we'll get
link errors for duplicate symbols.
* It uses header files that relative to the `gtest-1.7.0/include/` directory
- (`"gtest/gtest.h"`), so we must add that directory the includes.
-* It uses "private" header files in `src/`, so we add `.` to the includes so it
- can `#include "src/gtest-internal-inl.h"`.
+ (`"gtest/gtest.h"`), so we must add that directory the include paths.
+* It uses "private" header files in `src/`, so we add that to the include pahs,
+ too, so it can `#include "src/gtest-internal-inl.h"`.
* It needs to link in pthread, so we add that as a `linkopt`.
The final rule looks like this:
@@ -191,9 +191,9 @@ cc_library(
exclude = ["gtest-1.7.0/src/gtest-all.cc"]
),
hdrs = glob(["gtest-1.7.0/include/**/*.h"]),
- includes = [
- "gtest-1.7.0",
- "gtest-1.7.0/include"
+ copts = [
+ "-Iexternal/gtest/gtest-1.7.0",
+ "-Iexternal/gtest/gtest-1.7.0/include"
],
linkopts = ["-pthread"],
visibility = ["//visibility:public"],
@@ -224,9 +224,9 @@ cc_library(
exclude = ["src/gtest-all.cc"]
),
hdrs = glob(["include/**/*.h"]),
- includes = [
- ".",
- "include"
+ copts = [
+ "-Iexternal/gtest",
+ "-Iexternal/gtest/include"
],
linkopts = ["-pthread"],
visibility = ["//visibility:public"],
@@ -251,6 +251,7 @@ Then create a BUILD file for your tests:
cc_test(
name = "my_test",
srcs = ["my_test.cc"],
+ copts = ["-Iexternal/gtest"],
deps = ["@gtest//:main"],
)
```