2021-01-24 00:40:18 +00:00
|
|
|
{ lib, stdenv }:
|
2017-09-02 21:48:55 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
foo = stdenv.mkDerivation {
|
|
|
|
name = "foo-test";
|
|
|
|
|
2019-06-19 15:45:34 +00:00
|
|
|
dontUnpack = true;
|
2017-09-02 21:48:55 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin $out/include $out/lib
|
|
|
|
$CC -o $out/bin/foo ${./cc-main.c}
|
|
|
|
chmod +x $out/bin/foo
|
|
|
|
cp ${./foo.c} $out/include/foo.h
|
2017-09-12 19:36:41 +00:00
|
|
|
$CC -shared \
|
2021-01-24 00:40:18 +00:00
|
|
|
${lib.optionalString stdenv.hostPlatform.isDarwin "-Wl,-install_name,$out/lib/libfoo.dylib"} \
|
2017-09-12 19:36:41 +00:00
|
|
|
-o $out/lib/libfoo${stdenv.hostPlatform.extensions.sharedLibrary} \
|
|
|
|
${./foo.c}
|
2017-09-02 21:48:55 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
bar = stdenv.mkDerivation {
|
|
|
|
name = "bar-test";
|
|
|
|
outputs = [
|
|
|
|
"out"
|
|
|
|
"dev"
|
|
|
|
];
|
|
|
|
|
2019-06-19 15:45:34 +00:00
|
|
|
dontUnpack = true;
|
2017-09-02 21:48:55 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin $dev/include $dev/lib
|
|
|
|
$CC -o $out/bin/bar ${./cc-main.c}
|
|
|
|
chmod +x $out/bin/bar
|
|
|
|
cp ${./bar.c} $dev/include/bar.h
|
2017-09-12 19:36:41 +00:00
|
|
|
$CC -shared \
|
2021-01-24 00:40:18 +00:00
|
|
|
${lib.optionalString stdenv.hostPlatform.isDarwin "-Wl,-install_name,$dev/lib/libbar.dylib"} \
|
2017-09-12 19:36:41 +00:00
|
|
|
-o $dev/lib/libbar${stdenv.hostPlatform.extensions.sharedLibrary} \
|
|
|
|
${./bar.c}
|
2017-09-02 21:48:55 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "stdenv-inputs-test";
|
|
|
|
phases = [ "buildPhase" ];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
foo
|
|
|
|
bar
|
|
|
|
];
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
env
|
|
|
|
|
|
|
|
printf "checking whether binaries are available... " >&2
|
|
|
|
foo && bar
|
|
|
|
|
|
|
|
printf "checking whether compiler can find headers... " >&2
|
|
|
|
$CC -o include-check ${./include-main.c}
|
|
|
|
./include-check
|
|
|
|
|
|
|
|
printf "checking whether compiler can find headers... " >&2
|
|
|
|
$CC -o include-check ${./include-main.c}
|
|
|
|
./include-check
|
|
|
|
|
|
|
|
printf "checking whether compiler can find libraries... " >&2
|
|
|
|
$CC -lfoo -lbar -o lib-check ${./lib-main.c}
|
|
|
|
./lib-check
|
|
|
|
|
|
|
|
touch $out
|
|
|
|
'';
|
|
|
|
|
2021-01-24 00:40:18 +00:00
|
|
|
meta.platforms = lib.platforms.all;
|
2017-09-02 21:48:55 +00:00
|
|
|
}
|