Replies: 2 comments 1 reply
-
Hi @thahnen For CDT managed build projects, take a look at: InternalCoreModelUtil.findBuildConfiguration() for some inspiration. The CDT CMakeProjectGenerator assumes a build folder named Does this answer your question? |
Beta Was this translation helpful? Give feedback.
1 reply
-
Just for everyone looking at this thinking about what the solution was: No direct solution was found for CMake, but an overall "good" solution was found: public Set<IPath> getExcludedPaths(IProject project) {
var exclusions = new HashSet<IPath>();
try {
// 1) Check whether this is a CDT project
var cProject = CoreModel.getDefault().getProjectDescription(project, false);
if (cProject == null) {
return exclusions;
}
var projectPath = project.getFullPath().makeAbsolute().toOSString();
// 2) Iterate over all the different configurations, e.g. Debug or Release
for (var config : cProject.getConfigurations()) {
var configData = config.getConfigurationData();
if (configData == null) {
continue;
}
var buildData = configData.getBuildData();
if (buildData == null) {
continue;
}
// 3) Iterate over all the output directories as there can be multiple ones per configuration
for (var outputDirectory : buildData.getOutputDirectories()) {
var outputDirectoryPath = outputDirectory.getFullPath().makeAbsolute().toOSString();
if (!projectPath.equals(outputDirectoryPath)) {
// Only when the output directory is not the project directory we keep it. For example CMake projects can
// generate CDT projects where the output is the project directory, this case should not be taken into
// account and is up to the user. By default we will exclude compilation output when it is somewhere in a
// sub-directory, e.g. "Debug" or "Release"!
exclusions.add(org.eclipse.core.runtime.Path.fromOSString(
"/" + project.getName() + "/" + outputDirectory.getFullPath()));
}
}
}
} catch (Exception err) {
SonarLintLogger.get().error("Error while getting the exclusions of project '" + project.getName()
+ "' based on CDT!", err);
}
return exclusions;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone,
Context
I have quite a specific question, but first I'd like to give some context:
In our Eclipse plug-in, we list all the files in a project and want to exclude files that are not related to the actual project content - like the generated and compiled output. In case of Java it would be the output directory (
bin
/build
/target
/ whatever).For JDT projects it is quite simple (after checking that it is actually a JDT project):
This code snippet above is a bit simplified.
Question
So, now leading to my queston. I'm not that familiar with CDT as well as CMake but from what I found out by testing by creating a normal C/C++ project inside Eclipse CPP as well as creating a simple CMake project and running the generator for Eclipse CDT4 - Unix Makefiles there doesn't seem to be something like a classpath.
I've checked the
.cproject
files from both projects and took a look at the CDT source code, starting withorg.eclipse.cdt.core.CCorePlugin
. There are this kind ofbuilder
tags that have abuildPath
attribute in the XML.But not for CMake projects that generated everything.
From the code, I couldn't find any reference except for it to be used in the
CCorePlugin#getExtensionScannerInfoProvider2
method. This seems to parse the XML structure?!Questions:
buildPath
attribute for thebuilder
in a straight CDT project?Thanks for some help and guidance in advance 🙇♂️
Best,
Tobias
Beta Was this translation helpful? Give feedback.
All reactions