2657 Commits

Author SHA1 Message Date
Jack Nagel
26c0524f1a DependencyCollector: return created dep from #add 2013-01-28 10:35:14 -06:00
Jack Nagel
210401654b Allow specifying a name attribute for X11Dependency 2013-01-28 10:35:14 -06:00
Jack Nagel
b90af5be13 Consider correct dependent when skipping build-time deps
We skip build-time deps when installing from bottles. However, the
current logic only considers the root, rather than the actual dependent
formula. Given

  A (bottled)
  |__B (not bottled)
     |__C (build-time)

C will be pruned from the effective dependency tree of A. This is wrong,
because C is required in order to build B.

Fix this by examining the current dependent rather than the root.

Fixes Homebrew/homebrew#17356.
2013-01-27 21:20:09 -06:00
Jack Nagel
5e83629119 Extract unsatisfied dependency logic from installer 2013-01-27 21:20:09 -06:00
Jack Nagel
41dec56d29 Invoke super() in requirement subclasses 2013-01-27 21:20:09 -06:00
Adam Vandenberg
68d312c46f audit: hint about depends_on Class 2013-01-27 14:54:48 -08:00
Jack Nagel
871f3a091a Update require 2013-01-27 16:29:19 -06:00
Sema
667b53ffb0 doctor: fix transposed git command
Closes Homebrew/homebrew#17338.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2013-01-27 13:17:19 -06:00
Misty De Meo
2e23e9a22d superenv: --use-gcc should specify gcc-4.2
Since 'gcc' is a symlink to 'llvm-gcc' on Xcode 4.3+, --use-gcc and
--use-llvm were doing exactly the same thing. Combined with the
previous commit, this allows users with either a leftover
/usr/bin/gcc-4.2 or a homebrewed apple-gcc42 to build with gcc.

This doesn't however fix Xcode-only systems with apple-gcc42.

Fixes Homebrew/homebrew#17243.
2013-01-26 22:57:56 -06:00
Misty De Meo
88609dd6ed xcrun: actually try fallbacks
xcrun has a lot of fallbacks if the first case fails but never actually
reaches them on CLT systems since it doesn't check the validity of the
first path before executing it.

(When should it reach these? Mainly for non-Xcode compilers we
support, e.g. apple-gcc42 which can be found by xcrun but which isn't
in /usr/bin)

The xcrun invocation also needed chomping.
2013-01-26 22:53:29 -06:00
Jack Nagel
adf90691f1 Split dependency classes into separate files 2013-01-26 20:30:05 -06:00
Jack Nagel
f62762b3ab Generate options immediately following depends_on
Given

  depends_on 'gnutls' => :recommended
  depends_on 'libgcrypt' unless build.without? 'gnutls'

the dependency on libgcrypt should be enabled by default. However, the
corresponding option has not yet been generated, so the condition is
true and the dependency is disabled.

Instead, add a hook method that fires after each depends_on and adds the
appropriate option.
2013-01-26 18:20:36 -06:00
Jack Nagel
036f3e7bfc Don't force universal for build deps 2013-01-26 17:24:17 -06:00
Jack Nagel
b8a884bcee FormulaInstaller: wrap --build-from-source in an Option object
c.f. Homebrew/homebrew#17327.
2013-01-26 13:53:32 -06:00
Jack Nagel
9a179d8b06 locks: ensure lock directory exists
Fixes Homebrew/homebrew#17326.
2013-01-26 13:18:45 -06:00
Jack Nagel
2534c1d45e audit: warn about nonexistent options passed to deps 2013-01-26 12:14:51 -06:00
Jack Nagel
5ac4e4f071 upgrade: use standard Tab accessor
Yes, the formula object does refer to a version that has not yet been
installed, but we were not looking into Formula#prefix, but #linked_keg,
which is version agnostic (since the original patch was committed, we
Tab#for_formula learned to look into #opt_prefix as well). The rest of
the logic is already embedded in the Tab accessors.
2013-01-26 12:14:51 -06:00
Jack Nagel
8d03c760c2 Fix Dependencies -> Array conversion 2013-01-26 12:14:51 -06:00
Jack Nagel
e05a509fb6 Tag Xcode and CLT requirements as build-time
This way they can be skipped when installing bottles.
2013-01-26 12:14:50 -06:00
samueljohn
620c063f8c Add "depends_on :clt" 2013-01-26 12:14:50 -06:00
Jack Nagel
109145bf21 Replace usages of recursive_deps with recursive_dependencies 2013-01-26 12:14:49 -06:00
Jack Nagel
82051a56ec upgrade: offload dependency expansion to FormulaInstaller
Now that FormulaInstaller does dependency expansion the _right_ way,
avoid duplicating the logic in upgrade. Instead, offload it to the
installer, which will generate an exception in check_install_sanity that
we can safely ignore when formulae in the outdated list are upgraded as
part of the dependency tree of another outdated formula.
2013-01-26 12:14:49 -06:00
Jack Nagel
18836d93d8 uses: utilize modern dependency API 2013-01-26 12:14:49 -06:00
Jack Nagel
fe802f05ef missing: ignore unused optional and recommended deps 2013-01-26 12:14:48 -06: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
Jack Nagel
046d802d09 FormulaInstaller: allow formulae to pass options to deps
Formulae can now pass build options to dependencies. The following
syntax is supported:

  depends_on 'foo' => 'with-bar'
  depends_on 'foo' => ['with-bar', 'with-baz']

If a dependency is already installed but lacks the required build
options, an exception is raised. Eventually we may be able to just stash
the existing keg and reinstall it with the combined set of used_options
and passed options, but enabling that is left for another day.
2013-01-26 12:14:46 -06:00
Jack Nagel
951872c4be FormulaInstaller: don't install bottle if options were passed 2013-01-26 12:14:46 -06:00
Jack Nagel
5822aa80cf FormulaInstaller: make tab an attr, but never a parameter 2013-01-26 12:14:46 -06:00
Jack Nagel
55681ca201 Dependency.expand_dependencies
Move Formula.expand_dependencies into the Dependency class, and extend
it to allow arbitrary filters to be applied when enumerating deps.

When supplied with a block, expand_dependencies will yield a [dependent,
dependency] pair for each dependency, allowing callers to filter out
dependencies that may not be applicable or useful in a given situation.

Deps can be skipped by simple calling Dependency.prune in the block,
e.g.:

  Dependency.expand_dependencies do |f, dep|
    Dependency.prune if dep.to_formula.installed?
  end

The return value of the method is the filtered list.

If no block is supplied, a default filter that omits optional or
recommended deps based on what the dependent formula has requested is
applied.

Formula#recursive_dependencies is now implemented on top of this,
allowing FormulaInstaller to exact detailed control over what deps are
installed. `brew missing` and `brew upgrade` can learn to use this to
apply the installed options set when expanding dependencies.

Move Formula.expand_deps and Formula#recursive_deps into compat, because
these methods do not respect the new optional and recommended tags and
thus should no longer be used.
2013-01-26 12:14:46 -06:00
Adam Vandenberg
d0161091d8 Let option override with/without descriptions 2013-01-26 12:14:45 -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
Adam Vandenberg
99850fcbda Formula::finalize_dsl 2013-01-26 12:14:45 -06:00
Jack Nagel
37a56fa513 FormulaInstaller: implement installation locks
FormulaInstaller now attempts to take a lock on a "foo.brewing" file for
the formula and all of its dependencies before attempting installation.

The lock is an advisory lock implemented using flock(), and as such it
only locks out other processes that attempt to take the lock. It also
means that it is never necessary to manually remove the lock file,
because the lock is not enforced by I/O.

The uninstall, link, and unlink commands all learn to respect this lock
as well, so that the installation cannot be corrupted by a concurrent
Homebrew process, and keg operations cannot occur simultaneously.
2013-01-26 12:14:45 -06:00
Jack Nagel
ea4188ecda FormulaInstaller: skip build-time deps for bottles 2013-01-26 12:14:44 -06:00
Jack Nagel
43d9f480af FormulaInstaller: factor out dependency installation 2013-01-26 12:14:44 -06:00
Jack Nagel
8b346d7a6d FormulaInstaller: factor out requirement checking 2013-01-26 12:14:44 -06:00
Jack Nagel
e9e16fefa9 Dependency#to_formula and associated helpers 2013-01-26 12:14:44 -06:00
Jack Nagel
a569261a9b Formula#recursive_dependencies
This behaves like recursive_deps, but the resulting list consists of
Dependency objects instead of Formula objects. The list maintains the
installable order property of recursive_deps.

While in the area, add some comments clarifying the purpose of related
methods.
2013-01-26 12:14:43 -06:00
Jack Nagel
02b8d34339 Tab#with? to mirror BuildOptions#with?
Eventually a common interface could be factored out into a module, but
for now this will suffice.
2013-01-26 12:14:43 -06:00
Jack Nagel
e2c4a05235 Tests for BuildOptions 2013-01-26 11:37:02 -06:00
Jack Nagel
5088fdd543 Move BuildOptions to a separate file 2013-01-26 11:37:02 -06:00
Jack Nagel
70ff06c827 Refactor option handling internals
Currently we handle options in several ways, and it is hard to remember
what code needs an option string ("--foo"), what needs only the name
("foo") and what needs an Option object.

Now that Option objects can act as strings and be converted to JSON, we
can start using them instead of passing around strings between Formula
objects, Tab objects, and ARGV-style arrays.

The Options class is a special collection that can be queried for the
inclusion of options in any form: '--foo', 'foo', or Option.new("foo").
2013-01-26 11:37:01 -06:00
Jack Nagel
26b1b88c97 BuildOptions: check has_option? for universal and 32-bit 2013-01-26 11:37:01 -06:00
Jack Nagel
cbf0fe6549 BuildOptions: simplify setting description 2013-01-26 11:37:01 -06:00
Jack Nagel
4062559acb Options can be dumped as JSON 2013-01-26 11:37:01 -06:00
Jack Nagel
a5471a0cb0 Options can be used interchangeably with Strings
We want to be able to use Option objects in place of strings and have
this be transparent. Defining to_str means that methods like
Kernel#system and Kernel#exec will be able to perform an implicit
conversion.
2013-01-26 11:37:01 -06:00
Jack Nagel
f3d3bc4368 Move option comparison into BuildOptions 2013-01-26 11:37:00 -06:00
Jack Nagel
d8a83073ff Clean up Tab creation 2013-01-26 11:37:00 -06:00
Mike McQuaid
a3daca1b13 Allow depending on requirement class or instance. 2013-01-26 14:33:05 +00:00
Mike McQuaid
ff4baa3fcc brew-cleanup: don't whine about permission denied.
Closes Homebrew/homebrew#14359.
2013-01-26 14:11:06 +00:00