Skip to content

Commit

Permalink
Compile thrift into dot-dir .thrift-gen-polyglot (#140)
Browse files Browse the repository at this point in the history
Similar to Proto

Signed-off-by: Yuri Shkuro <github@ysh.us>
  • Loading branch information
yurishkuro authored Jan 31, 2025
1 parent b6fbe1a commit 86b800d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
.idea/
gen-*/
.fmt.log
.import.log
.proto-gen-polyglot/
.thrift-gen-polyglot/
.scripts/
.tools/
coverage.txt

10 changes: 4 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ THRIFT_PY_ARGS=new_style,tornado
THRIFT_JAVA_ARGS=private-members
THRIFT_PHP_ARGS=psr4

THRIFT_GEN=--gen lua --gen go:$(THRIFT_GO_ARGS) --gen py:$(THRIFT_PY_ARGS) --gen java:$(THRIFT_JAVA_ARGS) --gen js:node --gen cpp --gen php:$(THRIFT_PHP_ARGS)
THRIFT_CMD=$(THRIFT) -o /data $(THRIFT_GEN)

THRIFT_FILES=agent.thrift jaeger.thrift sampling.thrift zipkincore.thrift crossdock/tracetest.thrift \
baggage.thrift dependency.thrift aggregation_validator.thrift
THRIFT_GEN_DIR=thrift-gen
Expand Down Expand Up @@ -66,7 +63,6 @@ swagger-validate:

.PHONY: clean
clean:
rm -rf *gen-* || true
rm -rf .*gen-* || true
rm -rf coverage.txt

Expand All @@ -84,9 +80,11 @@ thrift:
.PHONY: thrift-all
thrift-all: thrift-image clean $(THRIFT_FILES)

THRIFT_GEN_ARGS=--gen lua --gen go:$(THRIFT_GO_ARGS) --gen py:$(THRIFT_PY_ARGS) --gen java:$(THRIFT_JAVA_ARGS) --gen js:node --gen cpp --gen php:$(THRIFT_PHP_ARGS)
$(THRIFT_FILES):
@echo Compiling $@
$(THRIFT_CMD) /data/thrift/$@
@mkdir -p .thrift-gen-polyglot
$(THRIFT) -o /data/.thrift-gen-polyglot $(THRIFT_GEN_ARGS) /data/thrift/$@

.PHONY: thrift-image
thrift-image:
Expand Down Expand Up @@ -213,7 +211,7 @@ lint-license: setup-lint-scripts
@[ -s "$(FMT_LOG)" ] || echo "✅ All files have license headers"


.PHONY: lint-nocommit
.PHONY: lint-nocommit
lint-nocommit:
@if git diff origin/main | grep '@no''commit' ; then \
echo "❌ Cannot merge PR that contains @no""commit string" ; \
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ As of Jan 2025 this repository also hosts Go code:

## Generating code

This repository does not publish the generated code, but it does run Thrift and `protoc` generators as part of the CI to verify all IDL files. See the [Makefile](./Makefile) for example. In particular, the classes for different languages can be compiled using the `jaegertracing/protobuf` Docker image (see [README](https://github.com/jaegertracing/docker-protobuf/blob/master/README.md)).
This repository only include Go code for some of the Thrift and Protobuf modules. It also runs Thrift and `protoc` generators as part of the CI to verify all IDL files. See the [Makefile](./Makefile) for example. In particular, the classes for different languages can be compiled using the `jaegertracing/protobuf` Docker image (see [README](https://github.com/jaegertracing/docker-protobuf/blob/master/README.md)).

To generate the stubs for your own purposes:
* clone the repository
* run `make proto-all` or `make thrift-all`
* the stubs will be generated under `gen-{lang}` for Thrift and `proto-gen-{lang}` for Protobuf
* the stubs will be generated under `.thrift-gen-polyglot/gen-{lang}` for Thrift and `.proto-gen-polyglot/{lang}` for Protobuf


## Compatibility
Expand All @@ -32,7 +32,7 @@ The Jaeger repositories that use these IDL files usually import this repository
See [CONTRIBUTING](./CONTRIBUTING.md).

## License

[Apache 2.0 License](./LICENSE).


Expand Down

0 comments on commit 86b800d

Please sign in to comment.