diff options
Diffstat (limited to 'buildPackage.go')
| -rw-r--r-- | buildPackage.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/buildPackage.go b/buildPackage.go index 2fcfd32..95c76bb 100644 --- a/buildPackage.go +++ b/buildPackage.go @@ -47,7 +47,7 @@ func (c *controlBox) buildPackage() (bool, error) { } var fullfilename string - if args.Release { + if argv.Release { fullfilename = filepath.Join(homeDir, "go/bin", filename) } else { fullfilename = filename @@ -59,7 +59,7 @@ func (c *controlBox) buildPackage() (bool, error) { return false, errors.New("binary existed before build") } - if args.Release { + if argv.Release { os.Unsetenv("GO111MODULE") path := c.pathL.String() + "@latest" cmd := []string{"go", "install", "-v", "-x", path} @@ -71,9 +71,20 @@ func (c *controlBox) buildPackage() (bool, error) { } else { // set the GO111 build var to true. pass the versions to the compiler manually os.Setenv("GO111MODULE", "off") + cmd := []string{"go", "build", "-v", "-x"} + + // add some standard golang flags vldflag := "-X main.VERSION=" + version gldflag := "-X main.GUIVERSION=" + version // todo: git this from the filesystem - if shell.Run([]string{"go", "build", "-v", "-x", "-ldflags", vldflag, "-ldflags", gldflag}) { + cmd = append(cmd, "-ldflags", vldflag) + cmd = append(cmd, "-ldflags", gldflag) + + // add any flags from the command line + for _, flag := range argv.Ldflags { + cmd = append(cmd, "-ldflags", "-X " + flag) + } + + if shell.Run(cmd) { log.Warn("go build worked") } else { return false, errors.New("go build") @@ -144,7 +155,7 @@ func (c *controlBox) buildPackage() (bool, error) { // if the git repo has a "./build" script run it before packaging // this way the user can put custom files in the .deb package if c.status.Exists("build") { - if args.Release { + if argv.Release { os.Unsetenv("GO111MODULE") } else { os.Setenv("GO111MODULE", "off") |
