fix build rs

This commit is contained in:
Andrea Fioraldi 2021-01-05 14:43:37 +01:00
parent 1581993a3f
commit 7b72a025d3

View File

@ -4,7 +4,7 @@ use std::env;
use std::path::Path;
use std::process::Command;
const LIBPNG_URL: &str = "http://prdownloads.sourceforge.net/libpng/libpng-1.6.37.tar.gz?download";
const LIBPNG_URL: &str = "https://deac-fra.dl.sourceforge.net/project/libpng/libpng16/1.6.37/libpng-1.6.37.tar.xz";
fn main() {
let out_dir = env::var_os("OUT_DIR").unwrap();
@ -15,14 +15,9 @@ fn main() {
println!("cargo:rerun-if-changed=./runtime/rt.c",);
println!("cargo:rerun-if-changed=harness.cc");
cc::Build::new()
.file("../libfuzzer_runtime/rt.c")
.file("./harness.cc")
.compile("libfuzzer-sys");
let libpng = format!("{}/libpng-1.6.37", &out_dir);
let libpng_path = Path::new(&libpng);
let libpng_tar = format!("{}/libpng-1.6.37.tar.gz", &cwd);
let libpng_tar = format!("{}/libpng-1.6.37.tar.xz", &cwd);
if !libpng_path.is_dir() {
if !Path::new(&libpng_tar).is_file() {
@ -38,7 +33,7 @@ fn main() {
}
Command::new("tar")
.current_dir(&out_dir_path)
.arg("-xvzf")
.arg("-xvf")
.arg(&libpng_tar)
.status()
.unwrap();
@ -88,6 +83,12 @@ fn main() {
.unwrap();
}
cc::Build::new()
.include(&libpng_path)
.file("../libfuzzer_runtime/rt.c")
.file("./harness.cc")
.compile("libfuzzer-sys");
println!("cargo:rustc-link-search=native={}", &out_dir);
println!("cargo:rustc-link-search=native={}/.libs", &libpng);
println!("cargo:rustc-link-lib=static=png16");