【发布时间】:2012-01-20 14:57:47
【问题描述】:
我已经制作了一段时间的 makefile。它支持通过使用包含轻松创建 exe、lib 和 dll 类型的项目。
现在我又开始使用 mercurial,我注意到一切都很好而且很干净直到我进行了构建。您会看到我的目标文件进入每个子项目的源目录下方的子目录。我将我的 lib、exe 和 dll 文件构建到主工作目录下方的目录中。这意味着每当我执行hg status 时,它都会用“?”列出这些临时二进制文件,这是我不想要的视觉混乱。 (这不是 mercurial 的错,当然我不会天真地将它们签入 repo 或类似的东西。)我只希望 hg status 发现我可能忘记正确添加的文件,而不是这些临时构建的文件.
当前的目录结构是这样的:
projroot
-- subproj1 (for source files)
-- subproj1/intr (for object files, release build)
-- subproj2 (for source files)
-- subproj2/intr (for object files, release build)
-- bin (for exes and dlls)
-- lib (for libraries that I build)
所以我正在考虑重组 makefile 以将构建的文件(objs libs dlls 和 exes)保留在工作目录之外。大多数人是否将所有二进制文件保存在 projroot 上一级的目录中以避免 SCM 看到它们?必须有一些最佳实践。我使用的似乎不错,但我认为它有点过时了,当然,因为我已经看到了 ant 为 Java src 和类创建一个完全独立的树的方式。
这个结构怎么样?
projroot (contains common makefile includes and repo in here)
-- subproj1 (for source files)
-- subproj2 (for source files)
build
-- subproj1/intr (.o / .obj files in release build)
-- subproj1/intd
-- subproj2/intr
-- subproj2/intd
-- lib (all built libs)
-- bin (all built exes and DLLs)
构建目录位于工作目录之外,因此我们将使用的任何 SCM 都会忽略该目录。
您的答案必须考虑到 projroot 中的通用 makefile 源代码以及存在多个项目的事实,每个项目都有自己的构建二进制文件集合,您可能希望单独分发这些二进制文件。
【问题讨论】:
标签: c++ version-control mercurial build makefile