Skip to content

Commit

Permalink
remove StaticLink flag from Environment
Browse files Browse the repository at this point in the history
  • Loading branch information
0xe3b0c4 committed Aug 8, 2022
1 parent cfbeb69 commit 3066e04
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
9 changes: 3 additions & 6 deletions build/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,7 @@ func doInstall(cmdline []string) {

// Configure the build.
env := build.Env()
if *staticlink {
env.StaticLink = true
}
gobuild := tc.Go("build", buildFlags(env)...)
gobuild := tc.Go("build", buildFlags(env, *staticlink)...)

// arm64 CI builders are memory-constrained and can't handle concurrent builds,
// better disable it. This check isn't the best, it should probably
Expand Down Expand Up @@ -249,7 +246,7 @@ func doInstall(cmdline []string) {
}

// buildFlags returns the go tool flags for building.
func buildFlags(env build.Environment) (flags []string) {
func buildFlags(env build.Environment, staticlink bool) (flags []string) {
var ld []string
if env.Commit != "" {
ld = append(ld, "-X", "main.gitCommit="+env.Commit)
Expand All @@ -264,7 +261,7 @@ func buildFlags(env build.Environment) (flags []string) {
// alpine Linux.
if runtime.GOOS == "linux" {
staticlinkflag := ""
if env.StaticLink {
if staticlink {
staticlinkflag = "-static"
}
ld = append(ld, "-extldflags", fmt.Sprintf("' -Wl,-z,stack-size=0x800000 %s'", staticlinkflag))
Expand Down
7 changes: 0 additions & 7 deletions internal/build/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ var (
BuildnumFlag = flag.String("buildnum", "", `Overrides CI build number`)
PullRequestFlag = flag.Bool("pull-request", false, `Overrides pull request status of the build`)
CronJobFlag = flag.Bool("cron-job", false, `Overrides cron job status of the build`)
StaticLink = flag.Bool("static-link", false, `Overrides static link status of the build`)
)

// Environment contains metadata provided by the build environment.
Expand All @@ -46,7 +45,6 @@ type Environment struct {
Buildnum string
IsPullRequest bool
IsCronJob bool
StaticLink bool
}

func (env Environment) String() string {
Expand Down Expand Up @@ -74,7 +72,6 @@ func Env() Environment {
Buildnum: os.Getenv("TRAVIS_BUILD_NUMBER"),
IsPullRequest: os.Getenv("TRAVIS_PULL_REQUEST") != "false",
IsCronJob: os.Getenv("TRAVIS_EVENT_TYPE") == "cron",
StaticLink: false,
}
case os.Getenv("CI") == "True" && os.Getenv("APPVEYOR") == "True":
commit := os.Getenv("APPVEYOR_PULL_REQUEST_HEAD_COMMIT")
Expand All @@ -92,7 +89,6 @@ func Env() Environment {
Buildnum: os.Getenv("APPVEYOR_BUILD_NUMBER"),
IsPullRequest: os.Getenv("APPVEYOR_PULL_REQUEST_NUMBER") != "",
IsCronJob: os.Getenv("APPVEYOR_SCHEDULED_BUILD") == "True",
StaticLink: false,
}
default:
return LocalEnv()
Expand Down Expand Up @@ -172,8 +168,5 @@ func applyEnvFlags(env Environment) Environment {
if *CronJobFlag {
env.IsCronJob = true
}
if *StaticLink {
env.StaticLink = true
}
return env
}

0 comments on commit 3066e04

Please sign in to comment.