fix export section not written when needed

This commit is contained in:
2021-11-16 07:52:06 +01:00
parent 812847d9e5
commit 14810b7fc8
3 changed files with 15 additions and 9 deletions

6
default.nix Normal file
View File

@@ -0,0 +1,6 @@
with import <nixpkgs> {};
stdenv.mkDerivation {
name = "dev-environment"; # Probably put a more meaningful name here
buildInputs = [ pkg-config libxkbcommon ];
}

View File

@@ -44,6 +44,7 @@ fn print_help() {
println!( println!(
"Usage: "Usage:
uw8-tool make-base <version> uw8-tool make-base <version>
uw8-tool pack <wasm file> <uw8 file>" uw8-tool pack <wasm file> <uw8 file>
uw8-tool unpack <uw8 file> <wasm file>"
); );
} }

View File

@@ -370,21 +370,20 @@ impl<'a> ParsedModule<'a> {
} }
{ {
let mut base_exports = base.exports.clone(); let base_exports = base.exports.clone();
base_exports.sort();
let mut my_exports: Vec<(String, u32)> = self let my_exports: Vec<(String, u32)> = self
.exports .exports
.data .data
.iter() .iter()
.map(|(name, func)| (name.clone(), *function_map.get(func).unwrap())) .map(|(name, func)| (name.clone(), *function_map.get(func).unwrap()))
.collect(); .collect();
my_exports.sort();
if base_exports if base_exports.len() != my_exports.len()
.iter() || base_exports
.zip(my_exports.iter()) .iter()
.any(|((n1, t1), (n2, t2))| n1 != n2 && t1 != t2) .zip(my_exports.iter())
.any(|((n1, t1), (n2, t2))| n1 != n2 || t1 != t2)
{ {
let mut export_section = enc::ExportSection::new(); let mut export_section = enc::ExportSection::new();
for (name, fnc) in my_exports { for (name, fnc) in my_exports {