mirror of
https://github.com/fluencelabs/wasm-utils
synced 2025-03-15 11:10:49 +00:00
Preserve deploy symbol on optimize for substrate target
This commit is contained in:
parent
59384e09d0
commit
ec206fca64
11
src/build.rs
11
src/build.rs
@ -96,10 +96,7 @@ pub fn build(
|
||||
let mut public_api_entries = public_api_entries.to_vec();
|
||||
public_api_entries.push(target_runtime.symbols().call);
|
||||
if !skip_optimization {
|
||||
optimize(
|
||||
&mut module,
|
||||
public_api_entries,
|
||||
)?;
|
||||
optimize(&mut module, public_api_entries)?;
|
||||
}
|
||||
|
||||
if !has_ctor(&ctor_module, target_runtime) {
|
||||
@ -107,7 +104,11 @@ pub fn build(
|
||||
}
|
||||
|
||||
if !skip_optimization {
|
||||
optimize(&mut ctor_module, vec![target_runtime.symbols().create])?;
|
||||
let preserved_exports = match target_runtime {
|
||||
TargetRuntime::PWasm(_) => vec![target_runtime.symbols().call],
|
||||
TargetRuntime::Substrate(_) => vec![target_runtime.symbols().call, target_runtime.symbols().create],
|
||||
};
|
||||
optimize(&mut ctor_module, preserved_exports)?;
|
||||
}
|
||||
|
||||
if let TargetRuntime::PWasm(_) = target_runtime {
|
||||
|
@ -41,7 +41,7 @@ impl fmt::Display for Error {
|
||||
}
|
||||
}
|
||||
|
||||
/// If module has an exported function matching "create" symbol we want to pack it into "constructor".
|
||||
/// If a pwasm module has an exported function matching "create" symbol we want to pack it into "constructor".
|
||||
/// `raw_module` is the actual contract code
|
||||
/// `ctor_module` is the constructor which should return `raw_module`
|
||||
pub fn pack_instance(raw_module: Vec<u8>, mut ctor_module: elements::Module, target: &TargetRuntime) -> Result<elements::Module, Error> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user