Skip to content

Commit

Permalink
feat: wire up protobuf if requested (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle authored May 24, 2024
1 parent e2607d7 commit d46f05a
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 23 deletions.
7 changes: 6 additions & 1 deletion scaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ questions:
message: Setup version stamping?
description: "Read more: https://blog.aspect.build/versioning-releases-from-a-monorepo"
confirm: true
- name: protobuf
prompt:
message: Setup Protocol Buffers?
description: "Install rules_proto; see https://github.com/bazelbuild/rules_proto/discussions/213"
confirm: true

features:
- value: "{{ .Scaffold.lint }}"
Expand Down Expand Up @@ -71,12 +76,12 @@ presets:
lint: true
langs: ['JavaScript & TypeScript', 'Python']
stamp: true
protobuf: true
js:
lint: true
langs: ['JavaScript & TypeScript']
py:
lint: true
langs: ['Python']
minimal:
lint: false
langs: []
3 changes: 3 additions & 0 deletions {{ .ProjectSnake }}/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ common --@aspect_rules_ts//ts:default_to_tsc_transpiler
# --config=release
common:release --stamp --workspace_status_command=./tools/workspace_status.sh
{{ end }}
{{- if .Scaffold.protobuf }}
common --incompatible_enable_proto_toolchain_resolution
{{ end }}

# Load any settings & overrides specific to the current user from `.aspect/bazelrc/user.bazelrc`.
# This file should appear in `.gitignore` so that settings are not shared with team members. This
Expand Down
14 changes: 12 additions & 2 deletions {{ .ProjectSnake }}/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
bazel_dep(name = "aspect_bazel_lib", version = "2.7.6")
{{- if .Scaffold.lint }}
bazel_dep(name = "aspect_rules_lint", version = "0.21.0")
{{- end }}
{{- if .Scaffold.protobuf }}
bazel_dep(name = "rules_proto", version = "6.0.0")
bazel_dep(name = "toolchains_protoc", version = "0.2.4")
{{- end}}
bazel_dep(name = "rules_multitool", version = "0.7.1")
{{- if .Computed.javascript }}
bazel_dep(name = "aspect_rules_js", version = "2.0.0-rc1")
bazel_dep(name = "aspect_rules_ts", version = "3.0.0-rc0")
{{- end}}
{{- end }}
{{- if .Computed.python }}
bazel_dep(name = "rules_python", version = "0.32.2")
bazel_dep(name = "aspect_rules_py", version = "0.7.3")
Expand Down Expand Up @@ -50,4 +56,8 @@ pip.parse(
python_version = "3.9",
)
use_repo(pip, "pip")
{{- end}}
{{- end }}

{{- if .Scaffold.protobuf }}
register_toolchains("//tools/toolchains:all", dev_dependency = True)
{{- end }}
2 changes: 1 addition & 1 deletion {{ .ProjectSnake }}/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# direct and indirect dependencies are pinned.
# Therefore we only need to constrain versions in this file when some ranges
# of dependency versions are not compatible.
requests
protobuf
31 changes: 12 additions & 19 deletions {{ .ProjectSnake }}/requirements_lock.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,16 @@
#
# bazel run //:requirements.update
#
certifi==2023.7.22 \
--hash=sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082 \
--hash=sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9
# via requests
charset-normalizer==2.1.1 \
--hash=sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845 \
--hash=sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f
# via requests
idna==3.7 \
--hash=sha256:028ff3aadf0609c1fd278d8ea3089299412a7a8b9bd005dd08b9f8285bcb5cfc \
--hash=sha256:82fee1fc78add43492d3a1898bfa6d8a904cc97d8427f683ed8e798d07761aa0
# via requests
requests==2.32.0 \
--hash=sha256:f2c3881dddb70d056c5bd7600a4fae312b2a300e39be6a118d30b90bd27262b5 \
--hash=sha256:fa5490319474c82ef1d2c9bc459d3652e3ae4ef4c4ebdd18a21145a47ca4b6b8
protobuf==5.26.0 \
--hash=sha256:2c334550e1cb4efac5c8a3987384bf13a4334abaf5ab59e40479e7b70ecd6b19 \
--hash=sha256:6ee9d1aa02f951c5ce10bf8c6cfb7604133773038e33f913183c8b5201350600 \
--hash=sha256:7e47c57303466c867374a17b2b5e99c5a7c8b72a94118e2f28efb599f19b4069 \
--hash=sha256:82f5870d74c99addfe4152777bdf8168244b9cf0ac65f8eccf045ddfa9d80d9b \
--hash=sha256:8eef61a90631c21b06b4f492a27e199a269827f046de3bb68b61aa84fcf50905 \
--hash=sha256:a49b6c5359bf34fb7bf965bf21abfab4476e4527d822ab5289ee3bf73f291159 \
--hash=sha256:ca825f4eecb8c342d2ec581e6a5ad1ad1a47bededaecd768e0d3451ae4aaac2b \
--hash=sha256:dfd29f6eb34107dccf289a93d44fb6b131e68888d090b784b691775ac84e8213 \
--hash=sha256:e184175276edc222e2d5e314a72521e10049938a9a4961fe4bea9b25d073c03f \
--hash=sha256:efd4f5894c50bd76cbcfdd668cd941021333861ed0f441c78a83d8254a01cc9f \
--hash=sha256:f9ecc8eb6f18037e0cbf43256db0325d4723f429bca7ef5cd358b7c29d65f628
# via -r requirements.txt
urllib3==1.26.18 \
--hash=sha256:34b97092d7e0a3a8cf7cd10e386f401b3737364026c45e622aa02903dffe0f07 \
--hash=sha256:f8ecc1bba5667413457c529ab955bf8c67b45db799d159066261719e328580a0
# via requests
14 changes: 14 additions & 0 deletions {{ .ProjectSnake }}/tools/toolchains/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Scaffold.protobuf }}
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain")

{{- if .Computed.python }}
# Configure protoc to have the right arguments for generating Python stubs.
proto_lang_toolchain(
name = "protoc_py_toolchain",
command_line = "--python_out=%s",
progress_message = "Generating Python proto_library %{label}",
runtime = "@pip//protobuf",
toolchain_type = "@rules_python//python/proto:toolchain_type",
)
{{- end}}
{{- end}}

0 comments on commit d46f05a

Please sign in to comment.