Skip to content
This repository has been archived by the owner on Sep 4, 2022. It is now read-only.

Commit

Permalink
Reduce deps to build on linux from 61 -> to 48
Browse files Browse the repository at this point in the history
  • Loading branch information
kpp committed Feb 16, 2019
1 parent e699c57 commit 6125168
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
20 changes: 12 additions & 8 deletions libsodium-sys/Cargo.toml
Expand Up @@ -15,20 +15,24 @@ version = "0.2.0"
travis-ci = { repository = "sodiumoxide/sodiumoxide" }

[build-dependencies]
cc = "1.0.9"
flate2 = "1.0.1"
http_req = "0.2.1"
pkg-config = "0.3.11"
libc = { version = "0.2.41" , default-features = false }
http_req = { version = "0.4", default-features = false, features = ["rust-tls"] }
sha2 = "0.8"
tar = "0.4.15"
zip = "0.5"
pkg-config = "0.3"



[target.'cfg(target_env = "msvc")'.build-dependencies]
libc = { version = "=0.2.48" , default-features = false }
vcpkg = "0.2"
zip = "0.5"

[target.'cfg(not(target_env = "msvc"))'.build-dependencies]
cc = "1.0"
libflate = "0.1"
tar = "0.4"

[dependencies]
libc = { version = "^0.2.41" , default-features = false }
libc = { version = "=0.2.48" , default-features = false }

[lib]
name = "libsodium_sys"
23 changes: 11 additions & 12 deletions libsodium-sys/build.rs
@@ -1,10 +1,10 @@
#[cfg(not(windows))]
extern crate cc;
#[cfg(not(target_env = "msvc"))]
extern crate flate2;
extern crate http_req;
#[cfg(target_env = "msvc")]
extern crate libc;
#[cfg(not(target_env = "msvc"))]
extern crate libflate;
extern crate pkg_config;
extern crate sha2;
#[cfg(not(target_env = "msvc"))]
Expand Down Expand Up @@ -145,24 +145,23 @@ fn find_libsodium_pkg() {
/// Download the specified URL into a buffer which is returned.
fn download(url: &str, expected_hash: &str) -> Cursor<Vec<u8>> {
// Send GET request
let response = request::get(url).unwrap();
let mut response_body = Vec::new();
let response = request::get(url, &mut response_body).unwrap();

// Only accept 2xx status codes
if response.status_code() < 200 && response.status_code() >= 300 {
if !response.status_code().is_success() {
panic!("Download error: HTTP {}", response.status_code());
}
let resp_body = response.body();
let buffer = resp_body.to_vec();

// Check the SHA-256 hash of the downloaded file is as expected
let hash = Sha256::digest(&buffer);
let hash = Sha256::digest(&response_body);
assert_eq!(
&format!("{:x}", hash),
expected_hash,
"\n\nDownloaded libsodium file failed hash check.\n\n"
);

Cursor::new(buffer)
Cursor::new(response_body)
}

fn get_install_dir() -> String {
Expand Down Expand Up @@ -231,7 +230,7 @@ fn build_libsodium() {

#[cfg(all(windows, not(target_env = "msvc")))]
fn build_libsodium() {
use flate2::read::GzDecoder;
use libflate::gzip::Decoder;
use tar::Archive;

// Download gz tarball
Expand All @@ -242,7 +241,7 @@ fn build_libsodium() {
let compressed_file = download(&url, SHA256);

// Unpack the tarball
let gz_decoder = GzDecoder::new(compressed_file);
let gz_decoder = Decoder::new(compressed_file).unwrap();
let mut archive = Archive::new(gz_decoder);

// Extract just the appropriate version of libsodium.a and headers to the install path
Expand Down Expand Up @@ -280,7 +279,7 @@ fn build_libsodium() {

#[cfg(not(windows))]
fn build_libsodium() {
use flate2::read::GzDecoder;
use libflate::gzip::Decoder;
use std::process::Command;
use std::str;
use tar::Archive;
Expand Down Expand Up @@ -318,7 +317,7 @@ fn build_libsodium() {
let compressed_file = download(&url, SHA256);

// Unpack the tarball
let gz_decoder = GzDecoder::new(compressed_file);
let gz_decoder = Decoder::new(compressed_file).unwrap();
let mut archive = Archive::new(gz_decoder);
archive.unpack(&source_dir).unwrap();
source_dir.push_str(&format!("/{}", basename));
Expand Down

0 comments on commit 6125168

Please sign in to comment.