generated from bazel-contrib/rules-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: examples folder standalone (#25)
- Loading branch information
Showing
26 changed files
with
183 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
e2e/ | ||
e2e/ | ||
examples/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
load("@platforms//host:constraints.bzl", "HOST_CONSTRAINTS") | ||
load("@bazel_skylib//rules:build_test.bzl", "build_test") | ||
|
||
platform( | ||
name = "no_cgo_host_platform", | ||
constraint_values = HOST_CONSTRAINTS + [ | ||
"@rules_go//go/toolchain:cgo_off", | ||
], | ||
# Placeholder until there are docs tests | ||
build_test( | ||
name = "tautology", | ||
targets = ["//:BUILD.bazel"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1 @@ | ||
# Marker that this is the root of a Bazel workspace. | ||
|
||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar") | ||
|
||
# Note: this is simpler than using rules_jvm_external with a maven installation, | ||
# but users would probably get this JAR file that way. | ||
http_jar( | ||
name = "protobuf-java", | ||
sha256 = "0532ad1024d62361561acaedb974d7d16889e7670b36e23e9321dd6b9d334ef9", | ||
urls = ["https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/4.27.0-RC3/protobuf-java-4.27.0-RC3.jar"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# The main ingredient: allow us to register toolchains other than com_google_protobuf targets | ||
common --incompatible_enable_proto_toolchain_resolution | ||
common --@aspect_rules_py//py:interpreter_version=3.9.18 | ||
|
||
# See https://github.com/bazelbuild/rules_python/issues/1069#issuecomment-1942053014 | ||
common --action_env=RULES_PYTHON_ENABLE_PYSTAR=0 | ||
|
||
# Force rules_go to disable CGO even though we have a (fake) C++ toolchain registered. | ||
common --host_platform=//tools:no_cgo_host_platform |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
7.3.0 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
bazel_dep(name = "toolchains_protoc", version = "0.0.0") | ||
bazel_dep(name = "aspect_bazel_lib", version = "2.8.1") | ||
bazel_dep(name = "aspect_rules_py", version = "0.7.1") | ||
bazel_dep(name = "rules_java", version = "7.6.5") | ||
bazel_dep(name = "rules_proto", version = "6.0.0") | ||
bazel_dep(name = "rules_python", version = "0.32.2") | ||
bazel_dep(name = "rules_go", version = "0.48.0") | ||
bazel_dep(name = "rules_uv", version = "0.10.0") | ||
|
||
# This example is in the same repo with the ruleset, so we should point to the code at HEAD | ||
# rather than use any release on the Bazel Central Registry. | ||
local_path_override( | ||
module_name = "toolchains_protoc", | ||
path = "..", | ||
) | ||
|
||
####### PROTOBUF ########## | ||
protoc = use_extension("@toolchains_protoc//protoc:extensions.bzl", "protoc") | ||
protoc.toolchain( | ||
google_protobuf = "com_google_protobuf", | ||
# Demonstrate overriding the default version | ||
version = "v28.0", | ||
) | ||
use_repo(protoc, "com_google_protobuf", "toolchains_protoc_hub") | ||
|
||
register_toolchains("@toolchains_protoc_hub//:all") | ||
|
||
register_toolchains("//tools/toolchains:all") | ||
|
||
####### PYTHON ########## | ||
# Shows how a typical Python user fetches all the dependencies of their app, including the protobuf runtime | ||
dev_pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") | ||
dev_pip.parse( | ||
hub_name = "pypi", | ||
python_version = "3.11", | ||
requirements_lock = "//tools:requirements.txt", | ||
) | ||
use_repo(dev_pip, "pypi") | ||
|
||
####### JAVA ########## | ||
# Note: this is simpler than using rules_jvm_external with a maven installation, | ||
# however it can cause version skew on the classpath if Coursier resolves a different version | ||
# from the constraint solution. | ||
# Users with a maven.install should instead do something like | ||
# maven.install( | ||
# artifacts = [ | ||
# "com.google.protobuf:protobuf-java:4.27.1", | ||
# "io.grpc:grpc-all:1.51.1", | ||
# ], | ||
# lock_file = "//:maven_install.json", | ||
# ) | ||
http_jar = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar") | ||
|
||
http_jar( | ||
name = "protobuf-java", | ||
sha256 = "0532ad1024d62361561acaedb974d7d16889e7670b36e23e9321dd6b9d334ef9", | ||
urls = ["https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/4.27.0-RC3/protobuf-java-4.27.0-RC3.jar"], | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
py_test( | ||
name = "message_test", | ||
srcs = ["message_test.py"], | ||
deps = ["//examples:foo_py_proto"], | ||
deps = ["//:foo_py_proto"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
load("@platforms//host:constraints.bzl", "HOST_CONSTRAINTS") | ||
load("@rules_uv//uv:pip.bzl", "pip_compile") | ||
|
||
pip_compile( | ||
name = "generate_requirements_txt", | ||
requirements_in = "requirements.in", | ||
requirements_txt = "requirements.txt", | ||
) | ||
|
||
# Don't allow rules_go to compile the Go SDK with cgo enabled, as that | ||
# would cause a dependency on a functional C++ toolchain. | ||
# This value is referenced in the .bazelrc | ||
platform( | ||
name = "no_cgo_host_platform", | ||
constraint_values = HOST_CONSTRAINTS + [ | ||
"@rules_go//go/toolchain:cgo_off", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
protobuf==5.28.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# This file was autogenerated by uv via the following command: | ||
# bazel run @@//tools:generate_requirements_txt | ||
--index-url https://pypi.org/simple | ||
|
||
protobuf==5.28.0 \ | ||
--hash=sha256:018db9056b9d75eb93d12a9d35120f97a84d9a919bcab11ed56ad2d399d6e8dd \ | ||
--hash=sha256:510ed78cd0980f6d3218099e874714cdf0d8a95582e7b059b06cabad855ed0a0 \ | ||
--hash=sha256:532627e8fdd825cf8767a2d2b94d77e874d5ddb0adefb04b237f7cc296748681 \ | ||
--hash=sha256:6206afcb2d90181ae8722798dcb56dc76675ab67458ac24c0dd7d75d632ac9bd \ | ||
--hash=sha256:66c3edeedb774a3508ae70d87b3a19786445fe9a068dd3585e0cefa8a77b83d0 \ | ||
--hash=sha256:6d7cc9e60f976cf3e873acb9a40fed04afb5d224608ed5c1a105db4a3f09c5b6 \ | ||
--hash=sha256:853db610214e77ee817ecf0514e0d1d052dff7f63a0c157aa6eabae98db8a8de \ | ||
--hash=sha256:d001a73c8bc2bf5b5c1360d59dd7573744e163b3607fa92788b7f3d5fefbd9a5 \ | ||
--hash=sha256:dde74af0fa774fa98892209992295adbfb91da3fa98c8f67a88afe8f5a349add \ | ||
--hash=sha256:dde9fcaa24e7a9654f4baf2a55250b13a5ea701493d904c54069776b99a8216b \ | ||
--hash=sha256:eef7a8a2f4318e2cb2dee8666d26e58eaf437c14788f3a2911d0c3da40405ae8 | ||
# via -r tools/requirements.in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"""Define a non-functional cc toolchain. | ||
To fail-fast in cases where we are forced to compile third-party C++ code, | ||
define a cc toolchain that doesn't work, by using 'false' as the compiler. | ||
See https://bazel.build/tutorials/ccp-toolchain-config | ||
""" | ||
|
||
load("defs.bzl", "cc_toolchain_config") | ||
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain") | ||
|
||
# Configure protoc to have the right arguments for generating Python stubs. | ||
# NB: the protobuf team intends to remove --python_out and instead use a protoc plugin for Python stub emit. | ||
proto_lang_toolchain( | ||
name = "protoc_py_toolchain", | ||
command_line = "--python_out=%s", | ||
progress_message = "Generating Python proto_library %{label}", | ||
runtime = "@pypi//protobuf", | ||
toolchain_type = "@rules_python//python/proto:toolchain_type", | ||
) | ||
|
||
# Same as above, but for Java | ||
proto_lang_toolchain( | ||
name = "protoc_java_toolchain", | ||
command_line = "--java_out=%s", | ||
progress_message = "Generating Java proto_library %{label}", | ||
runtime = "@protobuf-java//jar", | ||
toolchain_type = "@rules_java//java/proto:toolchain_type", | ||
) | ||
|
||
################ | ||
# Setup a non-functional C++ toolchain, so we're assured that no C++ compilation | ||
# will be expected for engineers working in our repo. | ||
# That's the critical guarantee of toolchains_protoc | ||
filegroup(name = "empty") | ||
|
||
cc_toolchain_config(name = "noop_toolchain_config") | ||
|
||
cc_toolchain( | ||
name = "noop_toolchain", | ||
all_files = ":empty", | ||
compiler_files = ":empty", | ||
dwp_files = ":empty", | ||
linker_files = ":empty", | ||
objcopy_files = ":empty", | ||
strip_files = ":empty", | ||
supports_param_files = 0, | ||
toolchain_config = ":noop_toolchain_config", | ||
toolchain_identifier = "noop-toolchain", | ||
) | ||
|
||
toolchain( | ||
name = "cc_toolchain", | ||
toolchain = ":noop_toolchain", | ||
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", | ||
) |
File renamed without changes.
Oops, something went wrong.