mirror of
https://github.com/nix-community/naersk
synced 2025-02-16 19:28:23 +00:00
Use cargo_release arg list for --release
This commit is contained in:
parent
df0c276e7a
commit
6c072bd0ed
2 changed files with 5 additions and 15 deletions
16
build.nix
16
build.nix
|
@ -89,8 +89,6 @@ with rec
|
|||
outputs = [ "out" ] ++ lib.optional (doDoc && copyDocsToSeparateOutput) "doc";
|
||||
preInstallPhases = lib.optional doDoc [ "docPhase" ];
|
||||
|
||||
CARGO_BUILD_PROFILE = if release then "release" else "debug";
|
||||
|
||||
# Otherwise specifying CMake as a dep breaks the build
|
||||
dontUseCmakeConfigure = true;
|
||||
|
||||
|
@ -118,6 +116,8 @@ with rec
|
|||
|
||||
configurePhase =
|
||||
''
|
||||
cargo_release=( ${lib.optionalString release "--release" } )
|
||||
|
||||
runHook preConfigure
|
||||
|
||||
mkdir -p target
|
||||
|
@ -174,17 +174,7 @@ with rec
|
|||
docPhase = lib.optionalString doDoc ''
|
||||
runHook preDoc
|
||||
|
||||
# cargo doc defaults to "debug", but it doesn't have a
|
||||
# "--debug" flag, only "--release", so we can't just pass
|
||||
# "--$CARGO_BUILD_PROFILE" like we do with "cargo build" and "cargo
|
||||
# test"
|
||||
doc_arg=""
|
||||
if [ "$CARGO_BUILD_PROFILE" == "release" ]
|
||||
then
|
||||
doc_arg="--release"
|
||||
fi
|
||||
|
||||
logRun cargo doc --offline $doc_arg || ${if doDocFail then "false" else "true" }
|
||||
logRun cargo doc --offline "''${cargo_release[*]}" || ${if doDocFail then "false" else "true" }
|
||||
|
||||
${lib.optionalString removeReferencesToSrcFromDocs ''
|
||||
# Remove references to the source derivation to reduce closure size
|
||||
|
|
|
@ -96,10 +96,10 @@ with rec
|
|||
find . -type f -name '*.rs' -exec touch {} +
|
||||
'';
|
||||
cargoBuild = attrs.cargoBuild or ''
|
||||
cargo build --$CARGO_BUILD_PROFILE -j $NIX_BUILD_CORES -Z unstable-options --out-dir out
|
||||
cargo build "''${cargo_release}" -j $NIX_BUILD_CORES -Z unstable-options --out-dir out
|
||||
'';
|
||||
cargoTestCommands = attrs.cargoTestCommands or [
|
||||
"cargo test --$CARGO_BUILD_PROFILE -j $NIX_BUILD_CORES"
|
||||
''cargo test "''${cargo_release}" -j $NIX_BUILD_CORES''
|
||||
];
|
||||
};
|
||||
buildPackageSingleStep = src: attrs:
|
||||
|
|
Loading…
Add table
Reference in a new issue