THRIFT-5583: Add skip_remote arg to go compiler

Client: go
This commit is contained in:
Yuxuan 'fishy' Wang 2022-05-09 11:05:11 -07:00 committed by Yuxuan 'fishy' Wang
parent a24bcd39a5
commit dae1437ca0
3 changed files with 17 additions and 4 deletions

View File

@ -5,6 +5,7 @@
### Go
- [THRIFT-5539](https://issues.apache.org/jira/browse/THRIFT-5539) - `TDebugProtocol.DuplicateTo` is now deprecated, `TDuplicateToProtocol` has been provided as the replacement
- [THRIFT-5583](https://issues.apache.org/jira/browse/THRIFT-5583) - Add `skip_remote` arg to compiler, which can be used to skip the generating of -remote folders for services
## 0.16.0

View File

@ -83,6 +83,7 @@ public:
package_flag = "";
read_write_private_ = false;
ignore_initialisms_ = false;
skip_remote_ = false;
for( iter = parsed_options.begin(); iter != parsed_options.end(); ++iter) {
if( iter->first.compare("package_prefix") == 0) {
gen_package_prefix_ = (iter->second);
@ -94,6 +95,8 @@ public:
read_write_private_ = true;
} else if( iter->first.compare("ignore_initialisms") == 0) {
ignore_initialisms_ = true;
} else if( iter->first.compare("skip_remote") == 0) {
skip_remote_ = true;
} else {
throw "unknown option go:" + iter->first;
}
@ -297,6 +300,7 @@ private:
std::string gen_thrift_import_;
bool read_write_private_;
bool ignore_initialisms_;
bool skip_remote_;
/**
* File streams
@ -2015,7 +2019,9 @@ void t_go_generator::generate_service(t_service* tservice) {
generate_service_client(tservice);
generate_service_server(tservice);
generate_service_helpers(tservice);
if(!skip_remote_) {
generate_service_remote(tservice);
}
f_types_ << endl;
}
@ -4267,4 +4273,6 @@ THRIFT_REGISTER_GENERATOR(go, "Go",
" ignore_initialisms\n"
" Disable automatic spelling correction of initialisms (e.g. \"URL\")\n" \
" read_write_private\n"
" Make read/write methods private, default is public Read/Write\n")
" Make read/write methods private, default is public Read/Write\n"
" skip_remote\n"
" Skip the generating of -remote folders for the client binaries for services\n")

View File

@ -23,9 +23,13 @@ else
GOBUILDEXTRA =
endif
THRIFTARGS = -out gopath/src/ --gen go:thrift_import=github.com/apache/thrift/lib/go/thrift,package_prefix=github.com/apache/thrift/lib/go/test/gopath/src/$(COMPILER_EXTRAFLAG)
THRIFT_GO_ARGS_BASE = thrift_import=github.com/apache/thrift/lib/go/thrift,package_prefix=github.com/apache/thrift/lib/go/test/gopath/src/
THRIFTARGS = -out gopath/src/ --gen go:$(THRIFT_GO_ARGS_BASE)$(COMPILER_EXTRAFLAG)
THRIFTTEST = $(top_srcdir)/test/ThriftTest.thrift
THRIFTARGS_SKIP_REMOTE = -out gopath/src/ --gen go:skip_remote,$(THRIFT_GO_ARGS_BASE)$(COMPILER_EXTRAFLAG)
# Thrift for GO has problems with complex map keys: THRIFT-2063
gopath: $(THRIFT) $(THRIFTTEST) \
IncludesTest.thrift \
@ -91,7 +95,7 @@ gopath: $(THRIFT) $(THRIFTTEST) \
$(THRIFT) $(THRIFTARGS) EqualsTest.thrift
$(THRIFT) $(THRIFTARGS) ConflictArgNamesTest.thrift
$(THRIFT) $(THRIFTARGS) -r ConstOptionalField.thrift
$(THRIFT) $(THRIFTARGS) ProcessorMiddlewareTest.thrift
$(THRIFT) $(THRIFTARGS_SKIP_REMOTE) ProcessorMiddlewareTest.thrift
ln -nfs ../../tests gopath/src/tests
cp -r ./dontexportrwtest gopath/src
touch gopath