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

Update build.zig for Zig 0.13.0 #46

Merged
merged 2 commits into from
Jun 15, 2024
Merged

Update build.zig for Zig 0.13.0 #46

merged 2 commits into from
Jun 15, 2024

Conversation

hans-tvs
Copy link
Contributor

cwd_relative is relative to the cwd of the build runner process, which causes problems (missing files, as my build step looks in the wrong location for zig-protobuf's source code) when I try to import zig-protobuf as a module or add a proto-generating build-step using the exact instructions in the README.

This PR just replaces that with b.path, which makes those dependencies relative to your build.zig instead. I'm not intimately familiar with all your build steps, so it might be worth spot-checking that's semantically correct, but that change is sufficient for me to be able to import and use this in another Zig project in the manner described in the README.

@HendrikJanssen
Copy link

Interesting, I just now stumbled on that exact same issue!

I also think it would be nice to correct the zig-cache directory to the relocated .zig-cache dir in

const base_cache_dir_rel = try std.fs.path.join(allocator, &.{ "zig-cache", "zig-protobuf", "protoc" });

Also, the README.md should probably include the correct way to setup the gen-protoc step:

const protoc_step = protobuf.RunProtocStep.create(b, protobuf_dep.builder, target, .{
        .destination_directory = b.path("src/proto"),
        .source_files = &.{
            "protocol/all.proto",
        },
        .include_directories = &.{},
    });

@hans-tvs
Copy link
Contributor Author

Nice catch. I was wondering where that zig-cache was coming from, and I forgotten I'd made that same destination_directory change in my calling code.

@Arwalk
Copy link
Owner

Arwalk commented Jun 15, 2024

Thanks a lot, guys. I realise I haven't checked imports in an external project, so I'm not surprised this error appeared.

I'll check this ASAP.
I am very happy to know people use this library, and your comments and commits are appreciated.

Copy link
Owner

@Arwalk Arwalk left a comment

Choose a reason for hiding this comment

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

Successfully imported the updated library on a toy/demo project, could run gen-proto, build and run successfully.

@Arwalk Arwalk merged commit 7c49ed6 into Arwalk:master Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants