Skip to content

Commit

Permalink
Add tags and scope attribute passthrough to ScroogeGen (pantsbuild#8599)
Browse files Browse the repository at this point in the history
### Problem

`ScroogeGen` overrides the default `_copy_target_attributes` property from
`SimpleCodegenTask`, removing the `tags` and `scope` passthroughs and adding
`strict_deps`. Removing these properties may prevent easy implementation of
certain solutions, such as adding `use-compiler:rsc-and-zinc` tags to Scala
thrift library targets.

### Solution

`ScroogeGen._copy_target_attributes` will not remove any attributes from the
default list, and only add `strict_deps`.

### Result

Users would be able to pass along attributes such as
`tags = {"use-compiler:rsc-and-zinc"}` to generated thrift targets.
  • Loading branch information
wiwa authored and stuhood committed Nov 11, 2019
1 parent 345aa07 commit 744f6e0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,4 @@ def _resolved_export_info(self):

@property
def _copy_target_attributes(self):
return ['provides', 'strict_deps']
return super()._copy_target_attributes + ['strict_deps']
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def _test_create_build_str(self, language, compiler_args):
language='{language}',
compiler_args={compiler_args},
strict_deps=True,
tags=['my_tag'],
)
'''.format(language=language, compiler_args=compiler_args_str))

Expand Down Expand Up @@ -130,6 +131,7 @@ def _test_help(self, language, library_type, compiler_args, sources):
self.assertEqual(call_kwargs['provides'], None)
self.assertEqual(call_kwargs['derived_from'], target)
self.assertEqual(call_kwargs['strict_deps'], True)
self.assertEqual(call_kwargs['tags'], {'my_tag'})

sources = call_kwargs['sources']
self.assertEqual(sources.files, ())
Expand Down

0 comments on commit 744f6e0

Please sign in to comment.