15knots / cmake4eclipse

Let Eclipse use CMake to generate the buildscripts for Eclipse CDT
Eclipse Public License 2.0
84 stars 26 forks source link

CMake Compilation DB Provider include pathes pointing nowhere #187

Open ChristianS99 opened 1 year ago

ChristianS99 commented 1 year ago

Describe the bug The entries of the CMake Compilation DB Provider are pointing to pathes like <workspace>/.metadata/.plugins/org.eclipse.cdt.docker.launcher/HEADERS/unix_var_run_docker_sock/<imagename>/usr/include (and others) Problem is, <workspace>/.metadata/.plugins/org.eclipse.cdt.docker.launcher/ is empty, no HEADERS dir.

Since this is a build inside a docker container, Compilation DB is expecting, that some one copies the headers from the container there, but doesn't. AsI don't know who should do this copying step, it might be that this isn't a problem from cmake4eclipse, but some other component. (But I have to start asking somewhere :) )

Expected behavior The needed inlcudes should be, where Compilation DB expects them or Compilation DB should search them at the right place (From a more higher level, I want the Indexer to work. During my investigation, this is what I noticed, but if there is a different way to make the indexer work, that's fine for me too)

Useful Information

What is in Eclipse's Error Log? <pls tell me, where I find those if needed>

Thx for help!

15knots commented 1 year ago

Describe the bug The entries of the CMake Compilation DB Provider are pointing to pathes like /.metadata/.plugins/org.eclipse.cdt.docker.launcher/HEADERS/unix_var_run_docker_sock//usr/include (and others) Problem is, /.metadata/.plugins/org.eclipse.cdt.docker.launcher/ is empty, no HEADERS dir.

AFAICT, copying the header files from the container into .../HEADERS is handled by CDT's docker launcher plugin at the end of a build (see org.eclipse.linuxtools.docker.ui.launch.ContainerLauncher#runCommand(String, String, IProject, IErrorMessageHolder, List<String>, String, List<String>, Map<String, String>, Properties, boolean, boolean, HashMap<String, String>, boolean). The directories that get copied are determined in org.eclipse.cdt.docker.launcher.ContainerCommandLauncher#execute(IPath, String[], String[], IPath, IProgressMonitor).

The CMake Compilation DB Provider does not handle copying but detects that the build was running in a container and the maps the directories reported inside the container (such as /usr/include) to .../HEADERS.

What is in Eclipse's Error Log? <pls tell me, where I find those if needed>

Windows | Show View | Error Log.

Problems encountered by the CMake Compilation DB Provider areshown in the Problems View at severity level 'Info'.

ChristianS99 commented 1 year ago
eclipse.buildId=4.28.0.20230608-1200
java.version=17.0.7
java.vendor=Gentoo
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=de_DE
Framework arguments:  -product org.eclipse.epp.package.cpp.product
Command-line arguments:  -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.cpp.product

org.eclipse.core.jobs
Error
Tue Sep 12 22:30:20 CEST 2023
An internal error occurred during: "Parsing compilation database of project dipra-switch".

java.lang.NullPointerException: Cannot invoke "org.mandas.docker.client.DockerClient.pull(String, org.mandas.docker.client.ProgressHandler)" because "clt" is null
    at org.eclipse.linuxtools.internal.docker.core.DockerConnection.pullImage(DockerConnection.java:1241)
    at org.eclipse.linuxtools.internal.docker.core.DockerConnection.pullImage(DockerConnection.java:1256)
    at org.eclipse.cdt.internal.docker.launcher.ContainerLaunchUtils.provideDockerImage(ContainerLaunchUtils.java:134)
    at org.eclipse.cdt.docker.launcher.ContainerCommandLauncher.execute(ContainerCommandLauncher.java:311)
    at de.marw.cmake4eclipse.mbs.internal.JsonCompilationDatabaseParser$EnvCommandlauncher.execute(JsonCompilationDatabaseParser.java:597)
    at org.eclipse.cdt.jsoncdb.core.internal.builtins.CompilerBuiltinsDetector.detectBuiltins(CompilerBuiltinsDetector.java:107)
    at org.eclipse.cdt.jsoncdb.core.CompileCommandsJsonParser.detectBuiltins(CompileCommandsJsonParser.java:290)
    at org.eclipse.cdt.jsoncdb.core.CompileCommandsJsonParser.processJsonFile(CompileCommandsJsonParser.java:193)
    at org.eclipse.cdt.jsoncdb.core.CompileCommandsJsonParser.parse(CompileCommandsJsonParser.java:455)
    at de.marw.cmake4eclipse.mbs.internal.JsonCompilationDatabaseParser.parseAndSetEntries(JsonCompilationDatabaseParser.java:316)
    at de.marw.cmake4eclipse.mbs.internal.JsonCompilationDatabaseParser$1.runInWorkspace(JsonCompilationDatabaseParser.java:407)
    at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:43)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

that's the only error I find in the error log, can't make much of it, but it looks like CDT.

Problem view has lot's of errors, all <symbol> could not be resolved, probably coming from the problem with the indexer. There are also some warnings, and one is

Description Resource    Path    Location    Type
File '/home/chriss/Radiodata/DipraSwitch/dipra-switch/branches/scada/daemon/_Ubuntu 18.04 Release/compile_commands.json' was not created in the build. Your workbench will not know all include paths and preprocessor defines. dipra-switch        org.eclipse.cdt.jsoncdb.core.CompileCommandsJsonParser  JSON compilation database

This is interesting as the build was not running in '.../_Ubuntu 18.04 Release/' but in '.../_Ubuntu 22.04 Debug' (I have different build configurations for different Ubuntu Releases, which are built with a docker container based on the matching Ubuntu Release) Maybe this is something to look at?

15knots commented 1 year ago

The stack trace stems from either CDT or org.eclipse.linuxtools. Looks like the client field of org.eclipse.linuxtools.internal.docker.core.DockerConnection is not initialized. So pls file an issue at CDT and reference this one over there.

Problem view has lot's of errors, all could not be resolved

These are compiler errors, take a look at the Console view, C/C++ Build console.

The message _compilecommands.json' was not created in the build is confusing to me: If the file does not exist, the code causing the NPE would never be called. Maybe it is a message that has not been deleted? You could check the timestamps.

ChristianS99 commented 1 year ago

yes, right. the message about compile_commands.json was old. It doesn't contain a timestamp, but it could be deleted, and doesn't appear again.