Skip to content

Commit

Permalink
[fix #2] write temp files to OUT_DIR
Browse files Browse the repository at this point in the history
  • Loading branch information
dcuddeback committed Jan 7, 2018
1 parent c49163f commit 5efe989
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
extern crate pkg_config;

use std::fs::{self,File};
use std::env;
use std::fs::File;
use std::path::Path;
use std::process::Command;

use std::io::prelude::*;

fn check_func(function_name: &str) -> bool {
let test_file_path = format!("target/build/check_{}.rs", function_name);
let test_file_name = Path::new(&test_file_path[..]);

fs::create_dir_all("target/build").unwrap();
let out_dir = env::var_os("OUT_DIR").unwrap();
let test_file_name = Path::new(&out_dir).join(format!("check_{}.rs", function_name));

{
let mut test_file = File::create(test_file_name).unwrap();
let mut test_file = File::create(&test_file_name).unwrap();

writeln!(&mut test_file, "extern \"C\" {{").unwrap();
writeln!(&mut test_file, " fn {}();", function_name).unwrap();
Expand All @@ -27,8 +26,8 @@ fn check_func(function_name: &str) -> bool {
}

let output = Command::new("rustc").
arg(test_file_name).
arg("--out-dir").arg("target/build/").
arg(&test_file_name).
arg("--out-dir").arg(&out_dir).
arg("-l").arg("udev").
output().unwrap();

Expand Down

0 comments on commit 5efe989

Please sign in to comment.