-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
add inclusion/exclusion directives to build.zig.zon for deciding which files belong the package #14311
Comments
It's time for |
It seems to me that the answers to these open questions that are most likely to guide users towards creating packages without unintended files are:
|
I think @ifreund's suggestion matches Zig's design philosophy of "make the Right Way easy and the Wrong Way hard" (represented in the Zen as "Communicate intent precisely", "Edge cases matter" and "Only one obvious way to do things") I do wonder whether being able to exclude things might still be useful, eg. for a directory containing things you want, with one file or subdirectory that you don't. However, I can't come up with an example that wouldn't be better solved by reorganizing the project, so that may not actually be a problem. |
Additional GitHub search keywords for this issue: blacklist, whitelist, include, exclude, ignore |
One reason to make it based on inclusion rules rather than exclusion rules would be that if some method of file delivery happens to add extra files, these will not get picked up and screw up the hash. For example, maybe somebody tries to make a mirror, but they accidentally add If it were based on exclusion rules, then it would make sense to allow exclusion rules at the depender's side of things along with the URL and hash specification. We can avoid this and keep things simpler with inclusion rules. |
Organize everything around a Fetch task which does a bunch of stuff in a worker thread without touching any shared state, and then queues up Fetch tasks for its dependencies. This isn't the theoretical optimal package fetching performance because CPU cores don't necessarily map 1:1 with I/O tasks, and each fetch task contains a mixture of computations and I/O. However, it is expected for this to significantly outperform master branch, which fetches everything recursively with only one thread. The logic is now a lot more linear and easy to follow. Everything that is embarassingly parallel is done on the thread pool, and then after everything is fetched, the worker threads are joined and the main thread does the finishing touches of stitching together the dependencies.zig import files. There is only one tiny little critical section and it does not even have any error handling in it. This also lays the groundwork for #14281 because in system mode, all this fetching logic will be skipped, but the "finishing touches" mentioned above still need to be done. With this branch, that logic is separated out and no longer recursively tangled with fetching stuff. Additionally, this branch: * Implements inclusion directives in `build.zig.zon` for deciding which files belong the package (#14311). * Adds basic documentation for `build.zig.zon` files. * Adds support for fetching dependencies with the `file://` protocol scheme (#17364). * Adds a workaround for a Linux/btrfs file system bug (#17282). This commit is a work-in-progress. Still todo: 1. Hook up the CLI to the new system. 2. Restore the module table creation logic after all the fetching is done. 3. Fix compilation errors, get the tests passing, and regression test against real world projects.
Organize everything around a Fetch task which does a bunch of stuff in a worker thread without touching any shared state, and then queues up Fetch tasks for its dependencies. This isn't the theoretical optimal package fetching performance because CPU cores don't necessarily map 1:1 with I/O tasks, and each fetch task contains a mixture of computations and I/O. However, it is expected for this to significantly outperform master branch, which fetches everything recursively with only one thread. The logic is now a lot more linear and easy to follow. Everything that is embarassingly parallel is done on the thread pool, and then after everything is fetched, the worker threads are joined and the main thread does the finishing touches of stitching together the dependencies.zig import files. There is only one tiny little critical section and it does not even have any error handling in it. This also lays the groundwork for #14281 because in system mode, all this fetching logic will be skipped, but the "finishing touches" mentioned above still need to be done. With this branch, that logic is separated out and no longer recursively tangled with fetching stuff. Additionally, this branch: * Implements inclusion directives in `build.zig.zon` for deciding which files belong the package (#14311). * Adds basic documentation for `build.zig.zon` files. * Adds support for fetching dependencies with the `file://` protocol scheme (#17364). * Adds a workaround for a Linux/btrfs file system bug (#17282). This commit is a work-in-progress. Still todo: 1. Hook up the CLI to the new system. 2. Restore the module table creation logic after all the fetching is done. 3. Fix compilation errors, get the tests passing, and regression test against real world projects.
Organize everything around a Fetch task which does a bunch of stuff in a worker thread without touching any shared state, and then queues up Fetch tasks for its dependencies. This isn't the theoretical optimal package fetching performance because CPU cores don't necessarily map 1:1 with I/O tasks, and each fetch task contains a mixture of computations and I/O. However, it is expected for this to significantly outperform master branch, which fetches everything recursively with only one thread. The logic is now a lot more linear and easy to follow. Everything that is embarassingly parallel is done on the thread pool, and then after everything is fetched, the worker threads are joined and the main thread does the finishing touches of stitching together the dependencies.zig import files. There is only one tiny little critical section and it does not even have any error handling in it. This also lays the groundwork for #14281 because in system mode, all this fetching logic will be skipped, but the "finishing touches" mentioned above still need to be done. With this branch, that logic is separated out and no longer recursively tangled with fetching stuff. Additionally, this branch: * Implements inclusion directives in `build.zig.zon` for deciding which files belong the package (#14311). * Adds basic documentation for `build.zig.zon` files. * Adds support for fetching dependencies with the `file://` protocol scheme (#17364). * Adds a workaround for a Linux/btrfs file system bug (#17282). This commit is a work-in-progress. Still todo: 1. Hook up the CLI to the new system. 2. Restore the module table creation logic after all the fetching is done. 3. Fix compilation errors, get the tests passing, and regression test against real world projects.
Landed in f7bc55c. Follow-up issue: This is currently implemented as a required field for the root package, but the rest of the dependency tree is allowed to omit the |
Extracted from #14265.
The motivation for doing this is mirrors (#14291). Idea being that if you fetch a tarball, perhaps it does not contain any superfluous files, while the same package fetched via git protocol (#14295) does have some extra files that are not intended to be part of the package. Both URLs should work, and their hashes should be identical. This means some files should be excluded from the package.
I could see this going one of two ways:
...with exclusions:
...or with inclusions:
Two open questions:
Either way, here is how fetching a package works:
The guarantee should be upheld that if the hash matches, the file system should match exactly. This means that, since empty directories are not included in the hash, empty directories should be removed by step 2, along with the inclusion/exclusion rules.
The text was updated successfully, but these errors were encountered: