Skip to content

Commit

Permalink
Merge pull request #1728 from xushiwei/t
Browse files Browse the repository at this point in the history
gop build/install/test/run: use share importer
  • Loading branch information
xushiwei committed Feb 12, 2024
2 parents 17387ec + bccfd79 commit f58ccba
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
9 changes: 5 additions & 4 deletions cmd/internal/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/goplus/gop/cl"
"github.com/goplus/gop/cmd/internal/base"
"github.com/goplus/gop/x/gocmd"
"github.com/goplus/gop/x/gopenv"
"github.com/goplus/gop/x/gopprojs"
"github.com/goplus/gox"
)
Expand Down Expand Up @@ -75,9 +74,11 @@ func runCmd(cmd *base.Command, args []string) {
log.Panicln("too many arguments:", args)
}

gopEnv := gopenv.Get()
conf := &gop.Config{Gop: gopEnv}
confCmd := &gocmd.BuildConfig{Gop: gopEnv}
conf, err := gop.NewDefaultConf(".")
if err != nil {
log.Panicln("gop.NewDefaultConf:", err)
}
confCmd := &gocmd.BuildConfig{Gop: conf.Gop}
if *flagOutput != "" {
output, err := filepath.Abs(*flagOutput)
if err != nil {
Expand Down
9 changes: 5 additions & 4 deletions cmd/internal/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/goplus/gop/cl"
"github.com/goplus/gop/cmd/internal/base"
"github.com/goplus/gop/x/gocmd"
"github.com/goplus/gop/x/gopenv"
"github.com/goplus/gop/x/gopprojs"
"github.com/goplus/gox"
"github.com/goplus/mod/modfetch"
Expand Down Expand Up @@ -72,9 +71,11 @@ func runCmd(cmd *base.Command, args []string) {
cl.SetDisableRecover(true)
}

gopEnv := gopenv.Get()
conf := &gop.Config{Gop: gopEnv}
confCmd := &gocmd.Config{Gop: gopEnv}
conf, err := gop.NewDefaultConf(".")
if err != nil {
log.Panicln("gop.NewDefaultConf:", err)
}
confCmd := &gocmd.Config{Gop: conf.Gop}
confCmd.Flags = pass.Args
for _, proj := range projs {
install(proj, conf, confCmd)
Expand Down
9 changes: 5 additions & 4 deletions cmd/internal/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/goplus/gop/cl"
"github.com/goplus/gop/cmd/internal/base"
"github.com/goplus/gop/x/gocmd"
"github.com/goplus/gop/x/gopenv"
"github.com/goplus/gop/x/gopprojs"
"github.com/goplus/gox"
"github.com/qiniu/x/log"
Expand Down Expand Up @@ -81,9 +80,11 @@ func runCmd(cmd *base.Command, args []string) {
}

noChdir := *flagNoChdir
gopEnv := gopenv.Get()
conf := &gop.Config{Gop: gopEnv}
confCmd := &gocmd.Config{Gop: gopEnv}
conf, err := gop.NewDefaultConf(".")
if err != nil {
log.Panicln("gop.NewDefaultConf:", err)
}
confCmd := &gocmd.Config{Gop: conf.Gop}
confCmd.Flags = pass.Args
run(proj, args, !noChdir, conf, confCmd)
}
Expand Down
9 changes: 5 additions & 4 deletions cmd/internal/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/goplus/gop/cl"
"github.com/goplus/gop/cmd/internal/base"
"github.com/goplus/gop/x/gocmd"
"github.com/goplus/gop/x/gopenv"
"github.com/goplus/gop/x/gopprojs"
"github.com/goplus/gox"
)
Expand Down Expand Up @@ -70,9 +69,11 @@ func runCmd(cmd *base.Command, args []string) {
cl.SetDisableRecover(true)
}

gopEnv := gopenv.Get()
conf := &gop.Config{Gop: gopEnv}
confCmd := &gocmd.Config{Gop: gopEnv}
conf, err := gop.NewDefaultConf(".")
if err != nil {
log.Panicln("gop.NewDefaultConf:", err)
}
confCmd := &gocmd.Config{Gop: conf.Gop}
confCmd.Flags = pass.Args
for _, proj := range projs {
test(proj, conf, confCmd)
Expand Down
2 changes: 1 addition & 1 deletion gengo.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func genGoDir(dir string, conf *Config, genTestPkg, recursively bool, flags GenF
} else {
fn = func(path string, d fs.DirEntry, err error) error {
if err == nil && d.IsDir() {
if strings.HasPrefix(d.Name(), "_") || hasMod(path) { // skip _
if strings.HasPrefix(d.Name(), "_") || (path != dir && hasMod(path)) { // skip _
return filepath.SkipDir
}
if e := genGoIn(path, conf, genTestPkg, flags); e != nil && notIgnNotated(e, conf) {
Expand Down

0 comments on commit f58ccba

Please sign in to comment.