Alternative dependencies in the Homebrew formula (e.g. for use with gcc)

How can I describe alternative dependencies in a Homebrew formula? There are two different types that I think of.

1. Alternative packages

My formula may depend on a P or Q package, but it must have one of them. So I want either

 depends_on 'P' 

or

 depends_on 'Q' 

and I need at least one.

2. Alternative flags for the same package

My formula requires another package X to build, and it needs package X with one of the two flags A and B That is, I want either

 depends_on 'X' => [:build, 'A'] 

or

 depends_on 'X' => [:build, 'B'] 

and I need at least one.

Example

A specific example of the use of these alternative dependencies is a gcc dependent formula. There are several packages for gcc (for example, gcc4[3-9] ) that can be supported # 1 above. gcc has an enable-all-languages flag, which implies enable-java , so if a formula that requires gcj will use # 2 to indicate alternative flags.

+5
gcc homebrew dependencies
Jan 14 '14 at 13:53 on
source share
1 answer

I recently discovered that it is possible to have dependencies conditionally defined by options. The general scheme:

 option 'with-Q', 'Depend on Q instead of P' depends_on 'P' if !build.with?('Q') depends_on 'Q' if build.with?('Q') 

It can also be used for one dependency with alternative flags. This example is taken from my pdftk formula :

 option 'with-java', 'Build gcc using --with-java instead of --with-all-languages' depends_on 'gcc' => ['with-all-languages'] if !build.with?('java') depends_on 'gcc' => ['with-java'] if build.with?('java') 

This is not an ideal solution for solving alternative dependencies, but it is probably the only thing that supports Homebrew.

0
Feb 26 '15 at 9:22
source share



All Articles