buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djspie...@apache.org
Subject svn commit: r917126 - in /buildr/trunk/lib/buildr/core: cc.rb osx.rb
Date Sun, 28 Feb 2010 04:37:28 GMT
Author: djspiewak
Date: Sun Feb 28 04:37:28 2010
New Revision: 917126

URL: http://svn.apache.org/viewvc?rev=917126&view=rev
Log:
Added notifications for CC compilation

Modified:
    buildr/trunk/lib/buildr/core/cc.rb
    buildr/trunk/lib/buildr/core/osx.rb

Modified: buildr/trunk/lib/buildr/core/cc.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/core/cc.rb?rev=917126&r1=917125&r2=917126&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/core/cc.rb (original)
+++ buildr/trunk/lib/buildr/core/cc.rb Sun Feb 28 04:37:28 2010
@@ -39,7 +39,15 @@
     
     def monitor_and_compile
       # we don't want to actually fail if our dependencies don't succede
-      [:compile, 'test:compile'].each { |name| project.task(name).invoke }
+      begin
+        [:compile, 'test:compile'].each { |name| project.task(name).invoke }
+        notify_build_status(true, project)
+      rescue Exception => ex
+        $stderr.puts $terminal.color(ex.message, :red)
+        $stderr.puts
+        
+        notify_build_status(false, project)
+      end
       
       main_dirs = project.compile.sources.map(&:to_s)
       test_dirs = project.task('test:compile').sources.map(&:to_s)
@@ -89,13 +97,32 @@
           project.task(:compile).reenable if in_main
           project.task('test:compile').reenable if in_test
           
-          project.task(:resources).filter.run if in_res
-          project.task(:compile).invoke
-          project.task('test:compile').invoke
+          successful = true
+          begin
+            project.task(:resources).filter.run if in_res
+            project.task(:compile).invoke if in_main
+            project.task('test:compile').invoke if in_test
+          rescue Exception => ex
+            $stderr.puts $terminal.color(ex.message, :red)
+            successful = false
+          end
+          
+          notify_build_status(successful, project)
+          puts $terminal.color("Build complete", :green) if successful
         end
       end
     end
     
+    def notify_build_status(successful, project)
+       if RUBY_PLATFORM =~ /darwin/ && $stdout.isatty && verbose
+         if successful
+           growl_notify('Completed', 'Your build has completed', project.path_to)
+         else
+           growl_notify('Failed', 'Your build has failed with an error', project.path_to)
+         end
+       end
+    end
+    
     def check_mtime(pattern, old_times)
       times = {}
       changed = []

Modified: buildr/trunk/lib/buildr/core/osx.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/core/osx.rb?rev=917126&r1=917125&r2=917126&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/core/osx.rb (original)
+++ buildr/trunk/lib/buildr/core/osx.rb Sun Feb 28 04:37:28 2010
@@ -16,7 +16,7 @@
 
 # Let's see if we can use Growl.  Must be running from console in verbose mode.
 if $stdout.isatty && verbose
-  notify = lambda do |type, title, message|
+  def growl_notify(type, title, message)
     begin
       # Loading Ruby Cocoa can slow the build down (hooks on Object class), so we're
       # saving the best for last and only requiring it at the very end.
@@ -39,8 +39,8 @@
       # calls raises an exception; system doesn't have osx/cocoa, e.g. MacPorts Ruby 1.9,
       # so we also need to rescue LoadError.
     end
-  end  
+  end
   
-  Buildr.application.on_completion { |title, message| notify['Completed', title, message]
if verbose }
-  Buildr.application.on_failure { |title, message, ex| notify['Failed', title, message] if
verbose }
+  Buildr.application.on_completion { |title, message| growl_notify('Completed', title, message)
if verbose }
+  Buildr.application.on_failure { |title, message, ex| growl_notify('Failed', title, message)
if verbose }
 end



Mime
View raw message