Skip to content

Commit

Permalink
Fix rpc style in compiler_args check. (#4730)
Browse files Browse the repository at this point in the history
### Problem

While trying to test the pants build at Twitter, I realized that the compiler_args_has_rpc_style method was broken because the compiler args will have double dash in front e.g. --finagle whereas values in _RPC_STYLES don't. This results in scrooge generation failing if both compiler_args and rpc_style specify rpc style.

### Solution

Fixed the check.

### Result

Setting compiler args to --finagle in java_thrift_libraries pants targets now succeeds even if rpc_style is defined.
  • Loading branch information
pankajroark authored and Stu Hood committed Jul 10, 2017
1 parent d4959df commit b1746b9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def execute_codegen(self, target, target_workdir):
self._must_have_sources(target)

def compiler_args_has_rpc_style(compiler_args):
return bool(_RPC_STYLES & set(compiler_args))
return "--finagle" in compiler_args or "--ostrich" in compiler_args

def merge_rpc_style_with_compiler_args(compiler_args, rpc_style):
new_compiler_args = list(compiler_args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ def test_good(self):
pants_run = self.run_pants(cmd)
self.assert_success(pants_run)

def test_both_compiler_args_and_rpc_style(self):
# scrooge_gen should pass when both compiler_args and rpc_style are specified
cmd = ['gen', self.thrift_test_target('both-compiler-args-and-rpc-style')]
pants_run = self.run_pants(cmd)
self.assert_success(pants_run)

def test_namespace_map(self):
# scrooge_gen should pass with namespace_map specified
cmd = ['gen', self.thrift_test_target('namespace-map-thrift')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,12 @@ java_thrift_library(
'some_dir',
],
)

java_thrift_library(
name = 'both-compiler-args-and-rpc-style',
sources = ['good.thrift'],
compiler='scrooge',
language='scala',
compiler_args=['--finagle'],
rpc_style='finagle',
)

0 comments on commit b1746b9

Please sign in to comment.