Skip to content

Commit

Permalink
need infra sync
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarTawfik committed Nov 25, 2024
1 parent 7b9b478 commit b47940f
Show file tree
Hide file tree
Showing 35 changed files with 283 additions and 290 deletions.
48 changes: 19 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ members = [
"crates/codegen/runtime/cargo/wasm",
"crates/codegen/runtime/generator",
"crates/codegen/runtime/npm/package",
"crates/codegen/runtime/sync",
"crates/codegen/spec",
"crates/codegen/testing",

Expand All @@ -33,8 +34,9 @@ members = [
"crates/solidity/outputs/cargo/wasm",
"crates/solidity/outputs/npm/package",
"crates/solidity/outputs/spec",
"crates/solidity/sync",
"crates/solidity/testing/perf",
"crates/solidity/testing/sanctuary",
"crates/solidity/testing/sanctuary",
"crates/solidity/testing/snapshots",
"crates/solidity/testing/solc",

Expand All @@ -43,6 +45,7 @@ members = [
"crates/testlang/outputs/cargo/tests",
"crates/testlang/outputs/cargo/wasm",
"crates/testlang/outputs/npm/package",
"crates/testlang/sync",
]

[workspace.dependencies]
Expand All @@ -58,6 +61,7 @@ codegen_runtime_cargo_crate = { path = "crates/codegen/runtime/cargo/crate", ver
codegen_runtime_cargo_wasm = { path = "crates/codegen/runtime/cargo/wasm", version = "0.18.3" }
codegen_runtime_generator = { path = "crates/codegen/runtime/generator", version = "0.18.3" }
codegen_runtime_npm_package = { path = "crates/codegen/runtime/npm/package", version = "0.18.3" }
codegen_runtime_sync = { path = "crates/codegen/runtime/sync", version = "0.18.3" }
codegen_spec = { path = "crates/codegen/spec", version = "0.18.3" }
codegen_testing = { path = "crates/codegen/testing", version = "0.18.3" }

Expand All @@ -75,6 +79,7 @@ solidity_cargo_wasm = { path = "crates/solidity/outputs/cargo/wasm", version = "
solidity_language = { path = "crates/solidity/inputs/language", version = "0.18.3" }
solidity_npm_package = { path = "crates/solidity/outputs/npm/package", version = "0.18.3" }
solidity_spec = { path = "crates/solidity/outputs/spec", version = "0.18.3" }
solidity_sync = { path = "crates/solidity/sync", version = "0.18.3" }
solidity_testing_perf = { path = "crates/solidity/testing/perf", version = "0.18.3" }
solidity_testing_sanctuary = { path = "crates/solidity/testing/sanctuary", version = "0.18.3" }
solidity_testing_snapshots = { path = "crates/solidity/testing/snapshots", version = "0.18.3" }
Expand All @@ -85,6 +90,7 @@ testlang_cargo_tests = { path = "crates/testlang/outputs/cargo/tests", version =
testlang_cargo_wasm = { path = "crates/testlang/outputs/cargo/wasm", version = "0.18.3" }
testlang_language = { path = "crates/testlang/inputs/language", version = "0.18.3" }
testlang_npm_package = { path = "crates/testlang/outputs/npm/package", version = "0.18.3" }
testlang_sync = { path = "crates/testlang/sync", version = "0.18.3" }

#
# External
Expand Down
5 changes: 0 additions & 5 deletions crates/codegen/runtime/cargo/crate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ __experimental_bindings_api = ["dep:metaslang_bindings"]
__private_ariadne_errors = ["dep:ariadne"]
__private_testing_utils = []

[build-dependencies]
anyhow = { workspace = true }
infra_utils = { workspace = true }
codegen_runtime_generator = { workspace = true }

[dependencies]
ariadne = { workspace = true, optional = true }
metaslang_bindings = { workspace = true, optional = true }
Expand Down
9 changes: 0 additions & 9 deletions crates/codegen/runtime/cargo/crate/build.rs

This file was deleted.

5 changes: 0 additions & 5 deletions crates/codegen/runtime/cargo/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ publish = false
[lib]
crate-type = ["cdylib"]

[build-dependencies]
anyhow = { workspace = true }
codegen_runtime_generator = { workspace = true }
infra_utils = { workspace = true }

[dependencies]
codegen_runtime_cargo_crate = { workspace = true }
paste = { workspace = true }
Expand Down
9 changes: 0 additions & 9 deletions crates/codegen/runtime/cargo/wasm/build.rs

This file was deleted.

5 changes: 0 additions & 5 deletions crates/codegen/runtime/npm/package/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,5 @@ publish = false

description = "TypeScript runtime copied over by codegen"

[build-dependencies]
anyhow = { workspace = true }
infra_utils = { workspace = true }
codegen_runtime_generator = { workspace = true }

[lints]
workspace = true
9 changes: 0 additions & 9 deletions crates/codegen/runtime/npm/package/build.rs

This file was deleted.

15 changes: 15 additions & 0 deletions crates/codegen/runtime/sync/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "codegen_runtime_sync"
version.workspace = true
rust-version.workspace = true
edition.workspace = true
publish = false

[build-dependencies]
anyhow = { workspace = true }
codegen_runtime_generator = { workspace = true }
infra_utils = { workspace = true }
rayon = { workspace = true }

[lints]
workspace = true
22 changes: 22 additions & 0 deletions crates/codegen/runtime/sync/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use anyhow::Result;
use codegen_runtime_generator::RuntimeGenerator;
use infra_utils::cargo::CargoWorkspace;
use rayon::iter::{IntoParallelIterator, ParallelIterator};

fn main() {
[
|| generate_stubs("codegen_runtime_cargo_crate"),
|| generate_stubs("codegen_runtime_cargo_wasm"),
|| generate_stubs("codegen_runtime_npm_package"),
]
.into_par_iter()
.for_each(|callback| callback().unwrap());
}

fn generate_stubs(crate_name: &str) -> Result<()> {
let source_dir = CargoWorkspace::locate_source_crate(crate_name)?;

RuntimeGenerator::generate_stubs(&source_dir)?;

Ok(())
}
1 change: 1 addition & 0 deletions crates/codegen/runtime/sync/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//! Used to synchronize any generated source files for this runtime.
33 changes: 12 additions & 21 deletions crates/infra/cli/src/commands/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use infra_utils::terminal::Terminal;
use rayon::iter::{ParallelBridge, ParallelIterator};
use strum::IntoEnumIterator;

use crate::toolchains::mkdocs::Mkdocs;
use crate::toolchains::wasm::WasmPackage;
use crate::utils::{ClapExtensions, OrderedCommand};

Expand All @@ -24,50 +23,46 @@ impl CheckController {

#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, ValueEnum)]
enum CheckCommand {
/// Runs the build steps to (re-)generate any runtime source files.
Sync,
/// Run 'cargo check' for all crates, features, and targets.
Cargo,
/// Run `cargo doc` to generate Rustdoc documentation and check for any broken links.
Rustdoc,
/// Check NPM packages for any outdated codegen steps.
Npm,
/// Check mkdocs documentation for any build issues or broken links.
Mkdocs,
}

impl OrderedCommand for CheckCommand {
fn execute(&self) -> Result<()> {
Terminal::step(format!("check {name}", name = self.clap_name()));

match self {
CheckCommand::Sync => check_sync(),
CheckCommand::Cargo => check_cargo(),
CheckCommand::Rustdoc => check_rustdoc(),
CheckCommand::Npm => check_npm(),
CheckCommand::Mkdocs => check_mkdocs(),
};

Ok(())
}
}

fn check_cargo() {
// 'cargo clippy' will run both 'cargo check', and 'clippy' lints:
fn check_sync() {
Command::new("cargo")
.arg("clippy")
.flag("--workspace")
.flag("--all-features")
.flag("--all-targets")
.flag("--no-deps")
.arg("check")
.property("--package", "codegen_runtime_sync")
.property("--package", "solidity_sync")
.property("--package", "testlang_sync")
.add_build_rustflags()
.run();
}

fn check_rustdoc() {
fn check_cargo() {
// 'cargo clippy' will run both 'cargo check', and 'clippy' lints:
Command::new("cargo")
.arg("doc")
.arg("clippy")
.flag("--workspace")
.flag("--all-features")
.flag("--all-targets")
.flag("--no-deps")
.flag("--document-private-items")
.add_build_rustflags()
.run();
}
Expand All @@ -77,7 +72,3 @@ fn check_npm() {
.par_bridge()
.for_each(|package| package.build().unwrap());
}

fn check_mkdocs() {
Mkdocs::check();
}
Loading

0 comments on commit b47940f

Please sign in to comment.