Skip to content

Commit

Permalink
Refactored Makefile for faster development
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Oct 7, 2015
1 parent d86abfb commit b92b51e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ host_rsa*
id_rsa*

profile.out

.docker-container-built
42 changes: 33 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
PACKAGES := .
COMMANDS := $(addprefix ./,$(wildcard cmd/*))

VERSION := $(shell cat .goxc.json | jq -c .PackageVersion | sed 's/"//g')
SOURCES := $(shell find . -name "*.go")

all: build


build:
build: $(notdir $(COMMANDS))

run: build
./ssh2docker

$(notdir $(COMMANDS)): $(SOURCES)
go get -t ./...
gofmt -w $(PACKAGES) $(COMMANDS)
go test -i $(PACKAGES) $(COMMANDS)
for command in $(COMMANDS); do \
go build -o `basename $$command` $$command; \
done
gofmt -w $(PACKAGES) ./cmd/$@
go test -i $(PACKAGES) ./cmd/$@
go build -o $@ ./cmd/$@


test:
Expand Down Expand Up @@ -42,8 +46,28 @@ convey:


.PHONY: build-docker
build-docker:
make -C contrib/docker
build-docker: contrib/docker/.docker-container-built


contrib/docker/.docker-container-built: dist/latest/ssh2docker_latest_linux_386
cp dist/latest/ssh2docker_latest_linux_386 contrib/docker/ssh2docker
docker build -t moul/ssh2docker:latest contrib/docker
docker run -it --rm moul/ssh2docker --version
docker inspect --type=image --format="{{ .Id }}" moul/ssh2docker > $@.tmp
mv $@.tmp $@


.PHONY: run-docker
run-docker: build-docker
docker run -it --rm -p 2222:2222 moul/ssh2docker


dist/latest/ssh2docker_latest_linux_386: $(SOURCES)
mkdir -p dist
rm -f dist/latest
(cd dist; ln -s $(VERSION) latest)
goxc -bc="linux,386" xc
cp dist/latest/ssh2docker_$(VERSION)_linux_386 dist/latest/ssh2docker_latest_linux_386


.PHONY: docker-ps
Expand Down
11 changes: 2 additions & 9 deletions contrib/docker/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
all: ssh2docker


.PHONY: ssh2docker
ssh2docker:
cd ../..; goxc -bc="linux,386" xc
cp ../../dist/*/ssh2docker_*_linux_386 ssh2docker
docker build -t moul/ssh2docker:latest .
docker run -it --rm moul/ssh2docker --version
run-docker build-docker:
$(MAKE) -C ../../ $@

0 comments on commit b92b51e

Please sign in to comment.