Skip to content

Commit

Permalink
add nix target to compiler-wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
PgBiel committed Sep 30, 2024
1 parent b629710 commit 0672ee0
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion compiler-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ pub fn compile_package(project_id: usize, target: &str) -> Result<(), String> {
let target = match target.to_lowercase().as_str() {
"erl" | "erlang" => Target::Erlang,
"js" | "javascript" => Target::JavaScript,
"nix" => Target::Nix,
_ => {
let msg = format!("Unknown target `{target}`, expected `erlang` or `javascript`");
let msg = format!("Unknown target `{target}`, expected `erlang`, `javascript` or `nix`");
return Err(msg);
}
};
Expand Down Expand Up @@ -150,6 +151,17 @@ pub fn read_compiled_erlang(project_id: usize, module_name: &str) -> Option<Stri
fs.read(&Utf8PathBuf::from(path)).ok()
}

/// Get the compiled Nix output for a given module.
///
/// You need to call `compile_package` before calling this function.
///
#[wasm_bindgen]
pub fn read_compiled_nix(project_id: usize, module_name: &str) -> Option<String> {
let fs = get_filesystem(project_id);
let path = format!("/build/{}.nix", module_name);
fs.read(&Utf8PathBuf::from(path)).ok()
}

/// Clear any stored warnings. This is performed automatically when before compilation.
///
#[wasm_bindgen]
Expand Down

0 comments on commit 0672ee0

Please sign in to comment.