Che: Add support for C/C++

Created on 4 Jul 2019  路  19Comments  路  Source: eclipse/che

Description

We should have support for C/C++ out of the box in Eclipse Che.

The work would consist in integrating existing C/C++ language server and provide default stack for it.

Reference:
[1] https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools
[2] https://docs.google.com/document/d/182PBN5LBNTlbhsqqsb5QHg9t5HNK3rSLrnIMPSGjyN0/edit#heading=h.tyhhnnuon2rs
[3] https://github.com/eclipse-cdt/cdt-vscode
[4] https://github.com/eclipse-cdt/cdt-gdb-vscode

Screenshot from 2019-08-06 12-40-35

arelanguages kinenhancement statublocked tealanguages

Most helpful comment

from @ferdaarikan:
We should also reach out to: https://github.com/eclipse-cdt/cdt-vscode and check if they would be interested to publish the CDT VS Code extension to Che.

All 19 comments

@slemeur one of the getting-started [1] factories is C/C++
Are you ok to replace it with Go for Che 7 GA? Once C/C++ support will be in place we would also add a dedicated devfile to the getting-started page

[1] https://www.eclipse.org/che/getting-started/cloud/

@ibuziuk yep.

from @ferdaarikan:
We should also reach out to: https://github.com/eclipse-cdt/cdt-vscode and check if they would be interested to publish the CDT VS Code extension to Che.

It's ok to do this after 7.0, but is it something we _need_ to do in the first sprint after 7.0? I imagine we'll have plenty of bugs to fix.

The C++ VS Code extension has the same license problems as the C# one has: we cannot reuse it. This needs analysis, but we'll probably have to package our own plugin. The language server (clangd) does not have licensing problems.

@tsmaeder @slemeur
eclipse-cdt/cdt-vscode [1] provides the same functionality as VS Code extension [2] but it work in conjunction with two other extensions [3] [4]

[1] https://github.com/eclipse-cdt/cdt-vscode
[2] https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools
[3] https://github.com/eclipse-cdt/cdt-gdb-vscode
[4] https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd

And is it possible to package them together?

I think so.

@l0rd
Could you pls create a repository in https://github.com/che-incubator/ to put dockerfiles to build and host vsix packages for [1] [2]

For instance che-incubator/che-cpptools

[1] https://github.com/eclipse-cdt/cdt-vscode
[2] https://github.com/eclipse-cdt/cdt-gdb-vscode

Can I ask some question about this issue?
Is there any plan to support LLVM (Clang) in this C++ environment(dockerfile)?

@wonjooncho
Hello.
There will be two docker containers:

  1. custom docker container with tools needed to run C++ plugin: clang g++ gdb
  2. development container with g++, gdb: https://registry.centos.org/centos/devtoolset-7-toolchain-centos7/latest

Here is the devfile for the testing purpose to play with c/c++ tools

Screenshot from 2019-08-06 12-40-35

apiVersion: 1.0.0
metadata:
  name: cpp
projects:
  -
    name: cpp-hello-world
    source:
      type: git
      location: 'https://github.com/che-samples/cpp-hello-world'
components:
-
  type: chePlugin
  reference: https://raw.githubusercontent.com/tolusha/plugins-registry/master/plugins/tolusha/cpptools/0.1/meta.yaml
  alias: cpp-plugin
  preferences:
    clangd.path: /usr/bin/clangd
    cdt.clangd.binaries.enable: false
-
  type: dockerimage
  alias: cpp-dev
  image: registry.centos.org/centos/devtoolset-7-toolchain-centos7
  command: ['sleep']
  args: ['infinity']
  memoryLimit: 512Mi
  mountSources: true
commands:
  -
    name: build
    actions:
      - type: exec
        component: cpp-dev
        command: g++ -g hello.cpp -o hello.out
        workdir: ${CHE_PROJECTS_ROOT}/cpp-hello-world
  -
    name: debug
    actions:
      - type: vscode-launch
        referenceContent: >
          {
            "version": "0.2.0",
            "configurations": [
                {
                    "type": "gdb",
                    "name": "Debug c++ application",
                    "request": "launch",
                    "program": "/projects/cpp-hello-world/hello.out"
                }
            ]
          }

@tolusha

When I created a workspace with c/c++ stack I faced the same issue as below screen.
image

Even if I reload, I keep getting a message to reload.
I used the che-theia, plugin-registry and devfile-registry you updated recently.

I would appreciate it if you would help this issue.

@kellyhyomin
Unfortunately I can't test the plugin with the latest images due some issues.

  1. Regarding its current state, the error above is expected because @theia/cpp extension isn't disabled in the version of Theia that is used for testing purpose. Despite the error the LS should work. Could you try some LS features to check it?

  2. clang is installed (it is requirement for plugins to work) in a sidecar container and not in a dev container.

@tolusha
Thank you for your help.
What version of theia can I use with the @ theia/cpp extension?
Other features, such as the hover function, seem to be working, but the code completion does not work properly.

It is supposed to use Che c/c++ plugin with the latest version or Eclipse Che (7.1.0-SNAPSHOT) but we have to fix this issue [1] at first
[1] https://github.com/theia-ide/theia/issues/5993

@tolusha
Thank you for your help.
I am using your devfile.yaml(https://github.com/eclipse/che-devfile-registry/blob/ab/cpp/devfiles/cpp/devfile.yaml) in che 7.1.0 version.
Why build g ++ with cpp-dev terminal rather than building with clang in cpp-plugin terminal?
I want to build with clang.

@kellyhyomin
I guess that's not a problem.

When you need to create a workspace just add a new component (or replace the existed) in the devfile and set the image with the clang inside. For instance:

  type: dockerimage
  alias: cpp-dev-clang
  image: <some image>
  command: ['sleep']
  args: ['infinity']
  memoryLimit: 512Mi
  mountSources: true
Was this page helpful?
0 / 5 - 0 ratings