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

[rsc-compile] support explicit tagging of targets in rsc compile #7362

Merged
merged 14 commits into from Mar 16, 2019

use hyphens

  • Loading branch information...
baroquebobcat committed Mar 14, 2019
commit 0c01351bc17d0b9d641e36b4c1517516400b01c0
@@ -89,7 +89,7 @@ def add_for_target(self, *args, **kwargs):
product.add_for_target(*args, **kwargs)


class _JvmCompileWorkflowType(enum(['zinc_only', 'rsc_then_zinc'])):
class _JvmCompileWorkflowType(enum(['zinc-only', 'rsc-then-zinc'])):
"""Target classifications used to correctly schedule Zinc and Rsc jobs.
There are some limitations we have to work around before we can compile everything through Rsc
@@ -103,10 +103,10 @@ class _JvmCompileWorkflowType(enum(['zinc_only', 'rsc_then_zinc'])):
As we work on improving our Rsc integration, we'll need to create more workflows to more closely
map the supported features of Rsc. This enum class allows us to do that.
- zinc_only: compiles targets just with Zinc and uses the Zinc products of their dependencies.
- rsc_then_zinc: compiles targets with Rsc to create "header" jars, then runs Zinc against the
- zinc-only: compiles targets just with Zinc and uses the Zinc products of their dependencies.
- rsc-then-zinc: compiles targets with Rsc to create "header" jars, then runs Zinc against the
Rsc products of their dependencies. The Rsc compile uses the Rsc products of Rsc compatible
targets and the Zinc products of zinc_only targets.
targets and the Zinc products of zinc-only targets.
"""

@classmethod
@@ -230,8 +230,8 @@ def confify(entries):
rsc_cc, compile_cc = compile_contexts[target]
if rsc_cc.workflow is not None:
cp_entries = rsc_cc.workflow.resolve_for_enum_variant({
'zinc_only': lambda : confify([compile_cc.jar_file]),
'rsc_then_zinc': lambda : confify(
'zinc-only': lambda : confify([compile_cc.jar_file]),
'rsc-then-zinc': lambda : confify(
to_classpath_entries([rsc_cc.rsc_jar_file], self.context._scheduler)),
})()
self.context.products.get_data('rsc_classpath').add_for_target(
@@ -262,17 +262,17 @@ def _classify_compile_target(self, target):
def _key_for_target_as_dep(self, target, workflow):
# used for jobs that are either rsc jobs or zinc jobs run against rsc
return workflow.resolve_for_enum_variant({
'zinc_only': lambda: self._zinc_key_for_target(target, workflow),
'rsc_then_zinc': lambda: self._rsc_key_for_target(target),
'zinc-only': lambda: self._zinc_key_for_target(target, workflow),
'rsc-then-zinc': lambda: self._rsc_key_for_target(target),
})()

def _rsc_key_for_target(self, target):
return 'rsc({})'.format(target.address.spec)

def _zinc_key_for_target(self, target, workflow):
return workflow.resolve_for_enum_variant({
'zinc_only': lambda: 'zinc({})'.format(target.address.spec),
'rsc_then_zinc': lambda: 'zinc_against_rsc({})'.format(target.address.spec),
'zinc-only': lambda: 'zinc({})'.format(target.address.spec),
'rsc-then-zinc': lambda: 'zinc_against_rsc({})'.format(target.address.spec),
})()

def create_compile_jobs(self,
@@ -427,26 +427,26 @@ def make_zinc_job(target, input_product_key, output_products, dep_keys):
# Currently, rsc only supports outlining scala.
workflow = rsc_compile_context.workflow
workflow.resolve_for_enum_variant({
'zinc_only': lambda: None,
'rsc_then_zinc': lambda: rsc_jobs.append(make_rsc_job(compile_target, invalid_dependencies)),
'zinc-only': lambda: None,
'rsc-then-zinc': lambda: rsc_jobs.append(make_rsc_job(compile_target, invalid_dependencies)),
})()

# Create the zinc compile jobs.
# - Scala zinc compile jobs depend on the results of running rsc on the scala target.
# - Java zinc compile jobs depend on the zinc compiles of their dependencies, because we can't
# generate jars that make javac happy at this point.
workflow.resolve_for_enum_variant({
# NB: zinc_only zinc jobs run zinc and depend on zinc compile outputs.
'zinc_only': lambda: zinc_jobs.append(
# NB: zinc-only zinc jobs run zinc and depend on zinc compile outputs.
'zinc-only': lambda: zinc_jobs.append(
make_zinc_job(
compile_target,
input_product_key='runtime_classpath',
output_products=[
runtime_classpath_product,
self.context.products.get_data('rsc_classpath')],
dep_keys=only_zinc_invalid_dep_keys(invalid_dependencies))),
'rsc_then_zinc': lambda: zinc_jobs.append(
# NB: rsc_then_zinc jobs run zinc and depend on both rsc and zinc compile outputs.
'rsc-then-zinc': lambda: zinc_jobs.append(
# NB: rsc-then-zinc jobs run zinc and depend on both rsc and zinc compile outputs.
make_zinc_job(
compile_target,
input_product_key='rsc_classpath',
@@ -612,14 +612,14 @@ def _jdk_libs_abs(self, nonhermetic_dist):
def _on_invalid_compile_dependency(self, dep, compile_target, contexts):
"""Decide whether to continue searching for invalid targets to use in the execution graph.
If a necessary dep is a rsc_then_zinc dep and the root is a zinc_only one, continue to recurse
because otherwise we'll drop the path between Zinc compile of the zinc_only target and a Zinc
compile of a transitive rsc_then_zinc dependency.
If a necessary dep is a rsc-then-zinc dep and the root is a zinc-only one, continue to recurse
because otherwise we'll drop the path between Zinc compile of the zinc-only target and a Zinc
compile of a transitive rsc-then-zinc dependency.
This is only an issue for graphs like J -> S1 -> S2, where J is a zinc_only target,
S1/2 are rsc_then_zinc targets and S2 must be on the classpath to compile J successfully.
This is only an issue for graphs like J -> S1 -> S2, where J is a zinc-only target,
S1/2 are rsc-then-zinc targets and S2 must be on the classpath to compile J successfully.
"""
return contexts[compile_target][0].workflow.resolve_for_enum_variant({
'zinc_only': lambda : contexts[dep][0].workflow == _JvmCompileWorkflowType.rsc_then_zinc,
'rsc_then_zinc': lambda : False
'zinc-only': lambda : contexts[dep][0].workflow == _JvmCompileWorkflowType.rsc_then_zinc,
'rsc-then-zinc': lambda : False
})()
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.