diff options
| author | Adam Vandenberg | 2012-07-30 11:32:56 -0700 |
|---|---|---|
| committer | Adam Vandenberg | 2012-08-08 22:01:27 -0700 |
| commit | d1d52b3467d0b20e99c240247ef01005c49cb62b (patch) | |
| tree | e050891e60e76d38dd671ddba97f9f9035771a07 /Library/Homebrew/formula.rb | |
| parent | 0df4c6a703d67db76fc31ee78aed3fc1eed12cfd (diff) | |
| download | brew-d1d52b3467d0b20e99c240247ef01005c49cb62b.tar.bz2 | |
Add `option` to the DSL
Closes Homebrew/homebrew#9982
Diffstat (limited to 'Library/Homebrew/formula.rb')
| -rw-r--r-- | Library/Homebrew/formula.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index d78ded9b0..99a61daff 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -59,6 +59,9 @@ class Formula # If we got an explicit path, use that, else determine from the name @path = path.nil? ? self.class.path(name) : Pathname.new(path) @downloader = download_strategy.new(name, @active_spec) + + # Combine DSL `option` and `def options` + options.each {|o| self.class.build.add(o[0], o[1]) } end # Derive specs from class ivars @@ -160,6 +163,10 @@ class Formula def plist_name; 'homebrew.mxcl.'+name end def plist_path; prefix+(plist_name+'.plist') end + def build + self.class.build + end + # Use the @active_spec to detect the download strategy. # Can be overriden to force a custom download strategy def download_strategy @@ -579,6 +586,10 @@ private } end + def build + @build ||= BuildOptions.new(ARGV) + end + def url val=nil, specs=nil if val.nil? return @stable.url if @stable @@ -630,6 +641,14 @@ private dependencies.add(dep) end + def option name, description=nil + # Support symbols + name = name.to_s + raise "Option name is required." if name.empty? + raise "Options should not start with dashes." if name[0, 1] == "-" + build.add name, description + end + def conflicts_with formula, opts={} message = <<-EOS.undent #{formula} cannot be installed alongside #{name.downcase}. |
