Skip to content

Commit db3df34

Browse files
author
Ed Barnard
authored
Add a protocol-ftp feature which enables FTP support when using bundled libcurl (#322) (#325)
1 parent 6e8f555 commit db3df34

File tree

5 files changed

+39
-4
lines changed

5 files changed

+39
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ spnego = ["curl-sys/spnego"]
4444
static-curl = ["curl-sys/static-curl"]
4545
static-ssl = ["curl-sys/static-ssl"]
4646
force-system-lib-on-osx = ['curl-sys/force-system-lib-on-osx']
47+
protocol-ftp = ["curl-sys/protocol-ftp"]
4748

4849
[[test]]
4950
name = "atexit"

ci/run.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
set -ex
44

55
cargo test --target $TARGET --no-run
6-
cargo test --target $TARGET --no-run --features curl-sys/static-curl
6+
# First test with no extra protocols enabled.
7+
cargo test --target $TARGET --no-run --features static-curl
8+
# Then with all extra protocols enabled.
9+
cargo test --target $TARGET --no-run --features static-curl,protocol-ftp
710
if [ -z "$NO_RUN" ]; then
811
cargo test --target $TARGET
9-
cargo test --target $TARGET --features curl-sys/static-curl
12+
cargo test --target $TARGET --features static-curl
13+
cargo test --target $TARGET --features static-curl,protocol-ftp
1014
cargo run --manifest-path systest/Cargo.toml --target $TARGET
11-
cargo run --manifest-path systest/Cargo.toml --target $TARGET --features curl-sys/static-curl
15+
cargo run --manifest-path systest/Cargo.toml --target $TARGET --features curl-sys/static-curl,curl-sys/protocol-ftp
1216
cargo doc --no-deps --target $TARGET
1317
cargo doc --no-deps -p curl-sys --target $TARGET
1418
fi

curl-sys/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,4 @@ static-curl = []
5050
static-ssl = ["openssl-sys/vendored"]
5151
spnego = []
5252
force-system-lib-on-osx = []
53+
protocol-ftp = []

curl-sys/build.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ fn main() {
116116
.define("BUILDING_LIBCURL", None)
117117
.define("CURL_DISABLE_CRYPTO_AUTH", None)
118118
.define("CURL_DISABLE_DICT", None)
119-
.define("CURL_DISABLE_FTP", None)
120119
.define("CURL_DISABLE_GOPHER", None)
121120
.define("CURL_DISABLE_IMAP", None)
122121
.define("CURL_DISABLE_LDAP", None)
@@ -202,6 +201,15 @@ fn main() {
202201
.define("HAVE_GETPEERNAME", None)
203202
.warnings(false);
204203

204+
if cfg!(feature = "protocol-ftp") {
205+
cfg.file("curl/lib/curl_fnmatch.c")
206+
.file("curl/lib/ftp.c")
207+
.file("curl/lib/ftplistparser.c")
208+
.file("curl/lib/pingpong.c");
209+
} else {
210+
cfg.define("CURL_DISABLE_FTP", None);
211+
}
212+
205213
if cfg!(feature = "http2") {
206214
cfg.define("USE_NGHTTP2", None)
207215
.define("NGHTTP2_STATICLIB", None);

tests/protocols.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
extern crate curl;
2+
3+
#[cfg(all(feature = "static-curl", not(feature = "protocol-ftp")))]
4+
#[test]
5+
fn static_with_ftp_disabled() {
6+
assert!(curl::Version::get()
7+
.protocols()
8+
.filter(|&p| p == "ftp")
9+
.next()
10+
.is_none());
11+
}
12+
13+
#[cfg(all(feature = "static-curl", feature = "protocol-ftp"))]
14+
#[test]
15+
fn static_with_ftp_enabled() {
16+
assert!(curl::Version::get()
17+
.protocols()
18+
.filter(|&p| p == "ftp")
19+
.next()
20+
.is_some());
21+
}

0 commit comments

Comments
 (0)