15 Commits

Author SHA1 Message Date
Jack Nagel
f0b75b2869 Stop duping options when duping the build object
The options collection cannot be mutated from the build object, so it
can be shared among copies safely.
2014-08-09 10:30:43 -05:00
Jack Nagel
f4ae1c9e1b Hide the options data structure better 2014-07-31 19:59:09 -05:00
Jack Nagel
abdff27cd7 Make options available on the spec objects 2014-07-31 19:37:39 -05:00
Jack Nagel
fd86e6d636 Remove confusing implicit options handling
This code is supposed to allow

  depends_on "foo" => "with-bar"

to work when foo has only a "without-bar" option.

The options system was not designed to support this. Unfortunately, it
was bolted on anyway. The implementation is extremely difficult to
understand, and it only works for certain types of options, which is
confusing from a user's point of view. Luckily, no formulae in core or
the official taps rely on the behavior in order to function.

It is hindering progress in improving this code, so I am removing it.
2014-07-30 21:46:22 -05:00
Jack Nagel
0a605cbf8b Simplify BuildOptions copy tests 2014-07-30 20:15:18 -05:00
Jack Nagel
4b6abc7da2 Use assert_includes 2014-06-18 20:34:10 -05:00
Jack Nagel
982e9239b8 Use a custom test class so we can avoid monkeypatching 2014-06-18 20:32:51 -05:00
Jack Nagel
f3e9c5c070 Fix up some assertions 2014-06-11 13:05:10 -05:00
Jack Nagel
71b21c920f Copies of BuildOptions should not share underlying collections 2013-09-14 17:03:56 -05:00
Jack Nagel
a871baadf5 Fix breakage in option recognition
Fixes Homebrew/homebrew#22347.
2013-09-05 18:51:27 -05:00
Samuel John
59a0c1e1b5 Improve python tests for brew bots
Allow `build.with?` and similar methods to be used during the test
phase. The BuildOptions (`build`) are initialized with the
`Tab.used_options` unless explicitly overwritten on the command line.

So basically `build.with?` works in `def install` and in `test do` as
one would naively expect. (For the test, gramatically it should be
`built.with?` but who cares)

If a formula was installed `--with-python`, now the tests are also
run `--with-python`. This enables us to use the `python do ... end` in
a meaningful manner.

Using `python do ... end` blocks for the tests, because the bot.brew.sh has
system python per default and we need to set the PYTHONPATH for the test.
Potentially to different values for Python 2.x and 3.x.
2013-09-05 15:26:57 +02:00
Samuel John
c524895666 Python 2.x and 3.x support
New `depends_on :python` Dependency.
New `depends_on :python3` Dependency.

To avoid having multiple formulae with endings -py2 and -py3,
we will handle support for different pythons (2.x vs. 3.x)
in the same formula.
Further brewed vs. external python will be transparently supported.

The formula also gets a new object `python`, which is false if
no Python is available or the user has disabled it. Otherwise
it is defined and provides several support methods:

python.site_packages # the site-packages in the formula's Cellar
python.global_site_packages
python.binary # the full path to the python binary
python.prefix
python.version
python.version.major
python.version.minor
python.xy # => e.g. "python2.7"
python.incdir # includes of python
python.libdir # the python dylib library
python.pkg_config_path # used internally by brew
python.from_osx?
python.framework?
python.universal?
python.pypy?
python.standard_caveats # Text to set PYTHONPATH for python.from_osx?
python.if3then3 # => "" for 2.x and to "3" for 3.x.

Further, to avoid code duplication, `python` takes an optional
block that is run twice if the formula defines depends_on
:python AND :python3.

python do
  system python, 'setup.py', "--prefix=#{prefix}"
end

Read more in the Homebrew wiki.
2013-06-03 17:29:43 +02:00
Jack Nagel
cf08b71bf8 FormulaInstaller: construct new ARGV from an Options collection
The array of options that is passed to the spawned build process is a
combination of the current ARGV, options passed in by a dependent
formula, and an existing install receipt. The objects that are
interacting here each expect the resulting collection to have certain
properties, and the expectations are not consistent.

Clear up this confusing mess by only dealing with Options collections.
This keeps our representation of options uniform across the codebase.

We can remove BuildOptions dependency on HomebrewArgvExtension, which
allows us to pass any Array-like collection to Tab.create. The only
other site inside of FormulaInstaller that uses the array is the #exec
call, and there it is splatted and thus we can substitute our Options
collection there as well.
2013-01-26 12:14:47 -06:00
Adam Vandenberg
6193167f58 Add support for optional and recommended deps
Optional deps are not installed by default but generate a corresponding
"with-foo" option for the formula. Recommended deps _are_ installed by
default, and generate a corresponding "without-foo" option.
2013-01-26 12:14:45 -06:00
Jack Nagel
e2c4a05235 Tests for BuildOptions 2013-01-26 11:37:02 -06:00