From ffa3e1fb17f008d9239035dc09b2916761206bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Carlos=20Ch=C3=A1vez?= Date: Wed, 7 Sep 2022 07:56:12 +0200 Subject: [PATCH] chore: adds build tools check in magefile. (#21) This PR makes sure you have the right build tools before attempting to build. Co-authored-by: Anuraag Agrawal --- magefile.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/magefile.go b/magefile.go index 1c79c8d0c8cb8..da5088e33dc64 100644 --- a/magefile.go +++ b/magefile.go @@ -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 }