简体   繁体   English

如何跨多个 AOSP 项目创建补丁?

[英]how do you create a patch across multiple AOSP projects?

The process documented here is for making a change to a single project (aka git repo).此处记录的过程用于对单个项目(又名 git repo)进行更改。

But the change I have (implement a single new piece of functionality) spans multiple projects, is it possible to create a single patch to do this or does this need to be broken up into seperate interdependant patches?但是我所做的更改(实现单个新功能)跨越多个项目,是否可以创建单个补丁来执行此操作,还是需要将其分解为单独的相互依赖的补丁?

I think you should divide your patch into patches for each project.我认为您应该将补丁分成每个项目的补丁。 Here is the logic why I think this.这就是我为什么这么认为的逻辑。 Each Android project has it's own .git directory, ie these projects are in separate git repositories.每个 Android 项目都有自己的 .git 目录,即这些项目位于单独的 git 存储库中。 Repo tool is just an addition over git commands, ie it does not provide you with new functionality. Repo 工具只是对 git 命令的补充,即它不为您提供新功能。 Thus, you cannot create a patch that will span across the projects (because they are not connected).因此,您不能创建跨项目的补丁(因为它们没有连接)。 Therefore, you need to divide your patch into separate patches for each AOSP project that is affected by your new functionality.因此,您需要为每个受新功能影响的 AOSP 项目将补丁划分为单独的补丁。

To create a project wide diff, use this command: repo diff > /path/to/store/patch/all-changes.diff要创建项目范围的差异,请使用以下命令: repo diff > /path/to/store/patch/all-changes.diff

Next, one can also use repo forall -p -c git status to check the status of each project.接下来,还可以使用repo forall -p -c git status查看每个项目的状态。

repo forall -p -c git diff will show diff for each project. repo forall -p -c git diff将显示每个项目的差异。

Even I am trying to figure out how to generate patches for individual projects.甚至我都在试图弄清楚如何为单个项目生成补丁。 However, if you understand the AOSP source, all the projects are coming from aosp_root/.repo/manifests/default.xml但是,如果您了解AOSP源代码,那么所有项目都来自aosp_root/.repo/manifests/default.xml

If you try something like repo forall -p -c git diff > /path/to/patch/change.diff , this file will contain all the patches.如果你尝试像repo forall -p -c git diff > /path/to/patch/change.diff这样的东西,这个文件将包含所有的补丁。 I still haven't figured out how to extract the -p part, which prints the project name (Usually is a relative path inside the aosp_root), and convert it into a patch name.我还没有弄清楚如何提取打印项目名称的-p部分(通常是aosp_root内部的相对路径),并将其转换为补丁名称。

However, these things are really not hard to in a bash environment with some scripting.但是,这些东西在带有一些脚本的 bash 环境中确实不难。 Heck, I think repo is also open source, meaning you could even modify it youself!哎呀,我认为 repo 也是开源的,这意味着你甚至可以自己修改它!

If you take a look at this manifest, you should notice that the projects are interpreted same way as git repo projects which are easy to clone and reproduce the patches for.如果您查看此清单,您应该注意到这些项目的解释方式与 git repo 项目的解释方式相同,这些项目易于克隆和复制补丁。 Though very similar to git, AOSP folder structure varies from device to device, SOM to SOM.尽管与 git 非常相似,但 AOSP 文件夹结构因设备、SOM 到 SOM 而异。 It makes it a little harder to actually create individual projects due to path and other dissimilarities.由于路径和其他不同之处,实际创建单个项目变得有点困难。

One thing that I am familiar with is using a tool like splitpatch on linux machines to split out the patches.我熟悉的一件事是在 linux 机器上使用像splitpatch这样的工具来拆分补丁。 However, this tool like others, will find splitting AOSP patches since many files have the same name, for example, if you change Android.mk across multiple projects, the patch splitter finds it hard to understand this structure, so it thinks that the same file was modified over and over.但是这个工具和其他工具一样,会发现拆分AOSP补丁,因为很多文件同名,比如跨多个项目修改Android.mk ,补丁拆分器很难理解这个结构,所以认为同名文件被反复修改。

If you refer the AOSP documentation, for anything, you'll find a good amount of information.如果您参考 AOSP 文档,您会发现大量信息。 Now you will need to use non-traditional search techniques to actually find most of them.现在您将需要使用非传统的搜索技术来实际找到其中的大部分。 The AOSP Documentation that Google provides on the web is not sufficient to understand everything. Google 在网络上提供的 AOSP 文档不足以了解所有内容。 It's just a starting point.这只是一个起点。

The actual documentation is found inside the specific project.实际文档可以在特定项目中找到。 If you look at the Readme files under that project, or the docs/ folder, then you might find something more relevant.如果您查看该项目下的Readme文件或docs/文件夹,您可能会发现更相关的内容。

It's easy to say that it's not well documented, but actually the problem is in exposure and organization.很容易说它没有很好的记录,但实际上问题在于曝光和组织。 Documentation is available abundantly, finding it often is the problem.文档很丰富,发现它往往是问题所在。

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

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