mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-22 23:17:15 +03:00
Inline Cargo.{toml,lock} checks in buildDepsOnly
This commit is contained in:
parent
aeb598b174
commit
8f6b608ca1
@ -18,9 +18,24 @@ let
|
||||
"cargoExtraArgs"
|
||||
"cargoTestCommand"
|
||||
];
|
||||
|
||||
throwMsg = throw ''
|
||||
unable to find Cargo.toml and Cargo.lock at ${path}. please ensure one of the following:
|
||||
- a Cargo.toml and Cargo.lock exists at the root of the source directory of the derivation
|
||||
- set `cargoArtifacts = buildDepsOnly { src = ./some/path/to/cargo/root; }`
|
||||
- set `cargoArtifacts = null` to skip reusing cargo artifacts altogether
|
||||
'';
|
||||
|
||||
path = args.src or throwMsg;
|
||||
cargoToml = path + /Cargo.toml;
|
||||
cargoLock = path + /Cargo.lock;
|
||||
dummySrc =
|
||||
if builtins.pathExists cargoToml && builtins.pathExists cargoLock
|
||||
then mkDummySrc args
|
||||
else throwMsg;
|
||||
in
|
||||
mkCargoDerivation (cleanedArgs // {
|
||||
src = mkDummySrc args;
|
||||
src = dummySrc;
|
||||
pnameSuffix = "-deps";
|
||||
pname = args.pname or crateName.pname;
|
||||
version = args.version or crateName.version;
|
||||
|
@ -3,26 +3,6 @@
|
||||
, mkCargoDerivation
|
||||
, vendorCargoDeps
|
||||
}:
|
||||
let
|
||||
cargoArtifactsFromArgs = args:
|
||||
if args ? src
|
||||
then
|
||||
let
|
||||
path = args.src;
|
||||
cargoToml = path + /Cargo.toml;
|
||||
cargoLock = path + /Cargo.lock;
|
||||
in
|
||||
if builtins.pathExists cargoToml && builtins.pathExists cargoLock
|
||||
then buildDepsOnly args
|
||||
else
|
||||
throw ''
|
||||
unable to find Cargo.toml and Cargo.lock at ${path}. please ensure one of the following:
|
||||
- a Cargo.toml and Cargo.lock exists at the root of the source directory of the derivation
|
||||
- set `cargoArtifacts = buildDepsOnly { src = ./some/path/to/cargo/root; }`
|
||||
- set `cargoArtifacts = null` to skip reusing cargo artifacts altogether
|
||||
''
|
||||
else null;
|
||||
in
|
||||
|
||||
{ cargoBuildCommand ? "cargo build --workspace --release"
|
||||
, cargoTestCommand ? "cargo test --workspace --release"
|
||||
@ -55,7 +35,7 @@ mkCargoDerivation (cleanedArgs // memoizedArgs // {
|
||||
# at the start of the derivation. Useful for caching incremental cargo builds.
|
||||
# This can be inferred automatically if the `src` root has both a Cargo.toml
|
||||
# and Cargo.lock file.
|
||||
cargoArtifacts = args.cargoArtifacts or (cargoArtifactsFromArgs args // memoizedArgs);
|
||||
cargoArtifacts = args.cargoArtifacts or (buildDepsOnly args // memoizedArgs);
|
||||
|
||||
buildPhaseCargoCommand = args.buildPhaseCargoCommand or ''
|
||||
${cargoBuildCommand} ${cargoExtraArgs}
|
||||
|
Loading…
Reference in New Issue
Block a user