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

Consider using zig compiler itself to do the build.zig.zon conversion. #1

Open
Cloudef opened this issue Jan 14, 2024 · 3 comments
Open

Comments

@Cloudef
Copy link
Owner

Cloudef commented Jan 14, 2024

While zon2json works right now for any build.zig.zon files I've thrown at it. The ast walker itself isn't really complete. Zon files itself are literally zig structs, so they may contain actual zig expressions I don't intend to maintain a zig interpreter so consider instead making zon2json a program that depends on zig compiler that generates a program that does something like:

const zon = <insert .zon contents here>;
std.io.getStdout().writer().print("{s}", std.json.fmt(zon, .{}));

This would make sure zon files are always handled properly. cons might be speed, but zig should cache the outputs.

At some point it might become possible to import zon files as well: ziglang/zig#14531

ref: ziglang/zig#15552

@Cloudef
Copy link
Owner Author

Cloudef commented Jan 14, 2024

Might be interesting as well
ziglang/zig#17731

It doesn't say anything about expressions and I assume this will be the official zon spec.
I'll update the zon2json to use this once it's landed.

@dermetfan
Copy link

Are you aware of https://github.com/nix-community/zon2nix?

@Cloudef
Copy link
Owner Author

Cloudef commented Jan 22, 2024

@dermetfan Yes it is actually one of the reasons I started doing this, because it could not handle recursive dependencies, and can't handle recent .zon formats.

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

No branches or pull requests

2 participants