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 generate vrl-wasm

##@ Utility

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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ crate::cli_subcommands! {
component_docs,
manifests,
release_cue,
mod vrl_wasm,
}

crate::script_wrapper! {
Expand Down
24 changes: 24 additions & 0 deletions vdev/src/commands/generate/vrl_wasm.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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");
let args = &["build", "--release", "--target", "wasm32-unknown-unknown"];

for crate_name in ["compiler", "core", "diagnostic", "parser"] {
println!("Compiling lib/vrl/{crate_name} to wasm32-unknown-unknown");
std::env::set_current_dir(vrl_path.join(crate_name))?;
app::exec("cargo", *args, false)?;
}
Ok(())
}
}