在源代码控制的项目中使用源代码控制的库 [英] Using source controlled libraries in source controlled projects

查看:86
本文介绍了在源代码控制的项目中使用源代码控制的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个构建可重用库的项目.所有这些项目都在源代码控制之下.

I have several projects that build reusable libraries. All these projects are under source control.

当我在项目中使用这些库时,我只需链接到本地​​驱动器上的同一ONE版本.但是,正如您可以想象的那样,当我再次提交时,这可能会导致问题,并且其他开发人员尝试克隆存储库.

When I use these libraries in a project I simply link to the same ONE version on my local drive. However as you can imagine, this can cause problems when I commit back, and a different developer tries to clone the repository.

在源代码控制下使用组件时的最佳实践是什么?我应该在主项目"源代码管理中包括图书馆项目"吗?这会引起问题吗?

What is the best practice when using components also under source control? Should I include the "library projects" in the "main project" source control? Will this cause problems?

NB:这些库采用了很多编译器指令,因此仅编译静态版本并链接到该版本几乎是不可能的.另外,我仍在并行开发它们.

NB: The libraries take quite a few compiler directives so its almost impossible to just compile a static version and link to that. Plus I'm still developing them in parallel.

推荐答案

您有两种主要的依赖关系:

You have two main kind of dependencies:

  • 源依赖项(您需要在项目的源中包括来自另一个项目的源),
  • 二进制依赖性(您需要包含一组打包的文件,例如在共享库中找到的文件).
  • source dependencies (you need to include, within the sources of your project, source from another project),
  • binary dependencies (you need to include a packaged set of files, like the ones found in a shared library).

如果当您说我在项目中使用这些库"时,是指您需要二进制文件才能进行项目编译,那么您可以将所述二进制文件存储在外部存储库中(即,不是(D)VCS类似于Mercurial,但

If, when you say "I use these libraries in a project", you mean you need the binaries in order for your project to compile, then you could store said binaries in an external repository (i.e. not a (D)VCS like Mercurial, but an artifact repository like Nexus)

但是,如果您的意思是需要包括源代码,因为在使用它们来开发项目时还需要对这些库进行一些改进,因此

But if you mean you need to include sources, because you are also making some evolutions to those libraries while using them to develop your project, then Mercurial subrepos are a better fit.

这篇关于在源代码控制的项目中使用源代码控制的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆