buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djspie...@apache.org
Subject svn commit: r925717 - /buildr/trunk/lib/buildr/scala/compiler.rb
Date Sun, 21 Mar 2010 02:44:02 GMT
Author: djspiewak
Date: Sun Mar 21 02:44:02 2010
New Revision: 925717

URL: http://svn.apache.org/viewvc?rev=925717&view=rev
Log:
Added support for the scalac's -dependencyfile option under Scala 2.8

* Shouldn't even *attempt* incremental compilation if we're doing a joint compilation
* Include target directory on the classpath whenever we compile with dependency tracing

Modified:
    buildr/trunk/lib/buildr/scala/compiler.rb

Modified: buildr/trunk/lib/buildr/scala/compiler.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/scala/compiler.rb?rev=925717&r1=925716&r2=925717&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/scala/compiler.rb (original)
+++ buildr/trunk/lib/buildr/scala/compiler.rb Sun Mar 21 02:44:02 2010
@@ -47,6 +47,19 @@ module Buildr::Scala
         DEFAULT_VERSION       # TODO return the version installed from Maven repo
       end
     end
+
+    def compatible_28?
+      md = version.match /^(\d)\.(\d)/
+      unless md.nil?
+        if md[1].to_i == 2
+          md[2].to_i >= 8
+        else
+          md[1].to_i > 2
+        end
+      else
+        false
+      end
+    end
   end
 
   # Scalac compiler:
@@ -136,12 +149,27 @@ module Buildr::Scala
     def compile(sources, target, dependencies) #:nodoc:
       check_options options, OPTIONS
 
+      java_sources = java_sources(sources)
+      enable_dep_tracing = Scala.compatible_28? && java_sources.empty?
+
+      dependencies.unshift target if enable_dep_tracing
+
       cmd_args = []
       cmd_args << '-classpath' << dependencies.join(File::PATH_SEPARATOR)
       source_paths = sources.select { |source| File.directory?(source) }
       cmd_args << '-sourcepath' << source_paths.join(File::PATH_SEPARATOR) unless
source_paths.empty?
       cmd_args << '-d' << File.expand_path(target)
       cmd_args += scalac_args
+
+      if enable_dep_tracing
+        dep_dir = File.expand_path(target)
+        Dir.mkdir dep_dir unless File.exists? dep_dir
+
+        cmd_args << '-make:transitivenocp'
+        cmd_args << '-dependencyfile'
+        cmd_args << File.expand_path('.scala-deps', dep_dir)
+      end
+
       cmd_args += files_from_sources(sources)
 
       unless Buildr.application.options.dryrun
@@ -160,7 +188,6 @@ module Buildr::Scala
           fail 'Failed to compile, see errors above' if Java.scala.tools.nsc.Main.reporter.hasErrors
         end
 
-        java_sources = java_sources(sources)
         unless java_sources.empty?
           trace 'Compiling mixed Java/Scala sources'
 



Mime
View raw message