1
2
3
4
5 package specgen
6
7 import (
8 "fmt"
9 "os"
10 "path/filepath"
11 "simd/archsimd/_gen/gentools"
12 )
13
14
15
16 func FindSpecDir(goroot string) (string, error) {
17 if goroot == "" {
18 goroot = gentools.DefaultGOROOT()
19 if goroot == "" {
20 return "", fmt.Errorf("could not find GOROOT")
21 }
22 }
23 path := filepath.Join(goroot, "src/simd/internal/spec")
24 if _, err := os.Stat(path); err != nil {
25 return "", fmt.Errorf("could not find spec package: %w (this tool requires a complete Go checkout)", err)
26 }
27 return path, nil
28 }
29
30 func MustFindSpecDir(goroot string) string {
31 path, err := FindSpecDir(goroot)
32 if err != nil {
33 fmt.Fprintln(os.Stderr, err.Error())
34 os.Exit(1)
35 }
36 return path
37 }
38
View as plain text