Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run the proto compiler in workunit. #4092

Merged
merged 3 commits into from Nov 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/python/pants/backend/codegen/tasks/BUILD
Expand Up @@ -81,6 +81,7 @@ python_library(
'src/python/pants/backend/jvm/tasks:jar_import_products',
'src/python/pants/base:build_environment',
'src/python/pants/base:exceptions',
'src/python/pants/base:workunit',
'src/python/pants/binaries:binary_util',
'src/python/pants/build_graph',
'src/python/pants/fs',
Expand Down
22 changes: 15 additions & 7 deletions src/python/pants/backend/codegen/tasks/protobuf_gen.py
Expand Up @@ -18,6 +18,7 @@
from pants.backend.jvm.tasks.jar_import_products import JarImportProducts
from pants.base.build_environment import get_buildroot
from pants.base.exceptions import TaskError
from pants.base.workunit import WorkUnitLabel
from pants.binaries.binary_util import BinaryUtil
from pants.build_graph.address import Address
from pants.fs.archive import ZIP
Expand Down Expand Up @@ -136,18 +137,25 @@ def execute_codegen(self, target, target_workdir):
protoc_environ['PATH'] = os.pathsep.join(self._extra_paths
+ protoc_environ['PATH'].split(os.pathsep))

# Note: The test_source_ordering integration test scrapes this output, so modify it with care.
self.context.log.debug('Executing: {0}'.format('\\\n '.join(args)))
process = subprocess.Popen(args, env=protoc_environ)
result = process.wait()
if result != 0:
raise TaskError('{0} ... exited non-zero ({1})'.format(self.protobuf_binary, result))
with self.context.new_workunit(name='protoc',
labels=[WorkUnitLabel.TOOL],
cmd=' '.join(args)) as workunit:
result = subprocess.call(args,
env=protoc_environ,
stdout=workunit.output('stdout'),
stderr=workunit.output('stderr'))
if result != 0:
raise TaskError('{} ... exited non-zero ({})'.format(self.protobuf_binary, result))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you are at it, do you think it would be more user friendly to show the command as well? e.g. https://github.com/wisechengyi/pants/blob/1e45167fab9a30f32207d025d91d2a071c8981fe/src/python/pants/backend/graph_info/tasks/cloc.py#L71-L71?


def _calculate_sources(self, target):
gentargets = OrderedSet()

def add_to_gentargets(target):
if self.is_gentarget(target):
gentargets.add(target)
def add_to_gentargets(tgt):
if self.is_gentarget(tgt):
gentargets.add(tgt)

self.context.build_graph.walk_transitive_dependency_graph(
[target.address],
add_to_gentargets,
Expand Down