chore(tvix): move filterRustCrateSrc to utils.nix
Change-Id: Ib6bae1ea0457d3309a6ec1e08b9e4b320523c161 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11857 Autosubmit: Ilan Joselevich <personal@ilanjoselevich.com> Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
This commit is contained in:
parent
ac51803ad8
commit
92c5433304
2 changed files with 29 additions and 29 deletions
|
|
@ -20,4 +20,23 @@
|
|||
);
|
||||
})
|
||||
(powerset features));
|
||||
|
||||
# Filters the given source, only keeping files related to the build, preventing unnecessary rebuilds.
|
||||
# Includes src in the root, all other .rs files, as well as Cargo.toml.
|
||||
# Additional files to be included can be specified in extraFileset.
|
||||
filterRustCrateSrc =
|
||||
{ root # The original src
|
||||
, extraFileset ? null # Additional filesets to include (e.g. fileFilter for proto files)
|
||||
}:
|
||||
lib.fileset.toSource {
|
||||
inherit root;
|
||||
fileset = (lib.fileset.intersection
|
||||
(lib.fileset.fromSource root) # We build our final fileset from the original src
|
||||
(lib.fileset.unions ([
|
||||
(root + "/src")
|
||||
(lib.fileset.fileFilter (f: f.hasExt "rs") root)
|
||||
# We assume that every Rust crate will at a minimum have .rs files and a Cargo.toml
|
||||
(lib.fileset.fileFilter (f: f.name == "Cargo.toml") root)
|
||||
] ++ lib.optional (extraFileset != null) extraFileset)));
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue