Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Commit

Permalink
Move thrift compilation to a script (#590)
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Jheng <wentworth@outlook.com>
  • Loading branch information
aaronjheng committed Aug 5, 2021
1 parent b29e5f0 commit a600bc4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
18 changes: 2 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down
32 changes: 32 additions & 0 deletions scripts/gen-thrift.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a600bc4

Please sign in to comment.