Unverified Commit a13b4a50 authored by Gaétan Lepage's avatar Gaétan Lepage Committed by GitHub
Browse files

wasmtime: add enableShared/enableStatic & shell completions (#440501)

parents d335e747 dfd0030e
Loading
Loading
Loading
Loading
+23 −2
Original line number Diff line number Diff line
@@ -3,9 +3,13 @@
  stdenv,
  rustPlatform,
  fetchFromGitHub,
  buildPackages,
  cmake,
  installShellFiles,
  versionCheckHook,
  nix-update-script,
  enableShared ? !stdenv.hostPlatform.isStatic,
  enableStatic ? stdenv.hostPlatform.isStatic,
}:
rustPlatform.buildRustPackage (finalAttrs: {
  pname = "wasmtime";
@@ -35,7 +39,10 @@ rustPlatform.buildRustPackage (finalAttrs: {
    "dev"
  ];

  nativeBuildInputs = [ cmake ];
  nativeBuildInputs = [
    cmake
    installShellFiles
  ];

  doCheck =
    with stdenv.buildPlatform;
@@ -54,10 +61,12 @@ rustPlatform.buildRustPackage (finalAttrs: {

  postInstall =
    let
      inherit (stdenv.targetPlatform.rust) cargoShortTarget;
      inherit (stdenv.hostPlatform.rust) cargoShortTarget;
    in
    ''
      moveToOutput lib $dev
      ${lib.optionalString (!enableShared) "rm $dev/lib/*.so{,.*}"}
      ${lib.optionalString (!enableStatic) "rm $dev/lib/*.a"}

      # copy the build.rs generated c-api headers
      # https://github.com/rust-lang/cargo/issues/9661
@@ -67,6 +76,18 @@ rustPlatform.buildRustPackage (finalAttrs: {
      install_name_tool -id \
        $dev/lib/libwasmtime.dylib \
        $dev/lib/libwasmtime.dylib
    ''
    + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
      installShellCompletion --cmd wasmtime \
        --bash <("$out/bin/wasmtime" completion bash) \
        --zsh <("$out/bin/wasmtime" completion zsh) \
        --fish <("$out/bin/wasmtime" completion fish)
    ''
    + lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
      installShellCompletion --cmd wasmtime \
        --bash "${buildPackages.wasmtime}"/share/bash-completion/completions/*.bash \
        --zsh "${buildPackages.wasmtime}"/share/zsh/site-functions/* \
        --fish "${buildPackages.wasmtime}"/share/fish/*/*
    '';

  nativeInstallCheckInputs = [