Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(vdev): Rewrite compile-vrl-wasm.sh to vdev #16751

Merged
merged 8 commits into from
Mar 16, 2023
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ test-vrl: ## Run the VRL test suite

.PHONY: compile-vrl-wasm
compile-vrl-wasm: ## Compile VRL crates to WASM target
@scripts/compile-vrl-wasm.sh
cargo vdev meta compile-vrl-wasm

##@ Utility

Expand Down
32 changes: 0 additions & 32 deletions scripts/compile-vrl-wasm.sh

This file was deleted.

36 changes: 36 additions & 0 deletions vdev/src/commands/meta/compile_vrl_wasm.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use std::path::Path;
use anyhow::Result;
use clap::Args;

use crate::app;

/// Compiles VRL crates to wasm32-unknown-unknown
#[derive(Args, Debug)]
#[command()]
pub struct Cli {}

impl Cli {
pub fn exec(self) -> Result<()> {
let vrl_path = Path::new(app::path()).join("lib").join("vrl");
// Can't use cargo vdev build because it defaults to Error: command: "cargo" "build" "--no-default-features" "--release" "--features" "default" "--target" "wasm32-unknown-unknown"
// Notice the --features "default", some of the crates below don't have default specified
jonathanpv marked this conversation as resolved.
Show resolved Hide resolved
// Causing the error: none of the selected packages contains these features: default
let args = vec!["build", "--release", "--target", "wasm32-unknown-unknown"];
println!("Compiling lib/vrl/compiler to wasm32-unknown-unknown");
std::env::set_current_dir(vrl_path.join("compiler"))?;
app::exec("cargo", &args, false)?;
jonathanpv marked this conversation as resolved.
Show resolved Hide resolved

println!("Compiling lib/vrl/core to wasm32-unknown-unknown");
std::env::set_current_dir(vrl_path.join("core"))?;
app::exec("cargo", &args, false)?;

println!("Compiling lib/vrl/diagnostic to wasm32-unknown-unknown");
std::env::set_current_dir(vrl_path.join("diagnostic"))?;
app::exec("cargo", &args, false)?;

println!("Compiling lib/vrl/parser to wasm32-unknown-unknown");
std::env::set_current_dir(vrl_path.join("parser"))?;
app::exec("cargo", &args, false)?;
Ok(())
}
}
1 change: 1 addition & 0 deletions vdev/src/commands/meta/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
crate::cli_subcommands! {
"Collection of meta-utilities..."
mod compile_vrl_wasm,
jonathanpv marked this conversation as resolved.
Show resolved Hide resolved
mod starship,
mod install_git_hooks,
}