cpp-use-cases.md: update use of http_archive
Update the documentation on common C++ build use cases, to use the
Starlark version of http_archive instead of the native versions that
have been removed by now.
Change-Id: If8166832c29b12d5f807298952bc82f7896f8f3c
PiperOrigin-RevId: 245052433
diff --git a/site/docs/cpp-use-cases.md b/site/docs/cpp-use-cases.md
index 47c6353..26f0a6d 100644
--- a/site/docs/cpp-use-cases.md
+++ b/site/docs/cpp-use-cases.md
@@ -110,20 +110,22 @@
## Including external libraries
Suppose you are using [Google Test](https://github.com/google/googletest). You
-can use one of the `new_` repository functions in the `WORKSPACE` file to
+can use one of the repository functions in the `WORKSPACE` file to
download Google Test and make it available in your repository:
```python
-new_http_archive(
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
+http_archive(
name = "gtest",
url = "https://github.com/google/googletest/archive/release-1.7.0.zip",
sha256 = "b58cb7547a28b2c718d1e38aee18a3659c9e3ff52440297e965f5edffe34b6d0",
- build_file = "gtest.BUILD",
+ build_file = "@//:gtest.BUILD",
)
```
-**NOTE:** If the destination already contains a `BUILD` file, you can use one of
-the `non-new_` functions.
+**NOTE:** If the destination already contains a `BUILD` file, you can leave
+out the `build_file` attribute.
Then create `gtest.BUILD`, a `BUILD` file used to compile Google Test.
Google Test has several "special" requirements that make its `cc_library` rule
@@ -161,11 +163,13 @@
```
This is somewhat messy: everything is prefixed with `googletest-release-1.7.0`
-as a byproduct of the archive's structure. You can make `new_http_archive` strip
+as a byproduct of the archive's structure. You can make `http_archive` strip
this prefix by adding the `strip_prefix` attribute:
```python
-new_http_archive(
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
+http_archive(
name = "gtest",
url = "https://github.com/google/googletest/archive/release-1.7.0.zip",
sha256 = "b58cb7547a28b2c718d1e38aee18a3659c9e3ff52440297e965f5edffe34b6d0",