Skip to content

Commit 636f4de

Browse files
authored
feat(generator): add quickstart/.bazelrc (#8679)
1 parent 81edf11 commit 636f4de

83 files changed

Lines changed: 1883 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

generator/internal/scaffold_generator.cc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ void GenerateScaffold(
172172
{"quickstart/Makefile", GenerateQuickstartMakefile},
173173
{"quickstart/WORKSPACE.bazel", GenerateQuickstartWorkspace},
174174
{"quickstart/BUILD.bazel", GenerateQuickstartBuild},
175+
{"quickstart/.bazelrc", GenerateQuickstartBazelrc},
175176
};
176177

177178
auto const vars = ScaffoldVars(googleapis_path, output_path, service);
@@ -1093,6 +1094,37 @@ cc_binary(
10931094
printer.Print(variables, kText);
10941095
}
10951096

1097+
void GenerateQuickstartBazelrc(
1098+
std::ostream& os, std::map<std::string, std::string> const& variables) {
1099+
auto constexpr kText = R"""(# Copyright $copyright_year$ Google LLC
1100+
#
1101+
# Licensed under the Apache License, Version 2.0 (the "License");
1102+
# you may not use this file except in compliance with the License.
1103+
# You may obtain a copy of the License at
1104+
#
1105+
# https://www.apache.org/licenses/LICENSE-2.0
1106+
#
1107+
# Unless required by applicable law or agreed to in writing, software
1108+
# distributed under the License is distributed on an "AS IS" BASIS,
1109+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1110+
# See the License for the specific language governing permissions and
1111+
# limitations under the License.
1112+
1113+
# To workaround a bug in Bazel [1], gRPC requires this flag on macOS builds,
1114+
# and there is (AFAIK) no way to "inherit" their definitions.
1115+
# [1]: https://github.com/bazelbuild/bazel/issues/4341
1116+
build --copt=-DGRPC_BAZEL_BUILD
1117+
1118+
# Do not create the convenience links, they are inconvenient when the build
1119+
# runs inside a docker image or if one builds a quickstart and then builds
1120+
# the project separately.
1121+
build --experimental_convenience_symlinks=ignore
1122+
)""";
1123+
google::protobuf::io::OstreamOutputStream output(&os);
1124+
google::protobuf::io::Printer printer(&output, '$');
1125+
printer.Print(variables, kText);
1126+
}
1127+
10961128
} // namespace generator_internal
10971129
} // namespace cloud
10981130
} // namespace google

generator/internal/scaffold_generator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ void GenerateQuickstartWorkspace(
7272
std::ostream& os, std::map<std::string, std::string> const& variables);
7373
void GenerateQuickstartBuild(
7474
std::ostream& os, std::map<std::string, std::string> const& variables);
75+
void GenerateQuickstartBazelrc(
76+
std::ostream& os, std::map<std::string, std::string> const& variables);
7577

7678
} // namespace generator_internal
7779
} // namespace cloud

generator/internal/scaffold_generator_test.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,15 @@ TEST_F(ScaffoldGenerator, QuickstartBuild) {
277277
EXPECT_THAT(actual, Not(HasSubstr("$copyright_year$")));
278278
}
279279

280+
TEST_F(ScaffoldGenerator, QuickstartBazelrc) {
281+
auto const vars = ScaffoldVars(path(), path(), service());
282+
std::ostringstream os;
283+
GenerateQuickstartBazelrc(os, vars);
284+
auto const actual = std::move(os).str();
285+
EXPECT_THAT(actual, HasSubstr("2034"));
286+
EXPECT_THAT(actual, Not(HasSubstr("$copyright_year$")));
287+
}
288+
280289
} // namespace
281290
} // namespace generator_internal
282291
} // namespace cloud
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# To workaround a bug in Bazel [1], gRPC requires this flag on macOS builds,
16+
# and there is (AFAIK) no way to "inherit" their definitions.
17+
# [1]: https://github.com/bazelbuild/bazel/issues/4341
18+
build --copt=-DGRPC_BAZEL_BUILD
19+
20+
# Do not create the convenience links, they are inconvenient when the build
21+
# runs inside a docker image or if one builds a quickstart and then builds
22+
# the project separately.
23+
build --experimental_convenience_symlinks=ignore
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# To workaround a bug in Bazel [1], gRPC requires this flag on macOS builds,
16+
# and there is (AFAIK) no way to "inherit" their definitions.
17+
# [1]: https://github.com/bazelbuild/bazel/issues/4341
18+
build --copt=-DGRPC_BAZEL_BUILD
19+
20+
# Do not create the convenience links, they are inconvenient when the build
21+
# runs inside a docker image or if one builds a quickstart and then builds
22+
# the project separately.
23+
build --experimental_convenience_symlinks=ignore
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# To workaround a bug in Bazel [1], gRPC requires this flag on macOS builds,
16+
# and there is (AFAIK) no way to "inherit" their definitions.
17+
# [1]: https://github.com/bazelbuild/bazel/issues/4341
18+
build --copt=-DGRPC_BAZEL_BUILD
19+
20+
# Do not create the convenience links, they are inconvenient when the build
21+
# runs inside a docker image or if one builds a quickstart and then builds
22+
# the project separately.
23+
build --experimental_convenience_symlinks=ignore
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# To workaround a bug in Bazel [1], gRPC requires this flag on macOS builds,
16+
# and there is (AFAIK) no way to "inherit" their definitions.
17+
# [1]: https://github.com/bazelbuild/bazel/issues/4341
18+
build --copt=-DGRPC_BAZEL_BUILD
19+
20+
# Do not create the convenience links, they are inconvenient when the build
21+
# runs inside a docker image or if one builds a quickstart and then builds
22+
# the project separately.
23+
build --experimental_convenience_symlinks=ignore
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# To workaround a bug in Bazel [1], gRPC requires this flag on macOS builds,
16+
# and there is (AFAIK) no way to "inherit" their definitions.
17+
# [1]: https://github.com/bazelbuild/bazel/issues/4341
18+
build --copt=-DGRPC_BAZEL_BUILD
19+
20+
# Do not create the convenience links, they are inconvenient when the build
21+
# runs inside a docker image or if one builds a quickstart and then builds
22+
# the project separately.
23+
build --experimental_convenience_symlinks=ignore
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# To workaround a bug in Bazel [1], gRPC requires this flag on macOS builds,
16+
# and there is (AFAIK) no way to "inherit" their definitions.
17+
# [1]: https://github.com/bazelbuild/bazel/issues/4341
18+
build --copt=-DGRPC_BAZEL_BUILD
19+
20+
# Do not create the convenience links, they are inconvenient when the build
21+
# runs inside a docker image or if one builds a quickstart and then builds
22+
# the project separately.
23+
build --experimental_convenience_symlinks=ignore
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# To workaround a bug in Bazel [1], gRPC requires this flag on macOS builds,
16+
# and there is (AFAIK) no way to "inherit" their definitions.
17+
# [1]: https://github.com/bazelbuild/bazel/issues/4341
18+
build --copt=-DGRPC_BAZEL_BUILD
19+
20+
# Do not create the convenience links, they are inconvenient when the build
21+
# runs inside a docker image or if one builds a quickstart and then builds
22+
# the project separately.
23+
build --experimental_convenience_symlinks=ignore

0 commit comments

Comments
 (0)