Skip to content

Commit

Permalink
chore(vdev): Rewrite compile-vrl-wasm.sh to vdev (#16751)
Browse files Browse the repository at this point in the history
* chore(vdev): Rewrite compile-vrl-wasm.sh to vdev

* Move compile-vrl-wasm to the top level

* Remove comment that wasn't an issue to begin with

* Refactor compile_vrl_wasm.rs to utilize for-loop

* Use correct vdev command for compile-vrl-wasm in Makefile

* Use .clone() in compile_vrl_wasm.rs to avoid clippy formatting error

* move vrl-wasm to generate subcommand, modify Makefile to use cargo vdev generate

* remove clone in vrl_wasm.js
  • Loading branch information
jonathanpv authored Mar 16, 2023
1 parent afae677 commit be9e2c4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 33 deletions.
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(())
}
}

0 comments on commit be9e2c4

Please sign in to comment.