Commit 3291bda7 authored by marius david's avatar marius david
Browse files

buildRustCrate: Do not compile binaries if all the requiredFeatures aren't enabled.

parent c83b87fe
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -69,7 +69,15 @@



    ${lib.optionalString (lib.length crateBin > 0) (lib.concatMapStringsSep "\n" (bin: ''
    ${lib.optionalString (lib.length crateBin > 0) (lib.concatMapStringsSep "\n" (bin:
    let
      haveRequiredFeature = if bin ? requiredFeatures then
        # Check that all element in requiredFeatures are also present in crateFeatures
        lib.intersectLists bin.requiredFeatures crateFeatures == bin.requiredFeatures
      else
        true;
    in
    if haveRequiredFeature then ''
      mkdir -p target/bin
      BIN_NAME='${bin.name or crateName}'
      ${if !bin ? path then ''
@@ -79,6 +87,8 @@
        BIN_PATH='${bin.path}'
      ''}
        ${build_bin} "$BIN_NAME" "$BIN_PATH"
    '' else ''
      echo Binary ${bin.name or crateName} not compiled due to not having all of the required features -- ${lib.escapeShellArg (builtins.toJSON bin.requiredFeatures)} -- enabled.
    '') crateBin)}

    ${lib.optionalString buildTests ''