-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
ability to fetch only needed dependencies #14597
Copy link
Copy link
Closed
Labels
acceptedThis proposal is planned.This proposal is planned.proposalThis issue suggests language modifications. If it also has the "accepted" label then it is planned.This issue suggests language modifications. If it also has the "accepted" label then it is planned.zig build systemstd.Build, the build runner, `zig build` subcommand, package managementstd.Build, the build runner, `zig build` subcommand, package management
Milestone
Description
Activity
Metadata
Metadata
Assignees
Labels
acceptedThis proposal is planned.This proposal is planned.proposalThis issue suggests language modifications. If it also has the "accepted" label then it is planned.This issue suggests language modifications. If it also has the "accepted" label then it is planned.zig build systemstd.Build, the build runner, `zig build` subcommand, package managementstd.Build, the build runner, `zig build` subcommand, package management
Type
Projects
- StatusShow more project fieldsProposals
This is a competing proposal to #14591.
Inside of a build.zig file, there may be conditional logic that decides whether a dependency is needed. For example:
Key point here being that
b.dependency("mp3lame")is only called if theenable_libmp3lameoption is set to true. This means that when that option is not set, libmp3lame is in fact not a dependency.This proposal is to embrace arbitrary logic deciding what is or isn't a dependency. Instead of marking categories of dependencies in the
build.zig.zonfile, Zig would have the heuristic choice to pre-fetch some, all, or none of the dependencies. When running build.zig, if any packages referenced with dependency() were not fetched already, the build runner would exit in a special manner and communicate the set of dependency packages that were missing. Zig would fetch them and then re-execute the build runner.Along with this proposal would come a new flag to
zig build:--fetch. Note that this is still part of thezig buildsubcommand - indeed it would support all of the same flags and build options as a standardzig buildoperation. However, in this case, after running the build.zig script, it would not actually perform the make(). Instead it would only fetch missing packages for the given set of flags. In most typical cases, no additional flags would be used, but one could imagine passing something like this:zig build --fetch --Denable-libmp3lame=falseto avoid fetching libmp3lame in the above example.Related: #14283