Please sign in to comment.
Allow build scripts to specify dependencies
Currently Cargo is quite conservative in how it determines whether a build script should be run. The heuristic used is "did any file in the project directory change", but this is almost always guaranteed to be too coarse grained in situations like: * If the build script takes a long time to run it's advantageous to run it as few times as possible. Being able to inform Cargo about precisely when a build script should be run should provide more robust support here. * Build scripts may not always have all of their dependencies in-tree or in the crate root. Sometimes a dependency could be elsewhere in a repository and scripts need a method of informing Cargo about this (as currently these compiles don't happen then they should). This commit adds this support in build scripts via a new `rerun-if-changed` directive which can be printed to standard output (using the standard Cargo metadata format). The value for this key is a path relative to the crate root, and Cargo will only look at these paths when determining whether to rerun the build script. Any other file changes will not trigger the build script to be rerun. Currently the printed paths may either be a file or a directory, and a directory is deeply traversed. The heuristic for trigger a rerun is detecting whether any input file has been modified since the build script was last run (determined by looking at the modification time of the output file of the build script). This current implementation means that if you depend on a directory and then delete a file within it the build script won't be rerun, but this is already the case and can perhaps be patched up later. Future extensions could possibly include the usage of glob patterns in build script paths like the `include` and `exclude` features of `Cargo.toml`, but these should be backwards compatible to add in the future. Closes rust-lang#1162
- Loading branch information...
Showing with 197 additions and 24 deletions.