Skip to content
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
2 changes: 1 addition & 1 deletion cmd_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func gopyRunCmdBuild(cmdr *commander.Command, args []string) error {
bind.NoMake = cfg.NoMake

for _, path := range args {
bpkg, err := loadPackage(path, true) // build first
bpkg, err := loadPackage(path, true, cfg.BuildTags) // build first
if err != nil {
return fmt.Errorf("gopy-gen: go build / load of package failed with path=%q: %v", path, err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd_exe.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func gopyRunCmdExe(cmdr *commander.Command, args []string) error {
}

for _, path := range args {
buildPkgRecurse(cfg.OutputDir, path, path, exmap)
buildPkgRecurse(cfg.OutputDir, path, path, exmap, cfg.BuildTags)
}
return runBuild(bind.ModeExe, cfg)
}
2 changes: 1 addition & 1 deletion cmd_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func gopyRunCmdGen(cmdr *commander.Command, args []string) error {
bind.NoMake = cfg.NoMake

for _, path := range args {
bpkg, err := loadPackage(path, true) // build first
bpkg, err := loadPackage(path, true, cfg.BuildTags) // build first
if err != nil {
return fmt.Errorf("gopy-gen: go build / load of package failed with path=%q: %v", path, err)
}
Expand Down
8 changes: 4 additions & 4 deletions cmd_pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ func gopyRunCmdPkg(cmdr *commander.Command, args []string) error {
}

for _, path := range args {
buildPkgRecurse(cfg.OutputDir, path, path, exmap)
buildPkgRecurse(cfg.OutputDir, path, path, exmap, cfg.BuildTags)
}
return runBuild(bind.ModePkg, cfg)
}

func buildPkgRecurse(odir, path, rootpath string, exmap map[string]struct{}) error {
func buildPkgRecurse(odir, path, rootpath string, exmap map[string]struct{}, buildTags string) error {
buildFirst := path == rootpath
bpkg, err := loadPackage(path, buildFirst)
bpkg, err := loadPackage(path, buildFirst, buildTags)
if err != nil {
return fmt.Errorf("gopy-gen: go build / load of package failed with path=%q: %v", path, err)
}
Expand Down Expand Up @@ -171,7 +171,7 @@ func buildPkgRecurse(odir, path, rootpath string, exmap map[string]struct{}) err
continue
}
sp := filepath.Join(path, dr)
buildPkgRecurse(odir, sp, rootpath, exmap)
buildPkgRecurse(odir, sp, rootpath, exmap, buildTags)
}
return nil
}
11 changes: 9 additions & 2 deletions gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,21 @@ func genPkg(mode bind.BuildMode, cfg *BuildCfg) error {
return err
}

func loadPackage(path string, buildFirst bool) (*packages.Package, error) {
func loadPackage(path string, buildFirst bool, buildTags string) (*packages.Package, error) {
cwd, err := os.Getwd()
if err != nil {
return nil, err
}

if buildFirst {
cmd := exec.Command("go", "build", "-v", path)
args := []string{"build"}
if buildTags != "" {
buildTagStr := fmt.Sprintf("\"%s\"", strings.Join(strings.Split(buildTags, ","), " "))
args = append(args, "-tags", buildTagStr)
}
args = append(args, "-v", "path")
fmt.Printf("go %v\n", strings.Join(args, " "))
cmd := exec.Command("go", args...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
Expand Down