80 Commits

Author SHA1 Message Date
Markus Reiter
da9289eff0 Add more type signatures. 2020-11-13 12:26:36 +01:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Markus Reiter
17544fc275 Replace usage of DelegateClass with SimpleDelegator. 2020-10-09 16:45:13 +02:00
Markus Reiter
50f40b5978 Document Dependencies and Requirements. 2020-08-26 03:13:58 +02:00
William Ma
e05538a7d9 Create DependenciesHelpers file, add tests 2020-07-31 11:35:45 -04:00
William Ma
7be2b943cb uses: Print cask uses 2020-07-30 12:59:01 -04:00
William Ma
cc63cece76 deps: print cask dependencies
* Allow references to commands when using `brew deps`, e.g. `brew deps
cellery`
* Fix crash when using `brew deps <formula> --installed
--include-requirements`
* Do not include runtime dependencies as direct dependencies when using
`--tree`
2020-07-28 20:24:19 -04:00
Markus Reiter
cfbe1fb3c7 Add helper functions for deps and uses explicitly. 2020-07-25 02:37:10 +02:00
Bo Anderson
b8ba083e12 dependencies: fix recursive_includes not handling deps of test deps 2020-05-19 19:14:48 +01:00
Mike McQuaid
5f721c6986
Cleanup ARGV.include? usage
Remove usage where `Homebrew.args` could be used instead or, due to the
`Homebrew.args` parsing, there was dead code that was never executed
(and no-one complained about not working).
2020-05-10 15:28:31 +01:00
EricFromCanada
c31335c46d deps: don't skip those that are both :build and :test
plus a code readability improvement
2019-12-27 17:35:18 -05:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Mike McQuaid
d64429a736
rubocop: enable Style/IfUnlessModifier. 2019-02-21 12:55:49 +00:00
Markus Reiter
e9b9ea49a1 Update to RuboCop 0.59.1. 2018-09-17 03:45:59 +02:00
Mike McQuaid
592bafe24e Refactor dependencies usage
Reuse more code to avoid errors due to duplication.
2018-03-24 16:55:16 +00:00
Markus Reiter
3b4ee58c49 Refactor using Forwardable and DelegateClass. 2017-06-28 09:25:31 +02:00
Markus Reiter
e851c9bf6c Style/Alias: Prefer alias. 2016-09-23 18:19:53 +02:00
Markus Reiter
52ff988530 Fix RuboCop CaseEquality. 2016-09-23 15:30:06 +02:00
Jack Nagel
dc79f803b1 Remove unnecessary array allocations
These classes are never instantiated with arguments, so we can get rid
of the unnecessary array splatting.
2014-11-21 17:03:59 -06:00
Jack Nagel
a412b49c2c Fix dependency equality 2014-11-21 17:03:58 -06:00
Jack Nagel
1a1f9aa323 Improve inspect output for dependency collections 2014-11-20 22:37:47 -06:00
Jack Nagel
4c4193e905 Use the Enumerable implementation of include? 2014-08-14 00:03:34 -05:00
Jack Nagel
618b894c3e Replace ComparableSet with a Requirements collection 2014-07-03 14:50:57 -05:00
Jack Nagel
3f6827374f Use to_a definition from Enumerable 2014-07-01 21:26:41 -05:00
Jack Nagel
0b2c6e87f1 Implement equality for Dependencies collections 2014-02-13 16:31:12 -05:00
Jack Nagel
2d93935e6a Add type accessors to Dependencies 2013-05-10 23:45:06 -05:00
Jack Nagel
adf90691f1 Split dependency classes into separate files 2013-01-26 20:30:05 -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
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
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
Jack Nagel
e9e16fefa9 Dependency#to_formula and associated helpers 2013-01-26 12:14:44 -06:00
Mike McQuaid
a3daca1b13 Allow depending on requirement class or instance. 2013-01-26 14:33:05 +00:00
Jack Nagel
3725f771de Infer path to be added for requirements that search PATH
When a requirement is specified like:

  satisfy { which "foo" }

There is no reason that we should inject all of ENV.userpaths! into the
build environment. Instead, infer the directory to be added to PATH from
the Pathname that is returned.

This is another step towards condensing the "which program" requirements
down into a one-liner DSL element.
2013-01-22 14:59:10 -06:00
Jack Nagel
b9e5f1229b requirements: enable userpaths by default during evaluation 2013-01-22 14:11:21 -06:00
Jack Nagel
452e79cf68 Allow satisfied? to be specified in a block
Instead of overriding #satisfied?, Requirement subclasses can specify
the condition in a block:

  satisfy do
    some_condition?
  end

The contents of the block are evaluated in the context of the instance,
and so have access to instance variables and instance methods as before.
Additionally, it is wrapped in an ENV.with_build_environment block. This
can be disabled by passing :build_env => false to satisfy:

  satisfy :build_env => false do
    some_condition?
  end
2013-01-21 17:24:12 -06:00
Jack Nagel
2503cedf2c Object#instance_exec for Ruby 1.8.6
Not thread safe! But I don't think we care.

We want to evaluate the env DSL block in the context of ENV for asthetic
reasons, but we also want access to methods on the requirement instance.
We can use #instance_exec to pass the requirement itself into the block:

  class Foo < Requirement
    env do |req|
      append 'PATH', req.some_path
    end

    def some_path
      which 'something'
    end
  end

Also add a simplified version of Object#instance_exec for Ruby 1.8.6.
2013-01-21 17:24:11 -06:00
Jack Nagel
c53af42117 Allow env DSL to take a block
In addition to

  env :userpaths
  env :std

requirements can now do

  env do
    append 'PATH', '/some/path/to/bin'
    # and more
  end
2013-01-21 17:24:10 -06:00
Jack Nagel
e629f14d56 Remove <=> from Dependency interface
It is important that dep equality corresponds to the name attribute, but
we may want to use the Comparable interface to sort them by installation
order in the future. Code that needs to sort them alphabetically should
just use sort_by.
2013-01-13 21:01:15 -06:00
Xiyue Deng
2d445d54b5 Add tex requirement
* Detect `latex' and `bibtex' commands.
* Recommend installing MacTeX when no LaTeX installation is found.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2013-01-13 18:25:35 -08:00
Jack Nagel
dfa387700d Allow conversion of Dependencies to Array
This is needed for the intersection code in `brew deps` to work right,
but can hopefully be refactored away somehow eventually.
2013-01-07 18:17:51 -06:00
Jack Nagel
429caf69a9 Remove Array subclassing
Inheriting from Array (and other core types) is problematic:

  - It exposes a very wide interface with many methods that are not
    really relevant to the subclass.
  - It can cause some weird side effects, as many Array operations are
    in C and have hardcoded return values; for example, combining two
    array subclasses returns a new Array instead of the subclass.

Avoid these problems using delegation and the Enumerable module where
applicable.
2013-01-07 14:32:14 -06:00
Alex Reece
6672ef5f9f Add support for external ocaml deps via opam
Closes Homebrew/homebrew#16280.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
2013-01-04 21:50:31 -08:00
Jack Nagel
9c8a73cf41 Allow requirements to specify env options 2012-12-26 14:37:03 -06:00
Jack Nagel
f8d253950f Add a small DSL for setting requirement options 2012-12-26 14:37:02 -06:00
Jack Nagel
1c56cda4f1 Factor out MySQL and Postgres requirements 2012-11-08 16:01:59 -06:00
Jack Nagel
d1f754c02e Allow requirements to record tags
To allow

  depends_on :x11 => :optional

and friends to work as expected, make requirements record any tags and
add special handling to the X11Dependency to record both a minimum
version and additional tags.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-10-25 14:28:53 -05:00
Jack Nagel
a1af5a6cc3 Move requirement subclasses to a separate file
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-10-25 12:51:36 -05:00