mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-16 23:03:40 +01:00
Merge pull request #78706 from andir/buildRustCrate-no-out-path-overlaying
buildRustCrate: do not overlay OUT_PATH on src/
This commit is contained in:
commit
23593e42c8
2 changed files with 21 additions and 9 deletions
|
@ -137,16 +137,7 @@ in ''
|
||||||
CRATENAME=$(echo ${crateName} | sed -e "s/\(.*\)-sys$/\U\1/")
|
CRATENAME=$(echo ${crateName} | sed -e "s/\(.*\)-sys$/\U\1/")
|
||||||
grep -P "^cargo:(?!(rustc-|warning=|rerun-if-changed=|rerun-if-env-changed))" target/build/${crateName}.opt \
|
grep -P "^cargo:(?!(rustc-|warning=|rerun-if-changed=|rerun-if-env-changed))" target/build/${crateName}.opt \
|
||||||
| sed -e "s/cargo:\([^=]*\)=\(.*\)/export DEP_$(echo $CRATENAME)_\U\1\E=\2/" > target/env
|
| sed -e "s/cargo:\([^=]*\)=\(.*\)/export DEP_$(echo $CRATENAME)_\U\1\E=\2/" > target/env
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
if [[ -n "$(ls target/build/${crateName}.out)" ]]; then
|
|
||||||
|
|
||||||
if [[ -e "${libPath}" ]]; then
|
|
||||||
cp -r target/build/${crateName}.out/* $(dirname ${libPath}) #*/
|
|
||||||
else
|
|
||||||
cp -r target/build/${crateName}.out/* src #*/
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
runHook postConfigure
|
runHook postConfigure
|
||||||
''
|
''
|
||||||
|
|
|
@ -199,6 +199,27 @@ let
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
# Regression test for https://github.com/NixOS/nixpkgs/issues/74071
|
||||||
|
# Whenevever a build.rs file is generating files those should not be overlayed onto the actual source dir
|
||||||
|
buildRsOutDirOverlay = {
|
||||||
|
src = symlinkJoin {
|
||||||
|
name = "buildrs-out-dir-overlay";
|
||||||
|
paths = [
|
||||||
|
(mkLib "src/lib.rs")
|
||||||
|
(mkFile "build.rs" ''
|
||||||
|
use std::env;
|
||||||
|
use std::ffi::OsString;
|
||||||
|
use std::fs;
|
||||||
|
use std::path::Path;
|
||||||
|
fn main() {
|
||||||
|
let out_dir = env::var_os("OUT_DIR").expect("OUT_DIR not set");
|
||||||
|
let out_file = Path::new(&out_dir).join("lib.rs");
|
||||||
|
fs::write(out_file, "invalid rust code!").expect("failed to write lib.rs");
|
||||||
|
}
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
brotliCrates = (callPackage ./brotli-crates.nix {});
|
brotliCrates = (callPackage ./brotli-crates.nix {});
|
||||||
in lib.mapAttrs (key: value: mkTest (value // lib.optionalAttrs (!value?crateName) { crateName = key; })) cases // {
|
in lib.mapAttrs (key: value: mkTest (value // lib.optionalAttrs (!value?crateName) { crateName = key; })) cases // {
|
||||||
|
|
Loading…
Reference in a new issue