diff --git a/Makefile b/Makefile index bb7463cf..ee7b2126 100644 --- a/Makefile +++ b/Makefile @@ -21,9 +21,7 @@ LINT_LOG=lint.log THRIFT_VER=0.14 THRIFT_IMG=jaegertracing/thrift:$(THRIFT_VER) -THRIFT=docker run -v "${PWD}:/data" $(THRIFT_IMG) thrift -THRIFT_GO_ARGS=thrift_import="github.com/apache/thrift/lib/go/thrift" -THRIFT_GEN_DIR=thrift-gen +THRIFT=docker run -v "${PWD}:/data" -u ${shell id -u}:${shell id -g} $(THRIFT_IMG) thrift PASS=$(shell printf "\033[32mPASS\033[0m") FAIL=$(shell printf "\033[31mFAIL\033[0m") @@ -105,19 +103,7 @@ thrift: idl-submodule thrift-compile # TODO at the moment we're not generating tchan_*.go files .PHONY: thrift-compile thrift-compile: thrift-image - $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/agent.thrift - $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/sampling.thrift - $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/jaeger.thrift - $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/zipkincore.thrift - $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/$(THRIFT_GEN_DIR) /data/idl/thrift/baggage.thrift - $(THRIFT) -o /data --gen go:$(THRIFT_GO_ARGS) --out /data/crossdock/thrift/ /data/idl/thrift/crossdock/tracetest.thrift - sed -i '' 's|"zipkincore"|"$(PROJECT_ROOT)/thrift-gen/zipkincore"|g' $(THRIFT_GEN_DIR)/agent/*.go - sed -i '' 's|"jaeger"|"$(PROJECT_ROOT)/thrift-gen/jaeger"|g' $(THRIFT_GEN_DIR)/agent/*.go - sed -i '' 's|"github.com/apache/thrift/lib/go/thrift"|"github.com/uber/jaeger-client-go/thrift"|g' \ - $(THRIFT_GEN_DIR)/*/*.go crossdock/thrift/tracetest/*.go - rm -rf thrift-gen/*/*-remote - rm -rf crossdock/thrift/*/*-remote - rm -rf thrift-gen/jaeger/collector.go + docker run -v "${PWD}:/data" -u ${shell id -u}:${shell id -g} $(THRIFT_IMG) /data/scripts/gen-thrift.sh .PHONY: idl-submodule idl-submodule: diff --git a/scripts/gen-thrift.sh b/scripts/gen-thrift.sh new file mode 100755 index 00000000..e80ecef7 --- /dev/null +++ b/scripts/gen-thrift.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -e + +PROJECT_ROOT="$( + cd "$(dirname "$0")/.." + pwd +)" + +IMPORT_PATH=github.com/uber/jaeger-client-go +THRIFT_GEN_DIR=thrift-gen +THRIFT_GO_ARGS=thrift_import="github.com/apache/thrift/lib/go/thrift" + +pushd $PROJECT_ROOT 1>/dev/null + +thrift -o ./ --gen go:${THRIFT_GO_ARGS} --out ${THRIFT_GEN_DIR} idl/thrift/agent.thrift +thrift -o ./ --gen go:${THRIFT_GO_ARGS} --out ${THRIFT_GEN_DIR} idl/thrift/sampling.thrift +thrift -o ./ --gen go:${THRIFT_GO_ARGS} --out ${THRIFT_GEN_DIR} idl/thrift/jaeger.thrift +thrift -o ./ --gen go:${THRIFT_GO_ARGS} --out ${THRIFT_GEN_DIR} idl/thrift/zipkincore.thrift +thrift -o ./ --gen go:${THRIFT_GO_ARGS} --out ${THRIFT_GEN_DIR} idl/thrift/baggage.thrift +thrift -o ./ --gen go:${THRIFT_GO_ARGS} --out crossdock/thrift/ idl/thrift/crossdock/tracetest.thrift + +sed -i 's|"zipkincore"|"'${IMPORT_PATH}'/thrift-gen/zipkincore"|g' ${THRIFT_GEN_DIR}/agent/*.go +sed -i 's|"jaeger"|"'${IMPORT_PATH}'/thrift-gen/jaeger"|g' ${THRIFT_GEN_DIR}/agent/*.go +sed -i 's|"github.com/apache/thrift/lib/go/thrift"|"github.com/uber/jaeger-client-go/thrift"|g' \ + ${THRIFT_GEN_DIR}/*/*.go crossdock/thrift/tracetest/*.go + +rm -rf thrift-gen/*/*-remote +rm -rf crossdock/thrift/*/*-remote +rm -rf thrift-gen/jaeger/collector.go + +popd 1>/dev/null