github.com/mutagen-io/mutagen@v0.18.0-rc1/pkg/mutagen/build.go (about)

     1  package mutagen
     2  
     3  import (
     4  	"errors"
     5  	"path/filepath"
     6  	"runtime"
     7  )
     8  
     9  const (
    10  	// BuildDirectoryName is the name of the build directory to create inside
    11  	// the root of the Mutagen source tree.
    12  	BuildDirectoryName = "build"
    13  )
    14  
    15  // SourceTreePath computes the path to the Mutagen source directory.
    16  func SourceTreePath() (string, error) {
    17  	// Compute the path to this file.
    18  	_, filePath, _, ok := runtime.Caller(0)
    19  	if !ok {
    20  		return "", errors.New("unable to compute file path")
    21  	}
    22  
    23  	// Compute the path to the Mutagen source directory.
    24  	return filepath.Dir(filepath.Dir(filepath.Dir(filePath))), nil
    25  }