Crates.io | build-deps |
lib.rs | build-deps |
version | 0.1.4 |
source | src |
created_at | 2019-01-21 16:02:26.939775 |
updated_at | 2019-07-28 16:45:08.562468 |
description | Rust build-script dependencies generator for data/IDL files |
homepage | https://github.com/frehberg/test-generator/tree/master/build-deps |
repository | https://github.com/frehberg/test-generator/tree/master/build-deps |
max_upload_size | |
id | 109830 |
size | 52,235 |
This is the Rust build-script dependencies generator for data/IDL files
The functionality shall be integrated into the build.script build.rs
. The function rerun_if_changed_paths(glob_pattern: &str)
will expand the GLOB pattern and will print the files-paths and directory paths to console. The Cargo-tool will evaluate
the output. The compilation of the crate is re-run if specified files have changed since the last build.
"data/*"
will enumerate all files/directories in directory "data/" and watchin changes
"data/"
- will add the directory itself to the watch-list, triggering a rerun in case new entities are added.
"data/**/*.protobuf"
will traverse all sub-directories enumerating all protobuf files.
"data/**"
will traverse all sub-directories enumerating all directories.
Add files, if changes to files shall be detected.
Add directories, if the build-process shall be rerun in case of new files.
This illustrates a setup. Intention in this example is to rerun the build-process if the files in directory "data/*" have been modified or new files have been added to that directory.
The build-process will execute proc_macros reading those files and generating Rust-code.
A complete example/setup can be found at github test-generator/example
For further tooling around the build-scripts, please take a look at the crate build-helper
[package]
name = "datatester"
build = "build.rs"
...
[build-dependencies]
build-deps = "^0.1"
...
// declared in Cargo.toml as "[build-dependencies]"
extern crate build_deps;
fn main() {
// Enumerate files in sub-folder "data/*", being relevant for the code-generation (for example)
// If function returns with error, exit with error message.
build_deps::rerun_if_changed_paths( "data/*" ).unwrap();
// Adding the parent directory "data" to the watch-list will capture new-files being added
build_deps::rerun_if_changed_paths( "data" ).unwrap();
}
The following diagram illustrates the integration of the build-script into the conditional cargo build-process.