new patches for cargo
This commit is contained in:
@@ -2,7 +2,7 @@ SRCREV_cargo = "a0f0abca4f718e36ddc7cc23f9bce4c51d93cbe5"
|
||||
require cargo.inc
|
||||
|
||||
SRC_URI += " \
|
||||
file://0001-custom_build-add-BUILD_KIND-env-var.patch \
|
||||
file://0001-custom_build-add-the-HOST-environment-variable.patch \
|
||||
\
|
||||
git://github.com/carllerche/curl-rust.git;protocol=https;name=curl-rust;destsuffix=curl-rust \
|
||||
file://curl-rust/0001-curl-sys-avoid-explicitly-linking-in-openssl-If-it-.patch;patchdir=../curl-rust \
|
||||
@@ -13,7 +13,6 @@ SRC_URI += " \
|
||||
\
|
||||
git://github.com/alexcrichton/gcc-rs.git;protocol=https;name=gcc-rs;destsuffix=gcc-rs \
|
||||
file://gcc-rs/0001-Support-use-of-namespaced-environment-variables-base.patch;patchdir=../gcc-rs \
|
||||
file://gcc-rs/0001-Avoid-death-when-lacking-BUILD_KIND.patch;patchdir=../gcc-rs \
|
||||
"
|
||||
|
||||
SRCREV_curl-rust = "5d0f5c8848e3cf1e12480a1923ae888e24d58f63"
|
||||
|
||||
+15
-21
@@ -1,55 +1,49 @@
|
||||
From ccbbb148c237bbd6bfb8b98e34fb3ad8404348f0 Mon Sep 17 00:00:00 2001
|
||||
From 41de2918fa69fa7e48bcfe7b3e68974befb0d5e6 Mon Sep 17 00:00:00 2001
|
||||
From: Cody P Schafer <dev@codyps.com>
|
||||
Date: Wed, 3 Dec 2014 13:09:46 -0500
|
||||
Subject: [PATCH] custom_build: add BUILD_KIND env var
|
||||
Subject: [PATCH] custom_build: add the HOST environment variable
|
||||
|
||||
---
|
||||
src/cargo/ops/cargo_rustc/custom_build.rs | 6 +++++-
|
||||
src/doc/build-script.md | 3 +++
|
||||
tests/test_cargo_compile_custom_build.rs | 3 +++
|
||||
3 files changed, 11 insertions(+), 1 deletion(-)
|
||||
src/cargo/ops/cargo_rustc/custom_build.rs | 3 ++-
|
||||
src/doc/build-script.md | 1 +
|
||||
tests/test_cargo_compile_custom_build.rs | 2 ++
|
||||
3 files changed, 5 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs
|
||||
index 6791e66..b0d2bf7 100644
|
||||
index 6791e66..07ccbaf 100644
|
||||
--- a/src/cargo/ops/cargo_rustc/custom_build.rs
|
||||
+++ b/src/cargo/ops/cargo_rustc/custom_build.rs
|
||||
@@ -61,7 +61,11 @@ pub fn prepare(pkg: &Package, target: &Target, req: Platform,
|
||||
@@ -61,7 +61,8 @@ pub fn prepare(pkg: &Package, target: &Target, req: Platform,
|
||||
}))
|
||||
.env("DEBUG", Some(profile.get_debug().to_string()))
|
||||
.env("OPT_LEVEL", Some(profile.get_opt_level().to_string()))
|
||||
- .env("PROFILE", Some(profile.get_env()));
|
||||
+ .env("PROFILE", Some(profile.get_env()))
|
||||
+ .env("BUILD_KIND", Some(match kind {
|
||||
+ Kind::Host => "HOST",
|
||||
+ Kind::Target => "TARGET",
|
||||
+ }));
|
||||
+ .env("HOST", Some(cx.config.rustc_host()));
|
||||
|
||||
// Be sure to pass along all enabled features for this package, this is the
|
||||
// last piece of statically known information that we have.
|
||||
diff --git a/src/doc/build-script.md b/src/doc/build-script.md
|
||||
index f5ece41..34de9cd 100644
|
||||
index f5ece41..3a3f0ea 100644
|
||||
--- a/src/doc/build-script.md
|
||||
+++ b/src/doc/build-script.md
|
||||
@@ -43,6 +43,9 @@ all passed in the form of environment variables:
|
||||
@@ -43,6 +43,7 @@ all passed in the form of environment variables:
|
||||
* `TARGET` - the target triple that is being compiled for. Native code should be
|
||||
compiled for this triple. Some more information about target
|
||||
triples can be found in [clang's own documentation][clang].
|
||||
+* `BUILD_KIND` - the kind of the build, one of "TARGET" or "HOST". Use
|
||||
+ discretion when utilizing this, very often the `TARGET`
|
||||
+ variable is preferable.
|
||||
+* `HOST` - the host triple of the rust compiler.
|
||||
* `NUM_JOBS` - the parallelism specified as the top-level parallelism. This can
|
||||
be useful to pass a `-j` parameter to a system like `make`.
|
||||
* `CARGO_MANIFEST_DIR` - The directory containing the manifest for the package
|
||||
diff --git a/tests/test_cargo_compile_custom_build.rs b/tests/test_cargo_compile_custom_build.rs
|
||||
index 9ea71f0..1dd3c6b 100644
|
||||
index 9ea71f0..aef3c77 100644
|
||||
--- a/tests/test_cargo_compile_custom_build.rs
|
||||
+++ b/tests/test_cargo_compile_custom_build.rs
|
||||
@@ -99,6 +99,9 @@ test!(custom_build_env_vars {
|
||||
@@ -99,6 +99,8 @@ test!(custom_build_env_vars {
|
||||
assert!(out.as_slice().starts_with(r"{0}"));
|
||||
assert!(Path::new(out).is_dir());
|
||||
|
||||
+ let kind = os::getenv("BUILD_KIND").unwrap();
|
||||
+ assert_eq!(kind.as_slice(), "TARGET");
|
||||
+ let _host = os::getenv("HOST").unwrap();
|
||||
+
|
||||
let _feat = os::getenv("CARGO_FEATURE_FOO").unwrap();
|
||||
}}
|
||||
@@ -1,27 +0,0 @@
|
||||
From f2872c1887de199d1ba773d092548876113775bf Mon Sep 17 00:00:00 2001
|
||||
From: Cody P Schafer <dev@codyps.com>
|
||||
Date: Wed, 3 Dec 2014 14:21:29 -0500
|
||||
Subject: [PATCH] Avoid death when lacking BUILD_KIND
|
||||
|
||||
---
|
||||
src/lib.rs | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/lib.rs b/src/lib.rs
|
||||
index 18718b9..d22d833 100644
|
||||
--- a/src/lib.rs
|
||||
+++ b/src/lib.rs
|
||||
@@ -115,8 +115,8 @@ fn get_var(var_base: &str) -> Option<String> {
|
||||
let target_u = target.split('-')
|
||||
.collect::<Vec<&str>>()
|
||||
.connect("_");
|
||||
- let kind = os::getenv("BUILD_KIND")
|
||||
- .expect("Environment variable 'BUILD_KIND' is unset");
|
||||
+ let kind = os::getenv("BUILD_KIND")
|
||||
+ .unwrap_or(String::from_str("TARGET"));
|
||||
os::getenv(format!("{}_{}", var_base, target).as_slice())
|
||||
.or_else(|| os::getenv(format!("{}_{}", var_base, target_u).as_slice()))
|
||||
.or_else(|| os::getenv(format!("{}_{}", kind, var_base).as_slice()))
|
||||
--
|
||||
2.1.3
|
||||
|
||||
+12
-11
@@ -1,16 +1,16 @@
|
||||
From 5f5cb84a50a505a7876999729d4f53f59fa913ec Mon Sep 17 00:00:00 2001
|
||||
From 94205321c27fc40f7c9604558e08db345cd5a81a Mon Sep 17 00:00:00 2001
|
||||
From: Cody P Schafer <dev@codyps.com>
|
||||
Date: Wed, 3 Dec 2014 13:41:11 -0500
|
||||
Subject: [PATCH] Support use of namespaced environment variables based on
|
||||
target triplet and BUILD_KIND
|
||||
TARGET and HOST
|
||||
|
||||
---
|
||||
README.md | 25 +++++++++++++++++++++++++
|
||||
src/lib.rs | 20 +++++++++++++++++---
|
||||
2 files changed, 42 insertions(+), 3 deletions(-)
|
||||
src/lib.rs | 21 ++++++++++++++++++---
|
||||
2 files changed, 43 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/README.md b/README.md
|
||||
index bb7047d..73b72d7 100644
|
||||
index bb7047d..0268ce1 100644
|
||||
--- a/README.md
|
||||
+++ b/README.md
|
||||
@@ -11,6 +11,31 @@ fn main() {
|
||||
@@ -40,27 +40,28 @@ index bb7047d..73b72d7 100644
|
||||
+
|
||||
+If none of these varaibles exist, gcc-rs uses built-in defaults
|
||||
+
|
||||
+In addition to the the above optional environment variables, `gcc-rs` has some functions with hard requirements on some variables supplied by [cargo's build-script driver][cargo] that it has the `TARGET`, `OUT_DIR`, `OPT_LEVEL`, and `BUILD_KIND` variables
|
||||
+In addition to the the above optional environment variables, `gcc-rs` has some functions with hard requirements on some variables supplied by [cargo's build-script driver][cargo] that it has the `TARGET`, `OUT_DIR`, `OPT_LEVEL`, and `HOST` variables
|
||||
+
|
||||
# Windows notes
|
||||
|
||||
Currently use of this crate means that Windows users will require gcc to be
|
||||
diff --git a/src/lib.rs b/src/lib.rs
|
||||
index 51157c8..18718b9 100644
|
||||
index 51157c8..bb0cb3c 100644
|
||||
--- a/src/lib.rs
|
||||
+++ b/src/lib.rs
|
||||
@@ -109,8 +109,22 @@ fn run(cmd: &mut Command) {
|
||||
@@ -109,8 +109,23 @@ fn run(cmd: &mut Command) {
|
||||
}
|
||||
}
|
||||
|
||||
+fn get_var(var_base: &str) -> Option<String> {
|
||||
+ let target = os::getenv("TARGET")
|
||||
+ .expect("Environment variable 'TARGET' is unset");
|
||||
+ let host = os::getenv("HOST")
|
||||
+ .expect("Environment variable 'HOST' is unset");
|
||||
+ let kind = if host == target { "HOST" } else { "TARGET" };
|
||||
+ let target_u = target.split('-')
|
||||
+ .collect::<Vec<&str>>()
|
||||
+ .connect("_");
|
||||
+ let kind = os::getenv("BUILD_KIND")
|
||||
+ .expect("Environment variable 'BUILD_KIND' is unset");
|
||||
+ os::getenv(format!("{}_{}", var_base, target).as_slice())
|
||||
+ .or_else(|| os::getenv(format!("{}_{}", var_base, target_u).as_slice()))
|
||||
+ .or_else(|| os::getenv(format!("{}_{}", kind, var_base).as_slice()))
|
||||
@@ -73,7 +74,7 @@ index 51157c8..18718b9 100644
|
||||
"gcc".to_string()
|
||||
} else {
|
||||
"cc".to_string()
|
||||
@@ -118,11 +132,11 @@ fn gcc() -> String {
|
||||
@@ -118,11 +133,11 @@ fn gcc() -> String {
|
||||
}
|
||||
|
||||
fn ar() -> String {
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
From 66911257957f29ccf3a4386956977e97168200e7 Mon Sep 17 00:00:00 2001
|
||||
From: Cody P Schafer <dev@codyps.com>
|
||||
Date: Tue, 25 Nov 2014 16:28:25 -0500
|
||||
Subject: [PATCH] XXX: hacks
|
||||
|
||||
---
|
||||
src/lib.rs | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/lib.rs b/src/lib.rs
|
||||
index de90de6..a388af3 100644
|
||||
--- a/src/lib.rs
|
||||
+++ b/src/lib.rs
|
||||
@@ -99,13 +99,14 @@ pub fn compile_library(output: &str, config: &Config, files: &[&str]) {
|
||||
}
|
||||
|
||||
fn run(cmd: &mut Command) {
|
||||
- println!("running: {}", cmd);
|
||||
+ println!("running: '{}' : {}", cmd.program(), cmd);
|
||||
assert!(cmd.stdout(InheritFd(1))
|
||||
.stderr(InheritFd(2))
|
||||
.status()
|
||||
.unwrap()
|
||||
.success());
|
||||
|
||||
+ println!("Run done");
|
||||
}
|
||||
|
||||
fn gcc() -> String {
|
||||
--
|
||||
2.1.3
|
||||
|
||||
Reference in New Issue
Block a user