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

feat(compile): Noir std lib embedded #973

Merged
merged 4 commits into from
Mar 10, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
chore: better str handling for readability
Koby committed Mar 10, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit e2be7a38e19d5095832e41623fdd8cae1e3f3492
8 changes: 4 additions & 4 deletions crates/wasm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -36,11 +36,11 @@ const BUILD_INFO: BuildInfo = BuildInfo {
dirty: env!("GIT_DIRTY"),
};

pub fn add_noir_lib(driver: &mut Driver, crate_name: String) {
pub fn add_noir_lib(driver: &mut Driver, crate_name: &str) {
let path_to_lib = PathBuf::from(&crate_name).join("lib.nr");
let library_crate = driver.create_non_local_crate(path_to_lib, CrateType::Library);

driver.propagate_dep(library_crate, &CrateName::new(crate_name.as_str()).unwrap());
driver.propagate_dep(library_crate, &CrateName::new(crate_name).unwrap());
}

#[wasm_bindgen]
@@ -55,10 +55,10 @@ pub fn compile(args: JsValue) -> JsValue {
driver.create_local_crate(path, CrateType::Binary);

// We are always adding std lib implicitly. It comes bundled with binary.
add_noir_lib(&mut driver, (&"std").to_string());
add_noir_lib(&mut driver, "std");

for dependency in options.optional_dependencies_set {
add_noir_lib(&mut driver, dependency);
add_noir_lib(&mut driver, dependency.as_str());
}

driver.check_crate(&options.compile_options).unwrap_or_else(|_| panic!("Crate check failed"));