Skip to content

Commit

Permalink
Support env -u e.g. unsetting vars under OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
foot committed Mar 10, 2016
1 parent 3391bcc commit d7e9d13
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ GO_BUILD_INSTALL_DEPS=-i
GO_BUILD_TAGS='netgo unsafe'
GO_BUILD_FLAGS=$(GO_BUILD_INSTALL_DEPS) -ldflags "-extldflags \"-static\" -X main.version=$(SCOPE_VERSION)" -tags $(GO_BUILD_TAGS)


This comment has been minimized.

Copy link
@2opremio

2opremio Mar 12, 2016

Contributor

Extra space

all: $(SCOPE_EXPORT)

$(DOCKER_DISTRIB):
Expand Down Expand Up @@ -67,6 +68,15 @@ $(SCOPE_EXE) $(RUNSVINIT) lint tests shell prog/static.go: $(SCOPE_BACKEND_BUILD

else

UNAME := $(shell uname)
ifeq ($(UNAME), Darwin)
UNSET_GOARCH_GOOS=unset GOARCH GOOS;

This comment has been minimized.

Copy link
@2opremio

2opremio Mar 12, 2016

Contributor

Can't we simply use unset in both OSX and Linux?

UNSET_GOGC=unset GOGC;
else
UNSET_GOARCH_GOOS=env -u GOGC -u GOOS

This comment has been minimized.

Copy link
@2opremio

2opremio Mar 12, 2016

Contributor

s/GOGC/GOARCH/ which is why circle is failing.

UNSET_GOGC=env -u GOGC
endif

$(SCOPE_EXE): $(SCOPE_BACKEND_BUILD_UPTODATE)
time $(GO) build $(GO_BUILD_FLAGS) -o $@ ./$(@D)
@strings $@ | grep cgo_stub\\\.go >/dev/null || { \
Expand All @@ -79,12 +89,12 @@ $(SCOPE_EXE): $(SCOPE_BACKEND_BUILD_UPTODATE)
}

%.codecgen.go: $(CODECGEN_EXE)
rm -f $@ && env -u GOARCH -u GOOS $(GO) build -i -tags $(GO_BUILD_TAGS) ./$(@D) # workaround for https://github.com/ugorji/go/issues/145
cd $(@D) && env -u GOARCH -u GOOS $(GO_ENVS) $(shell pwd)/$(CODECGEN_EXE) -rt $(GO_BUILD_TAGS) -u -o $(@F) $(notdir $(call GET_CODECGEN_DEPS,$(@D)))
rm -f $@ && $(UNSET_GOARCH_GOOS) $(GO) build -i -tags $(GO_BUILD_TAGS) ./$(@D) # workaround for https://github.com/ugorji/go/issues/145
cd $(@D) && $(UNSET_GOARCH_GOOS) $(GO_ENVS) $(shell pwd)/$(CODECGEN_EXE) -rt $(GO_BUILD_TAGS) -u -o $(@F) $(notdir $(call GET_CODECGEN_DEPS,$(@D)))

$(CODECGEN_EXE): $(CODECGEN_DIR)/*.go
mkdir -p $(@D)
env -u GOARCH -u GOOS $(GO) build -i -tags $(GO_BUILD_TAGS) -o $@ ./$(CODECGEN_DIR)
$(UNSET_GOARCH_GOOS) $(GO) build -i -tags $(GO_BUILD_TAGS) -o $@ ./$(CODECGEN_DIR)

$(RUNSVINIT): $(SCOPE_BACKEND_BUILD_UPTODATE)
time $(GO) build $(GO_BUILD_FLAGS) -o $@ ./$(@D)
Expand All @@ -93,7 +103,7 @@ shell: $(SCOPE_BACKEND_BUILD_UPTODATE)
/bin/bash

tests: $(SCOPE_BACKEND_BUILD_UPTODATE)
env -u GOGC $(GO_ENVS) ./tools/test -no-go-get
$(UNSET_GOGC) $(GO_ENVS) ./tools/test -no-go-get

This comment has been minimized.

Copy link
@2opremio

2opremio Mar 12, 2016

Contributor

I've just realized this wasn't working since GO_ENVS sets GOGC anyways. Will fix


lint: $(SCOPE_BACKEND_BUILD_UPTODATE)
./tools/lint .
Expand Down

0 comments on commit d7e9d13

Please sign in to comment.