Skip to content

Commit

Permalink
Improve Makefiles
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakhellesoy committed Jul 16, 2018
1 parent 7c30255 commit 288f80d
Show file tree
Hide file tree
Showing 23 changed files with 118 additions and 95 deletions.
7 changes: 5 additions & 2 deletions .templates/go/default.mk
Expand Up @@ -29,6 +29,9 @@ unlink:
go test ${ARGS}
touch $@

clean:
rm -f .deps .linked .tested
clean: clean-go
.PHONY: clean

clean-go:
rm -f .deps .linked .tested
.PHONY: clean-go
7 changes: 5 additions & 2 deletions .templates/ruby/default.mk
Expand Up @@ -25,6 +25,9 @@ Gemfile.lock: Gemfile $(GEMSPECS)
bundle exec rspec --color
touch $@

clean:
rm -f .deps .linked .tested Gemfile.lock
clean: clean-ruby
.PHONY: clean

clean-ruby:
rm -f .deps .linked .tested Gemfile.lock
.PHONY: clean-ruby
2 changes: 1 addition & 1 deletion Makefile
@@ -1,6 +1,6 @@
SHELL := /usr/bin/env bash
MAKEFILES=messages/Makefile \
formatter/Makefile \
dots-formatter/Makefile \
gherkin/Makefile \
datatable/Makefile \
config/Makefile \
Expand Down
7 changes: 5 additions & 2 deletions cucumber-expressions/go/default.mk
Expand Up @@ -29,6 +29,9 @@ unlink:
go test ${ARGS}
touch $@

clean:
rm -f .deps .linked .tested
clean: clean-go
.PHONY: clean

clean-go:
rm -f .deps .linked .tested
.PHONY: clean-go
9 changes: 1 addition & 8 deletions cucumber-expressions/ruby/Makefile
@@ -1,8 +1 @@
default:
bundle install
rake
rake install
.PHONY: default

clean:
.PHONY: clean
include default.mk
7 changes: 5 additions & 2 deletions cucumber-expressions/ruby/default.mk
Expand Up @@ -25,6 +25,9 @@ Gemfile.lock: Gemfile $(GEMSPECS)
bundle exec rspec --color
touch $@

clean:
rm -f .deps .linked .tested Gemfile.lock
clean: clean-ruby
.PHONY: clean

clean-ruby:
rm -f .deps .linked .tested Gemfile.lock
.PHONY: clean-ruby
5 changes: 1 addition & 4 deletions dots-formatter/go/Makefile
Expand Up @@ -37,8 +37,5 @@ dist_compressed/dots-formatter-go-%: dist/dots-formatter-go-%
bin/dots-formatter: .deps $(GO_SOURCE_FILES)
go build -o $@ ./cli

clean: clean-custom

clean-custom:
clean:
rm -rf bin/dots-formatter dist/* dist_compressed
.PHONY: clean-custom
7 changes: 5 additions & 2 deletions dots-formatter/go/default.mk
Expand Up @@ -29,6 +29,9 @@ unlink:
go test ${ARGS}
touch $@

clean:
rm -f .deps .linked .tested
clean: clean-go
.PHONY: clean

clean-go:
rm -f .deps .linked .tested
.PHONY: clean-go
7 changes: 5 additions & 2 deletions dots-formatter/ruby/default.mk
Expand Up @@ -25,6 +25,9 @@ Gemfile.lock: Gemfile $(GEMSPECS)
bundle exec rspec --color
touch $@

clean:
rm -f .deps .linked .tested Gemfile.lock
clean: clean-ruby
.PHONY: clean

clean-ruby:
rm -f .deps .linked .tested Gemfile.lock
.PHONY: clean-ruby
15 changes: 6 additions & 9 deletions gherkin/go/Makefile
@@ -1,8 +1,8 @@
include default.mk

GHERKIN_DIALECTS := $(shell cat gherkin-languages.json | jq --compact-output --sort-keys . | base64 | tr -d '\n')
EXES := $(shell find dist -name 'gherkin-*')
UPX_EXES = $(patsubst dist/gherkin-%,dist_compressed/gherkin-%,$(EXES))
EXES := $(shell find dist -name 'gherkin-go-*')
UPX_EXES = $(patsubst dist/gherkin-go-%,dist_compressed/gherkin-go-%,$(EXES))

GOOD_FEATURE_FILES = $(shell find testdata/good -name "*.feature")
BAD_FEATURE_FILES = $(shell find testdata/bad -name "*.feature")
Expand All @@ -26,15 +26,15 @@ default: .compared
touch $@

.dist: .compared .deps
gox -ldflags "-X main.version=${CIRCLE_TAG} -X main.gherkinDialects=${GHERKIN_DIALECTS}" -output "dist/gherkin-{{.OS}}-{{.Arch}}" -rebuild ./cli
gox -ldflags "-X main.version=${CIRCLE_TAG} -X main.gherkinDialects=${GHERKIN_DIALECTS}" -output "dist/gherkin-go-{{.OS}}-{{.Arch}}" -rebuild ./cli
touch $@

dist/gherkin-%: .dist
dist/gherkin-go-%: .dist

.dist-compressed: $(UPX_EXES)
touch $@

dist_compressed/gherkin-%: dist/gherkin-%
dist_compressed/gherkin-go-%: dist/gherkin-go-%
mkdir -p dist_compressed
# requires upx in PATH to compress supported binaries
# may produce an error ARCH not supported
Expand Down Expand Up @@ -101,8 +101,5 @@ dialects_builtin.go: gherkin-languages.json dialects_builtin.go.jq
cat $< | jq --sort-keys --from-file dialects_builtin.go.jq --raw-output --compact-output > $@
gofmt -w $@

clean: clean-custom

clean-custom:
clean:
rm -rf .compared .built acceptance bin/ dist/* dist_compressed/ .dist .dist-compressed
.PHONY: clean_custom
7 changes: 5 additions & 2 deletions gherkin/go/default.mk
Expand Up @@ -29,6 +29,9 @@ unlink:
go test ${ARGS}
touch $@

clean:
rm -f .deps .linked .tested
clean: clean-go
.PHONY: clean

clean-go:
rm -f .deps .linked .tested
.PHONY: clean-go
2 changes: 2 additions & 0 deletions gherkin/java/.gitignore
Expand Up @@ -4,5 +4,7 @@ target/
acceptance/
.built
.compared
.deps
.tested
dependency-reduced-pom.xml
gherkin-go/
47 changes: 17 additions & 30 deletions gherkin/java/Makefile
@@ -1,4 +1,5 @@
SHELL := /usr/bin/env bash
include default.mk

GOOD_FEATURE_FILES = $(shell find testdata/good -name "*.feature")
BAD_FEATURE_FILES = $(shell find testdata/bad -name "*.feature")

Expand All @@ -9,88 +10,74 @@ PROTOBUFBINS = $(patsubst testdata/%.feature,testdata/%.feature.protobuf.bin,$(G
PROTOBUFS = $(patsubst testdata/%.feature,acceptance/testdata/%.feature.protobuf.bin.ndjson,$(GOOD_FEATURE_FILES))
ERRORS = $(patsubst testdata/%.feature,acceptance/testdata/%.feature.errors.ndjson,$(BAD_FEATURE_FILES))

JAVA_FILES = $(shell find . -name "*.java")

ifdef TRAVIS_BRANCH
LIBRARY_VERSION=$(TRAVIS_TAG)
endif
ifdef TRAVIS_TAG
LIBRARY_VERSION=$(TRAVIS_TAG)
endif
ifndef LIBRARY_VERSION
LIBRARY_VERSION=$(shell git rev-parse --abbrev-ref HEAD)
endif

.DELETE_ON_ERROR:

default: .compared
.PHONY: default

.compared: $(PROTOBUFS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES)
.deps:
./scripts/s3-download gherkin-go $(LIBRARY_VERSION)
touch $@

.built: $(JAVA_FILES) LICENSE pom.xml gherkin-go
mvn install
.compared: $(PROTOBUFS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES)
touch $@

gherkin-go:
./scripts/s3-download gherkin-go $(LIBRARY_VERSION)

# # Generate
# acceptance/testdata/%.feature.ast.ndjson: testdata/%.feature .built
# acceptance/testdata/%.feature.ast.ndjson: testdata/%.feature .tested
# mkdir -p `dirname $@`
# bin/gherkin --no-source --no-pickles $< | jq --sort-keys --compact-output "." > $<.ast.ndjson

acceptance/testdata/%.feature.ast.ndjson: testdata/%.feature testdata/%.feature.ast.ndjson .built
acceptance/testdata/%.feature.ast.ndjson: testdata/%.feature testdata/%.feature.ast.ndjson .tested
mkdir -p `dirname $@`
bin/gherkin --no-source --no-pickles --json $< | jq --sort-keys --compact-output "." > $@
diff --unified <(jq "." $<.ast.ndjson) <(jq "." $@)

# # Generate - we only do this in the Java project, then rsync to others
# testdata/%.feature.protobuf.bin: testdata/%.feature .built
# testdata/%.feature.protobuf.bin: testdata/%.feature .tested
# mkdir -p `dirname $@`
# bin/gherkin --protobuf $< > $@

# # Generate
# acceptance/testdata/%.feature.protobuf.bin.ndjson: testdata/%.feature .built
# acceptance/testdata/%.feature.protobuf.bin.ndjson: testdata/%.feature .tested
# mkdir -p `dirname $@`
# cat $<.protobuf.bin | bin/gherkin | jq --sort-keys --compact-output "." > $<.protobuf.bin.ndjson

acceptance/testdata/%.feature.protobuf.bin.ndjson: testdata/%.feature.protobuf.bin .built
acceptance/testdata/%.feature.protobuf.bin.ndjson: testdata/%.feature.protobuf.bin .tested
mkdir -p `dirname $@`
cat $< | bin/gherkin --json | jq --sort-keys --compact-output "." > $@
diff --unified <(jq "." $<.ndjson) <(jq "." $@)

# # Generate
# acceptance/testdata/%.feature.pickles.ndjson: testdata/%.feature .built
# acceptance/testdata/%.feature.pickles.ndjson: testdata/%.feature .tested
# mkdir -p `dirname $@`
# bin/gherkin --no-source --no-ast $< | jq --sort-keys --compact-output "." > $<.pickles.ndjson

acceptance/testdata/%.feature.pickles.ndjson: testdata/%.feature testdata/%.feature.pickles.ndjson .built
acceptance/testdata/%.feature.pickles.ndjson: testdata/%.feature testdata/%.feature.pickles.ndjson .tested
mkdir -p `dirname $@`
bin/gherkin --no-source --no-ast --json $< | jq --sort-keys --compact-output "." > $@
diff --unified <(jq "." $<.pickles.ndjson) <(jq "." $@)

# # Generate
# acceptance/testdata/%.feature.source.ndjson: testdata/%.feature .built
# acceptance/testdata/%.feature.source.ndjson: testdata/%.feature .tested
# mkdir -p `dirname $@`
# bin/gherkin --no-ast --no-pickles $< | jq --sort-keys --compact-output "." > $<.source.ndjson

acceptance/testdata/%.feature.source.ndjson: testdata/%.feature testdata/%.feature.source.ndjson .built
acceptance/testdata/%.feature.source.ndjson: testdata/%.feature testdata/%.feature.source.ndjson .tested
mkdir -p `dirname $@`
bin/gherkin --no-ast --no-pickles --json $< | jq --sort-keys --compact-output "." > $@
diff --unified <(jq "." $<.source.ndjson) <(jq "." $@)

# # Generate
# acceptance/testdata/%.feature.errors.ndjson: testdata/%.feature .built
# acceptance/testdata/%.feature.errors.ndjson: testdata/%.feature .tested
# mkdir -p `dirname $@`
# bin/gherkin --no-source $< | jq --sort-keys --compact-output "." > $<.errors.ndjson

acceptance/testdata/%.feature.errors.ndjson: testdata/%.feature testdata/%.feature.errors.ndjson .built
acceptance/testdata/%.feature.errors.ndjson: testdata/%.feature testdata/%.feature.errors.ndjson .tested
mkdir -p `dirname $@`
bin/gherkin --no-source --json $< | jq --sort-keys --compact-output "." > $@
diff --unified <(jq "." $<.errors.ndjson) <(jq "." $@)

clean:
rm -rf .compared .built acceptance target gherkin-go
.PHONY: clean
rm -rf .compared acceptance gherkin-go
26 changes: 26 additions & 0 deletions gherkin/java/default.mk
@@ -0,0 +1,26 @@
SHELL := /usr/bin/env bash
JAVA_SOURCE_FILES = $(shell find . -name "*.java")

ifdef TRAVIS_BRANCH
LIBRARY_VERSION=$(TRAVIS_BRANCH)
endif
ifdef TRAVIS_TAG
LIBRARY_VERSION=$(TRAVIS_TAG)
endif
ifndef LIBRARY_VERSION
LIBRARY_VERSION=$(shell git rev-parse --abbrev-ref HEAD)
endif

default: .tested
.PHONY: default

.tested: pom.xml $(JAVA_SOURCE_FILES) .deps
mvn install
touch $@

clean: clean-java
.PHONY: clean

clean-java:
rm -rf target
.PHONY: clean-java
Expand Up @@ -22,7 +22,7 @@ public class Gherkin implements GherkinMessages {
private final boolean includeSource;
private final boolean includeAst;
private final boolean includePickles;
static final Exe EXE = new Exe(new ExeFile("gherkin-{{.OS}}-{{.Arch}}{{.Ext}}"));
static final Exe EXE = new Exe(new ExeFile("gherkin-go-{{.OS}}-{{.Arch}}{{.Ext}}"));

private Gherkin(List<String> paths, List<Source> sources, boolean includeSource, boolean includeAst, boolean includePickles) {
this.paths = paths;
Expand Down
9 changes: 3 additions & 6 deletions gherkin/ruby/Makefile
Expand Up @@ -14,7 +14,7 @@ ERRORS = $(patsubst testdata/%.feature,acceptance/testdata/%.feature.error
.tested: .compared

.deps:
./scripts/s3-download gherkin-go $(LIBRARY_VERSION) gherkin-go
./scripts/s3-download gherkin-go $(LIBRARY_VERSION)
touch $@

.compared: $(ERRORS) $(SOURCES) $(PICKLES) $(PROTOBUFS) $(ASTS)
Expand Down Expand Up @@ -45,8 +45,5 @@ acceptance/testdata/%.feature.errors.ndjson: testdata/%.feature testdata/%.featu
bundle exec bin/gherkin --no-source $< | jq --sort-keys --compact-output "." > $@
diff --unified <(jq "." $<.errors.ndjson) <(jq "." $@)

clean: clean_custom

clean_custom:
rm -rf .compared acceptance
.PHONY: clean_custom
clean:
rm -rf .compared acceptance gherkin-go
7 changes: 5 additions & 2 deletions gherkin/ruby/default.mk
Expand Up @@ -25,6 +25,9 @@ Gemfile.lock: Gemfile $(GEMSPECS)
bundle exec rspec --color
touch $@

clean:
rm -f .deps .linked .tested Gemfile.lock
clean: clean-ruby
.PHONY: clean

clean-ruby:
rm -f .deps .linked .tested Gemfile.lock
.PHONY: clean-ruby
7 changes: 5 additions & 2 deletions messages/go/default.mk
Expand Up @@ -29,6 +29,9 @@ unlink:
go test ${ARGS}
touch $@

clean:
rm -f .deps .linked .tested
clean: clean-go
.PHONY: clean

clean-go:
rm -f .deps .linked .tested
.PHONY: clean-go
1 change: 1 addition & 0 deletions messages/ruby/.gitignore
@@ -1,3 +1,4 @@
coverage/
Gemfile.lock
pkg/
.tested
17 changes: 3 additions & 14 deletions messages/ruby/Makefile
@@ -1,20 +1,9 @@
SHELL := /usr/bin/env bash
include default.mk

default: rspec
.PHONY: default

rspec: Gemfile.lock lib/cucumber/messages_pb.rb
rake
rake install
.PHONY: rspec
.deps: lib/cucumber/messages_pb.rb

lib/cucumber/messages_pb.rb: messages.proto
protoc --ruby_out lib/cucumber $<

clean:
rm -rf lib/cucumber/messages_pb.rb Gemfile.lock
.PHONY: clean

Gemfile.lock: Gemfile
bundle install
touch $@
rm -f lib/cucumber/messages_pb.rb
7 changes: 5 additions & 2 deletions messages/ruby/default.mk
Expand Up @@ -25,6 +25,9 @@ Gemfile.lock: Gemfile $(GEMSPECS)
bundle exec rspec --color
touch $@

clean:
rm -f .deps .linked .tested Gemfile.lock
clean: clean-ruby
.PHONY: clean

clean-ruby:
rm -f .deps .linked .tested Gemfile.lock
.PHONY: clean-ruby

0 comments on commit 288f80d

Please sign in to comment.