Permalink
Browse files

Allow scalac and javac builds to be unflattened.

  • Loading branch information...
1 parent 7f853fc commit 398e2bf56446eb9f150c9601102480dbfc007541 Benjy committed Jun 27, 2012
Showing with 32 additions and 0 deletions.
  1. +16 −0 src/python/twitter/pants/tasks/java_compile.py
  2. +16 −0 src/python/twitter/pants/tasks/scala_compile.py
@@ -24,6 +24,7 @@
from twitter.common.dirutil import safe_open, safe_mkdir
from twitter.pants import is_apt
from twitter.pants.targets import JavaLibrary, JavaTests
+from twitter.pants.targets.internal import InternalTarget
from twitter.pants.tasks import TaskError
from twitter.pants.tasks.binary_utils import nailgun_profile_classpath
from twitter.pants.tasks.jvm_compiler_dependencies import Dependencies
@@ -75,6 +76,12 @@ def setup_parser(cls, option_group, args, mkflag):
help="[%default] Compile java code with all configured warnings "
"enabled.")
+ option_group.add_option(mkflag("flatten"), mkflag("flatten", negate=True),
+ dest="java_compile_flatten", default=True,
+ action="callback", callback=mkflag.set_bool,
+ help="[%default] Compile java code for all dependencies in a "
+ "single pass.")
+
def __init__(self, context):
NailgunTask.__init__(self, context, workdir=context.config.get('java-compile', 'nailgun_dir'))
@@ -94,9 +101,18 @@ def __init__(self, context):
else:
self._args.extend(context.config.getlist('java-compile', 'no_warning_args'))
+ self._flatten = context.options.java_compile_flatten
self._confs = context.config.getlist('java-compile', 'confs')
def execute(self, targets):
+ if not self._flatten and len(targets) > 1:
+ topologically_sorted_targets = filter(JavaCompile._is_java, reversed(InternalTarget.sort_targets(targets)))
+ for target in topologically_sorted_targets:
+ self.execute([target])
+ return
+
+ self.context.log.info('Compiling targets %s' % str(targets))
+
java_targets = filter(JavaCompile._is_java, targets)
if java_targets:
with self.context.state('classpath', []) as cp:
@@ -27,6 +27,7 @@
from twitter.pants.targets.scala_library import ScalaLibrary
from twitter.pants.targets.scala_tests import ScalaTests
from twitter.pants.targets import resolve_target_sources
+from twitter.pants.targets.internal import InternalTarget
from twitter.pants.tasks import TaskError
from twitter.pants.tasks.binary_utils import nailgun_profile_classpath
from twitter.pants.tasks.jvm_compiler_dependencies import Dependencies
@@ -48,6 +49,12 @@ def setup_parser(cls, option_group, args, mkflag):
help="[%default] Compile scala code with all configured warnings "
"enabled.")
+ option_group.add_option(mkflag("flatten"), mkflag("flatten", negate=True),
+ dest="scala_compile_flatten", default=True,
+ action="callback", callback=mkflag.set_bool,
+ help="[%default] Compile scala code for all dependencies in a "
+ "single pass.")
+
def __init__(self, context):
NailgunTask.__init__(self, context, workdir=context.config.get('scala-compile', 'nailgun_dir'))
@@ -73,10 +80,19 @@ def __init__(self, context):
else:
self._args.extend(context.config.getlist('scala-compile', 'no_warning_args'))
+ self._flatten = context.options.scala_compile_flatten
self._confs = context.config.getlist('scala-compile', 'confs')
self._depfile = os.path.join(workdir, 'dependencies')
def execute(self, targets):
+ if not self._flatten and len(targets) > 1:
+ topologically_sorted_targets = filter(is_scala, reversed(InternalTarget.sort_targets(targets)))
+ for target in topologically_sorted_targets:
+ self.execute([target])
+ return
+
+ self.context.log.info('Compiling targets %s' % str(targets))
+
scala_targets = filter(is_scala, targets)
if scala_targets:
with self.context.state('classpath', []) as cp:

0 comments on commit 398e2bf

Please sign in to comment.