Skip to content

Commit

Permalink
Add support for libexec
Browse files Browse the repository at this point in the history
  • Loading branch information
5nord committed May 24, 2023
1 parent 8a56a26 commit d0a0eb8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"os"
"os/exec"
"path/filepath"
"runtime/pprof"
"strings"
"syscall"
Expand Down Expand Up @@ -74,6 +75,13 @@ var (
if path, err := exec.LookPath("k3-" + args[0]); err == nil {
return proc.Exec(path, args[1:]...)
}
conf, err := project.NewConfig(project.WithK3())
if err != nil {
return fmt.Errorf("unknown command: %w", err)
}
if path, err := exec.LookPath(filepath.Join(conf.K3.Root, "libexec", "ntt-"+args[0])); err == nil {
return proc.Exec(path, args[1:]...)
}
return fmt.Errorf("unknown command: %s", args[0])
}

Expand Down
6 changes: 3 additions & 3 deletions project/internal/k3/k3.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
var ErrNotFound = errors.New("not found")

type Instance struct {
root string
Root string

Compiler string
Runtime string
Expand Down Expand Up @@ -169,7 +169,7 @@ func getInstall(ctx context.Context, prefix string) (*Instance, error) {
defer region.End()
log.Tracef(ctx, "k3", "get install: %s\n", prefix)

k := Instance{root: prefix}
k := Instance{Root: prefix}

if k3c := env.Getenv("K3C"); k3c != "" {
k.Compiler = k3c
Expand Down Expand Up @@ -234,7 +234,7 @@ func getRepo(ctx context.Context, k3SourceDir, k3BinaryDir, mtcBinaryDir string)
defer region.End()
log.Tracef(ctx, "k3", "get repo: %s %s %s\n", k3SourceDir, k3BinaryDir, mtcBinaryDir)

k := Instance{root: k3BinaryDir}
k := Instance{Root: k3BinaryDir}

if k3c := env.Getenv("K3C"); k3c != "" {
k.Compiler = k3c
Expand Down
3 changes: 0 additions & 3 deletions project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ type Config struct {
ResultsFile string `json:"results_file"`

K3 struct {
// K3 root folder
Root string `json:",omitempty"`

k3.Instance `json:",inline"`

// T3XF is the path to the T3XF file.
Expand Down

0 comments on commit d0a0eb8

Please sign in to comment.