cargo: more fixups
This commit is contained in:
@@ -10,7 +10,6 @@ SRC_URI += " \
|
|||||||
\
|
\
|
||||||
git://github.com/alexcrichton/ssh2-rs.git;protocol=https;name=ssh2-rs;destsuffix=ssh2-rs \
|
git://github.com/alexcrichton/ssh2-rs.git;protocol=https;name=ssh2-rs;destsuffix=ssh2-rs \
|
||||||
file://ssh2-rs/0001-Unconditionally-depend-on-openssl-sys.patch;patchdir=../ssh2-rs \
|
file://ssh2-rs/0001-Unconditionally-depend-on-openssl-sys.patch;patchdir=../ssh2-rs \
|
||||||
file://ssh2-rs/0002-libssh2-sys-only-support-pkg-config.patch;patchdir=../ssh2-rs \
|
|
||||||
\
|
\
|
||||||
git://github.com/alexcrichton/git2-rs.git;protocol=https;name=git2-rs;destsuffix=git2-rs \
|
git://github.com/alexcrichton/git2-rs.git;protocol=https;name=git2-rs;destsuffix=git2-rs \
|
||||||
file://git2-rs/0001-Add-generic-openssl-sys-dep.patch;patchdir=../git2-rs \
|
file://git2-rs/0001-Add-generic-openssl-sys-dep.patch;patchdir=../git2-rs \
|
||||||
|
|||||||
@@ -1,150 +0,0 @@
|
|||||||
From 1ddeb7b82b0f2a03a2f3054970ad24284b11fe64 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Cody P Schafer <dev@codyps.com>
|
|
||||||
Date: Fri, 13 Feb 2015 14:01:14 -0500
|
|
||||||
Subject: [PATCH 2/2] libssh2-sys: only support pkg-config
|
|
||||||
|
|
||||||
---
|
|
||||||
libssh2-sys/build.rs | 125 +--------------------------------------------------
|
|
||||||
1 file changed, 2 insertions(+), 123 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/libssh2-sys/build.rs b/libssh2-sys/build.rs
|
|
||||||
index 9cab3b0..c10361c 100644
|
|
||||||
--- a/libssh2-sys/build.rs
|
|
||||||
+++ b/libssh2-sys/build.rs
|
|
||||||
@@ -1,131 +1,10 @@
|
|
||||||
-#![feature(old_io, old_path, env, core)]
|
|
||||||
-
|
|
||||||
extern crate "pkg-config" as pkg_config;
|
|
||||||
|
|
||||||
-use std::env;
|
|
||||||
-use std::old_io::{self, fs, Command};
|
|
||||||
-use std::old_io::process::InheritFd;
|
|
||||||
-use std::old_io::fs::PathExtensions;
|
|
||||||
-
|
|
||||||
fn main() {
|
|
||||||
match pkg_config::find_library("libssh2") {
|
|
||||||
Ok(..) => return,
|
|
||||||
- Err(..) => {}
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- let mut cflags = env::var("CFLAGS").unwrap_or(String::new());
|
|
||||||
- let target = env::var("TARGET").unwrap();
|
|
||||||
- let windows = target.contains("windows") || target.contains("mingw");
|
|
||||||
- cflags.push_str(" -ffunction-sections -fdata-sections");
|
|
||||||
-
|
|
||||||
- if target.contains("i686") {
|
|
||||||
- cflags.push_str(" -m32");
|
|
||||||
- } else if target.as_slice().contains("x86_64") {
|
|
||||||
- cflags.push_str(" -m64");
|
|
||||||
- }
|
|
||||||
- if !target.contains("i686") {
|
|
||||||
- cflags.push_str(" -fPIC");
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- match env::var("DEP_OPENSSL_ROOT") {
|
|
||||||
- Ok(s) => {
|
|
||||||
- cflags.push_str(format!(" -I{}/include", s).as_slice());
|
|
||||||
- cflags.push_str(format!(" -L{}/lib", s).as_slice());
|
|
||||||
+ Err(..) => {
|
|
||||||
+ panic!("Could not find libssh2");
|
|
||||||
}
|
|
||||||
- Err(..) => {}
|
|
||||||
}
|
|
||||||
-
|
|
||||||
- let src = Path::new(env::var("CARGO_MANIFEST_DIR").unwrap());
|
|
||||||
- let dst = Path::new(env::var("OUT_DIR").unwrap());
|
|
||||||
-
|
|
||||||
- let mut config_opts = Vec::new();
|
|
||||||
- if windows {
|
|
||||||
- config_opts.push("--without-openssl".to_string());
|
|
||||||
- config_opts.push("--with-wincng".to_string());
|
|
||||||
- }
|
|
||||||
- config_opts.push("--enable-shared=no".to_string());
|
|
||||||
- config_opts.push("--disable-examples-build".to_string());
|
|
||||||
- config_opts.push(format!("--prefix={}", dst.display()));
|
|
||||||
-
|
|
||||||
- let _ = fs::rmdir_recursive(&dst.join("include"));
|
|
||||||
- let _ = fs::rmdir_recursive(&dst.join("lib"));
|
|
||||||
- let _ = fs::rmdir_recursive(&dst.join("build"));
|
|
||||||
- fs::mkdir(&dst.join("build"), old_io::USER_DIR).unwrap();
|
|
||||||
-
|
|
||||||
- let root = src.join("libssh2-1.4.4-20140901");
|
|
||||||
- // Can't run ./configure directly on msys2 b/c we're handing in
|
|
||||||
- // Windows-style paths (those starting with C:\), but it chokes on those.
|
|
||||||
- // For that reason we build up a shell script with paths converted to
|
|
||||||
- // posix versions hopefully...
|
|
||||||
- //
|
|
||||||
- // Also apparently the buildbots choke unless we manually set LD, who knows
|
|
||||||
- // why?!
|
|
||||||
- run(Command::new("sh")
|
|
||||||
- .env("CFLAGS", cflags)
|
|
||||||
- .env("LD", which("ld").unwrap())
|
|
||||||
- .cwd(&dst.join("build"))
|
|
||||||
- .arg("-c")
|
|
||||||
- .arg(format!("{} {}", root.join("configure").display(),
|
|
||||||
- config_opts.connect(" "))
|
|
||||||
- .replace("C:\\", "/c/")
|
|
||||||
- .replace("\\", "/")));
|
|
||||||
- run(Command::new(make())
|
|
||||||
- .arg(format!("-j{}", env::var("NUM_JOBS").unwrap()))
|
|
||||||
- .cwd(&dst.join("build/src")));
|
|
||||||
-
|
|
||||||
- // Don't run `make install` because apparently it's a little buggy on mingw
|
|
||||||
- // for windows.
|
|
||||||
- fs::mkdir_recursive(&dst.join("lib/pkgconfig"), old_io::USER_DIR).unwrap();
|
|
||||||
-
|
|
||||||
- // Which one does windows generate? Who knows!
|
|
||||||
- let p1 = dst.join("build/src/.libs/libssh2.a");
|
|
||||||
- let p2 = dst.join("build/src/.libs/libssh2.lib");
|
|
||||||
- if p1.exists() {
|
|
||||||
- fs::rename(&p1, &dst.join("lib/libssh2.a")).unwrap();
|
|
||||||
- } else {
|
|
||||||
- fs::rename(&p2, &dst.join("lib/libssh2.a")).unwrap();
|
|
||||||
- }
|
|
||||||
- fs::rename(&dst.join("build/libssh2.pc"),
|
|
||||||
- &dst.join("lib/pkgconfig/libssh2.pc")).unwrap();
|
|
||||||
-
|
|
||||||
- {
|
|
||||||
- let root = root.join("include");
|
|
||||||
- let dst = dst.join("include");
|
|
||||||
- for file in fs::walk_dir(&root).unwrap() {
|
|
||||||
- if fs::stat(&file).unwrap().kind != old_io::FileType::RegularFile { continue }
|
|
||||||
-
|
|
||||||
- let part = file.path_relative_from(&root).unwrap();
|
|
||||||
- let dst = dst.join(part);
|
|
||||||
- fs::mkdir_recursive(&dst.dir_path(), old_io::USER_DIR).unwrap();
|
|
||||||
- fs::copy(&file, &dst).unwrap();
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if windows {
|
|
||||||
- println!("cargo:rustc-flags=-l ws2_32 -l bcrypt -l crypt32");
|
|
||||||
- }
|
|
||||||
- println!("cargo:rustc-flags=-L {}/lib -l ssh2:static", dst.display());
|
|
||||||
- println!("cargo:root={}", dst.display());
|
|
||||||
- println!("cargo:include={}/include", dst.display());
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-fn make() -> &'static str {
|
|
||||||
- if cfg!(target_os = "freebsd") {"gmake"} else {"make"}
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-fn run(cmd: &mut Command) {
|
|
||||||
- println!("running: {:?}", cmd);
|
|
||||||
- assert!(cmd.stdout(InheritFd(1))
|
|
||||||
- .stderr(InheritFd(2))
|
|
||||||
- .status()
|
|
||||||
- .unwrap()
|
|
||||||
- .success());
|
|
||||||
-
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
-fn which(cmd: &str) -> Option<Path> {
|
|
||||||
- let cmd = format!("{}{}", cmd, env::consts::EXE_SUFFIX);
|
|
||||||
- env::split_paths(&env::var("PATH").unwrap()).map(|p| {
|
|
||||||
- p.join(&cmd)
|
|
||||||
- }).find(|p| p.exists())
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.3.0
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user