Skip to content

Proposal: remove anonymousDependency once relative paths are supported in build.zig.zon #17238

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

Closed
mlugg opened this issue Sep 22, 2023 · 3 comments · Fixed by #18590
Closed
Labels
accepted This proposal is planned. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. zig build system std.Build, the build runner, `zig build` subcommand, package management
Milestone

Comments

@mlugg
Copy link
Member

mlugg commented Sep 22, 2023

Once #14603 or similar is merged, std.Build.anonymousDependency is redundant: its use cases can be instead handled by specifying a local path in build.zig.zon and calling std.Build.dependency as you would for a remote dependency.

In fact, anonymousDependency is strictly less useful. Here are some key use cases it does not support:

As such, std.Build.anonymousDependency should be removed, giving one obvious and straightforward way to reference local dependencies.

@mlugg mlugg added the proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. label Sep 22, 2023
@andrewrk andrewrk added the zig build system std.Build, the build runner, `zig build` subcommand, package management label Sep 22, 2023
@andrewrk andrewrk added this to the 0.13.0 milestone Sep 22, 2023
@andrewrk andrewrk added the accepted This proposal is planned. label Sep 22, 2023
@binarycraft007
Copy link
Contributor

binarycraft007 commented Sep 30, 2023

Once #14603 or similar is merged, std.Build.anonymousDependency is redundant: its use cases can be instead handled by specifying a local path in build.zig.zon and calling std.Build.dependency as you would for a remote dependency.

In fact, anonymousDependency is strictly less useful. Here are some key use cases it does not support:

* Temporarily overriding a dependency path for a package to refer to a local development copy. This will be particularly useful once [ability to specify additional build dependency mirrors that affect any package in the full dependency tree #14292](https://github.com/ziglang/zig/issues/14292) is implemented.

* Referencing a vendored dependency which in turn has remote dependencies. This is impossible via `anonymousDependency` because the build system cannot call into the actual package manager (which is integrated into the compiler).

As such, std.Build.anonymousDependency should be removed, giving one obvious and straightforward way to reference local dependencies.

what about the use case where I need to embed artifact in one build step to another:
https://github.com/binarycraft007/wechat-hook/blob/main/build.zig#L34
https://github.com/binarycraft007/wechat-hook/blob/main/src/main.zig#L14

maybe we can restrict anonymousDependency's usecase without removing it. because in some usecases, like the one I showed above, file dependency in build.zig.zon can't replace that, because we won't know artifact's path until it's generated.

@mlugg
Copy link
Member Author

mlugg commented Sep 30, 2023

This issue is about dependencies between packages (in the sense of the package manager), not about Zig modules. The code you reference is not using anonymousDependency.

@binarycraft007
Copy link
Contributor

This issue is about dependencies between packages (in the sense of the package manager), not about Zig modules. The code you reference is not using anonymousDependency.

sorry, I misunderstood it, thanks for the clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted This proposal is planned. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. zig build system std.Build, the build runner, `zig build` subcommand, package management
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants