fix go plugin build/install
This commit is contained in:
parent
b1d6923ca2
commit
5673e2cc2e
23
build.go
23
build.go
|
@ -44,8 +44,11 @@ func (f *Forge) doBuild(repo *gitpb.Repo, userFlags []string, goWhat string) err
|
|||
defer os.Unsetenv("GO111MODULE")
|
||||
}
|
||||
|
||||
if err := repo.ValidGoSum(); err != nil {
|
||||
return err
|
||||
if f.IsGoWork() {
|
||||
// there must be a valid go.mod file if compiling with go.work
|
||||
if err := repo.ValidGoSum(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if repo.Exists(".forge") {
|
||||
|
@ -77,17 +80,27 @@ func (f *Forge) doBuild(repo *gitpb.Repo, userFlags []string, goWhat string) err
|
|||
if repo.CheckDirty() {
|
||||
version = version + "-dirty"
|
||||
}
|
||||
cmd := []string{"go"}
|
||||
if repo.RepoType() == "plugin" {
|
||||
if goWhat == "install" {
|
||||
return errors.New("Can not go install plugins yet")
|
||||
log.Info("Can not go install plugins yet. just building to ~/go/lib/")
|
||||
}
|
||||
cmd = append(cmd, "build")
|
||||
} else {
|
||||
cmd = append(cmd, goWhat)
|
||||
}
|
||||
cmd := []string{"go", goWhat}
|
||||
|
||||
// if this is a plugin, use buildmode=plugin
|
||||
if repo.RepoType() == "plugin" {
|
||||
_, fname := filepath.Split(repo.FullPath)
|
||||
cmd = append(cmd, "-buildmode=plugin", "-o", fname+".so")
|
||||
soname := fname + "." + version + ".so"
|
||||
if goWhat == "install" {
|
||||
homeDir, _ := os.UserHomeDir()
|
||||
fullname := filepath.Join(homeDir, "go/lib", soname)
|
||||
cmd = append(cmd, "-buildmode=plugin", "-o", fullname)
|
||||
} else {
|
||||
cmd = append(cmd, "-buildmode=plugin", "-o", soname)
|
||||
}
|
||||
}
|
||||
cmd = append(cmd, "-v")
|
||||
|
||||
|
|
Loading…
Reference in New Issue