Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust readme: use zig fetch in ## How to use #89

Merged
merged 2 commits into from
Jan 31, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,11 @@ There are 2 branches you can use for your development.
## How to use

1. Add `protobuf` to your `build.zig.zon`.
```zig
.{
.name = "my_project",
.version = "0.0.1",
.paths = .{""},
.dependencies = .{
.protobuf = .{
.url = "https://github.com/Arwalk/zig-protobuf/archive/<some-commit-sha>.tar.gz",
.hash = "12ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
// leave the hash as is, the build system will tell you which hash to put here based on your commit
},
},
}
```sh
zig fetch --save "git+https://github.com/Arwalk/zig-protobuf#v2.0.0"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing <3

```
1. Use the `protobuf` module
1. Use the `protobuf` module. In your `build.zig`'s build function, add the dependency as module before
`b.installArtifact(exe)`.
```zig
pub fn build(b: *std.Build) !void {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm hesitant to keep this one for context, the snippet "goes inside the build fn"

Copy link
Contributor Author

@42LM 42LM Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem :) i will just revert it. I have been overthinking this before, too 😅.

EDIT:
I totally understand where you are coming from @menduz, it is hard to find a good convention for this.

I do not really remember if at first i read it in an article about zig or simply saw it in the zigzap release notes, but i find this to be a good pattern.

So it is either easy to use for people who know the drill and can simply copy and insert, but does not give meaningful context for people who are not that familiar with zig yet

...or it gives additional information to people being not that familiar with the zig build process, but with manually selecting the lines you need to copy over to the build.zig file.

Its the small things haha 🫠

So in the end my conclusion is it is helpful to show pub fn build(b: *std.Build) !void { at this state of zig i guess ;).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with this personally. As stated in #48 we need to make a proper documentation at some point.

// first create a build for the dependency
Expand All @@ -60,7 +50,6 @@ There are 2 branches you can use for your development.
}
```


## Generating .zig files out of .proto definitions

You can do this programatically as a compilation step for your application. The following snippet shows how to create a `zig build gen-proto` command for your project.
Expand Down