0

Overview

I working on an OS project. It only uses header-files provided by the project code-base. The CMake meta-build, and ninja build system seems to be unrecognized by compilation and code-completion system out-of-the box. I've solved the syntax-checker, and I provide the solution for context.

For code-completion, it's working in parts. I think it's running on company-etags, which gets the function names, but not the rest of the signature. I'm after a solution that can include the arg-types in the code-completion.

Suspected cause: file structure confusing the company backend

Extract of the code-base structure. . is the repository root. The

.
├── build
│   ├── build.ninja
│   ├── CMakeCache.txt
│   ├── CMakeFiles
│   ├── rules.ninja
│   ├── projects
│   │   ├── ...

    ...
    ...
├── CMakeLists.txt -> tools/seL4/cmake-tool/default-CMakeLists.txt
├── init-build.sh -> projects/aos/init-build.sh
├── .gitignore -> projects/aos/.gitignore
├── projects
│   ├── aos <- all development happens in here. 
│   │   ├── CMakeLists.txt
│   │   ├── .gitignore
│   │   ├── compile_commands.json
│   │   ├── init-build.sh
│   │   ├── CMakeLists.txt
        ...
│   │   ├── some-aos-proj-lib
│   │   │   ├── CMakeLists.txt
│   │   │   ├── include
│   │   │   │   └── aos
│   │   │   │       ├── some-lib-file.h
│   │   │   │       ├── another-lib-file.h
│   │   │   └── src
│   │   │       ├── irq.h <- location of one func sig that completion needs
│   │   │       ├── ...
│   ├── some-lib <- the sub-dirs of libs at this level
│   │   ├── ... <- contain a bunch of .h files needed for code completion
│   ├── another-lib 
│   │   ├── ...
        ...
...

initially /build is empty. To build the project:

$ cd build
$ ../init-build.sh
$ ninja

Problem

I've solved the compile-time problem of the header-file resolution of the default M-x projectile-project-compile (<.h> and ".h"), but code completion is still name only (seems to be running on an etags backend.

  ;; runs a ninja build from the path in .build-dir
  (projectile-register-project-type 'ninja '(".build-dir")
                                    :compile "ninja -C `cat .build-dir`")

NOTE: .build-dir has the single line /full/path/to/build, so ninja happens in /build

Stuck!

So now we come to where I'm stuck: code-completion.

In trying to solve this code-completion problem, this is what I've learned

  • company needs a backend.
  • The irony backend can work with a compilation database (cdb)
  • The ninja build system can generate the cdb for irony
  • There is some sort of mechanism forcompany-irony to use a cdb for completion.

referencing this question, we get to see a hint at what to do. Because this project I'm working on is structured differently, I'm not so sure about where my project root, and what paths to add to compile-command, as far as company is concerned.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.