Skip to content

Commit

Permalink
Update build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakhellesoy committed Jul 16, 2018
1 parent 288f80d commit e81dbb0
Show file tree
Hide file tree
Showing 37 changed files with 446 additions and 151 deletions.
1 change: 0 additions & 1 deletion .gitignore
@@ -1,6 +1,5 @@
# Java
.idea/
target/
dependency-reduced-pom.xml

# Node
Expand Down
29 changes: 28 additions & 1 deletion .templates/go/default.mk
Expand Up @@ -3,14 +3,41 @@ GOPATH := $(shell go env GOPATH)
GO_SOURCE_FILES = $(shell find . -name "*.go")

SUBREPO := $(shell cat .subrepo)
LIBNAME := $(shell cat .subrepo | cut -d'/' -f2)
GOX_LDFLAGS := "-X main.version=${TRAVIS_TAG}"
EXES := $(shell find dist -name '$(LIBNAME)-*')
UPX_EXES = $(patsubst dist/$(LIBNAME)-%,dist_compressed/$(LIBNAME)-%,$(EXES))
IN_GOPATH := $(shell [[ "$$(pwd)" == ${GOPATH}/* ]] && echo 1 || echo 0)
ifeq ($(IN_GOPATH), 0)
.deps: .linked
endif

ifneq (,$(wildcard ./cli))
default: .dist
endif

default: .tested
.PHONY: default

.dist: .deps
mkdir -p dist
gox -ldflags $(GOX_LDFLAGS) -output "dist/$(LIBNAME)-{{.OS}}-{{.Arch}}" -rebuild ./cli
touch $@

dist/$(LIBNAME)-%: .dist

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

dist_compressed/$(LIBNAME)-%: dist/$(LIBNAME)-%
mkdir -p dist_compressed
# requires upx in PATH to compress supported binaries
# may produce an error ARCH not supported
-upx $< -o $@

# Test the integrity
if [ -f "$@" ]; then upx -t $@ || rm $@; fi

# Symlink this dir to GOPATH
.linked:
mkdir -p $$(dirname ${GOPATH}/src/github.com/${SUBREPO})
Expand All @@ -33,5 +60,5 @@ clean: clean-go
.PHONY: clean

clean-go:
rm -f .deps .linked .tested
rm -rf .deps .linked .tested dist/* dist_compressed
.PHONY: clean-go
26 changes: 26 additions & 0 deletions .templates/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 .deps .tested
.PHONY: clean-java
21 changes: 15 additions & 6 deletions .templates/s3-download
Expand Up @@ -3,6 +3,9 @@
# Downloads cross-compiled go executables for bundling inside platform-
# specific packages such as gem, jar, npm module etc.
#
# If the files are available locally, they are copied. If not, they
# are downloaded from S3.
#
set -euf -o pipefail

basename=$1
Expand Down Expand Up @@ -35,10 +38,16 @@ for platform in \
windows-386.exe \
windows-amd64.exe
do
# cURL occasionaly fails. Try up to 3 times with a 5 sec sleep in-betweeen.
for i in 1 2 3; do
url="${baseurl}/${basename}/${version}/${basename}-${platform}"
file="${basename}/${basename}-${platform}"
curl "${url}" -o "${file}" && chmod +x "${file}" && break || sleep 5;
done
src_url="${baseurl}/${basename}/${version}/${basename}-${platform}"
src_file="../go/dist/${basename}-${platform}"
file="${basename}/${basename}-${platform}"

if [ -e ${src_file} ]; then
cp ${src_file} ${file}
else
# cURL occasionaly fails. Try up to 3 times with a 5 sec sleep in-betweeen.
for i in 1 2 3; do
curl "${src_url}" -o "${file}" && chmod +x "${file}" && break || sleep 5;
done
fi
done
2 changes: 2 additions & 0 deletions config/java/.gitignore
Expand Up @@ -3,3 +3,5 @@
target/
release.properties
pom.xml.releaseBackup
.deps
.tested
12 changes: 3 additions & 9 deletions config/java/Makefile
@@ -1,10 +1,4 @@
default: .built
.PHONY: default
include default.mk

.built: pom.xml
mvn install
touch $@

clean:
rm -rf target .built
.PHONY: clean
.deps:
touch $@
26 changes: 26 additions & 0 deletions config/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 .deps .tested
.PHONY: clean-java
29 changes: 28 additions & 1 deletion cucumber-expressions/go/default.mk
Expand Up @@ -3,14 +3,41 @@ GOPATH := $(shell go env GOPATH)
GO_SOURCE_FILES = $(shell find . -name "*.go")

SUBREPO := $(shell cat .subrepo)
LIBNAME := $(shell cat .subrepo | cut -d'/' -f2)
GOX_LDFLAGS := "-X main.version=${TRAVIS_TAG}"
EXES := $(shell find dist -name '$(LIBNAME)-*')
UPX_EXES = $(patsubst dist/$(LIBNAME)-%,dist_compressed/$(LIBNAME)-%,$(EXES))
IN_GOPATH := $(shell [[ "$$(pwd)" == ${GOPATH}/* ]] && echo 1 || echo 0)
ifeq ($(IN_GOPATH), 0)
.deps: .linked
endif

ifneq (,$(wildcard ./cli))
default: .dist
endif

default: .tested
.PHONY: default

.dist: .deps
mkdir -p dist
gox -ldflags $(GOX_LDFLAGS) -output "dist/$(LIBNAME)-{{.OS}}-{{.Arch}}" -rebuild ./cli
touch $@

dist/$(LIBNAME)-%: .dist

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

dist_compressed/$(LIBNAME)-%: dist/$(LIBNAME)-%
mkdir -p dist_compressed
# requires upx in PATH to compress supported binaries
# may produce an error ARCH not supported
-upx $< -o $@

# Test the integrity
if [ -f "$@" ]; then upx -t $@ || rm $@; fi

# Symlink this dir to GOPATH
.linked:
mkdir -p $$(dirname ${GOPATH}/src/github.com/${SUBREPO})
Expand All @@ -33,5 +60,5 @@ clean: clean-go
.PHONY: clean

clean-go:
rm -f .deps .linked .tested
rm -rf .deps .linked .tested dist/* dist_compressed
.PHONY: clean-go
2 changes: 2 additions & 0 deletions cucumber-expressions/java/.gitignore
Expand Up @@ -3,3 +3,5 @@
target/
release.properties
pom.xml.releaseBackup
.deps
.tested
12 changes: 3 additions & 9 deletions cucumber-expressions/java/Makefile
@@ -1,10 +1,4 @@
default: .built
.PHONY: default
include default.mk

.built: pom.xml
mvn install
touch $@

clean:
rm -rf target .built
.PHONY: clean
.deps:
touch $@
26 changes: 26 additions & 0 deletions cucumber-expressions/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 .deps .tested
.PHONY: clean-java
1 change: 1 addition & 0 deletions cucumber-expressions/ruby/.gitignore
@@ -1,3 +1,4 @@
coverage/
Gemfile.lock
pkg/
.tested
6 changes: 5 additions & 1 deletion datatable/java/.gitignore
@@ -1,3 +1,7 @@
.idea/
*.iml
target/
dependency-reduced-pom.xml
release.properties
pom.xml.releaseBackup
.deps
.tested
12 changes: 3 additions & 9 deletions datatable/java/Makefile
@@ -1,10 +1,4 @@
default: .built
.PHONY: default
include default.mk

.built: pom.xml
mvn install
touch $@

clean:
rm -rf target .built
.PHONY: clean
.deps:
touch $@
26 changes: 26 additions & 0 deletions datatable/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 .deps .tested
.PHONY: clean-java
30 changes: 0 additions & 30 deletions dots-formatter/go/Makefile
@@ -1,10 +1,5 @@
include default.mk

EXES := $(shell find dist -name 'dots-formatter-go-*')
UPX_EXES = $(patsubst dist/dots-formatter-go-%,dist_compressed/dots-formatter-go-%,$(EXES))

default: bin/dots-formatter

.deps:
go get github.com/fatih/color
go get github.com/gogo/protobuf/io
Expand All @@ -14,28 +9,3 @@ default: bin/dots-formatter
# https://github.com/mitchellh/gox/pull/112
go get github.com/aslakhellesoy/gox
touch $@

.dist: .deps
mkdir -p dist
gox -ldflags "-X main.version=${CIRCLE_TAG}" -output "dist/dots-formatter-go-{{.OS}}-{{.Arch}}" -rebuild ./cli
touch $@

dist/dots-formatter-go-%: .dist

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

dist_compressed/dots-formatter-go-%: dist/dots-formatter-go-%
mkdir -p dist_compressed
# requires upx in PATH to compress supported binaries
# may produce an error ARCH not supported
-upx $< -o $@

# Test the integrity
if [ -f "$@" ]; then upx -t $@ || rm $@; fi

bin/dots-formatter: .deps $(GO_SOURCE_FILES)
go build -o $@ ./cli

clean:
rm -rf bin/dots-formatter dist/* dist_compressed

0 comments on commit e81dbb0

Please sign in to comment.