【问题标题】:Fix source file search path when doing out-of-source autotools build within emacs在 emacs 中进行源外自动工具构建时修复源文件搜索路径
【发布时间】:2009-11-23 13:24:50
【问题描述】:

我有一个使用自动工具的项目。 autotools 的一个不错的功能是“源外”构建,而不是这样做:

cd foobar
./configure
make

我实际上为构建创建了一个文件夹,我在其中进行配置:

cd foobar/builds/linux
../../configure
make

(好处是我的源文件夹没有被生成的 Makefile 破坏,它在交叉编译时很有帮助)。

因此,当我在 emacs 中处理我的代码时,要运行编译,我将执行 M-x compile 将编译命令指定为 cd ~/foobar/builds/linux ; make

这工作正常,直到发生编译错误。编译缓冲区将列出具有丑陋路径的文件(如../../../../src...),它指向相对于构建文件夹的源文件。但是,似乎emacs在编译结束时不会留在构建文件夹中,所以链接不指向任何东西。因此,我无法轻松浏览回错误。

我尝试与compilation-search-path 一起玩,但没有运气。

有没有办法强制 emacs '留在'编译文件夹中(以便 编译 缓冲区中的路径引用现有文件?)

谢谢

PH

【问题讨论】:

    标签: emacs compilation autotools


    【解决方案1】:

    如果您改用make -C ~/foobar/builds/linux,emacs 应该能够跟踪发出的Entering directory ...Leaving directory ... 消息并使用它来保持对文件的正确引用。

    【讨论】:

    • 谢谢,但它似乎没有帮助.. 我可能应该补充一点,我有几个源文件夹,并且我在顶层运行 make。例如: * 我在 /home/phtrivier/prj/foobar/builds/linux/current 中构建 * 我在 /home/phtrivier/prj/foobar/src/client 的文件中有错误 在编译缓冲区中,使用 'make -C ~/foobar/builds/linux/current check' 我得到错误:make[2]: entrant dans le répertoire « /home/phtrivier/prj/foobar/builds/linux/current/src/client ...(编译行跳过) ../../../../../src/client/whatever.cpp 但是点击该行时却找不到:(
    【解决方案2】:

    使用 jamessan 的建议,我可以通过以下方式部分解决问题:

    • 将“编译目录”设置为“源”文件夹之一 (builds/linux/current/src/client)
    • 设置 'compilation-command 以使用 -C 更改为这些源文件夹之一

    不确定是否两者都需要,或者这是否是做事的最佳方式......

    还是谢谢!

    【讨论】:

      猜你喜欢
      • 2011-09-11
      • 1970-01-01
      • 2018-03-09
      • 2013-08-03
      • 1970-01-01
      • 2012-10-02
      • 1970-01-01
      • 2010-11-02
      • 1970-01-01
      相关资源
      最近更新 更多