Merge pull request #298847 from ShamrockLee/build-go-module-buildflag
buildGoModule: warn about buildFlags only when using buildPhase provided by buildGoModule
This commit is contained in:
commit
7c4cc6476b
|
@ -163,8 +163,10 @@ let
|
||||||
inherit (go) GOOS GOARCH;
|
inherit (go) GOOS GOARCH;
|
||||||
|
|
||||||
GOFLAGS = GOFLAGS
|
GOFLAGS = GOFLAGS
|
||||||
++ lib.optional (!proxyVendor) "-mod=vendor"
|
++ lib.warnIf (lib.any (lib.hasPrefix "-mod=") GOFLAGS) "use `proxyVendor` to control Go module/vendor behavior instead of setting `-mod=` in GOFLAGS"
|
||||||
++ lib.optional (!allowGoReference) "-trimpath";
|
(lib.optional (!proxyVendor) "-mod=vendor")
|
||||||
|
++ lib.warnIf (builtins.elem "-trimpath" GOFLAGS) "`-trimpath` is added by default to GOFLAGS by buildGoModule when allowGoReference isn't set to true"
|
||||||
|
(lib.optional (!allowGoReference) "-trimpath");
|
||||||
inherit CGO_ENABLED enableParallelBuilding GO111MODULE GOTOOLCHAIN;
|
inherit CGO_ENABLED enableParallelBuilding GO111MODULE GOTOOLCHAIN;
|
||||||
|
|
||||||
# If not set to an explicit value, set the buildid empty for reproducibility.
|
# If not set to an explicit value, set the buildid empty for reproducibility.
|
||||||
|
@ -196,7 +198,12 @@ let
|
||||||
runHook postConfigure
|
runHook postConfigure
|
||||||
'');
|
'');
|
||||||
|
|
||||||
buildPhase = args.buildPhase or (''
|
buildPhase = args.buildPhase or (
|
||||||
|
lib.warnIf (buildFlags != "" || buildFlagsArray != "")
|
||||||
|
"Use the `ldflags` and/or `tags` attributes instead of `buildFlags`/`buildFlagsArray`"
|
||||||
|
lib.warnIf (builtins.elem "-buildid=" ldflags)
|
||||||
|
"`-buildid=` is set by default as ldflag by buildGoModule"
|
||||||
|
''
|
||||||
runHook preBuild
|
runHook preBuild
|
||||||
|
|
||||||
exclude='\(/_\|examples\|Godeps\|testdata'
|
exclude='\(/_\|examples\|Godeps\|testdata'
|
||||||
|
@ -313,9 +320,4 @@ let
|
||||||
} // meta;
|
} // meta;
|
||||||
});
|
});
|
||||||
in
|
in
|
||||||
lib.warnIf (buildFlags != "" || buildFlagsArray != "")
|
|
||||||
"Use the `ldflags` and/or `tags` attributes instead of `buildFlags`/`buildFlagsArray`"
|
|
||||||
lib.warnIf (builtins.elem "-buildid=" ldflags) "`-buildid=` is set by default as ldflag by buildGoModule"
|
|
||||||
lib.warnIf (builtins.elem "-trimpath" GOFLAGS) "`-trimpath` is added by default to GOFLAGS by buildGoModule when allowGoReference isn't set to true"
|
|
||||||
lib.warnIf (lib.any (lib.hasPrefix "-mod=") GOFLAGS) "use `proxyVendor` to control Go module/vendor behavior instead of setting `-mod=` in GOFLAGS"
|
|
||||||
package
|
package
|
||||||
|
|
Loading…
Reference in New Issue
Block a user