Commit f1d9560d authored by David McFarland's avatar David McFarland
Browse files

cygwin.cygwinDllLinkHook: add tests

parent dcebaab6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -10,4 +10,6 @@ makeSetupHook {
  substitutions = {
    objdump = "${lib.getBin binutils-unwrapped}/${stdenv.targetPlatform.config}/bin/objdump";
  };

  passthru.tests = callPackage ./tests { };
} ./cygwin-dll-link.sh
+130 −0
Original line number Diff line number Diff line
{
  dieHook,
  lib,
  stdenv,
  testers,
  runCommand,
}:

rec {
  dll = stdenv.mkDerivation {
    name = "dll";
    src = ./dll;
    outputs = [
      "out"
      "dev"
    ];
    buildInputs = [ dll2 ];
    strictDeps = true;
  };

  dll2 = stdenv.mkDerivation {
    name = "dll2";
    src = ./dll2;
    outputs = [
      "out"
      "dev"
    ];
  };

  exe = stdenv.mkDerivation {
    name = "exe";
    src = ./exe;
    buildInputs = [ dll ];
    nativeBuildInputs = [ dieHook ];
    strictDeps = true;
    doCheck = true;
    postFixup = ''[[ -e "$out"/bin/cyghello2.dll ]] || die missing indirect dependency'';
  };

  link-dll = exe.overrideAttrs {
    name = "link-dll";
    preFixup = ''
      ln -s ${lib.getLib dll}/bin/cyghello.dll "$out"/bin/
    '';
  };

  user32 = stdenv.mkDerivation {
    name = "user32";
    src = ./user32;
    allowedImpureDLLs = [ "USER32.dll" ];
  };

  impure-dll = testers.testBuildFailure (
    user32.overrideAttrs {
      name = "impure-dll";
      allowedImpureDLLs = [ ];
    }
  );

  user32-dll = stdenv.mkDerivation {
    name = "user32-dll";
    src = ./user32-dll;
    outputs = [
      "out"
      "dev"
    ];
    allowedImpureDLLs = [ "USER32.dll" ];
  };

  user32-exe = stdenv.mkDerivation {
    name = "user32-exe";
    src = ./user32-exe;
    buildInputs = [ user32-dll ];
    strictDeps = true;
    doCheck = true;
  };

  link-dir-dll = exe.overrideAttrs {
    name = "link-dir-dll";
    preFixup = ''
      mkdir "$out"/libexec
      ln -s ${lib.getLib user32-dll}/bin/cygpeek.dll "$out"/libexec/
      linkDLLsDir="$out"/bin linkDLLs "$out"/libexec/cygpeek.dll
    '';
  };

  link-dir-exe = exe.overrideAttrs {
    name = "link-dir-exe";
    preFixup = ''
      mkdir "$out"/libexec
      ln -s ${lib.getLib user32-exe}/bin/{peek.exe,cygpeek.dll} "$out"/libexec/
      linkDLLsDir="$out"/bin linkDLLs "$out"/libexec/peek.exe
    '';
  };

  link-user32-dll = exe.overrideAttrs {
    name = "link-user32-dll";
    preFixup = ''
      ln -s ${lib.getLib user32-dll}/bin/cygpeek.dll "$out"/bin/
    '';
  };

  copy-dll-impure = testers.testBuildFailure (
    user32-exe.overrideAttrs {
      name = "copy-dll-impure";
      preFixup = ''
        cp ${lib.getLib user32-dll}/bin/cygpeek.dll "$out"/bin/
      '';
    }
  );

  copy-dll = user32-exe.overrideAttrs {
    name = "copy-dll";
    preFixup = ''
      cp ${lib.getLib user32-dll}/bin/cygpeek.dll "$out"/bin/
      linkDLLs "$out"/bin/cygpeek.dll
    '';
    allowedImpureDLLs = [ "USER32.dll" ];
  };

  double-link = user32-exe.overrideAttrs {
    name = "double-link";
    preFixup = ''linkDLLs "$out"'';
  };

  utf8-glob = runCommand "utf8-glob" { } ''
    touch NetLock_Arany_=Class_Gold=_Főtanstvny:49412ce40010.crt
    ls -l NetLock* > "$out"
  '';
}
+16 −0
Original line number Diff line number Diff line
.PHONY: all install
all: cyghello.dll

install: $(out)/bin/cyghello.dll $(out)/lib/libhello.dll.a $(out)/include/hello.h

cyghello.dll libhello.dll.a: hello.c
	$(CC) -o $@ $^ -shared -Wl,--out-implib,libhello.dll.a -Wl,--export-all-symbols -lhello2

$(out)/bin/cyghello.dll: cyghello.dll
	install -m755 -D $< $@

$(out)/lib/libhello.dll.a: libhello.dll.a
	install -m644 -D $< $@

$(out)/include/hello.h: hello.h
	install -m644 -D $< $@
+7 −0
Original line number Diff line number Diff line
#include "hello.h"
#include <stdio.h>
#include <hello2.h>

void hello() {
				hello2();
}
+2 −0
Original line number Diff line number Diff line
#pragma once
void hello();
Loading