Commit Graph

1571 Commits

Author SHA1 Message Date
Paul Stemmet f5bdb0d3f4
merge: master <--- feat/refactor-rust-rules
* HEAD
| \
| * 87aee8e1 <github@luxolus.com> rust: refactor {prost_proto|tonic_grpc}_library macros
| /
| master

Signed-off-by: Bazaah <github@luxolus.com>
2024-09-28 01:07:58 +00:00
Paul Stemmet 87aee8e13b
rust: refactor {prost_proto|tonic_grpc}_library macros
So, I think I understand where the original work is coming from, but
fundamentally disagree with its implementation.

The idea was to create "drop in" macros that you can use to easily
create rust pb bindings, abstracting over the varied and complex tooling
that the rust ecosystem requires.

I believe this to be a mistake:

1. Potential for version mismatch for rlib symbols

    Anyone who remembers the "bad old days" of tokio 0.x (and futures
    0.1, for that matter) knows the pain of attempting to link against
    two different versions of the same symbol, because some dep you have
    is using an older version of the exported symbol.

    The use of "bundled" fallbacks in the varied xxx_dep(s) macro args
    invite this same issue.

    Instead, callers should made aware of the needed deps and be
    required to provide their own, ensuring their projects remain
    coherent.

    The bundled should *only* be used for creating the needed binaries
    for protoc codegen

2. Focus on UX over documentation

    The entire //rust:... subsystem of this project is misleadingly
    documented, to the point that it is easier to simply read the
    entire code base, rather than the docs.

    There was an attempt to compensate for this via the examples/ and
    ease-of-use in the public macros and rules, however the lack of
    documentation leaves users that need to integrate with more complex
    monorepos completely confused about how to correctly satisfy the
    mandatory args, what expected values for these args are, etc

Therefore, this refactor of the top level *_library macros adds proper
documentation each, and simplifies the args and notifies the caller of
the requirements to call each macro.
2024-09-28 00:48:14 +00:00
Paul Stemmet decb8d8c26
rust: fixup rust_prost_plugin tool label 2024-09-27 21:00:03 +00:00
Paul Stemmet 4b4af424c8
rust/3rdparty: crates_vendor repin 2024-09-27 18:24:36 +00:00
Paul Stemmet 40dd798dbf
rust/3rdparty: bump deps, rm example deps 2024-09-27 18:02:00 +00:00
Paul Stemmet bfe04468f3
internal: ensure proto_compile copies files not links
at least in bazel 7.2, this leads to dangling symlink issues, and
the remote cache complains about absolute symlinks.
2024-09-27 17:14:40 +00:00
Paul Stemmet 99827e2d37
rust: rm erroneous mod_file kwarg to rust_proto_crate_root
I'm not sure how or even if this ever worked previously
2024-09-27 17:13:55 +00:00
Adam Liddell f6dc2de237 Fix buildifier lint 2023-12-14 17:22:04 +00:00
Adam Liddell c77d668709 Prepare 4.6.0 release 2023-12-14 17:18:44 +00:00
Adam Liddell 72e5f39e8d Apply buildifier 2023-12-14 17:12:27 +00:00
Adam Liddell 32e9feb4e2
Merge pull request #296 from maghoff/rust-allow-all-clippy-lints
rust: Allow all clippy lints for generated code.
2023-12-14 17:11:20 +00:00
Adam Liddell 6228726efc
Merge branch 'master' into rust-allow-all-clippy-lints 2023-12-14 17:00:46 +00:00
Adam Liddell 2996d2ff01
Merge pull request #297 from maghoff/rust-json-compliant-casing
rust: JSON compliant casing
2023-12-14 16:16:47 +00:00
Adam Liddell 95c188a970
Merge branch 'master' into rust-json-compliant-casing 2023-12-14 15:09:31 +00:00
Adam Liddell fdf1ea5fc9
Merge branch 'master' into rust-json-compliant-casing 2023-12-14 15:09:06 +00:00
Adam Liddell 60b8b27460 Update rulegen to apply Bazel 7 attr fix 2023-12-14 15:07:22 +00:00
Adam Liddell e7349ceb6c
Merge pull request #298 from yeswalrus/patch-1
Only forward nocopts to cc_library if present in kwargs
2023-12-14 14:40:05 +00:00
Walter Gray fcc828b67f
Update cpp_proto_library.bzl
Modifies the cc_library call to only forward arguments if they're present in kwargs.
This is vital for bazel 7.0.0 compatibility since the `nocopts` attribute is removed (it's actually been deprecated since 2019 but the documentation was never updated).
2023-12-06 11:18:57 -08:00
Magnus Hovland Hoff a20e3ebb6e Use casing compliant with standard JSON serialization.
Quoting [1]:

> By default proto3 JSON printer should convert the field name to
> lowerCamelCase and use that as the JSON name. An implementation
> may provide an option to use proto field name as the JSON name
> instead.

The serde plugin does this correctly, but when the rules specify
the `preserve_proto_field_names` option, two things happen:

1. The generated serde code preserves the proto field names
2. The user of these bazel rules cannot override the choice

If, instead, rules_proto_grpc avoids specifying this flag, it can
be optionally added to the rust_prost_proto_library invocation in
user code via `options`:

    options = {
        "//rust:rust_serde_plugin": ["preserve_proto_field_names"],
    },

Thus, the better default is to leave out this flag from
rules_proto_grpc and instead allow the user to choose.

[1]: https://protobuf.dev/programming-guides/proto3/#json
2023-12-05 12:31:37 +01:00
Magnus Hovland Hoff f75e9d5bcf Allow all clippy lints for generated code.
The lints are generally appropriate for hand-written code, but
oftentimes the best solution for generated code violates such
guidelines. Typically, therefore, generated code is not subject to
such linting.

The most precise way to disable linting for this generated code in
a bazel environment is to add `#![allow(clippy::all)]` to the top
level of the generated crate.
2023-12-05 12:22:26 +01:00
Adam Liddell aa1786dd77 Partial revert of 38f4d41424 2023-10-18 15:20:45 +01:00
Adam Liddell 38f4d41424 Update docs and readme for 4.5.0 2023-09-12 13:04:37 +01:00
Adam Liddell 6dd1799084 Remove platforms repo, see #263 2023-09-11 13:38:00 +01:00
Adam Liddell e7d0d2a5d7 Merge branch 'master' of github.com:rules-proto-grpc/rules_proto_grpc 2023-09-11 12:33:17 +01:00
Adam Liddell 34d9f5b3b2 Update changelog to prepare 4.5.0 release 2023-09-11 12:32:58 +01:00
Adam Liddell 6ed0781461
Merge pull request #265 from echochamber/rust-prost-tonic
Rust prost tonic
2023-09-08 12:51:41 +01:00
Adam Liddell ea677214f1 Remove comment about flag that is not actually specified 2023-09-08 12:27:00 +01:00
Adam Liddell f2cc8a3369 Align rulegen and buildifier 2023-09-08 12:20:17 +01:00
Adam Liddell 6a0f5f93a6 Workaround failing hash derive 2023-09-08 12:00:14 +01:00
Adam Liddell 284f8985ff Fix incorrectly merged line... 2023-09-08 11:46:22 +01:00
Adam Liddell 6d0eadd0ab
Merge branch 'master' into rust-prost-tonic 2023-09-08 11:44:10 +01:00
Adam Liddell 798a95fca2 Fix test failures due to ipv4/ipv6 mismatch 2023-09-08 11:38:51 +01:00
Adam Liddell e58969fd93 Improve C++ client error logging to debug test failure 2023-09-08 11:30:16 +01:00
Adam Liddell 3cf9c7ec36
Merge pull request #274 from dprogm/feature/snake_case_path_conversion
Provide a path conversion from snake_case to dashed-case
2023-09-07 15:37:05 +01:00
Adam Liddell 79d04faea1
Apply buildifier 2023-09-07 15:36:13 +01:00
Dirk Müller c17fe86581 Provide a path conversion from snake_case to dashed-case 2023-09-07 15:19:15 +01:00
Adam Liddell 203f6d0d6d
Merge pull request #279 from kartones-forks/fix-custom-plugins-doc
docs: fix missing 'env' at custom_plugins rst doc
2023-08-29 14:20:08 +01:00
Kartones 336fe336b3
docs: fix missing 'env' at custom_plugins rst doc
As stated in
c6a88cbc4f/internal/plugin.bzl (L53C10-L53C13)
the text and type is fine but name 'extra_protoc_args' is incorrectly duplicated
2023-08-22 06:47:49 +02:00
Adam Liddell c6a88cbc4f
Merge pull request #276 from jemeador/cpp-no-prefix-mode
Support NO_PREFIX output_mode for cpp rules
2023-08-18 16:21:32 +01:00
Jeremy Meador dd753a2881 Support NO_PREFIX output_mode for cpp rules 2023-08-09 09:37:52 -07:00
Adam Liddell 7514aab1ad Remove unused args 2023-07-26 22:50:34 +01:00
Adam Liddell 47f267d82c Fix rust grpc compile example rulegen 2023-07-26 22:47:35 +01:00
Adam Liddell dcf69b2a49 Move ProstProtoInfo into rust common.bzl 2023-07-26 22:43:14 +01:00
Adam Liddell ba53acaef3 Fix rust proto library example rulegen 2023-07-26 22:40:30 +01:00
Adam Liddell 209b776169 Fix rust proto compile example rulegen 2023-07-26 22:29:53 +01:00
Adam Liddell 4cc5cc68d5 Actually add common.bzl... 2023-07-25 23:54:25 +01:00
Adam Liddell 4bdc3ad38c Extract _prepare_prost_proto_deps to common.bzl 2023-07-25 23:51:17 +01:00
Adam Liddell 09d5274b39 Extract _crate function to common.bzl 2023-07-25 23:49:29 +01:00
Adam Liddell 63fe77af11 Rename compile.bzl -> common.bzl 2023-07-25 23:48:01 +01:00
Adam Liddell 49f68d78b0 Generate Rust library rules with rulegen 2023-07-25 23:44:06 +01:00