mirror of
https://github.com/caddyserver/xcaddy.git
synced 2024-11-08 02:10:10 +00:00
Honor CGO_ENABLED environment variable (fix #17)
This commit is contained in:
parent
4ce3d1db07
commit
a1e17ca9b9
3 changed files with 13 additions and 1 deletions
|
@ -83,7 +83,7 @@ func (b Builder) Build(ctx context.Context, outputFile string) error {
|
||||||
env = setEnv(env, "GOOS="+b.OS)
|
env = setEnv(env, "GOOS="+b.OS)
|
||||||
env = setEnv(env, "GOARCH="+b.Arch)
|
env = setEnv(env, "GOARCH="+b.Arch)
|
||||||
env = setEnv(env, "GOARM="+b.ARM)
|
env = setEnv(env, "GOARM="+b.ARM)
|
||||||
env = setEnv(env, fmt.Sprintf("CGO_ENABLED=%t", b.Cgo))
|
env = setEnv(env, fmt.Sprintf("CGO_ENABLED=%s", b.Compile.CgoEnabled()))
|
||||||
|
|
||||||
log.Println("[INFO] Building Caddy")
|
log.Println("[INFO] Building Caddy")
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,9 @@ func runBuild(ctx context.Context, args []string) error {
|
||||||
|
|
||||||
// perform the build
|
// perform the build
|
||||||
builder := xcaddy.Builder{
|
builder := xcaddy.Builder{
|
||||||
|
Compile: xcaddy.Compile{
|
||||||
|
Cgo: os.Getenv("CGO_ENABLED") == "1",
|
||||||
|
},
|
||||||
CaddyVersion: caddyVersion,
|
CaddyVersion: caddyVersion,
|
||||||
Plugins: plugins,
|
Plugins: plugins,
|
||||||
Replacements: replacements,
|
Replacements: replacements,
|
||||||
|
|
|
@ -11,6 +11,15 @@ type Compile struct {
|
||||||
Cgo bool `json:"cgo,omitempty"`
|
Cgo bool `json:"cgo,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CgoEnabled returns "1" if c.Cgo is true, "0" otherwise.
|
||||||
|
// This is used for setting the CGO_ENABLED env variable.
|
||||||
|
func (c Compile) CgoEnabled() string {
|
||||||
|
if c.Cgo {
|
||||||
|
return "1"
|
||||||
|
}
|
||||||
|
return "0"
|
||||||
|
}
|
||||||
|
|
||||||
// Platform represents a build target.
|
// Platform represents a build target.
|
||||||
type Platform struct {
|
type Platform struct {
|
||||||
OS string `json:"os,omitempty"`
|
OS string `json:"os,omitempty"`
|
||||||
|
|
Loading…
Reference in a new issue