Skip to content

Commit

Permalink
chore: adds build tools check in magefile. (envoyproxy#21)
Browse files Browse the repository at this point in the history
This PR makes sure you have the right build tools before attempting to
build.

Co-authored-by: Anuraag Agrawal <anuraaga@gmail.com>
  • Loading branch information
jcchavezs and anuraaga committed Sep 7, 2022
1 parent 02f30a6 commit ffa3e1f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,23 @@ func Check() {
mg.SerialDeps(Lint, Test)
}

func CheckBuildTools() error {
if err := sh.Run("tinygo", "version"); err != nil {
return errors.New("missing build tool tinygo (https://tinygo.org/getting-started/install/)")
}

wabtTools := []string{"wasm2wat", "wasm-opt", "wasm2wat"}
for _, t := range wabtTools {
if err := sh.Run(t, "--version"); err != nil {
return fmt.Errorf("missing build tool %q, we recommend you to install wabt (https://github.com/WebAssembly/wabt)", t)
}
}
return nil
}

// Build builds the Coraza wasm plugin.
func Build() error {
mg.Deps(CheckBuildTools)
if err := os.MkdirAll("build", 0755); err != nil {
return err
}
Expand Down

0 comments on commit ffa3e1f

Please sign in to comment.