【问题标题】:How `erl -make` does its work?`erl -make` 是如何工作的?
【发布时间】:2013-08-22 04:45:02
【问题描述】:

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

  1. 编译文件a.erl
  2. 从其他目录复制旧版本的a.erl
  3. 编译文件a.erl
  4. a.erl 未编译

然后我在 OS X 上测试,a.erl 编译成功。

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

【问题讨论】:

    标签: erlang


    【解决方案1】:

    听起来你已经想通了:当源文件比编译后的文件更新时会触发重新编译。您的 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 下也是如此。

    【讨论】:

      猜你喜欢
      • 2013-01-09
      • 2021-06-24
      • 1970-01-01
      • 2015-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-04
      • 1970-01-01
      相关资源
      最近更新 更多