Skip to content

Commit

Permalink
remove common submodule + refactoring + fmt rules + ci
Browse files Browse the repository at this point in the history
  • Loading branch information
awnion committed Jan 28, 2024
1 parent 2e4875d commit ecf4929
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 18 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
on: [push, pull_request]

name: Lint and Test

jobs:
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: clippy, rustfmt
- run: cargo fmt --all -- --check
- run: cargo clippy -- -D warnings

test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo test --all-features
4 changes: 0 additions & 4 deletions .gitmodules

This file was deleted.

24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
[package]
build = 'common/build/build.rs'
edition = '2021'
name = 'tvm_executor'
version = '1.16.99'
edition = "2021"
name = "tvm_executor"
rust-version = "1.75.0"
version = "2.0.0"

[dependencies]
failure = '0.1.6'
lazy_static = '1.4'
log = '0.4'
tvm_block = { git = 'https://github.com/tvmlabs/tvm-block.git', branch = "main" }
tvm_types = { git = 'https://github.com/tvmlabs/tvm-types.git', branch = "main" }
tvm_vm = { git = 'https://github.com/tvmlabs/tvm-vm.git', branch = "main" }
failure = "0.1.6"
lazy_static = "1.4"
log = "0.4"
tvm_block = { git = "https://github.com/tvmlabs/tvm-block", branch = "main" }
tvm_types = { git = "https://github.com/tvmlabs/tvm-types", branch = "main" }
tvm_vm = { git = "https://github.com/tvmlabs/tvm-vm", branch = "main" }

[features]
signature_with_id = [ 'tvm_block/signature_with_id', 'tvm_vm/signature_with_id' ]
signature_with_id = [ "tvm_block/signature_with_id", "tvm_vm/signature_with_id" ]

[[bench]]
harness = false
name = 'benchmarks'
name = "benchmarks"

[lib]
bench = false
Expand Down
24 changes: 24 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use std::process::Command;

fn get_value(cmd: &str, args: &[&str]) -> String {
if let Ok(result) = Command::new(cmd).args(args).output() {
if let Ok(result) = String::from_utf8(result.stdout) {
return result;
}
}
"Unknown".to_string()
}

fn main() {
let git_branch = get_value("git", &["rev-parse", "--abbrev-ref", "HEAD"]);
let git_commit = get_value("git", &["rev-parse", "HEAD"]);
let commit_date = get_value("git", &["log", "-1", "--date=iso", "--pretty=format:%cd"]);
let build_time = get_value("date", &["+%Y-%m-%d %T %z"]);
let rust_version = get_value("rustc", &["--version"]);

println!("cargo:rustc-env=BUILD_GIT_BRANCH={}", git_branch);
println!("cargo:rustc-env=BUILD_GIT_COMMIT={}", git_commit);
println!("cargo:rustc-env=BUILD_GIT_DATE={}", commit_date);
println!("cargo:rustc-env=BUILD_TIME={}", build_time);
println!("cargo:rustc-env=BUILD_RUST_VERSION={}", rust_version);
}
1 change: 0 additions & 1 deletion common
Submodule common deleted from 91a06e
26 changes: 26 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# I can't rely on contributors using .editorconfig
newline_style = "Unix"
# require the shorthand instead of it being optional
use_field_init_shorthand = true
# outdated default — `?` was unstable at the time
# additionally the `try!` macro is deprecated now
use_try_shorthand = true
# Max to use the 100 char width for everything or Default. See https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#use_small_heuristics
use_small_heuristics = "Max"


version = "Two"
unstable_features = true

# better grepping
imports_granularity = "Item"
group_imports = "StdExternalCrate"

normalize_comments = true
reorder_impl_items = true
reorder_modules = true
wrap_comments = true

format_code_in_doc_comments = true
format_macro_bodies = true
format_macro_matchers = true
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ pub use vmsetup::*;
pub mod blockchain_config;
pub use blockchain_config::*;

include!("../common/src/info.rs");
pub fn build_commit() -> Option<&'static str> {
std::option_env!("BUILD_GIT_COMMIT")
}

0 comments on commit ecf4929

Please sign in to comment.