Revert "build.rs recursively delves into directories during library bake stage, correct misnamed file at machine/mod.rs:455 (#617)"
This reverts commit c1b577f2c7.
This commit is contained in:
32
build.rs
32
build.rs
@@ -3,7 +3,7 @@ extern crate indexmap;
|
||||
use crate::indexmap::IndexSet;
|
||||
|
||||
use std::env;
|
||||
use std::fs::{File, copy, create_dir_all, read_dir};
|
||||
use std::fs::{File, copy, read_dir};
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
@@ -15,44 +15,30 @@ fn main()
|
||||
let mut libraries = File::create(&dest_path).unwrap();
|
||||
let mut library_index = IndexSet::new();
|
||||
|
||||
let mut paths: Vec<_> = read_dir("./src/lib").unwrap()
|
||||
.map(|e| e.unwrap().path()).collect();
|
||||
let paths = read_dir("./src/lib").unwrap();
|
||||
|
||||
while let Some(item) = paths.pop() {
|
||||
if item.is_file() {
|
||||
let file_name = item.strip_prefix(".").unwrap();
|
||||
for item in paths {
|
||||
let item = item.unwrap().path();
|
||||
|
||||
if let Some(file_name) = item.file_name() {
|
||||
if let Some(ext) = item.extension() {
|
||||
if ext == "pl" {
|
||||
let file_stem = item.file_stem().unwrap();
|
||||
let file_str = file_stem.to_string_lossy().to_uppercase();
|
||||
let dest = Path::new(&out_dir).join(file_name);
|
||||
let dir_name = dest.parent().unwrap();
|
||||
|
||||
if !dir_name.exists() {
|
||||
create_dir_all(dir_name).unwrap();
|
||||
}
|
||||
|
||||
match copy(&item, dest) {
|
||||
Ok(_) => {
|
||||
}
|
||||
Err(e) => {
|
||||
panic!("die: {:?}", e)
|
||||
}
|
||||
Ok(_) => {},
|
||||
Err(e) => panic!("die: {:?}", e)
|
||||
};
|
||||
|
||||
let include_line = format!("static {}: &str = include_str!({:?});\n",
|
||||
file_str, file_name); //file_stem.to_string_lossy());
|
||||
let include_line = format!("static {}: &str = include_str!(\"{}.pl\");\n",
|
||||
file_str, file_stem.to_string_lossy());
|
||||
|
||||
libraries.write_all(include_line.as_bytes()).unwrap();
|
||||
library_index.insert(file_stem.to_string_lossy().to_string());
|
||||
}
|
||||
}
|
||||
} else if item.is_dir() {
|
||||
for entry in read_dir(item).unwrap() {
|
||||
let path = entry.unwrap().path();
|
||||
paths.push(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user