从 Eclipse CDT 项目中完全排除某些目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7498878/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 20:33:41  来源:igfitidea点击:

Completely exclude certain directories from Eclipse CDT project

eclipseeclipse-cdt

提问by user674669

I am working a C++ codebase that is built & run outside Eclipse.

我正在使用一个在 Eclipse 之外构建和运行的 C++ 代码库。

I made an Eclipse project out of it where I just use Eclipse for browsing/editing the code.

我用它制作了一个 Eclipse 项目,我只使用 Eclipse 浏览/编辑代码。

However, I can't figure out how to completelyexclude certain directories like build/ from it completely. They should be excluded not only during building but also during "Refresh workspace" which seems to get triggered so often. To give an example, my workspace is

但是,我无法弄清楚如何完全排除某些目录,例如 build/ 。它们不仅应该在构建期间被排除在外,还应该在“刷新工作区”期间被排除,这似乎经常被触发。举个例子,我的工作区是

d:\workspace

It has directories like

它有这样的目录

source/
build/
..

During startup, Eclipse picks up all directories inside the workspace automatically. However, I would like Eclipse to exclude build/completely.

在启动期间,Eclipse 会自动选取工作区中的所有目录。但是,我希望 Eclipsebuild/完全排除。

My code is on a remote machine, so "Refresh workspace" slows things down.

我的代码在远程机器上,所以“刷新工作区”会减慢速度。

回答by ks1322

You can do it by adding Resource filters. Add Exclude Allresource filter type to root folder of your project. See also this answer.

您可以通过添加资源过滤器来实现。将Exclude All资源过滤器类型添加到项目的根文件夹。另请参阅此答案

回答by breakpoint

I am very firmly of the opinion that all answers for questions like this need to include the version in which they have been tested-- because, like most things in Eclipse, this has gradually changed. In Eclipse Neon.3 (4.6.3), you can do this more directly.

NOTE: The excluded directory will no longer show up in the Project Explorer tree AT ALL.
If this will be a problem, select a different technique!


Otherwise, proceed as follows:

1. Left-click the project root in the Project Explorer tree to ensure proper context (you "shouldn't need to do this"-- like a lot of things in Eclipse).
2. Right-click the folder you wish to exclude in the Project Explorer tree.
3. Select the "Resource Configurations..." submenu.
4. Select "Exclude from Build".
5. Right-click the project root in Project Explorer.
6. Select the "Index" submenu.
7. Select "Rebuild".

If you were trying to do this because you were getting duplicate symbols, verify this has fixed your problem:

1. Open a file referencing the symbol that was getting duplicate definitions.
2. Left click the actual characters of the actual name in the actual code.
3. Press F3.
4. Verify that you either go immediately to the declaration you consider
correct, you see a list including only that entry and its ancestors.
5. Upvote this answer, and reply if you find that it works with a newer version, please.

我非常坚定地认为,对于此类问题的所有答案都需要包括测试过的版本——因为与 Eclipse 中的大多数事情一样,这已经逐渐改变了。在Eclipse Neon.3 (4.6.3) 中,您可以更直接地执行此操作。

注意:排除的目录将不再显示在项目资源管理器树中。
如果这会成为问题,请选择不同的技术!


否则,请执行以下操作:

1. 左键单击 Project Explorer 树中的项目根以确保正确的上下文(您“不应该这样做”——就像 Eclipse 中的很多事情一样)。
2. 在项目资源管理器树中右键单击要排除的文件夹。
3. 选择“资源配置...”子菜单。
4. 选择“从构建中排除”。
5. 在项目资源管理器中右键单击项目根。
6. 选择“索引”子菜单。
7. 选择“重建”。

如果您尝试这样做是因为您获得了重复的符号,请验证这是否解决了您的问题:

1. 打开一个引用获得重复定义的符号的文件。
2. 左键单击实际代码中实际名称的实际字符。
3. 按 F3。
4. 验证您是否立即转到您认为
正确的声明,您会看到一个仅包含该条目及其祖先的列表。
5. 给这个答案点赞,如果你发现它适用于较新的版本,请回复

回答by MikeW

A quick fix that is almost as good (in terms of reducing Eclipse wheel-spin) is to mark the folder(s) in question as Derived, in (right-click) Properties.

几乎一样好的快速修复(在减少 Eclipse 轮旋转方面)是在(右键单击)属性中将有问题的文件夹标记为派生的。

Be careful if you subsequently want to use the text search operations for something and need to include things marked Derived - you need to explicitly 'include Derived' in the search.

如果您随后想要对某些内容使用文本搜索操作并且需要包含标记为 Derived 的内容,请小心 - 您需要在搜索中明确地“包含 Derived”。