aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Contributions/example-formula.rb161
1 files changed, 80 insertions, 81 deletions
diff --git a/Library/Contributions/example-formula.rb b/Library/Contributions/example-formula.rb
index ca6f9b69a..a2d8baba7 100644
--- a/Library/Contributions/example-formula.rb
+++ b/Library/Contributions/example-formula.rb
@@ -1,23 +1,21 @@
-require 'formula'
+require "formula"
# This is a non-functional example formula to showcase all features and
# therefore, its overly complex and dupes stuff just to comment on it.
# You may want to use `brew create` to start your own new formula!
# Documentation: https://github.com/Homebrew/homebrew/wiki/Formula-Cookbook
-
## Naming -- Every Homebrew formula is a class of the type `Formula`.
# Ruby classes have to start Upper case and dashes are not allowed.
# So we transform: `example-formula.rb` into `ExampleFormula`. Further,
# Homebrew does enforce that the name of the file and the class correspond.
# Check with `brew search` that the name is free.
class ExampleFormula < Formula
-
- homepage 'http://www.example.com' # used by `brew home example-formula`.
+ homepage "http://www.example.com" # used by `brew home example-formula`.
# The url of the archive. Prefer https (security and proxy issues):
- url 'https://packed.sources.and.we.prefer.https.example.com/archive-1.2.3.tar.bz2'
- mirror 'https://in.case.the.host.is.down.example.com' # `mirror` is optional.
+ url "https://packed.sources.and.we.prefer.https.example.com/archive-1.2.3.tar.bz2"
+ mirror "https://in.case.the.host.is.down.example.com" # `mirror` is optional.
# Optionally specify the download strategy `:using => ...`
# `:git`, `:hg`, `:svn`, `:bzr`, `:cvs`,
@@ -26,15 +24,15 @@ class ExampleFormula < Formula
# `:post` (download via an HTTP POST)
# `S3DownloadStrategy` (download from S3 using signed request)
# `UnsafeSubversionDownloadStrategy` (svn with invalid certs)
- url 'https://some.dont.provide.archives.example.com', :using => :git, :tag => '1.2.3'
+ url "https://some.dont.provide.archives.example.com", :using => :git, :tag => "1.2.3"
# version is seldom needed, because its usually autodetected from the URL/tag.
- version '1.2-final'
+ version "1.2-final"
# For integrity and security, we verify the hash (`openssl dgst -sha1 <FILE>`)
# You may also use sha256 if the software uses sha256 on their homepage.
# Leave it empty at first and `brew install` will tell you the expected.
- sha1 'cafebabe78901234567890123456789012345678'
+ sha1 "cafebabe78901234567890123456789012345678"
# Stable-only dependencies should be nested inside a `stable` block rather than
# using a conditional. It is preferrable to also pull the URL and checksum into
@@ -50,9 +48,9 @@ class ExampleFormula < Formula
# Optionally, specify a repository to be used. Brew then generates a
# `--HEAD` option. Remember to also test it.
# The download strategies (:using =>) are the same as for `url`.
- head 'https://we.prefer.https.over.git.example.com/.git'
- head 'https://example.com/.git', :branch => 'name_of_branch', :revision => 'abc123'
- head 'https://hg.is.awesome.but.git.has.won.example.com/', :using => :hg # If autodetect fails.
+ head "https://we.prefer.https.over.git.example.com/.git"
+ head "https://example.com/.git", :branch => "name_of_branch", :revision => "abc123"
+ head "https://hg.is.awesome.but.git.has.won.example.com/", :using => :hg # If autodetect fails.
head do
url "https://example.com/repo.git"
@@ -74,18 +72,18 @@ class ExampleFormula < Formula
## Options
- # Options can be used as arguemnts to `brew install`.
- # To switch features on/off: `'enable-something'` or `'disable-otherthing'`.
- # To use another software: `'with-other-software'` or `'without-foo'`
+ # Options can be used as arguments to `brew install`.
+ # To switch features on/off: `"with-something"` or `"with-otherthing"`.
+ # To use another software: `"with-other-software"` or `"without-foo"`
# Note, that for dependencies that are `:optional` or `:recommended`, options
# are generated automatically.
# Build a universal (On newer intel Macs this means a combined 32bit and
- # 64bit binary/library). Todo: better explain what this means for PPC.
+ # 64bit binary/library). TODO: better explain what this means for PPC.
option :universal
- option 'enable-spam', 'The description goes here without a dot at the end'
- option 'with-qt', 'Text here overwrites the autogenerated one from `depends_on "qt"`'
+ option "with-spam", "The description goes here without a dot at the end"
+ option "with-qt", "Text here overwrites the autogenerated one from `depends_on "qt"`"
# Only show an option if the Command Line Tools are installed:
- option 'with-dtrace', 'Experimental DTrace support' if MacOS::CLT.installed?
+ option "with-dtrace", "Experimental DTrace support" if MacOS::CLT.installed?
## Bottles
@@ -94,14 +92,14 @@ class ExampleFormula < Formula
# Read in the wiki about how to provide bottles:
# <https://github.com/Homebrew/homebrew/wiki/Bottles>
bottle do
- root_url 'http://mikemcquaid.com' # Optional root to calculate bottle URLs
- prefix '/opt/homebrew' # Optional HOMEBREW_PREFIX in which the bottles were built.
- cellar '/opt/homebrew/Cellar' # Optional HOMEBREW_CELLAR in which the bottles were built.
+ root_url "http://mikemcquaid.com" # Optional root to calculate bottle URLs
+ prefix "/opt/homebrew" # Optional HOMEBREW_PREFIX in which the bottles were built.
+ cellar "/opt/homebrew/Cellar" # Optional HOMEBREW_CELLAR in which the bottles were built.
revision 1 # Making the old bottle outdated without bumping the version of the formula.
- sha1 'd3d13fe6f42416765207503a946db01378131d7b' => :mountain_lion
- sha1 'cdc48e79de2dee796bb4ba1ad987f6b35ce1c1ee' => :lion
- sha1 'a19b544c8c645d7daad1d39a070a0eb86dfe9b9c' => :snow_leopard
- sha1 '583dc9d98604c56983e17d66cfca2076fc56312b' => :snow_leopard_32
+ sha1 "d3d13fe6f42416765207503a946db01378131d7b" => :mountain_lion
+ sha1 "cdc48e79de2dee796bb4ba1ad987f6b35ce1c1ee" => :lion
+ sha1 "a19b544c8c645d7daad1d39a070a0eb86dfe9b9c" => :snow_leopard
+ sha1 "583dc9d98604c56983e17d66cfca2076fc56312b" => :snow_leopard_32
end
def pour_bottle?
@@ -130,23 +128,24 @@ class ExampleFormula < Formula
# deciding if to use the system provided version or not.)
# `:build` means this dep is only needed during build.
- depends_on 'cmake' => :build
- # Explictly name formulae in other taps.
- depends_on 'homebrew/dupes/tcl-tk'
+ depends_on "cmake" => :build
+ # Explictly name formulae in other taps. Non-optional tap dependencies won't
+ # be accepted in core.
+ depends_on "homebrew/dupes/tcl-tk"
# `:recommended` dependencies are built by default. But a `--without-...`
# option is generated to opt-out.
- depends_on 'readline' => :recommended
+ depends_on "readline" => :recommended
# `:optional` dependencies are NOT built by default but a `--with-...`
# options is generated.
- depends_on 'glib' => :optional
+ depends_on "glib" => :optional
# If you need to specify that another formula has to be built with/out
# certain options (note, no `--` needed before the option):
- depends_on 'zeromq' => 'with-pgm'
- depends_on 'qt' => ['with-qtdbus', 'developer'] # Multiple options.
+ depends_on "zeromq" => "with-pgm"
+ depends_on "qt" => ["with-qtdbus", "developer"] # Multiple options.
# Optional and enforce that boost is built with `--with-c++11`.
- depends_on 'boost' => [:optional, 'with-c++11']
+ depends_on "boost" => [:optional, "with-c++11"]
# If a dependency is only needed in certain cases:
- depends_on 'sqlite' if MacOS.version == :leopard
+ depends_on "sqlite" if MacOS.version == :leopard
depends_on :xcode # If the formula really needs full Xcode.
depends_on :clt # If the formula really needs the CLTs for Xcode.
depends_on :tex # Homebrew does not provide a Tex Distribution.
@@ -164,24 +163,24 @@ class ExampleFormula < Formula
depends_on :libtool
depends_on :mysql => :recommended
# It is possible to only depend on something if
- # `build.with?` or `build.without? 'another_formula'`:
+ # `build.with?` or `build.without? "another_formula"`:
depends_on :mysql # allows brewed or external mysql to be used
- depends_on :postgresql if build.without? 'sqlite'
+ depends_on :postgresql if build.without? "sqlite"
depends_on :hg # Mercurial (external or brewed) is needed
- # If any Python >= 2.6 < 3.x is okay (either from OS X or brewed):
+ # If any Python >= 2.7 < 3.x is okay (either from OS X or brewed):
depends_on :python
# Python 3.x if the `--with-python3` is given to `brew install example`
depends_on :python3 => :optional
# Modules/Packages from other languages, such as :chicken, :jruby, :lua,
# :node, :ocaml, :perl, :python, :rbx, :ruby, can be specified by
- depends_on 'some_module' => :lua
+ depends_on "some_module" => :lua
## Conflicts
# If this formula conflicts with another one:
- conflicts_with 'imagemagick', :because => 'because this is just a stupid example'
+ conflicts_with "imagemagick", :because => "because this is just a stupid example"
## Failing with a certain compiler?
@@ -194,7 +193,7 @@ class ExampleFormula < Formula
fails_with :clang do
build 425
- cause 'multiple configure and compile errors'
+ cause "multiple configure and compile errors"
end
## Resources
@@ -203,8 +202,8 @@ class ExampleFormula < Formula
# install method. Resources can also be defined inside a stable, devel, or
# head block. This mechanism replaces ad-hoc "subformula" classes.
resource "additional_files" do
- url 'https://example.com/additional-stuff.tar.gz'
- sha1 'deadbeef7890123456789012345678901234567890'
+ url "https://example.com/additional-stuff.tar.gz"
+ sha1 "deadbeef7890123456789012345678901234567890"
end
@@ -249,7 +248,7 @@ class ExampleFormula < Formula
# archive has been unpacked or the repository has been cloned.
# Print a warning (do this rarely)
- opoo 'Dtrace features are experimental!' if build.with? 'dtrace'
+ opoo "Dtrace features are experimental!" if build.with? "dtrace"
# Sometimes we have to change a bit before we install. Mostly we
# prefer a patch but if you need the `prefix` of this formula in the
@@ -257,7 +256,7 @@ class ExampleFormula < Formula
# you don't have access to any var defined by the formula. Only
# HOMEBREW_PREFIX is available in the embedded patch.
# inreplace supports reg. exes.
- inreplace 'somefile.cfg', /look[for]what?/, "replace by #{bin}/tool"
+ inreplace "somefile.cfg", /look[for]what?/, "replace by #{bin}/tool"
# To call out to the system, we use the `system` method and we prefer
# you give the args separately as in the line below, otherwise a subshell
@@ -271,7 +270,7 @@ class ExampleFormula < Formula
# on options defined above, we usually make a list first and then
# use the `args << if <condition>` to append to:
args = ["--option1", "--option2"]
- args << "--i-want-spam" if build.include? "enable-spam"
+ args << "--i-want-spam" if build.with? "spam"
args << "--qt-gui" if build.with? "qt" # "--with-qt" ==> build.with? "qt"
args << "--some-new-stuff" if build.head? # if head is used instead of url.
args << "--universal-binary" if build.universal?
@@ -305,15 +304,15 @@ class ExampleFormula < Formula
# Do something only for clang
if ENV.compiler == :clang
# modify CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS in one go:
- ENV.append_to_cflags '-I ./missing/includes'
+ ENV.append_to_cflags "-I ./missing/includes"
end
# This is in general not necessary, but to show how to find the path to
# the Mac OS X SDK:
- ENV.append 'CPPFLAGS', "-I#{MacOS.sdk_path}/usr/include" unless MacOS::CLT.installed?
+ ENV.append "CPPFLAGS", "-I#{MacOS.sdk_path}/usr/include" unless MacOS::CLT.installed?
# Overwriting any env var:
- ENV['LDFLAGS'] = '--tag CC'
+ ENV["LDFLAGS"] = "--tag CC"
system "make", "install"
@@ -324,49 +323,49 @@ class ExampleFormula < Formula
# (`install` is a Homebrew mixin into Ruby's Pathname)
# The pathnames defined in the formula
- prefix # == HOMEBREW_PREFIX+'Cellar'+name+version
- bin # == prefix+'bin'
- doc # == share+'doc'+name
- include # == prefix+'include'
- info # == share+'info'
- lib # == prefix+'lib'
- libexec # == prefix+'libexec'
+ prefix # == HOMEBREW_PREFIX+"Cellar"+name+version
+ bin # == prefix+"bin"
+ doc # == share+"doc"+name
+ include # == prefix+"include"
+ info # == share+"info"
+ lib # == prefix+"lib"
+ libexec # == prefix+"libexec"
buildpath # The temporary directory where build occurs.
- man # share+'man'
- man1 # man+'man1'
- man2 # man+'man2'
- man3 # man+'man3'
- man4 # man+'man4'
- man5 # man+'man5'
- man6 # man+'man6'
- man7 # man+'man7'
- man8 # man+'man8'
- sbin # prefix+'sbin'
- share # prefix+'share'
- frameworks # prefix+'Frameworks'
- kext_prefix # prefix+'Library/Extensions'
+ man # share+"man"
+ man1 # man+"man1"
+ man2 # man+"man2"
+ man3 # man+"man3"
+ man4 # man+"man4"
+ man5 # man+"man5"
+ man6 # man+"man6"
+ man7 # man+"man7"
+ man8 # man+"man8"
+ sbin # prefix+"sbin"
+ share # prefix+"share"
+ frameworks # prefix+"Frameworks"
+ kext_prefix # prefix+"Library/Extensions"
# Configuration stuff that will survive formula updates
- etc # HOMEBREW_PREFIX+'etc'
+ etc # HOMEBREW_PREFIX+"etc"
# Generally we don't want var stuff inside the keg
- var # HOMEBREW_PREFIX+'var'
- bash_completion # prefix+'etc/bash_completion.d'
- zsh_completion # share+'zsh/site-functions'
+ var # HOMEBREW_PREFIX+"var"
+ bash_completion # prefix+"etc/bash_completion.d"
+ zsh_completion # share+"zsh/site-functions"
# Further possibilities with the pathnames:
# http://www.ruby-doc.org/stdlib-1.8.7/libdoc/pathname/rdoc/Pathname.html
# Sometime you will see that instead of `+` we build up a path with `/`
# because it looks nicer (but you can't nest more than two `/`):
- (var/'foo').mkpath
+ (var/"foo").mkpath
# Copy `./example_code/simple/ones` to share/demos
- (share/'demos').install "example_code/simple/ones"
+ (share/"demos").install "example_code/simple/ones"
# Copy `./example_code/simple/ones` to share/demos/examples
- (share/'demos').install "example_code/simple/ones" => 'examples'
+ (share/"demos").install "example_code/simple/ones" => "examples"
# Additional downloads can be defined as resources (see above).
# The stage method will create a temporary directory and yield
# to a block.
- resource("additional_files").stage { bin.install 'my/extra/tool' }
+ resource("additional_files").stage { bin.install "my/extra/tool" }
# `name` and `version` are accessible too, if you need them.
end
@@ -396,16 +395,16 @@ class ExampleFormula < Formula
# We are fine if the executable does not error out, so we know linking
# and building the software was ok.
- system bin/'foobar', '--version'
+ system bin/"foobar", "--version"
- (testpath/'Test.file').write <<-EOS.undent
+ (testpath/"Test.file").write <<-EOS.undent
writing some test file, if you need to
EOS
# To capture the output of a command, we use backtics:
- assert_equal 'OK', ` test.file`.strip
+ assert_equal "OK", ` test.file`.strip
# Need complete control over stdin, stdout?
- require 'open3'
+ require "open3"
Open3.popen3("#{bin}/example", "big5:utf-8") do |stdin, stdout, _|
stdin.write("\263\134\245\134\273\134")
stdin.close