• GNU make manual 翻译( 一百二十)


    继续翻译

    4.12.2 Static Pattern Rules versus Implicit Rules
    -------------------------------------------------
    
    A static pattern rule has much in common with an implicit rule defined
    as a pattern rule (*note Defining and Redefining Pattern Rules: Pattern
    Rules.).  Both have a pattern for the target and patterns for
    constructing the names of prerequisites.  The difference is in how
    `make' decides _when_ the rule applies.
    
       An implicit rule _can_ apply to any target that matches its pattern,
    but it _does_ apply only when the target has no recipe otherwise
    specified, and only when the prerequisites can be found.  If more than
    one implicit rule appears applicable, only one applies; the choice
    depends on the order of rules.
    
       By contrast, a static pattern rule applies to the precise list of
    targets that you specify in the rule.  It cannot apply to any other
    target and it invariably does apply to each of the targets specified.
    If two conflicting rules apply, and both have recipes, that's an error.
    
       The static pattern rule can be better than an implicit rule for these
    reasons:
    
       * You may wish to override the usual implicit rule for a few files
         whose names cannot be categorized syntactically but can be given
         in an explicit list.
    
       * If you cannot be sure of the precise contents of the directories
         you are using, you may not be sure which other irrelevant files
         might lead `make' to use the wrong implicit rule.  The choice
         might depend on the order in which the implicit rule search is
         done.  With static pattern rules, there is no uncertainty: each
         rule applies to precisely the targets specified.

    4.12.2 静态模式规则对隐式规则
    -------------------------------------------------

    一个静态模式规则比作为模式规则的隐式规则更为常用(*note Defining and Redefining Pattern Rules:Pattern Rules.) 这两种用法都有一个为目的定义的模式和为构建前提条件名称的模式。区别在于make 如何决定何时应用规则。

    一个隐式规则可以应用到任何符合其模式的目的上,但是仅当此目的没有片段时。如果有多于一个的隐式规则可用,只有一个会被应用;至于选择哪个要依赖于规则的顺序。

    与之相对比地,一个静态模式规则采用你给规则指定的,目的的精确的列表。它不能用于其他目的并且不变地应用的具体的目的。如果两个冲突的规则出现,并都有片段,则会引发错误。

     静态模式规则可以比隐式规则好的原因有两个:

    *你也许想为几个文件覆盖通常的隐式规则,这几个文件的名字无法通过语法分类,但是可以放入一个显式列表中。

    *如果你不确定你所使用的目录的准确内容,你将不确定哪些不相干的文件会使得make 使用了错误的隐式规则。这种选择依赖于隐式规则搜索时的顺序。而使用静态模式规则,则没有不确定性:每个规则精确地应用到指定的目的。

    后文待续

  • 相关阅读:
    Flink开发中的问题
    怎么确定一个Flink job的资源
    Flink统计日活
    Flink读取resource资源文件
    Spark-6-如何缓解消除数据倾斜
    Spark-5-如何定位导致数据倾斜的代码
    Spark-4-为何要处理数据倾斜
    集合遍历删除中遇到问题
    1206
    1205
  • 原文地址:https://www.cnblogs.com/gaojian/p/2703803.html
Copyright © 2020-2023  润新知