【问题标题】:GNU make lint prerequisiteGNU make lint 先决条件
【发布时间】:2016-01-03 15:16:14
【问题描述】:

GNU make manual 说:

虚假目标不应该是真实目标文件的先决条件;如果是,则每次make 更新该文件时都会运行其配方。

如果这就是我想要的呢?

例如,如果我有一个名为 lint 的虚假目标会 lints app/scripts/main.js,并且我希望它在每次 make 更新(转换和缩小)dist/scripts/main.js 时运行?

【问题讨论】:

  • 注意:我了解 Gulp,更喜欢使用 Make。

标签: makefile lint eslint


【解决方案1】:

我刚刚删除了lint 目标并将其配方作为dist/scripts/main.js 目标配方的第一个命令。

dist/scripts/main.js : app/scripts/main.js
    ./node_modules/.bin/eslint $< && \
    mkdir -p dist/scripts && \
    ./node_modules/.bin/babel $< | \
    ./node_modules/.bin/uglifyjs - --screw-ie8 -o $@ -m -c

【讨论】:

    【解决方案2】:

    更新的答案:当前的 GNU make 手册没有从问题中指定引用的“规则”,而是在关于 forced targets 的条目中明确表示要使用这个,其中包括一个注释:

    如您所见,以这种方式使用FORCE 与使用.PHONY clean 的结果相同。

    使用.PHONY 更明确、更有效。但是其他版本的make不支持.PHONY;因此FORCE 出现在许多makefile 中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-21
      • 1970-01-01
      • 2021-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-04
      相关资源
      最近更新 更多