Compile polkadot-runtime both for Wasm ad native, allowing for testing and direct usage.

This commit is contained in:
Gav
2018-01-09 13:47:28 +01:00
parent 5ab59bb171
commit b104f5e6e4
68 changed files with 98 additions and 23 deletions
@@ -0,0 +1,30 @@
#![warn(missing_docs)]
#![cfg_attr(feature = "strict", deny(warnings))]
#![no_std]
#![crate_type = "rlib"]
#![feature(global_allocator)]
#![feature(alloc)]
#![feature(allocator_api)]
//! Custom allocator crate for wasm
extern crate alloc;
extern crate pwasm_libc;
use alloc::heap::{Alloc, Layout, AllocErr};
/// Wasm allocator
pub struct WasmAllocator;
unsafe impl<'a> Alloc for &'a WasmAllocator {
unsafe fn alloc(&mut self, layout: Layout) -> Result<*mut u8, AllocErr> {
Ok(pwasm_libc::malloc(layout.size()))
}
unsafe fn dealloc(&mut self, ptr: *mut u8, _layout: Layout) {
pwasm_libc::free(ptr)
}
}
#[global_allocator]
static ALLOCATOR: WasmAllocator = WasmAllocator;