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

ability to add a package to build based on path to build.zig #353

Closed
andrewrk opened this issue May 2, 2017 · 2 comments · Fixed by #14265
Closed

ability to add a package to build based on path to build.zig #353

andrewrk opened this issue May 2, 2017 · 2 comments · Fixed by #14265
Labels
bug Observed behavior contradicts documented or intended behavior enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig build system std.Build, the build runner, `zig build` subcommand, package management
Milestone

Comments

@andrewrk
Copy link
Member

andrewrk commented May 2, 2017

This can be implemented in the zig build system:

Add a package by giving the path to a directory which has build.zig in it, an alias name which will be used as the @import(...) string, a set of build options (the same options available from the command line, visible from the --help menu), and an expected hash.

The build system does these steps when building:

  • Copies the entire directory to ./zig-pkg/alias/ inside the current project's build directory. If the directory already exists and contains the correct expected hash, this copy operation can be skipped. If the copy is performed, compute the hash while doing the copy, and ensure that the expected hash is correct. If not, discard the data and produce an error. If the existing directory contains a different hash than the expected one, remove it and proceed as if there were no directory there.
  • builds ./zig-pkg/alias/build.zig but instead of with build_runner.zig it uses its own runner, which does the following:
    • runs the pkg step. note that this recursively invokes this whole process. If the pkg step does not exist, it means no build step is necessary, and the copied source files is sufficient.
    • identifies the package's root source file and reports it via IPC
    • reports the package's dependencies via IPC
  • using all the collected information, correctly reports the --pkg-begin and --pkg-end arguments to the zig compiler

You can see how this fits into depending on URLs as packages. Instead of copying a directory, it would download and unpack a file, or clone/checkout a repository, rather than copy files, and everything else is the same. We can save that for another issue.

Bonus feature: when a hash is not matched based on a directory copy or a download, save the data in a LRU cache in case the user decides to update the expected hash to this value, and check this LRU cache before re-downloading/copying the data redundantly.

@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior enhancement Solving this issue will likely involve adding new logic or components to the codebase. labels May 2, 2017
@andrewrk andrewrk added this to the 0.2.0 milestone May 2, 2017
@andrewrk andrewrk modified the milestone: 0.2.0 Oct 19, 2017
@andrewrk andrewrk modified the milestones: 0.2.0, 0.3.0 Jan 25, 2018
@andrewrk andrewrk modified the milestones: 0.3.0, 0.4.0 Feb 28, 2018
@andrewrk
Copy link
Member Author

andrewrk commented Feb 5, 2019

This is part of a larger Zig Package Manager proposal + featureset. #943

@andrewrk andrewrk modified the milestones: 0.4.0, 0.5.0 Feb 15, 2019
@andrewrk andrewrk added the zig build system std.Build, the build runner, `zig build` subcommand, package management label Jul 4, 2019
@andrewrk andrewrk modified the milestones: 0.5.0, 0.6.0 Aug 27, 2019
@andrewrk andrewrk modified the milestones: 0.6.0, 0.7.0 Feb 10, 2020
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Oct 9, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Nov 6, 2020
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
@andrewrk
Copy link
Member Author

Resolved with #14265

@andrewrk andrewrk modified the milestones: 0.12.0, 0.11.0 Jan 12, 2023
@andrewrk andrewrk mentioned this issue Jan 13, 2023
32 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior enhancement Solving this issue will likely involve adding new logic or components to the codebase. 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.

1 participant