Commit 9315cef3 authored by Hero Bird's avatar Hero Bird Committed by GitHub

Factor unstable feature usage out into ink_alloc crate (#100)

* [core] Factor nightly alloc parts out of core into new alloc ink crate

* Further cleanup after factoring out ink_alloc crate

* [alloc] Use symlinks instead of copies
parent fa906cad
[package]
name = "ink_alloc"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
license = "GPL-3.0"
readme = "README.md"
repository = "https://github.com/paritytech/ink"
documentation = "https://github.com/paritytech/ink/wiki"
homepage = "https://www.parity.io/"
description = "[ink!] Rust based eDSL for writing smart contracts for Substrate"
keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"]
categories = ["no-std", "embedded"]
include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"]
[dependencies]
wee_alloc = { version = "0.4", default-features = false }
[features]
default = []
std = []
../LICENSE
\ No newline at end of file
../README.md
\ No newline at end of file
......@@ -14,26 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with ink!. If not, see <http://www.gnu.org/licenses/>.
use core::{
alloc::Layout,
panic::PanicInfo,
};
#[panic_handler]
pub fn panic(_info: &PanicInfo) -> ! {
pub fn panic(_info: &core::panic::PanicInfo) -> ! {
unsafe { core::intrinsics::abort() }
}
#[alloc_error_handler]
pub extern "C" fn oom(_: Layout) -> ! {
unsafe {
core::intrinsics::abort();
}
pub extern "C" fn oom(_: core::alloc::Layout) -> ! {
unsafe { core::intrinsics::abort() }
}
/// This is only required in non wasm32-unknown-unknown targets.
///
/// Since ink_core is targeted for wasm32-unknown-unknown we should
/// maybe remove this.
#[lang = "eh_personality"]
extern "C" fn eh_personality() {}
// Copyright 2018-2019 Parity Technologies (UK) Ltd.
// This file is part of ink!.
//
// ink! is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ink! is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ink!. If not, see <http://www.gnu.org/licenses/>.
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(
not(feature = "std"),
feature(core_intrinsics, alloc_error_handler,)
)]
#[cfg(not(feature = "std"))]
extern crate alloc;
#[cfg(not(feature = "std"))]
mod handlers;
// Use `wee_alloc` as the global allocator.
#[cfg(not(feature = "std"))]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
......@@ -18,11 +18,14 @@ categories = ["no-std", "embedded"]
include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"]
[dependencies]
ink_alloc = { path = "../alloc/" }
ink_utils = { path = "../utils/" }
parity-codec = { version = "3.2", default-features = false, features = ["derive", "full"] }
wee_alloc = { version = "0.4", default-features = false }
[features]
default = []
test-env = ["std"]
std = []
std = [
"ink_alloc/std",
"ink_utils/std",
]
......@@ -15,10 +15,6 @@
// along with ink!. If not, see <http://www.gnu.org/licenses/>.
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(
not(feature = "std"),
feature(core_intrinsics, lang_items, alloc_error_handler,)
)]
#![deny(
bad_style,
const_err,
......@@ -40,6 +36,7 @@
unused_comparisons,
unused_parens,
while_true,
// missing-copy-implementations,
// missing_docs,
trivial_casts,
trivial_numeric_casts,
......@@ -47,23 +44,14 @@
// unused_import_braces,
// unused_qualifications,
// unused_results,
// missing-copy-implementations
)]
#[cfg(not(feature = "std"))]
extern crate alloc;
// Use `wee_alloc` as the global allocator.
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
#[cfg(all(test, feature = "std"))]
#[macro_use]
mod test_utils;
#[cfg(not(feature = "std"))]
mod panic_handler;
mod byte_utils;
pub mod env;
pub mod memory;
......
......@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with ink!. If not, see <http://www.gnu.org/licenses/>.
//! The minimal test framework for the pdsl core libraries.
//! The minimal test framework for the ink! core libraries.
/// The set-up procedure of the entire crate under test.
fn setup() {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment