diff --git a/Makefile b/Makefile index 9ce16646cb6a8..beb2defdb8276 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/scripts/compile-vrl-wasm.sh b/scripts/compile-vrl-wasm.sh deleted file mode 100755 index 6ef300ababf60..0000000000000 --- a/scripts/compile-vrl-wasm.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -set -euo pipefail - -# wasm-compile-vrl.sh -# -# SUMMARY -# -# Compiles relevant crates to wasm32-unknown-unknown - -( - cd "$(dirname "${BASH_SOURCE[0]}")/../lib/vrl/compiler" - echo "Compiling lib/vrl/compiler to wasm32-unknown-unknown" - cargo build --release --target wasm32-unknown-unknown -) - -( - cd "$(dirname "${BASH_SOURCE[0]}")/../lib/vrl/core" - echo "Compiling lib/vrl/core to wasm32-unknown-unknown" - cargo build --release --target wasm32-unknown-unknown -) - -( - cd "$(dirname "${BASH_SOURCE[0]}")/../lib/vrl/diagnostic" - echo "Compiling lib/vrl/diagnostic to wasm32-unknown-unknown" - cargo build --release --target wasm32-unknown-unknown -) - -( - cd "$(dirname "${BASH_SOURCE[0]}")/../lib/vrl/parser" - echo "Compiling lib/vrl/parser to wasm32-unknown-unknown" - cargo build --release --target wasm32-unknown-unknown -) diff --git a/vdev/src/commands/generate.rs b/vdev/src/commands/generate/mod.rs similarity index 96% rename from vdev/src/commands/generate.rs rename to vdev/src/commands/generate/mod.rs index 770ab4896c433..14f6a626dd373 100644 --- a/vdev/src/commands/generate.rs +++ b/vdev/src/commands/generate/mod.rs @@ -3,6 +3,7 @@ crate::cli_subcommands! { component_docs, manifests, release_cue, + mod vrl_wasm, } crate::script_wrapper! { diff --git a/vdev/src/commands/generate/vrl_wasm.rs b/vdev/src/commands/generate/vrl_wasm.rs new file mode 100644 index 0000000000000..92975b7acd6a9 --- /dev/null +++ b/vdev/src/commands/generate/vrl_wasm.rs @@ -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(()) + } +}