项目文件夹结构:makefile 也是源代码吗?

发布于 2024-10-10 05:58:14 字数 793 浏览 0 评论 0原文

我有一个相当异构的大型项目 - 涉及不同的语言和编译器,在 GNU make 的帮助下完全生成一个构建。

项目文件夹结构包括:

project
   src
      haxe          --Haxe source code
      graphics      --Embeddable graphic resources
      locale        --Locale-specific resources
         chinese    --Chinese language resources
         english    --Generic English resources
   build
      china         --Chinese market
         debug      --Debugging/Testing for developer(s)
         release    --Release
      europe        --European market
         debug      -- ...
         release    -- ...

所有构建都是通过设置和运行“make”生成的。我无法决定这些 makefile 是否也应该放在“src”目录中?我通常认为我手写的原始材料是源代码(因为根据我的想法,它源自我,而不是由任何其他输入的任何程序生成的。)并且我确实手写我的 makefile。我考虑这一点的另一个原因是因为只有“src”目录是 Git 存储库 - 我真的不需要版本跟踪其他任何内容。我是否将所有 Makefile 放入“src”中?

I have a large project that is rather heterogenous - different languages and compilers are involved, altogether producing a build with the help of GNU make.

The project folder structure includes:

project
   src
      haxe          --Haxe source code
      graphics      --Embeddable graphic resources
      locale        --Locale-specific resources
         chinese    --Chinese language resources
         english    --Generic English resources
   build
      china         --Chinese market
         debug      --Debugging/Testing for developer(s)
         release    --Release
      europe        --European market
         debug      -- ...
         release    -- ...

All builds are produced by setting up and running 'make'. What I can't decide on is whether these makefiles should be put in 'src' directory as well? I generally consider original material I write by hand to be source code (since by my line of thought it originated from me and not produced by any program from some other input.) and I DO write my makefiles by hand. Another reason I consider this is because ONLY 'src' directory is a Git repository - I don't really need to version track anything else. Do I put all Makefiles into 'src'?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

凉世弥音 2024-10-17 05:58:14

您的 build 目录结构中当前有什么?这是编译后的输出吗?

直觉上(我可能来自与您完全不同的开发世界,因此“直觉上”是一个相对术语)当我看到一个 build 文件夹毗邻 src 文件夹时,我希望程序的源代码位于后者以及脚本/工具/等中。需要将其构建为前者。正如您所说,脚本(在本例中为 makefile,尽管也可能包含其他内容)本身就是源代码,但不是程序的源代码。区别在于,一个是“正在构建什么”,另一个是“如何构建它”。

如果我理解正确的话,src 是绑定到源代码管理的内容,而 build 不是?在这种情况下,我可能会在 srcbuild (或 builderbuilding 或类似性质的东西) > 存放脚本。它必须在生成输出之前爬上另一个文件夹,这可能有点不直观,但它应该与您已有的资源文件夹很好地放在一起。

What's currently in your build directory structure? Is that the compiled output?

Intuitively (and I may be coming from a very different development world than you, so "intuitively" is a relative term) when I see a build folder adjoining a src folder, I expect the program's source code to be in the latter and the scripts/tools/etc. needed to build it to be in the former. The scripts (makefiles in this case, though potentially also to include other things) are themselves source code, as you state, but aren't the program's source. The distinction is that one is "what is being built" and the other is "how to build it."

If I understand you correctly, src is what's bound to your source control and build isn't? Under that circumstance, I would probably create a build (or builder or building or something of that nature) under src to house the scripts. It may be slightly unintuitive that it has to climb another folder before producing its output, but it should sit nicely alongside the resource folders you have there already.

折戟 2024-10-17 05:58:14

标准做法是在 src/ 目录之外创建一个 Makefile,用于构建项目,并在 src/ 目录内创建另一个 Makefile 来构建各个模块。也就是说,我认为在你的情况下,将 Makefile 仅保留在 src/ 中就足够了。我不确定这是否适用,但您可能想看看 GNU autoconf 包,它正是用于此类事情。

Standard practice is to create a Makefile outside your src/ directory, which builds your project and within that src/ directory, another Makefile builds individual modules. That said, I think in your case it is sufficient to keep your Makefile solely in src/ though. I'm not sure if this applies, but you might want to look at the GNU autoconf package, it's used for exactly this type of thing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文