summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-ffmpreg/internal/wasm.go
blob: 94fdfbdde1e37556d5b3702ff77028c442a81c2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package internal

import (
	"os"

	"github.com/tetratelabs/wazero"
)

func init() {
	var err error

	if dir := os.Getenv("WAZERO_COMPILATION_CACHE"); dir != "" {
		// Use on-filesystem compilation cache given by env.
		Cache, err = wazero.NewCompilationCacheWithDir(dir)
		if err != nil {
			panic(err)
		}
	} else {
		// Use in-memory compilation cache.
		Cache = wazero.NewCompilationCache()
	}
}

// Shared WASM compilation cache.
var Cache wazero.CompilationCache