diff --git a/build/gbuild.json b/build/gbuild.json index 6f7b2c5..1ca2ab3 100755 --- a/build/gbuild.json +++ b/build/gbuild.json @@ -11,7 +11,8 @@ "upx": true, "build_args": [ "-ldflags", - "-X main.GitTag=$(git describe --abbrev=0 --tags) -X main.GitHash=$(git show -s --format=%H) -s -w" + "-X main.GitTag=$(git describe --abbrev=0 --tags) -X main.GitHash=$(git show -s --format=%H) -s -w", + "./cmd/gber/" ], - "work_dir": "/Volumes/data/projects/go/src/gvcgo_org/gobuilder/cmd/gber" + "work_dir": "/Volumes/data/projects/go/src/gvcgo_org/gobuilder" } \ No newline at end of file diff --git a/internal/builder.go b/internal/builder.go index 141921d..6e30dd6 100644 --- a/internal/builder.go +++ b/internal/builder.go @@ -135,8 +135,6 @@ func (g *GoBuilder) parseArgs() { return } - g.WorkDir = GetCurrentWorkingDir() - for idx, v := range args { v = strings.ReplaceAll(v, "#", "$") args[idx] = v @@ -249,7 +247,7 @@ func (g *GoBuilder) clearArgs(args []string) { } func (g *GoBuilder) prepareArgs(osInfo, archInfo string) (args []string, targetDir, binName string) { - inputArgs := g.BuildArgs + inputArgs := append([]string{}, g.BuildArgs...) // deepcopy if len(inputArgs) == 0 { inputArgs = append(inputArgs, g.WorkDir) @@ -311,7 +309,7 @@ func (g *GoBuilder) build(osInfo, archInfo string) { args := append([]string{"go", "build"}, inputArgs...) g.clearArgs(args) - if _, err := gutils.ExecuteSysCommand(false, "", args...); err != nil { + if _, err := gutils.ExecuteSysCommand(false, g.WorkDir, args...); err != nil { gprint.PrintError("Failed to build binaries: %+v", err) os.Exit(1) }