Skip to content

Move the submodule to a curl with ./configure #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "curl-sys/curl"]
path = curl-sys/curl
url = https://github.com/bagder/curl
url = https://github.com/alexcrichton/curl
17 changes: 3 additions & 14 deletions curl-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -12,6 +12,9 @@ git = "https://github.com/alexcrichton/pkg-config-rs"
name = "curl-sys"
path = "lib.rs"

[dependencies.libz-sys]
git = "https://github.com/alexcrichton/libz-sys"

# Unix platforms use OpenSSL for now to provide SSL functionality
[target.i686-apple-darwin.dependencies.openssl-sys]
git = "https://github.com/alexcrichton/openssl-sys"
@@ -25,17 +28,3 @@ path = "lib.rs"
git = "https://github.com/alexcrichton/openssl-sys"
[target.x86_64-unknown-freebsd.dependencies.openssl-sys]
git = "https://github.com/alexcrichton/openssl-sys"

# Unix platforms also use libz for compression
[target.i686-apple-darwin.dependencies.libz-sys]
git = "https://github.com/alexcrichton/libz-sys"
[target.x86_64-apple-darwin.dependencies.libz-sys]
git = "https://github.com/alexcrichton/libz-sys"
[target.i686-unknown-linux-gnu.dependencies.libz-sys]
git = "https://github.com/alexcrichton/libz-sys"
[target.x86_64-unknown-linux-gnu.dependencies.libz-sys]
git = "https://github.com/alexcrichton/libz-sys"
[target.i686-unknown-freebsd.dependencies.libz-sys]
git = "https://github.com/alexcrichton/libz-sys"
[target.x86_64-unknown-freebsd.dependencies.libz-sys]
git = "https://github.com/alexcrichton/libz-sys"
101 changes: 72 additions & 29 deletions curl-sys/build.rs
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ extern crate "pkg-config" as pkg_config;
use std::os;
use std::io::{mod, fs, Command};
use std::io::process::InheritFd;
use std::io::fs::PathExtensions;

fn main() {
let target = os::getenv("TARGET").unwrap();
@@ -31,7 +32,6 @@ fn main() {

let mut cflags = os::getenv("CFLAGS").unwrap_or(String::new());
let windows = target.contains("windows");
let mingw = windows && target.contains("gnu");
cflags.push_str(" -ffunction-sections -fdata-sections");

if target.contains("i686") {
@@ -48,37 +48,70 @@ fn main() {

let _ = fs::mkdir(&dst.join("build"), io::USER_DIR);

let mut cmd = Command::new("cmake");
if mingw {
cmd.arg("-G").arg("Unix Makefiles");
let mut config_opts = Vec::new();
if windows {
config_opts.push("--with-winssl".to_string());
} else {
config_opts.push("--without-ca-bundle".to_string());
config_opts.push("--without-ca-path".to_string());
}
run(cmd.arg(src.join("curl"))
.args(&[
"-DBUILD_CURL_EXE=OFF",
"-DBUILD_CURL_TESTS=OFF",
"-DCURL_STATICLIB=ON",
"-DCURL_DISABLE_FTP=ON",
"-DCURL_DISABLE_LDAP=ON",
"-DCURL_DISABLE_TELNET=ON",
"-DCURL_DISABLE_DICT=ON",
"-DCURL_DISABLE_TFTP=ON",
"-DCURL_DISABLE_RTSP=ON",
"-DCURL_DISABLE_LDAPS=ON",
"-DCURL_DISABLE_POP3=ON",
"-DCURL_DISABLE_POP3=ON",
"-DCURL_DISABLE_IMAP=ON",
"-DCURL_DISABLE_SMTP=ON",
"-DCURL_DISABLE_GOPHER=ON",
])
.arg(format!("-DCMAKE_C_FLAGS={}", cflags))
.arg("-DCMAKE_BUILD_TYPE=RelWithDebInfo")
.arg(format!("-DCMAKE_INSTALL_PREFIX={}", dst.display()))
.cwd(&dst.join("build")));
run(Command::new("cmake")
.arg("--build").arg(".")
.arg("--target").arg("install")
config_opts.push("--enable-static=yes".to_string());
config_opts.push("--enable-shared=no".to_string());
config_opts.push("--enable-optimize".to_string());
config_opts.push(format!("--prefix={}", dst.display()));

config_opts.push("--without-librtmp".to_string());
config_opts.push("--without-libidn".to_string());
config_opts.push("--without-libssh2".to_string());
config_opts.push("--without-nghttp2".to_string());
config_opts.push("--disable-ldap".to_string());
config_opts.push("--disable-ldaps".to_string());
config_opts.push("--disable-ftp".to_string());
config_opts.push("--disable-rtsp".to_string());
config_opts.push("--disable-dict".to_string());
config_opts.push("--disable-telnet".to_string());
config_opts.push("--disable-tftp".to_string());
config_opts.push("--disable-pop3".to_string());
config_opts.push("--disable-imap".to_string());
config_opts.push("--disable-smtp".to_string());
config_opts.push("--disable-gopher".to_string());
config_opts.push("--disable-manual".to_string());

// 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!("{} {}", src.join("curl/configure").display(),
config_opts.connect(" "))
.replace("C:\\", "/c/")
.replace("\\", "/")));
run(Command::new(make())
.arg(format!("-j{}", os::getenv("NUM_JOBS").unwrap()))
.cwd(&dst.join("build")));

// Don't run `make install` because apparently it's a little buggy on mingw
// for windows.
fs::mkdir_recursive(&dst.join("lib/pkgconfig"), io::USER_DIR).unwrap();

// Which one does windows generate? Who knows!
let p1 = dst.join("build/lib/.libs/libcurl.a");
let p2 = dst.join("build/lib/.libs/libcurl.lib");
if p1.exists() {
fs::rename(&p1, &dst.join("lib/libcurl.a")).unwrap();
} else {
fs::rename(&p2, &dst.join("lib/libcurl.a")).unwrap();
}
fs::rename(&dst.join("build/libcurl.pc"),
&dst.join("lib/pkgconfig/libcurl.pc")).unwrap();

if windows {
println!("cargo:rustc-flags=-l ws2_32");
}
@@ -96,3 +129,13 @@ fn run(cmd: &mut Command) {
.success());

}

fn make() -> &'static str {
if cfg!(target_os = "freebsd") {"gmake"} else {"make"}
}

fn which(cmd: &str) -> Option<Path> {
let cmd = format!("{}{}", cmd, os::consts::EXE_SUFFIX);
let paths = os::split_paths(os::getenv("PATH").unwrap());
paths.iter().map(|p| p.join(&cmd)).find(|p| p.exists())
}
2 changes: 1 addition & 1 deletion curl-sys/curl
Submodule curl updated 128 files
2 changes: 1 addition & 1 deletion curl-sys/lib.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
#![allow(non_camel_case_types)]

extern crate libc;
#[cfg(unix)] extern crate "libz-sys" as libz;
extern crate "libz-sys" as libz;
#[cfg(unix)] extern crate "openssl-sys" as openssl;

use libc::{c_void, c_int, c_char, c_uint, c_long};