sccommunity / crates-sgx

crates-sgx is a monorepo of all Rust crates ported for Teaclave SGX SDK targeting Intel SGX.
https://sccommunity.github.io/crates-sgx
Apache License 2.0
12 stars 2 forks source link

add color_quant #21

Closed sammyne closed 4 years ago

sammyne commented 4 years ago

Add Crates

Description

Add color_quant@master

Crate Meta

NOTICES

The original project failed to compile when upgrading to rust 2018, so this commit consists of two commits

  1. format and fix syntax errors for upgrading
  2. port to teaclave-sgx-sdk

Hence, the Diff of Changes reported below is the difference of 2 from 1.

Diff of Changes

diff --git a/crates/color_quant/Cargo.toml b/crates/color_quant/Cargo.toml
index d1e95ab..13502e6 100644
--- a/crates/color_quant/Cargo.toml
+++ b/crates/color_quant/Cargo.toml
@@ -6,4 +6,13 @@ authors = ["nwin <nwin@users.noreply.github.com>"]
 readme = "README.md"
 description = "Color quantization library to reduce n colors to 256 colors."
 repository = "https://github.com/PistonDevelopers/color_quant.git"
-edition = "2018"
\ No newline at end of file
+edition = "2018"
+
+[features]
+default = ["mesalock_sgx"]
+mesalock_sgx = ["sgx_tstd"]
+enclave_unit_test = ["sgx_tunittest"]
+
+[dependencies]
+sgx_tstd        = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk.git", tag = "v1.1.1", optional = true }
+sgx_tunittest   = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk.git", tag = "v1.1.1", optional = true }
diff --git a/crates/color_quant/src/lib.rs b/crates/color_quant/src/lib.rs
index fbc6b4b..593c2bc 100644
--- a/crates/color_quant/src/lib.rs
+++ b/crates/color_quant/src/lib.rs
@@ -60,6 +60,17 @@ that this copyright notice remain intact.
 //! let color_map = nq.color_map_rgba();
 //! ```
 //!
+
+#![cfg_attr(all(feature = "mesalock_sgx", not(target_env = "sgx")), no_std)]
+#![cfg_attr(
+    all(target_env = "sgx", target_vendor = "mesalock"),
+    feature(rustc_private)
+)]
+#[cfg(all(feature = "mesalock_sgx", not(target_env = "sgx")))]
+#[macro_use]
+extern crate sgx_tstd as std;
+use std::prelude::v1::*;
+
 use std::cmp::{max, min};

 macro_rules! clamp(