自制软件公式中的替代依赖项(例如,用于gcc) [英] Alternative dependencies in a Homebrew formula (e.g. for use with gcc)

查看:141
本文介绍了自制软件公式中的替代依赖项(例如,用于gcc)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何描述一种自制软件公式中的替代依赖关系?我有两种不同的类型。

1。替代包



我的公式可以依赖于包 P Q ,但它必须有其中之一。所以,我想要么

  depends_on'P'

  depends_on'Q'

我需要至少一个。



2。同一包裹的可选标记



我的公式需要另外一个包裹 X 来建造,它需要一个包裹 X 与两个标志之一 A B 。也就是说,我想要么

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



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

我需要至少一个。



示例



这些替代依赖关系有用的具体示例是一个取决于 gcc 。对于 gcc (例如 gcc4 [3-9] ),有多个包可以被上面的#1支持。 gcc 有一个标志 enable-all-languages ,这意味着 enable-java ,所以如果一个需要 gcj 的公式将使用#2来指定替代标记。

解决方案

我最近发现可以通过选项有条件地确定依赖关系。一般方案是:
$ b

选项'with-Q','取决于Q而不是P '

depends_on'P'if!build.with?('Q')
depends_on'Q'如果build.with?('Q')

这也可以用于替代标志的一个依赖项。这个例子取自我的 pdftk $公式
$ b

选项'with-java','Build gcc使用--with-java而不是--with-all-languages'

depends_on'gcc'=> ['with-all-languages'] if!build.with?('java')
depends_on'gcc'=> ['with-java'] if build.with?('java')

这不是处理替代依赖的完美解决方案,但它可能是唯一一个Homebrew将支持。


How can I describe alternative dependencies in a Homebrew formula? There are two different kinds I'm thinking of.

1. Alternative packages

My formula can depend on package P or Q, 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 for building, and it needs a package X with one of 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 where these alternative dependencies would be useful is a formula depending on gcc. There are multiple packages for gcc (e.g. gcc4[3-9]), which could be supported by #1 above. gcc has a flag enable-all-languages which implies enable-java, so if a formula that requires gcj would use #2 to specify the alternative flags.

解决方案

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

option 'with-Q', 'Depend on Q instead of P'

depends_on 'P' if !build.with?('Q')
depends_on 'Q' if  build.with?('Q')

This 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 a perfect solution to dealing with alternative dependencies, but it is probably the only one that Homebrew will support.

这篇关于自制软件公式中的替代依赖项(例如,用于gcc)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆