Skip to content
This repository was archived by the owner on Dec 8, 2021. It is now read-only.

Commit 45961b8

Browse files
authored
doc: improve instructions for WORKSPACE files (#1254)
We never explained that users need to load a Starlark function to use `http_archive()`. Also fix the documentation to use the current release, this will get "stale", but would be still functional and we warn users to update the version and SHA256 in the comments. Since I was fixing this I also updated the INSTALL.md file (and its generator) with the changes from #1252.
1 parent da2c79b commit 45961b8

File tree

4 files changed

+37
-25
lines changed

4 files changed

+37
-25
lines changed

INSTALL.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
There are two primary ways of obtaining `google-cloud-cpp-spanner`. You can use git:
77

88
```bash
9-
git clone [email protected]:googleapis/google-cloud-cpp-spanner.git $HOME/project
9+
git clone [email protected]:googleapis/google-cloud-cpp-spanner.git $HOME/google-cloud-cpp-spanner
1010
```
1111

1212
Or obtain the tarball release:
1313

1414
```bash
15-
mkdir -p $HOME/project
16-
wget -q https://github.com/googleapis/google-cloud-cpp-spanner/archive/v0.4.0.tar.gz
17-
tar -xf v0.4.0.tar.gz -C $HOME/project --strip=1
15+
mkdir -p $HOME/google-cloud-cpp-spanner
16+
wget -q https://github.com/googleapis/google-cloud-cpp-spanner/archive/v0.7.0.tar.gz
17+
tar -xf v0.7.0.tar.gz -C $HOME/google-cloud-cpp-spanner --strip=1
1818
```
1919

2020
# Installing google-cloud-cpp-spanner
@@ -84,12 +84,15 @@ download and compile `google-cloud-cpp-spanner` as part of you Bazel build. Add
8484
the following commands to your `WORKSPACE` file:
8585

8686
```Python
87+
# Add the necessary Starlark functions to fetch google-cloud-cpp-spanner.
88+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
89+
8790
# Update the version and SHA256 digest as needed.
8891
http_archive(
8992
name = "com_github_googleapis_google_cloud_cpp_spanner",
90-
sha256 = "1dbca07e3f268ffab4461a1d98b16201adda4688866a1929ac71c22c46e4fe74",
91-
strip_prefix = "google-cloud-cpp-spanner-0.6.0",
92-
url = "https://github.com/googleapis/google-cloud-cpp-spanner/archive/v0.6.0.tar.gz",
93+
sha256 = "9d7bd3de8e38f7e4b3e917766ed08fd8c8ff59a8b2f0997c4b1cb781a6fd1558",
94+
strip_prefix = "google-cloud-cpp-spanner-0.7.0",
95+
url = "https://github.com/googleapis/google-cloud-cpp-spanner/archive/v0.7.0.tar.gz",
9396
)
9497

9598
# Configure @com_google_googleapis to only compile C++ and gRPC:

ci/test-install/WORKSPACE

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,22 @@
1616
# loaded into a different Bazel project.
1717
workspace(name = "com_github_googleapis_google_cloud_cpp_spanner_test_install")
1818

19-
# Spanner currently does not have a release. Applications should use something
20-
# like the following:
19+
# To use the Cloud Spanner C++ client library applications should download it
20+
# using `http_archive()`. For example, use the following Starlark commands
21+
# (change the version and SHA256 hash as needed):
22+
#
23+
# load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
2124
#
2225
# http_archive(
2326
# name = "com_github_googleapis_google_cloud_cpp_spanner",
24-
# url = "http://github.com/googleapis/google-cloud-cpp-spanner/archive/v0.1.0.tar.gz",
25-
# strip_prefix = "google-cloud-cpp-spanner-0.1.0",
26-
# sha256 = "...",
27+
# sha256 = "9d7bd3de8e38f7e4b3e917766ed08fd8c8ff59a8b2f0997c4b1cb781a6fd1558",
28+
# strip_prefix = "google-cloud-cpp-spanner-0.7.0",
29+
# url = "https://github.com/googleapis/google-cloud-cpp-spanner/archive/v0.7.0.tar.gz",
2730
# )
2831
#
29-
30-
# But we want to test that the *current* version is correct, the CI builds
31-
# always have the source in /v.
32+
# In this WORKSPACE file we want to test that the *current* version is correct,
33+
# the CI builds always have the source in /v, so we use:
34+
#
3235
local_repository(
3336
name = "com_github_googleapis_google_cloud_cpp_spanner",
3437
path = "/v",

ci/test-readme/generate-install.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ cat <<'END_OF_PREAMBLE'
2626
There are two primary ways of obtaining `google-cloud-cpp-spanner`. You can use git:
2727
2828
```bash
29-
git clone [email protected]:googleapis/google-cloud-cpp-spanner.git $HOME/project
29+
git clone [email protected]:googleapis/google-cloud-cpp-spanner.git $HOME/google-cloud-cpp-spanner
3030
```
3131
3232
Or obtain the tarball release:
3333
3434
```bash
35-
mkdir -p $HOME/project
36-
wget -q https://github.com/googleapis/google-cloud-cpp-spanner/archive/v0.4.0.tar.gz
37-
tar -xf v0.4.0.tar.gz -C $HOME/project --strip=1
35+
mkdir -p $HOME/google-cloud-cpp-spanner
36+
wget -q https://github.com/googleapis/google-cloud-cpp-spanner/archive/v0.7.0.tar.gz
37+
tar -xf v0.7.0.tar.gz -C $HOME/google-cloud-cpp-spanner --strip=1
3838
```
3939
4040
# Installing google-cloud-cpp-spanner
@@ -104,12 +104,15 @@ download and compile `google-cloud-cpp-spanner` as part of you Bazel build. Add
104104
the following commands to your `WORKSPACE` file:
105105
106106
```Python
107+
# Add the necessary Starlark functions to fetch google-cloud-cpp-spanner.
108+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
109+
107110
# Update the version and SHA256 digest as needed.
108111
http_archive(
109112
name = "com_github_googleapis_google_cloud_cpp_spanner",
110-
sha256 = "1dbca07e3f268ffab4461a1d98b16201adda4688866a1929ac71c22c46e4fe74",
111-
strip_prefix = "google-cloud-cpp-spanner-0.6.0",
112-
url = "https://github.com/googleapis/google-cloud-cpp-spanner/archive/v0.6.0.tar.gz",
113+
sha256 = "9d7bd3de8e38f7e4b3e917766ed08fd8c8ff59a8b2f0997c4b1cb781a6fd1558",
114+
strip_prefix = "google-cloud-cpp-spanner-0.7.0",
115+
url = "https://github.com/googleapis/google-cloud-cpp-spanner/archive/v0.7.0.tar.gz",
113116
)
114117
115118
# Configure @com_google_googleapis to only compile C++ and gRPC:

google/cloud/spanner/doc/spanner-main.dox

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,15 @@ In your [WORKSPACE][workspace-definition-link] file add a dependency to download
107107
and install the library, for example:
108108

109109
@code {.py}
110+
# Add the necessary Starlark functions to fetch google-cloud-cpp-spanner.
111+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
112+
110113
# Change the version and SHA256 hash as needed.
111114
http_archive(
112115
name = "com_github_googleapis_google_cloud_cpp_spanner",
113-
sha256 = "1dbca07e3f268ffab4461a1d98b16201adda4688866a1929ac71c22c46e4fe74",
114-
strip_prefix = "google-cloud-cpp-spanner-0.6.0",
115-
url = "https://github.com/googleapis/google-cloud-cpp-spanner/archive/v0.6.0.tar.gz",
116+
sha256 = "9d7bd3de8e38f7e4b3e917766ed08fd8c8ff59a8b2f0997c4b1cb781a6fd1558",
117+
strip_prefix = "google-cloud-cpp-spanner-0.7.0",
118+
url = "https://github.com/googleapis/google-cloud-cpp-spanner/archive/v0.7.0.tar.gz",
116119
)
117120
@endcode
118121

0 commit comments

Comments
 (0)