0

我想在我的游戏和游戏编辑器之间分享我的模型。游戏采用 cocos2d 框架开发,包含 c++ 和 Objective-C 代码。编辑器在 Qt 中完成(在 windows 7 atm 上开发)。该模型是纯 C++(没有特定于平台的东西)。

我在工作中遇到了类似的问题,我通过将共享代码导出为项目并为其创建一个存储库来解决它。然后我将它添加为子项目并根据需要对其进行更新,但我不确定是否可以将子项目添加到 Qt。它实际上就像一个静态库存储库,它是编辑器和游戏存储库的子存储库,但我不知道该怎么做。

4

2 回答 2

2

听起来您正在寻找的是Git 子模块(强调我的):

经常发生的情况是,在处理一个项目时,您需要使用其中的另一个项目。也许它是第三方开发的库,或者您正在单独开发并在多个父项目中使用。在这些场景中会出现一个常见问题:您希望能够将两个项目视为独立的,但仍然能够在另一个项目中使用一个......

Git 使用子模块解决了这个问题。子模块允许您将 Git 存储库保留为另一个 Git 存储库的子目录。这使您可以将另一个存储库克隆到您的项目中并保持您的提交分开

您还可以在 Git 文档中阅读有关子模块的更多信息。

于 2013-07-09T05:56:30.670 回答
1

Subtree merging is another alternative.

For the gory details behind the git-subtree script see this and this (in the order of increasing hardcore-ness).

To cite the latter manual:

There are situations where you want to include contents in your project from an independently developed project. You can just pull from the other project as long as there are no conflicting paths.

The problematic case is when there are conflicting files. Potential candidates are Makefiles and other standard filenames. You could merge these files but probably you do not want to. A better solution for this problem can be to merge the project as its own subdirectory. This is not supported by the recursive merge strategy, so just pulling won’t work.

What you want is the subtree merge strategy, which helps you in such a situation.

The git-subtree script (which is included with Git in its contrib section in its relatively modern versions) facilitates subtree merges.

于 2013-07-09T14:03:55.433 回答