aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/work/build.go
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2019-10-25 13:41:36 -0400
committerCherry Zhang <cherryyz@google.com>2019-10-25 13:41:36 -0400
commitd77b809df908d81406ceced91fe1b1399f1e29f1 (patch)
tree065feecf4fe5217125d992aec9f099a39400da09 /src/cmd/go/internal/work/build.go
parent2e2ef666b4d0bf0e86aaa3afbef7fc17f34232e6 (diff)
parentfc8eb264bba88b9e4eb85fa7560817abb25767f4 (diff)
downloadgo-d77b809df908d81406ceced91fe1b1399f1e29f1.tar.gz
go-d77b809df908d81406ceced91fe1b1399f1e29f1.zip
[dev.link] all: merge branch 'master' into dev.link
The only conflict is in cmd/internal/obj/link.go and the resolution is trivial. Change-Id: Ic79b760865a972a0ab68291d06386531d012de86
Diffstat (limited to 'src/cmd/go/internal/work/build.go')
-rw-r--r--src/cmd/go/internal/work/build.go23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go
index 6264593c34..45dd165ce0 100644
--- a/src/cmd/go/internal/work/build.go
+++ b/src/cmd/go/internal/work/build.go
@@ -102,6 +102,16 @@ and test commands:
-mod mode
module download mode to use: readonly or vendor.
See 'go help modules' for more.
+ -modcacherw
+ leave newly-created directories in the module cache read-write
+ instead of making them read-only.
+ -modfile file
+ in module aware mode, read (and possibly write) an alternate go.mod
+ file instead of the one in the module root directory. A file named
+ "go.mod" must still be present in order to determine the module root
+ directory, but it is not accessed. When -modfile is specified, an
+ alternate go.sum file is also used: its path is derived from the
+ -modfile flag by trimming the ".mod" extension and appending ".sum".
-pkgdir dir
install and load all packages from dir instead of the usual locations.
For example, when building with a non-standard configuration,
@@ -221,9 +231,10 @@ type BuildFlagMask int
const (
DefaultBuildFlags BuildFlagMask = 0
OmitModFlag BuildFlagMask = 1 << iota
+ OmitModCommonFlags
)
-// addBuildFlags adds the flags common to the build, clean, get,
+// AddBuildFlags adds the flags common to the build, clean, get,
// install, list, run, and test commands.
func AddBuildFlags(cmd *base.Command, mask BuildFlagMask) {
cmd.Flag.BoolVar(&cfg.BuildA, "a", false, "")
@@ -240,6 +251,9 @@ func AddBuildFlags(cmd *base.Command, mask BuildFlagMask) {
if mask&OmitModFlag == 0 {
cmd.Flag.StringVar(&cfg.BuildMod, "mod", "", "")
}
+ if mask&OmitModCommonFlags == 0 {
+ AddModCommonFlags(cmd)
+ }
cmd.Flag.StringVar(&cfg.BuildContext.InstallSuffix, "installsuffix", "", "")
cmd.Flag.Var(&load.BuildLdflags, "ldflags", "")
cmd.Flag.BoolVar(&cfg.BuildLinkshared, "linkshared", false, "")
@@ -255,6 +269,13 @@ func AddBuildFlags(cmd *base.Command, mask BuildFlagMask) {
cmd.Flag.StringVar(&cfg.DebugActiongraph, "debug-actiongraph", "", "")
}
+// AddModCommonFlags adds the module-related flags common to build commands
+// and 'go mod' subcommands.
+func AddModCommonFlags(cmd *base.Command) {
+ cmd.Flag.BoolVar(&cfg.ModCacheRW, "modcacherw", false, "")
+ cmd.Flag.StringVar(&cfg.ModFile, "modfile", "", "")
+}
+
// tagsFlag is the implementation of the -tags flag.
type tagsFlag []string