build: add Clarity workspace member (#2744)

* build: add libvm workspace member

* chore: skip lib-clarity-vm in circleci

* refactor: address pavi's comment

* refactor: naming

* fix: update lib name

* refactor: rename, drop the lib suffix

* refactor: address Greg's comments

* style: rustfmt

Co-authored-by: Aaron Blankstein <aaron@blockstack.com>
This commit is contained in:
Reed Rosenbluth
2021-08-19 13:10:36 -07:00
committed by GitHub
parent f0dcf9c79d
commit e1f6efe1c5
5 changed files with 258 additions and 2 deletions

44
Cargo.lock generated
View File

@@ -1,5 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "addr2line"
version = "0.13.0"
@@ -355,6 +357,42 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "clarity"
version = "0.0.1"
dependencies = [
"assert-json-diff",
"chrono",
"curve25519-dalek",
"ed25519-dalek",
"integer-sqrt",
"lazy_static",
"libc",
"mio",
"percent-encoding",
"prometheus",
"rand 0.7.2",
"rand_chacha 0.2.2",
"regex",
"ripemd160",
"rusqlite",
"secp256k1",
"serde",
"serde_derive",
"serde_json",
"serde_stacker",
"sha2 0.8.2",
"sha2-asm",
"sha3",
"slog",
"slog-json",
"slog-term",
"stx-genesis",
"time 0.2.23",
"tini",
"url",
]
[[package]]
name = "clear_on_drop"
version = "0.2.4"
@@ -2445,6 +2483,12 @@ dependencies = [
"syn",
]
[[package]]
name = "tini"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11eeaa68267376df2aacbaaed9b0092544ebbc897cd59f61e81a1105fbaf102e"
[[package]]
name = "tinyvec"
version = "0.3.3"

View File

@@ -110,7 +110,8 @@ sha2-asm = "0.5.3"
[workspace]
members = [
".",
".",
"clarity",
"stx-genesis",
"testnet/stacks-node",
"testnet/puppet-chain"]

View File

@@ -48,7 +48,7 @@ jobs:
- run:
no_output_timeout: 200m
command: |
cargo test -j 1 --workspace
cargo test -j 1 --workspace --exclude clarity
all_tests:
docker:
- image: rust:1.40-stretch

86
clarity/Cargo.toml Normal file
View File

@@ -0,0 +1,86 @@
[package]
name = "clarity"
version = "0.0.1"
authors = [ "Jude Nelson <jude@stacks.org>",
"Aaron Blankstein <aaron@blockstack.com>",
"Ludo Galabru <ludovic@blockstack.com>" ]
license = "GPLv3"
homepage = "https://github.com/blockstack/stacks-blockchain"
repository = "https://github.com/blockstack/stacks-blockchain"
description = "Reference implementation of the Stacks 2.0 Blockchain"
keywords = [ "stacks", "stx", "bitcoin", "crypto", "blockstack", "decentralized", "dapps", "blockchain" ]
readme = "README.md"
[profile.release]
debug = true
[lib]
name = "clarity"
path = "../src/libclarity.rs"
[dependencies]
tini = "0.2"
rand = "=0.7.2"
rand_chacha = "=0.2.2"
serde = "1"
serde_derive = "1"
serde_stacker = "0.1"
sha3 = "0.8.2"
ripemd160 = "0.8.0"
regex = "1"
mio = "0.6"
lazy_static = "1.4.0"
url = "2.1.0"
percent-encoding = "2.1.0"
sha2 = "0.8.0"
prometheus = { version = "0.9", optional = true }
integer-sqrt = "0.1.3"
slog = { version = "2.5.2", features = [ "max_level_trace" ] }
slog-term = "2.6.0"
slog-json = { version = "2.3.0", optional = true }
chrono = "0.4.19"
libc = "0.2.82"
[dependencies.serde_json]
version = "1.0"
features = ["arbitrary_precision", "unbounded_depth"]
[dependencies.secp256k1]
version = "0.19.0"
features = ["serde", "recovery"]
[dependencies.rusqlite]
version = "=0.24.2"
features = ["blob", "serde_json", "i128_blob", "bundled", "trace"]
[dependencies.ed25519-dalek]
version = "=1.0.0-pre.3"
features = ["serde"]
[dependencies.curve25519-dalek]
version = "=2.0.0"
features = ["serde"]
[dependencies.time]
version = "0.2.23"
features = ["std"]
[dev-dependencies]
assert-json-diff = "1.0.0"
# a nightly rustc regression (35dbef235 2021-03-02) prevents criterion from compiling
# but it isn't necessary for tests: only benchmarks. therefore, commenting out for now.
# criterion = "0.3"
stx_genesis = { package = "stx-genesis", path = "../stx-genesis/."}
[features]
default = ["developer-mode"]
developer-mode = []
monitoring_prom = ["prometheus"]
slog_json = ["slog-json"]
[profile.dev.package.regex]
opt-level = 2
[target.'cfg(all(target_arch = "x86_64", not(target_env = "msvc")))'.dependencies]
sha2-asm = "0.5.3"

125
src/libclarity.rs Normal file
View File

@@ -0,0 +1,125 @@
// Copyright (C) 2013-2020 Blockstack PBC, a public benefit corporation
// Copyright (C) 2020 Stacks Open Internet Foundation
//
// This program 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.
//
// This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
#![allow(unused_imports)]
#![allow(dead_code)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![cfg_attr(test, allow(unused_variables, unused_assignments))]
extern crate curve25519_dalek;
extern crate ed25519_dalek;
extern crate rand;
extern crate rand_chacha;
extern crate rusqlite;
extern crate secp256k1;
extern crate serde;
extern crate tini;
#[macro_use]
extern crate lazy_static;
extern crate integer_sqrt;
extern crate mio;
extern crate percent_encoding;
extern crate regex;
extern crate ripemd160;
extern crate sha2;
extern crate sha3;
extern crate time;
extern crate url;
#[macro_use(o, slog_log, slog_trace, slog_debug, slog_info, slog_warn, slog_error)]
extern crate slog;
extern crate chrono;
#[cfg(feature = "slog_json")]
extern crate slog_json;
extern crate slog_term;
#[cfg(unix)]
extern crate libc;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate serde_json;
#[cfg(test)]
#[macro_use]
extern crate assert_json_diff;
#[cfg(feature = "monitoring_prom")]
#[macro_use]
pub extern crate prometheus;
#[macro_use]
pub mod codec;
#[macro_use]
pub mod util;
#[macro_use]
pub mod net;
#[macro_use]
/// The Clarity virtual machine
pub mod vm;
#[macro_use]
pub mod chainstate;
#[cfg(test)]
extern crate stx_genesis;
pub mod address;
pub mod burnchains;
/// A high level library for interacting with the Clarity vm
pub mod clarity_vm;
pub mod core;
pub mod deps;
pub mod clarity;
pub mod monitoring;
pub mod types;
// set via _compile-time_ envars
const GIT_BRANCH: Option<&'static str> = option_env!("GIT_BRANCH");
const GIT_COMMIT: Option<&'static str> = option_env!("GIT_COMMIT");
const GIT_TREE_CLEAN: Option<&'static str> = option_env!("GIT_TREE_CLEAN");
#[cfg(debug_assertions)]
const BUILD_TYPE: &'static str = "debug";
#[cfg(not(debug_assertions))]
const BUILD_TYPE: &'static str = "release";
pub fn version_string(pkg_name: &str, pkg_version: &str) -> String {
let git_branch = GIT_BRANCH.unwrap_or("");
let git_commit = GIT_COMMIT.unwrap_or("");
let git_tree_clean = GIT_TREE_CLEAN.unwrap_or("");
format!(
"{} {} ({}:{}{}, {} build, {} [{}])",
pkg_name,
pkg_version,
&git_branch,
git_commit,
git_tree_clean,
BUILD_TYPE,
std::env::consts::OS,
std::env::consts::ARCH
)
}