[macruby-changes] [943] MacRuby/branches/experimental/rakelib

source_changes at macosforge.org source_changes at macosforge.org
Mon Mar 16 16:00:16 PDT 2009


Revision: 943
          http://trac.macosforge.org/projects/ruby/changeset/943
Author:   eloy.de.enige at gmail.com
Date:     2009-03-16 16:00:15 -0700 (Mon, 16 Mar 2009)
Log Message:
-----------
Added available build options to the output of: $ rake -T

Modified Paths:
--------------
    MacRuby/branches/experimental/rakelib/builder.rake
    MacRuby/branches/experimental/rakelib/builder.rb

Modified: MacRuby/branches/experimental/rakelib/builder.rake
===================================================================
--- MacRuby/branches/experimental/rakelib/builder.rake	2009-03-16 21:50:06 UTC (rev 942)
+++ MacRuby/branches/experimental/rakelib/builder.rake	2009-03-16 23:00:15 UTC (rev 943)
@@ -1,5 +1,40 @@
 require File.expand_path('../builder', __FILE__)
+require 'rake'
 
+# We monkey-patch the method that Rake uses to display the tasks so we can add
+# the build options.
+module Rake
+  class Application
+    def formatted_macruby_options
+      $builder_options.sort_by { |name, _| name }.map do |name, default|
+        default = default.join(',') if default.is_a?(Array)
+        "        #{name.ljust(38)} \"#{default}\""
+      end.join("\n")
+    end
+    
+    alias_method :display_tasks_and_comments_without_macruby_options, :display_tasks_and_comments
+    
+    def display_tasks_and_comments
+      display_tasks_and_comments_without_macruby_options
+      puts %{
+  To change any of the default build options, use the rake build task
+  of choice with any of these following option-value pairs:
+
+    Usage: $ rake [task] [option=value, …]
+
+      #{'Option:'.ljust(30)} Default value:
+
+#{formatted_macruby_options}
+
+    Example:
+
+      $ rake all archs="i386,ppc" framework_instdir="~/Library/Frameworks"
+
+}
+    end
+  end
+end
+
 desc "Build known objects"
 task :objects => [:config_h, :dtrace_h, :revision_h] do
   sh "/usr/bin/ruby tool/compile_prelude.rb prelude.rb miniprelude.c.new"

Modified: MacRuby/branches/experimental/rakelib/builder.rb
===================================================================
--- MacRuby/branches/experimental/rakelib/builder.rb	2009-03-16 21:50:06 UTC (rev 942)
+++ MacRuby/branches/experimental/rakelib/builder.rb	2009-03-16 23:00:15 UTC (rev 943)
@@ -2,7 +2,11 @@
 # These variables can be set from the command line. Example:
 #    $ rake framework_instdir=~/Library/Frameworks sym_instdir=~/bin
 
+$builder_options = {}
+
 def do_option(name, default)
+  $builder_options[name] = default
+  
   val = ENV[name]
   if val
     if block_given?
@@ -31,8 +35,6 @@
 ENABLE_STATIC_LIBRARY = do_option('enable_static_library', 'no') { 'yes' }
 ENABLE_DEBUG_LOGGING = do_option('enable_debug_logging', true) { |x| x == 'true' }
 
-# TODO: we should find a way to document these options in rake's --help
-
 # Everything below this comment should *not* be modified.
 
 if ENV['build_as_embeddable']
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090316/8d5fb25e/attachment.html>


More information about the macruby-changes mailing list