2019-12-17 20:15:53 +00:00
{ stdenv }:
crateName : metadata : buildTests :
if ! buildTests then ''
2018-09-07 13:08:06 +00:00
runHook preInstall
2019-11-20 06:30:06 +00:00
# always create $out even if we do not have binaries. We are detecting binary targets during compilation, if those are missing there is no way to only have $lib
mkdir $ out
2018-09-07 13:08:06 +00:00
if [ [ - s target/env ] ] ; then
2019-11-20 06:30:06 +00:00
mkdir - p $ lib
cp target/env $ lib/env
2018-09-07 13:08:06 +00:00
fi
if [ [ - s target/link.final ] ] ; then
2019-11-20 06:30:06 +00:00
mkdir - p $ lib/lib
cp target/link.final $ lib/lib/link
2018-09-07 13:08:06 +00:00
fi
if [ [ " $ ( l s - A t a r g e t / l i b ) " ] ] ; then
2019-11-20 06:30:06 +00:00
mkdir - p $ lib/lib
2020-03-28 14:23:12 +00:00
cp - r target/lib /* $ l i b / l i b # */
2019-11-20 06:30:06 +00:00
for library in $ lib/lib /* . s o $ l i b / l i b / * . d y l i b ; d o # */
ln - s $ library $ ( echo $ library | sed - e " s / - ${ metadata } / / " )
2018-09-07 13:08:06 +00:00
done
fi
if [ [ " $ ( l s - A t a r g e t / b u i l d ) " ] ] ; then # */
2019-11-20 06:30:06 +00:00
mkdir - p $ lib/lib
cp - r target/build /* $ l i b / l i b # */
2018-09-07 13:08:06 +00:00
fi
2018-11-16 12:12:59 +00:00
if [ [ - d target/bin ] ] ; then
if [ [ " $ ( l s - A t a r g e t / b i n ) " ] ] ; then
mkdir - p $ out/bin
2020-03-28 14:23:12 +00:00
cp - rP target/bin /* $ o u t / b i n # */
2018-11-16 12:12:59 +00:00
fi
2018-09-07 13:08:06 +00:00
fi
2019-12-17 20:15:53 +00:00
runHook postInstall
'' e l s e
# for tests we just put them all in the output. No execution.
''
runHook preInstall
mkdir - p $ out/tests
if [ - e target/bin ] ; then
find target/bin / - type f - executable - exec cp { } $ out/tests \ ;
fi
if [ - e target/lib ] ; then
find target/lib / - type f \ ! - name ' * . rlib' \
2024-06-10 13:19:53 +00:00
- a \ ! - name ' * $ { stdenv . hostPlatform . extensions . library } ' \
2019-12-17 20:15:53 +00:00
- a \ ! - name ' * . d' \
- executable \
- print0 | xargs - - no-run-if-empty - - null install - - target $ out/tests ;
fi
2018-09-07 13:08:06 +00:00
runHook postInstall
''