mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-13 21:32:23 +03:00
buildRustCrate: Replace hyphen with underscore in env variables (#88054)
* Add test case for include dir * buildRustCrate: replace hyphen with underscore in env This fixes a bug that prevents encoding_c from building.
This commit is contained in:
parent
0300b47dd5
commit
c21cbf22d0
@ -179,9 +179,9 @@ in ''
|
||||
export $env
|
||||
done
|
||||
|
||||
CRATENAME=$(echo ${crateName} | sed -e "s/\(.*\)-sys$/\U\1/")
|
||||
CRATENAME=$(echo ${crateName} | sed -e "s/\(.*\)-sys$/\U\1/" -e "s/-/_/g")
|
||||
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
|
||||
| awk -F= "/^cargo:/ { sub(/^cargo:/, \"\", \$1); gsub(/-/, \"_\", \$1); print \"export \" toupper(\"DEP_$(echo $CRATENAME)_\" \$1) \"=\" \$2 }" > target/env
|
||||
set -e
|
||||
fi
|
||||
runHook postConfigure
|
||||
|
@ -344,6 +344,40 @@ let
|
||||
buildTests = true;
|
||||
expectedTestOutputs = [ "test baz_false ... ok" ];
|
||||
};
|
||||
# Regression test for https://github.com/NixOS/nixpkgs/pull/88054
|
||||
# Build script output should be rewritten as valid env vars.
|
||||
buildScriptIncludeDirDeps = let
|
||||
depCrate = mkCrate {
|
||||
crateName = "bar";
|
||||
src = symlinkJoin {
|
||||
name = "build-script-and-include-dir-bar";
|
||||
paths = [
|
||||
(mkFile "src/lib.rs" ''
|
||||
fn main() { }
|
||||
'')
|
||||
(mkFile "build.rs" ''
|
||||
use std::path::PathBuf;
|
||||
fn main() { println!("cargo:include-dir={}/src", std::env::current_dir().unwrap_or(PathBuf::from(".")).to_str().unwrap()); }
|
||||
'')
|
||||
];
|
||||
};
|
||||
};
|
||||
in {
|
||||
crateName = "foo";
|
||||
src = symlinkJoin {
|
||||
name = "build-script-and-include-dir-foo";
|
||||
paths = [
|
||||
(mkFile "src/main.rs" ''
|
||||
fn main() { }
|
||||
'')
|
||||
(mkFile "build.rs" ''
|
||||
fn main() { assert!(std::env::var_os("DEP_BAR_INCLUDE_DIR").is_some()); }
|
||||
'')
|
||||
];
|
||||
};
|
||||
buildDependencies = [ depCrate ];
|
||||
dependencies = [ depCrate ];
|
||||
};
|
||||
# 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 = {
|
||||
|
Loading…
Reference in New Issue
Block a user