Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gop build/install/test/run: use share importer #1728

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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