Skip to content

Commit

Permalink
Issue containers#324 Adding a build target and ensure compilation on …
Browse files Browse the repository at this point in the history
…macOS

- Making sure that build target can handle build tags and build on macOS
- Adding target to go fmt target
- Changing the order of the subtargets of all

Signed-off-by: Hardy Ferentschik <hardy@hibernate.org>

foo
  • Loading branch information
hferentschik committed Oct 3, 2017
1 parent cabb6ce commit 75d42cb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all tools test validate lint
.PHONY: all tools test validate lint .gitvalidation fmt

# Which github repostiory and branch to use for testing with skopeo
SKOPEO_REPO = projectatomic/skopeo
Expand All @@ -7,12 +7,14 @@ SKOPEO_BRANCH = master
SUDO =

ifeq ($(shell uname),Darwin)
DARWIN_BUILD_TAG = containers_image_ostree_stub
DARWIN_BUILD_TAG = containers_image_ostree_stub
endif
BUILDTAGS = btrfs_noversion libdm_no_deferred_remove $(DARWIN_BUILD_TAG)
BUILDFLAGS := -tags "$(BUILDTAGS)"

PACKAGES := $(shell go list $(BUILDFLAGS) ./... | grep -v github.com/containers/image/vendor)
SOURCE_DIRS := $(shell echo $(PACKAGES) | awk 'BEGIN{FS="/"; RS=" "}{print $$4}' | uniq)

# On macOS, (brew install gpgme) installs it within /usr/local, but /usr/local/include is not in the default search path.
# Rather than hard-code this directory, use gpgme-config. Sadly that must be done at the top-level user
# instead of locally in the gpgme subpackage, because cgo supports only pkg-config, not general shell scripts,
Expand All @@ -21,7 +23,10 @@ PACKAGES := $(shell go list $(BUILDFLAGS) ./... | grep -v github.com/containers/
# (and the user will probably find out because the cgo compilation will fail).
GPGME_ENV = CGO_CFLAGS="$(shell gpgme-config --cflags 2>/dev/null)" CGO_LDFLAGS="$(shell gpgme-config --libs 2>/dev/null)"

all: tools .gitvalidation test validate
all: tools build test validate .gitvalidation

build: vendor
@$(GPGME_ENV) go build $(BUILDFLAGS) $(PACKAGES)

tools: tools.timestamp

Expand Down Expand Up @@ -58,6 +63,9 @@ test-skopeo:
$(SUDO) make BUILDTAGS="$(BUILDTAGS)" check && \
rm -rf $${skopeo_path}

fmt:
@gofmt -l -s -w $(SOURCE_DIRS)

validate: lint
@go vet $(PACKAGES)
@test -z "$$(gofmt -s -l . | grep -ve '^vendor' | tee /dev/stderr)"
Expand All @@ -69,8 +77,6 @@ lint:
exit 1; \
fi

.PHONY: .gitvalidation

EPOCH_TEST_COMMIT ?= e68e0e1110e64f906f9b482e548f17d73e02e6b1

# When this is running in travis, it will only check the travis commit range
Expand Down
3 changes: 3 additions & 0 deletions ostree/ostree_stub.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// +build containers_image_ostree_stub

package ostree

0 comments on commit 75d42cb

Please sign in to comment.