Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: acba0f12f8da
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5a462920ca61
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on May 30, 2020

  1. 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.
    
    (cherry picked from commit c21cbf2)
    notriddle authored and Ekleog committed May 30, 2020
    Copy the full SHA
    5a46292 View commit details
Showing with 36 additions and 2 deletions.
  1. +2 −2 pkgs/build-support/rust/build-rust-crate/configure-crate.nix
  2. +34 −0 pkgs/build-support/rust/build-rust-crate/test/default.nix
4 changes: 2 additions & 2 deletions pkgs/build-support/rust/build-rust-crate/configure-crate.nix
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions pkgs/build-support/rust/build-rust-crate/test/default.nix
Original file line number Diff line number Diff line change
@@ -299,6 +299,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 = {