From 42e76b453c0fe9c65fb5ffd6db3057db33aa4bf4 Mon Sep 17 00:00:00 2001 From: Wolfgang Profer Date: Tue, 18 Oct 2016 17:13:47 +0200 Subject: [PATCH] Rebuild standard library when building with -a and -f This is a workaround for #328 which prevents static builds when target and host have the same GOOS and GOARCH. It does this by considering all packages, including the standard library, as stale when running `gb build -a -f`. Previously the `-f` flag ommitted the standard library. --- cmd/gb/build.go | 1 + context.go | 11 ++++++----- install.go | 4 ++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/cmd/gb/build.go b/cmd/gb/build.go index 0c12471..4d2debf 100644 --- a/cmd/gb/build.go +++ b/cmd/gb/build.go @@ -105,6 +105,7 @@ For more about where packages and binaries are installed, run 'gb help project'. Run: func(ctx *gb.Context, args []string) error { // TODO(dfc) run should take a *gb.Context not a *gb.Project ctx.Force = F + ctx.ForceAll = F && A ctx.Install = !FF pkgs, err := resolveRootPackages(ctx, args...) diff --git a/context.go b/context.go index a04b386..c941959 100644 --- a/context.go +++ b/context.go @@ -43,11 +43,12 @@ type Context struct { Statistics - Force bool // force rebuild of packages - Install bool // copy packages into $PROJECT/pkg - Verbose bool // verbose output - Nope bool // command specfic flag, under test it skips the execute action. - race bool // race detector requested + Force bool // force rebuild of packages + ForceAll bool // force rebuild of all packages, including the standard library + Install bool // copy packages into $PROJECT/pkg + Verbose bool // verbose output + Nope bool // command specfic flag, under test it skips the execute action. + race bool // race detector requested gcflags []string // flags passed to the compiler ldflags []string // flags passed to the linker diff --git a/install.go b/install.go index b4b2af1..b1c90d7 100644 --- a/install.go +++ b/install.go @@ -51,6 +51,10 @@ func isStale(pkg *Package) bool { return false } + if pkg.ForceAll { + return true + } + if !pkg.Standard && pkg.Force { return true }