Skip to content

Commit

Permalink
add extra rsc args (pantsbuild#7863)
Browse files Browse the repository at this point in the history
### Problem

While we can currently pass zinc extra arguments with `--args` and passthrough args, there's no equivalent for arguments to rsc. Additionally, rsc's output is hidden unless it fails.

### Solution

- Add `--extra-rsc-args` option (named to avoid clashing with any other options).
- Convert the rsc invocation to use `WorkUnitLabel.COMPILER` in order to view its output upon success (allowing rsc to e.g. print timings).

### Result

Rsc args can be added by setting an option, without pants changes!
  • Loading branch information
cosmicexplorer authored Jun 7, 2019
1 parent 1c749f7 commit 94ed8bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/python/pants/backend/jvm/tasks/jvm_compile/jvm_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,9 @@ def should_compile_incrementally(self, vts, ctx):

def _record_target_stats(self, target, classpath_len, sources_len, compiletime, is_incremental,
stats_key):
# TODO: classpath_len doesn't *really* capture what we're looking for -- the cumulative size of
# classpath files might be, though. Capturing the digest of the input classpath might give us
# that, though (as well as the source files?).
def record(k, v):
self.context.run_tracker.report_target_info(self.options_scope, target, [stats_key, k], v)
record('time', compiletime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ def register_options(cls, register):
default=cls.JvmCompileWorkflowType.rsc_and_zinc, metavar='<workflow>',
help='The workflow to use to compile JVM targets.')

register('--extra-rsc-args', type=list, default=[],
help='Extra arguments to pass to the rsc invocation.')

cls.register_jvm_tool(
register,
'rsc',
Expand Down Expand Up @@ -378,7 +381,7 @@ def nonhermetic_digest_classpath():
args = [
'-cp', os.pathsep.join(classpath_entry_paths),
'-d', rsc_jar_file_relative_path,
] + target_sources
] + self.get_options().extra_rsc_args + target_sources

self.write_argsfile(ctx, args)

Expand Down Expand Up @@ -618,7 +621,7 @@ def _runtool_hermetic(self, main, tool_name, distribution, input_digest, ctx):
res = self.context.execute_process_synchronously_without_raising(
epr,
self.name(),
[WorkUnitLabel.TOOL])
[WorkUnitLabel.COMPILER])

if res.exit_code != 0:
raise TaskError(res.stderr, exit_code=res.exit_code)
Expand All @@ -645,7 +648,7 @@ def _runtool_nonhermetic(self, parent_workunit, classpath, main, tool_name, dist
jvm_options=self.get_options().jvm_options,
args=['@{}'.format(ctx.args_file)],
workunit_name=tool_name,
workunit_labels=[WorkUnitLabel.TOOL],
workunit_labels=[WorkUnitLabel.COMPILER],
dist=distribution
)
if result != 0:
Expand Down

0 comments on commit 94ed8bf

Please sign in to comment.