“erl -make”如何发挥作用?

时间:2013-08-21 04:10:24

标签: erlang

我发现在erl -make以下的情况下不会编译文件。

  1. 编译文件a.erl
  2. 从其他目录中复制旧版a.erl
  3. 编译文件a.erl
  4. a.erl未编译
  5. 然后我在OS X上测试了它,a.erl编译成功。

    在上述两种情况下,唯一的区别是当我使用cp命令复制文件时OS X中的“上次修改时间”发生了更改,而在没有命令的情况下在Windows中没有更改。

1 个答案:

答案 0 :(得分:2)

听起来你已经弄清楚了:当源文件比编译文件更新时会触发重新编译。您的Windows shell保留了修改时间,因此我们不会重新编译。 Mac OS终端shell(bash)更新修改时间,因此旧文件看起来很新。

这是make(3)手册页的相关部分:

          Traversing the set of modules, it then recompiles  every  module
          for which at least one of the following conditions apply:

           * there is no object file, or

           * the  source  file  has  been modified since it was last com-
              piled, or,

           * an include file has been modified since the source file  was
              last compiled.

         As a side effect, the function prints the name of each module it
          tries to compile. If compilation fails for a  module,  the  make
          procedure stops and error is returned.

在Windows下,最好的办法是在强制重新编译时删除已编译的模块。您可能还有更好的时间使用某些源代码控制(SVN,Git等)。我相信即使在Windows下,他们也会更新恢复文件的修改时间。

相关问题