简体   繁体   English

为多个项目设置Perforce软件仓库

[英]Setting up Perforce depot for multiple projects

Summary: Want help to figure out how to setup the depot and my development environment so that I can support multiple, related projects. 简介:需要帮助来弄清楚如何设置软件仓库和开发环境,以便我可以支持多个相关项目。

Details: Until now I've had a depot which had in it only one project - ProjectA - robot version A. 详细信息:到目前为止,我有一个仓库,其中只有一个项目-ProjectA-机器人版本A。

I am starting to work on a new version (ProjectB) which has some differences in HW - I/O port mappings and timers have changed. 我开始使用新版本(ProjectB),该版本在硬件方面有一些差异-I / O端口映射和计时器已更改。 I would like to continue to develop code for both projects. 我想继续为两个项目开发代码。

This means that ProjectB will share some files with the ProjectA and some files will be different. 这意味着ProjectB将与ProjectA共享某些文件,而某些文件将有所不同。

Since the differences are HW related items what I'm thinking of doing is creating a common area and then project specific areas where the common area is for device independent code and project specific area is for device dependent code. 由于差异是硬件相关项目,因此我想做的是创建一个公共区域,然后投影特定区域,其中公共区域用于设备独立代码,而项目特定区域用于设备依赖代码。

The differences are big enough that I don't want to do #ifdef within files. 差异足够大,以至于我不想在文件中执行#ifdef。 Some differences are simple - different I/O port mapping and some are completely new modules. 有些区别很简单-不同的I / O端口映射,有些则是全新的模块。

To make maintainance easier, I would like to be able to compare differences between device dependent code and propagate selected changes. 为了使维护更容易,我希望能够比较设备相关代码之间的差异并传播选定的更改。

Finally, to minimize my burden during comparisons, I would like to mark differences that I know are okay so that in future comparisons they don't show up. 最后,为了最大程度地减少比较时的负担,我想标记一些我知道可以的差异,以免在以后的比较中它们不会出现。

Help! 救命!

Your instincts are good -- you're trying to Not Duplicate Code. 您的直觉很不错-您正在尝试不重复代码。 This is the core of good design & engineering. 这是良好设计与工程的核心。

As for the file layout, it's always annoying to have your directories too deep, but that's MUCH better than too shallow. 至于文件布局,目录太深总是很烦人,但这总比太浅要好。 Maybe: 也许:

<root>
  main/
    projects/
       robot1/...
       robot2/...
       shared1/
       shared2/

(Big repositories are much deeper than that, even.) (大型存储库比这还要深得多。)

As for how you make shared code -- you could have different setup.h or constants.h that drive what the various shared libraries do. 至于如何创建共享代码-您可以使用不同的setup.h或constants.h驱动各种共享库的工作。 Alternatively, build your shared libraries so they are parameterized at runtime. 或者,构建共享库,以便在运行时对其进行参数化。

SetupDrivers(0x80020); // address of PIO registers

And lastly -- if the projects really are different, decide if sharing the code really is the right thing. 最后,如果项目确实不同,则决定共享代码是否确实正确。 Usually yes, but everything is a choice. 通常是的,但是一切都是选择。 If you hope to manually "diff" your files to look for differences, it's really up to you to keep the structures close enough to diff. 如果您希望手动“差异化”文件以查找差异,那么实际上取决于您保持结构足够接近差异即可。 The "different config.h file for each project" idea mentioned above would help. 上面提到的“每个项目的不同config.h文件”想法会有所帮助。

If you roll your own diff tool (in python or whatever) you could use special comments to flag "expected different lines". 如果您滚动自己的差异工具(使用python或其他工具),则可以使用特殊注释来标记“预期的不同行”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM