package manager: allow overriding dependencies with local cache
This implements #20180 (the package overriding portion no the proposed command for examining the dependency tree). While the issue is not accepted I've found this very useful myself and should be mergeable (sans any issues with the testing approach explained below), so I expect to continue updating/rebasing this PR until the issue is either accepted or rejected.
The approach taken is to change the package root written to the generated dependencies.zig file to point into the local cache. In addition a new .local_override field is added to facilitate warning messages produced by the build runner.
I have some tests for verifying the behaviour of the package overriding at configure time (i.e. that the correct build.zig is used for the package) and compile time (that the correct version of the package is used), but I'm not sure at the moment how to integrate them into the test system as I don't think there is a way to get the effect of passing the --global-cache-dir, --cache-dir and --system flags to standalone tests, which would be needed for checking that the right thing happens when these flags are passed to zig build.
PR #20281 implements the tool described in #20180 for examining the hashes of dependencies - it could be merged into this PR, but it is also useful separately and the two PRs are not inter-dependant.
Btw you should probably remove the draft marker
Btw you should probably remove the draft marker
I don't think it's ready to merge until I figure out at least a way to get tests integrated with the build system.
I've added tests to the CI by directly modifying the CI scripts for linux and macos runners (I don't know the ps1 script syntax, so thought I'd better not mess with those). This seemed to be the simplest way to pass the cache-related flags to zig build, but if the approach taken is not an appropriate strategy let me know and I'll come up with something else.
The downside of the approach taken is that running zig build test can't be used to locally run the dependency overriding tests - you need to change directory to test/dependency_override and run ./run-tests.sh script with a positional argument for the path to a Zig compiler. The upside is that all the testing logic and filesystem side-effects (other than some normal usage of the global cache) are isolated to the test/dependency_override directory. Since testing the behaviour depends on placing various versions of packages into the global, local and --system directories, achieving the same solely within build.zig is probably going to be more complicated.
There also isn't a Windows equivalent of the run-tests.sh script.
I've added tests to the CI by directly modifying the CI scripts for linux and macos runners (I don't know the ps1 script syntax, so thought I'd better not mess with those).
This will conflict with the work being done in the ci-scripts branch, but moving the CI script changes to the build.zig files but should be straightforward to port.