Skip to content

Commit

Permalink
Fix make lint
Browse files Browse the repository at this point in the history
  • Loading branch information
fschutt committed Feb 2, 2023
1 parent 6a27607 commit e25f0a9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/cli/src/commands/create_exe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ impl PrefixMapCompilation {
return Ok(Self {
input_hashes: atoms
.iter()
.map(|(name, bytes)| (normalize_atom_name(&name), Self::hash_for_bytes(bytes)))
.map(|(name, bytes)| (normalize_atom_name(name), Self::hash_for_bytes(bytes)))
.collect(),
manual_prefixes: BTreeMap::new(),
compilation_objects: BTreeMap::new(),
Expand Down Expand Up @@ -562,11 +562,11 @@ impl PrefixMapCompilation {
[atom, prefix, path] => {
if only_validate_prefixes {
// only insert the prefix in order to not error out of the fs::read(path)
manual_prefixes.insert(normalize_atom_name(&atom), prefix.to_string());
manual_prefixes.insert(normalize_atom_name(atom), prefix.to_string());
} else {
let atom_hash = atoms
.iter()
.find_map(|(name, _)| if normalize_atom_name(&name) == normalize_atom_name(&atom) { Some(prefix.to_string()) } else { None })
.find_map(|(name, _)| if normalize_atom_name(name) == normalize_atom_name(atom) { Some(prefix.to_string()) } else { None })
.ok_or_else(|| anyhow::anyhow!("no atom {atom:?} found, for prefix {p:?}, available atoms are {available_atoms:?}"))?;

let current_dir = std::env::current_dir().unwrap().canonicalize().unwrap();
Expand All @@ -575,25 +575,25 @@ impl PrefixMapCompilation {
anyhow::anyhow!("could not read file for atom {atom:?} (prefix {p}, path {} in dir {}): {e}", path.display(), current_dir.display())
})?;

compilation_objects.insert(normalize_atom_name(&atom), bytes);
manual_prefixes.insert(normalize_atom_name(&atom), atom_hash.to_string());
compilation_objects.insert(normalize_atom_name(atom), bytes);
manual_prefixes.insert(normalize_atom_name(atom), atom_hash.to_string());
}
}
// atom + path, but default SHA256 prefix
[atom, path] => {
let atom_hash = atoms
.iter()
.find_map(|(name, bytes)| if normalize_atom_name(&name) == normalize_atom_name(&atom) { Some(Self::hash_for_bytes(bytes)) } else { None })
.find_map(|(name, bytes)| if normalize_atom_name(name) == normalize_atom_name(atom) { Some(Self::hash_for_bytes(bytes)) } else { None })
.ok_or_else(|| anyhow::anyhow!("no atom {atom:?} found, for prefix {p:?}, available atoms are {available_atoms:?}"))?;
manual_prefixes.insert(normalize_atom_name(&atom), atom_hash.to_string());
manual_prefixes.insert(normalize_atom_name(atom), atom_hash.to_string());

if !only_validate_prefixes {
let current_dir = std::env::current_dir().unwrap().canonicalize().unwrap();
let path = current_dir.join(path.replace("./", ""));
let bytes = std::fs::read(&path).map_err(|e| {
anyhow::anyhow!("could not read file for atom {atom:?} (prefix {p}, path {} in dir {}): {e}", path.display(), current_dir.display())
})?;
compilation_objects.insert(normalize_atom_name(&atom), bytes);
compilation_objects.insert(normalize_atom_name(atom), bytes);
}
}
// only prefix if atoms.len() == 1
Expand Down Expand Up @@ -737,7 +737,7 @@ fn compile_atoms(
let mut module_infos = BTreeMap::new();
for (a, data) in atoms {
let prefix = prefixes
.get_prefix_for_atom(&normalize_atom_name(&a))
.get_prefix_for_atom(&normalize_atom_name(a))
.ok_or_else(|| anyhow::anyhow!("no prefix given for atom {a}"))?;
let atom_name = utils::normalize_atom_name(a);
let output_object_path = output_dir.join(format!("{atom_name}.o"));
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/cli/tests/create_exe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ fn create_exe_works_multi_command_args_handling() -> anyhow::Result<()> {
}

/// Tests that create-exe works with underscores and dashes in command names
// Ignored because of -lunwind linker issue on Windows
// see https://github.com/wasmerio/wasmer/issues/3459
#[cfg_attr(target_os = "windows", ignore)]
#[test]
fn create_exe_works_underscore_module_name() -> anyhow::Result<()> {
Expand Down

0 comments on commit e25f0a9

Please sign in to comment.