Issue #272: Provide a flag to opt-in to resolving for current os/arch
diff --git a/glide.go b/glide.go index 4a29d06..9fe1e47 100644 --- a/glide.go +++ b/glide.go
@@ -43,6 +43,7 @@ "github.com/Masterminds/glide/msg" gpath "github.com/Masterminds/glide/path" "github.com/Masterminds/glide/repo" + "github.com/Masterminds/glide/util" "github.com/codegangsta/cli" @@ -202,6 +203,10 @@ Name: "use-gopath", Usage: "Copy dependencies from the GOPATH if they exist there.", }, + cli.BoolFlag{ + Name: "resolve-current", + Usage: "Resolve dependencies for only the current system rather than all build modes.", + }, }, Action: func(c *cli.Context) { if len(c.Args()) < 1 { @@ -209,6 +214,11 @@ os.Exit(1) } + if c.Bool("resolve-current") { + util.ResolveCurrent = true + msg.Warn("Only resolving dependencies for the current OS/Arch") + } + inst := &repo.Installer{ Force: c.Bool("force"), UseCache: c.Bool("cache"), @@ -465,8 +475,18 @@ Name: "use-gopath", Usage: "Copy dependencies from the GOPATH if they exist there.", }, + cli.BoolFlag{ + Name: "resolve-current", + Usage: "Resolve dependencies for only the current system rather than all build modes.", + }, }, Action: func(c *cli.Context) { + + if c.Bool("resolve-current") { + util.ResolveCurrent = true + msg.Warn("Only resolving dependencies for the current OS/Arch") + } + installer := &repo.Installer{ DeleteUnused: c.Bool("deleteOptIn"), UpdateVendored: c.Bool("update-vendored"),
diff --git a/util/util.go b/util/util.go index c16c4db..d73001a 100644 --- a/util/util.go +++ b/util/util.go
@@ -16,6 +16,12 @@ "github.com/Masterminds/vcs" ) +// ResolveCurrent selects whether the package should only the dependencies for +// the current OS/ARCH instead of all possible permutations. +// This is not concurrently safe which is ok for the current application. If +// other needs arise it may need to be re-written. +var ResolveCurrent = false + func init() { // Precompile the regular expressions used to check VCS locations. for _, v := range vcsList { @@ -263,9 +269,13 @@ func GetBuildContext() (*BuildCtxt, error) { buildContext := &BuildCtxt{build.Default} - // This tells the context scanning to skip filtering on +build flags or - // file names. - buildContext.UseAllFiles = true + // If we aren't resolving for the current system set to look at all + // build modes. + if !ResolveCurrent { + // This tells the context scanning to skip filtering on +build flags or + // file names. + buildContext.UseAllFiles = true + } if goRoot := os.Getenv("GOROOT"); len(goRoot) == 0 { out, err := exec.Command("go", "env", "GOROOT").Output()