From 4f81bbc5064a7d159ab1238a24d62fb8a6bff491 Mon Sep 17 00:00:00 2001 From: holygits Date: Thu, 24 Jan 2019 10:18:18 +1300 Subject: [PATCH] Don't pack Substrate ctor module --- src/build.rs | 20 ++++++++++++-------- src/pack.rs | 4 ---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/build.rs b/src/build.rs index 267183d..7c89139 100644 --- a/src/build.rs +++ b/src/build.rs @@ -102,17 +102,21 @@ pub fn build( )?; } - if has_ctor(&ctor_module, target_runtime) { - if !skip_optimization { - optimize(&mut ctor_module, vec![target_runtime.symbols().create])?; - } - let ctor_module = pack_instance( + if !has_ctor(&ctor_module, target_runtime) { + return Ok((module, None)) + } + + if !skip_optimization { + optimize(&mut ctor_module, vec![target_runtime.symbols().create])?; + } + + if let TargetRuntime::PWasm(_) = target_runtime { + ctor_module = pack_instance( parity_wasm::serialize(module.clone()).map_err(Error::Encoding)?, ctor_module.clone(), target_runtime, )?; - Ok((module, Some(ctor_module))) - } else { - Ok((module, None)) } + + Ok((module, Some(ctor_module))) } diff --git a/src/pack.rs b/src/pack.rs index f318925..b2d6c03 100644 --- a/src/pack.rs +++ b/src/pack.rs @@ -195,10 +195,6 @@ pub fn pack_instance(raw_module: Vec, mut ctor_module: elements::Module, tar ])).build() .build() .build(); - - if let TargetRuntime::Substrate(_) = target { - return Ok(new_module) - } for section in new_module.sections_mut() { if let &mut Section::Export(ref mut export_section) = section {