mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2025-01-01 08:25:55 +03:00
Merge pull request #73803 from andir/buildRustCrate-lib-output
buildRustCrate: add lib output
This commit is contained in:
commit
059faab65a
@ -193,6 +193,12 @@
|
||||
The aforementioned option was added this release.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
The <literal>buildRustCrate</literal> infrastructure now produces <literal>lib</literal> outputs in addition to the <literal>out</literal> output.
|
||||
This has led to drastically reduced closed sizes for some rust crates since development dependencies are now in the <literal>lib</literal> output.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
|
||||
|
@ -91,18 +91,18 @@
|
||||
|
||||
echo "$EXTRA_LINK_SEARCH" | while read i; do
|
||||
if [[ ! -z "$i" ]]; then
|
||||
for lib in $i; do
|
||||
echo "-L $lib" >> target/link
|
||||
L=$(echo $lib | sed -e "s#$(pwd)/target/build#$out/lib#")
|
||||
for library in $i; do
|
||||
echo "-L $library" >> target/link
|
||||
L=$(echo $library | sed -e "s#$(pwd)/target/build#$lib/lib#")
|
||||
echo "-L $L" >> target/link.final
|
||||
done
|
||||
fi
|
||||
done
|
||||
echo "$EXTRA_LINK" | while read i; do
|
||||
if [[ ! -z "$i" ]]; then
|
||||
for lib in $i; do
|
||||
echo "-l $lib" >> target/link
|
||||
echo "-l $lib" >> target/link.final
|
||||
for library in $i; do
|
||||
echo "-l $library" >> target/link
|
||||
echo "-l $library" >> target/link.final
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
@ -22,9 +22,9 @@ let
|
||||
else
|
||||
extern;
|
||||
in (if lib.lists.any (x: x == "lib") dep.crateType then
|
||||
" --extern ${name}=${dep.out}/lib/lib${extern}-${dep.metadata}.rlib"
|
||||
" --extern ${name}=${dep.lib}/lib/lib${extern}-${dep.metadata}.rlib"
|
||||
else
|
||||
" --extern ${name}=${dep.out}/lib/lib${extern}-${dep.metadata}${stdenv.hostPlatform.extensions.sharedLibrary}")
|
||||
" --extern ${name}=${dep.lib}/lib/lib${extern}-${dep.metadata}${stdenv.hostPlatform.extensions.sharedLibrary}")
|
||||
) dependencies);
|
||||
|
||||
echo_build_heading = colors: ''
|
||||
@ -96,12 +96,12 @@ stdenv.mkDerivation (rec {
|
||||
buildInputs = (crate.buildInputs or []) ++ buildInputs_;
|
||||
dependencies =
|
||||
builtins.map
|
||||
(dep: dep.override { rust = rust; release = release; verbose = verbose; crateOverrides = crateOverrides; })
|
||||
(dep: lib.getLib (dep.override { rust = rust; release = release; verbose = verbose; crateOverrides = crateOverrides; }))
|
||||
dependencies_;
|
||||
|
||||
buildDependencies =
|
||||
builtins.map
|
||||
(dep: dep.override { rust = rust; release = release; verbose = verbose; crateOverrides = crateOverrides; })
|
||||
(dep: lib.getLib (dep.override { rust = rust; release = release; verbose = verbose; crateOverrides = crateOverrides; }))
|
||||
buildDependencies_;
|
||||
|
||||
completeDeps = lib.lists.unique (dependencies ++ lib.lists.concatMap (dep: dep.completeDeps) dependencies);
|
||||
@ -160,6 +160,9 @@ stdenv.mkDerivation (rec {
|
||||
};
|
||||
installPhase = installCrate crateName metadata;
|
||||
|
||||
outputs = [ "out" "lib" ];
|
||||
outputDev = [ "lib" ];
|
||||
|
||||
} // extraDerivationAttrs
|
||||
)) {
|
||||
rust = rustc;
|
||||
|
@ -1,24 +1,26 @@
|
||||
crateName: metadata:
|
||||
''
|
||||
runHook preInstall
|
||||
mkdir -p $out
|
||||
# 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
|
||||
if [[ -s target/env ]]; then
|
||||
cp target/env $out/env
|
||||
mkdir -p $lib
|
||||
cp target/env $lib/env
|
||||
fi
|
||||
if [[ -s target/link.final ]]; then
|
||||
mkdir -p $out/lib
|
||||
cp target/link.final $out/lib/link
|
||||
mkdir -p $lib/lib
|
||||
cp target/link.final $lib/lib/link
|
||||
fi
|
||||
if [[ "$(ls -A target/lib)" ]]; then
|
||||
mkdir -p $out/lib
|
||||
cp target/lib/* $out/lib #*/
|
||||
for lib in $out/lib/*.so $out/lib/*.dylib; do #*/
|
||||
ln -s $lib $(echo $lib | sed -e "s/-${metadata}//")
|
||||
mkdir -p $lib/lib
|
||||
cp target/lib/* $lib/lib #*/
|
||||
for library in $lib/lib/*.so $lib/lib/*.dylib; do #*/
|
||||
ln -s $library $(echo $library | sed -e "s/-${metadata}//")
|
||||
done
|
||||
fi
|
||||
if [[ "$(ls -A target/build)" ]]; then # */
|
||||
mkdir -p $out/lib
|
||||
cp -r target/build/* $out/lib # */
|
||||
mkdir -p $lib/lib
|
||||
cp -r target/build/* $lib/lib # */
|
||||
fi
|
||||
if [[ -d target/bin ]]; then
|
||||
if [[ "$(ls -A target/bin)" ]]; then
|
||||
|
Loading…
Reference in New Issue
Block a user