Source file src/simd/archsimd/_gen/specgen/flag.go

     1  // Copyright 2026 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package specgen
     6  
     7  import (
     8  	"fmt"
     9  	"os"
    10  	"path/filepath"
    11  	"simd/archsimd/_gen/gentools"
    12  )
    13  
    14  // FindSpecDir returns the path to the standard spec package
    15  // GOROOT/simd/internal/spec. If GOROOT is "", it uses gentools.DefaultGOROOT().
    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