diff --git a/.travis.yml b/.travis.yml index 6fcbc34..efbd34c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: go go: - - 1.5 + - 1.7.1 addons: apt: @@ -13,20 +13,26 @@ addons: - libclang1-3.4 - libclang-3.4-dev +env: + global: + - CC=clang CXX=clang++ + # Coveralls.io + - secure: "pMyHrYdVIexMTlzQJj9lH6OJWEOSjeAg1qlq2BWndzTZgQ7etsokg3B6z7Lafpyt9bMFPt6ZIMwmSe5K4wa9UiGvroadjlHqNwl298Xa5P3ixbZYMtCNWHMz4y/FluzZPNOSKMpdXUcqF+pOPlmaxEh8Me3vvGTaQcNGXiqC1h//FDJNrtuBNymOkTRV7Us5bnVgwgXOrwSdVoOe4MvLcTeCOYn/iXCSjI+bZDdx3t3M3os5l2dbgW1xWSPlYojnHK3etByHNwJyK+LzVOY0TCbQCyxRQwtURmI+f9Ljgws9lEPbv7GCINi2y9RWxNydRHlxmoS/fsj1aWAPtmsVIVZpHE9wrXeY3zcCeQ7tYC8qI7JFba/IWnqplq5Z6Y3y998d1JzoSF4FZc6f34rEfMZEZOdk2PwqUzosB9lBGw/n3hOC6meth3SkqhZfW7QC1vM8EvsvOxdXQpsDluTX8DOace50YM3HTiSYls2KpNwXxSzAqVu46CZiqsbkQHjAXa2fdgmJzFpgRaXU3Ln8GOU4aVDI+2wJCR/XBTDHl32jR3uHlAdLPLpYpALm9ZcgzzDXRDFq5zUnKhEgau1HIOLeKL6HdVGD1x5W+/FP8PTtblgLkCMTctOQt+49Go9fk6DqI4Rv95tbUAnF+NXU/Zd4TA1eroG/wpuRIj2/e/E=" + install: - mkdir -p /home/travis/bin + - sudo ln -s /usr/bin/clang-3.4 /home/travis/bin/clang - sudo ln -s /usr/bin/llvm-config-3.4 /home/travis/bin/llvm-config - sudo ldconfig - llvm-config --version - llvm-config --includedir - llvm-config --libdir + - clang --version - make install-dependencies - make install-tools - - CGO_LDFLAGS="-L`llvm-config --libdir`" go get -u github.com/go-clang/bootstrap/... - script: # Install the project - make install @@ -35,10 +41,8 @@ script: - make lint # Do tests and code coverage - - ginkgo -r -cover -skipPackage="testdata" + - make test-full + + - ginkgo -cover -skipPackage="testdata" - gover - if [ "$TRAVIS_SECURE_ENV_VARS" = "true" ]; then goveralls -coverprofile=gover.coverprofile -service=travis-ci -repotoken $COVERALLS_TOKEN; fi - -env: - # Coveralls.io - secure: "pMyHrYdVIexMTlzQJj9lH6OJWEOSjeAg1qlq2BWndzTZgQ7etsokg3B6z7Lafpyt9bMFPt6ZIMwmSe5K4wa9UiGvroadjlHqNwl298Xa5P3ixbZYMtCNWHMz4y/FluzZPNOSKMpdXUcqF+pOPlmaxEh8Me3vvGTaQcNGXiqC1h//FDJNrtuBNymOkTRV7Us5bnVgwgXOrwSdVoOe4MvLcTeCOYn/iXCSjI+bZDdx3t3M3os5l2dbgW1xWSPlYojnHK3etByHNwJyK+LzVOY0TCbQCyxRQwtURmI+f9Ljgws9lEPbv7GCINi2y9RWxNydRHlxmoS/fsj1aWAPtmsVIVZpHE9wrXeY3zcCeQ7tYC8qI7JFba/IWnqplq5Z6Y3y998d1JzoSF4FZc6f34rEfMZEZOdk2PwqUzosB9lBGw/n3hOC6meth3SkqhZfW7QC1vM8EvsvOxdXQpsDluTX8DOace50YM3HTiSYls2KpNwXxSzAqVu46CZiqsbkQHjAXa2fdgmJzFpgRaXU3Ln8GOU4aVDI+2wJCR/XBTDHl32jR3uHlAdLPLpYpALm9ZcgzzDXRDFq5zUnKhEgau1HIOLeKL6HdVGD1x5W+/FP8PTtblgLkCMTctOQt+49Go9fk6DqI4Rv95tbUAnF+NXU/Zd4TA1eroG/wpuRIj2/e/E=" diff --git a/Makefile b/Makefile index d396d69..5f37fe7 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,9 @@ -.PHONY: all install install-dependencies install-tools lint test test-verbose +.PHONY: all install install-dependencies install-tools lint test test-full test-verbose -ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) -export ROOT_DIR +export ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) + +export CC := clang +export CXX := clang++ ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) $(eval $(ARGS):;@:) # turn arguments into do-nothing targets @@ -15,6 +17,8 @@ install-dependencies: go get -u golang.org/x/tools/imports/... go get -u github.com/stretchr/testify/... go get -u github.com/termie/go-shutil/... + + CGO_LDFLAGS="-L`llvm-config --libdir`" go get -u github.com/go-clang/bootstrap/... install-tools: # Install linting tools go get -u github.com/golang/lint/... @@ -26,8 +30,10 @@ install-tools: go get -u github.com/modocache/gover/... go get -u github.com/mattn/goveralls/... lint: install - scripts/lint.sh + $(ROOT_DIR)/scripts/lint.sh test: - CGO_LDFLAGS="-L`llvm-config --libdir`" go test -timeout 60s -race ./... + CGO_LDFLAGS="-L`llvm-config --libdir`" go test -timeout 60s ./... +test-full: + $(ROOT_DIR)/scripts/test-full.sh test-verbose: - CGO_LDFLAGS="-L`llvm-config --libdir`" go test -timeout 60s -race -v ./... + CGO_LDFLAGS="-L`llvm-config --libdir`" go test -timeout 60s -v ./... diff --git a/scripts/generate-and-test.sh b/scripts/generate-and-test.sh index 6b9adfa..06fedf9 100755 --- a/scripts/generate-and-test.sh +++ b/scripts/generate-and-test.sh @@ -12,7 +12,7 @@ export LLVM_VERSION=$1 cd $GOPATH/src/github.com/go-clang/v${LLVM_VERSION}/clang/ rm -rf clang-c/ -rm *_gen.go +rm -f *_gen.go go-clang-gen diff --git a/scripts/switch-clang-version.sh b/scripts/switch-clang-version.sh index 4e2e78e..5269202 100755 --- a/scripts/switch-clang-version.sh +++ b/scripts/switch-clang-version.sh @@ -13,6 +13,9 @@ export LLVM_VERSION=$1 sudo add-apt-repository --enable-source "deb http://llvm.org/apt/${CODENAME}/ llvm-toolchain-${CODENAME}-${LLVM_VERSION} main" sudo apt-get update -sudo rm /usr/bin/llvm-config +sudo rm -f /usr/bin/clang +sudo rm -f /usr/bin/llvm-config sudo apt-get install -y clang-$LLVM_VERSION libclang1-$LLVM_VERSION libclang-$LLVM_VERSION-dev llvm-$LLVM_VERSION llvm-$LLVM_VERSION-dev llvm-$LLVM_VERSION-runtime libclang-common-$LLVM_VERSION-dev +sudo ln -s /usr/bin/clang-$LLVM_VERSION /usr/bin/clang sudo ln -s /usr/bin/llvm-config-$LLVM_VERSION /usr/bin/llvm-config +sudo ldconfig diff --git a/scripts/test-full.sh b/scripts/test-full.sh new file mode 100755 index 0000000..6f6acd6 --- /dev/null +++ b/scripts/test-full.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -exuo pipefail + +LLVM_VERSION=$(clang --version | grep --max-count=1 "clang version" | sed -r 's/^.*clang version ([0-9]+\.[0-9]+).+$/\1/') + +# Test with the race detector +CGO_LDFLAGS="-L`llvm-config --libdir`" go test -timeout 60s -v -race ./... + +# Test with the address sanitizer +# TODO there is maybe a problem within clang https://github.com/go-clang/gen/issues/123 +# if [ $(echo "$LLVM_VERSION>=3.9" | bc -l) -ne 0 ] && [ $(find `llvm-config --libdir` | grep libclang_rt.san-x86_64.a | wc -l) -ne 0 ]; then CGO_LDFLAGS="-L`llvm-config --libdir` -fsanitize=memory" CGO_CPPFLAGS='-fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer' go test -timeout 60s -v -msan ./...; fi diff --git a/scripts/update-bootstrap.sh b/scripts/update-bootstrap.sh index 0c35acc..a60d1d5 100755 --- a/scripts/update-bootstrap.sh +++ b/scripts/update-bootstrap.sh @@ -12,7 +12,7 @@ make -C $GOPATH/src/github.com/go-clang/gen install cd $GOPATH/src/github.com/go-clang/bootstrap/clang/ rm -rf clang-c/ -rm *_gen.go +rm -f *_gen.go go-clang-gen diff --git a/scripts/vagrant-environment.sh b/scripts/vagrant-environment.sh index 0869feb..d7156d9 100755 --- a/scripts/vagrant-environment.sh +++ b/scripts/vagrant-environment.sh @@ -2,7 +2,7 @@ set -exuo pipefail -export GO_VERSION=1.5.3 +export GO_VERSION=1.7.1 # Install Go mkdir -p $HOME/go