Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: drop unnecessary build code copying stdlib #974

Merged
merged 1 commit into from
Mar 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 1 addition & 51 deletions crates/nargo/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use rustc_version::{version, Version};
use std::fs;
use std::path::{Path, PathBuf};
use std::path::Path;

/// Expects that the given directory is an existing path
fn rerun_if_stdlib_changes(directory: &Path) {
Expand All @@ -23,53 +22,6 @@ fn check_rustc_version() {
);
}

pub fn copy<U: AsRef<Path>, V: AsRef<Path>>(from: U, to: V) -> Result<(), std::io::Error> {
let mut stack = vec![PathBuf::from(from.as_ref())];

let output_root = PathBuf::from(to.as_ref());
let input_root = PathBuf::from(from.as_ref()).components().count();

while let Some(working_path) = stack.pop() {
println!("process: {:?}", &working_path);

// Generate a relative path
let src: PathBuf = working_path.components().skip(input_root).collect();

// Create a destination if missing
let dest = if src.components().count() == 0 {
output_root.clone()
} else {
output_root.join(&src)
};
if fs::metadata(&dest).is_err() {
println!(" mkdir: {dest:?}");
fs::create_dir_all(&dest)?;
}

for entry in fs::read_dir(working_path)? {
let entry = entry?;
let path = entry.path();

if path.is_dir() {
stack.push(path);
} else {
match path.file_name() {
Some(filename) => {
let dest_path = dest.join(filename);
println!(" copy: {:?} -> {:?}", &path, &dest_path);
fs::copy(&path, &dest_path)?;
}
None => {
println!("failed: {path:?}");
}
}
}
}
}

Ok(())
}

fn main() {
check_rustc_version();

Expand All @@ -79,6 +31,4 @@ fn main() {

let stdlib_src_dir = Path::new("../../noir_stdlib/");
rerun_if_stdlib_changes(stdlib_src_dir);
let target = dirs::config_dir().unwrap().join("noir-lang").join("std");
copy(stdlib_src_dir, target).unwrap();
}