Skip to content

Commit

Permalink
Merge pull request #19 from rust-math/curl
Browse files Browse the repository at this point in the history
Use curl instead of reqwest
  • Loading branch information
termoshtt authored Nov 2, 2019
2 parents cc755e3 + ffa4818 commit c275a4b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ links = "mkl_intel_lp64"
exclude = ["mkl_lib/mkl.tar.xz"]

[build-dependencies]
pkg-config = "0.3"
failure = "0.1"
reqwest = "0.9"
xz2 = "0.1"
tar = "0.4"
pkg-config = "0.3.16"
failure = "0.1.6"
xz2 = "0.1.6"
tar = "0.4.26"
curl = "0.4.25"

[dev-dependencies]
libc = "0.2"
libc = "0.2.65"
16 changes: 10 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

use curl::easy::Easy;
use failure::*;
use std::{env, fs, io, path::*};
use std::{
env, fs,
io::{self, Write},
path::*,
};

const S3_ADDR: &'static str = "https://s3-ap-northeast-1.amazonaws.com/rust-intel-mkl";

Expand Down Expand Up @@ -57,13 +62,12 @@ fn main() -> Fallible<()> {
let archive = out_dir.join(mkl::ARCHIVE);
if !archive.exists() {
eprintln!("Download archive from AWS S3: {}/{}", S3_ADDR, mkl::ARCHIVE);
let mut res = reqwest::get(&format!("{}/{}", S3_ADDR, mkl::ARCHIVE))?;
if !res.status().is_success() {
bail!("HTTP access failed: {}", res.status());
}
let f = fs::File::create(&archive)?;
let mut buf = io::BufWriter::new(f);
res.copy_to(&mut buf)?;
let mut easy = Easy::new();
easy.url(&format!("{}/{}", S3_ADDR, mkl::ARCHIVE))?;
easy.write_function(move |data| Ok(buf.write(data).unwrap()))?;
easy.perform()?;
assert!(archive.exists());
} else {
eprintln!("Use existing archive");
Expand Down

0 comments on commit c275a4b

Please sign in to comment.