Sarcasm / irony-mode

A C/C++ minor mode for Emacs powered by libclang
GNU General Public License v3.0
906 stars 99 forks source link

Problem on JSON compilation database parsing #520

Open av0r opened 5 years ago

av0r commented 5 years ago

Hello! I created simple project to illustrate the problem:

.
├── meson.build
└── src
    ├── hello.c
    ├── include
    │   └── hello.h
    └── main.c

after that I run 'meson build' and 'ninja-build -C build' and get

.
├── build
│   ├── build.ninja
│   ├── compile_commands.json
│   ├── hello_world
│   ├── hello_world@exe
│   │   ├── src_hello.c.o
│   │   └── src_main.c.o
│   ├── meson-logs
│   │   └── meson-log.txt
│   └── meson-private
│       ├── build.dat
│       ├── coredata.dat
│       ├── install.dat
│       ├── meson_benchmark_setup.dat
│       ├── meson.lock
│       ├── meson_test_setup.dat
│       ├── sanitycheckc.c
│       └── sanitycheckc.exe
├── meson.build
└── src
    ├── hello.c
    ├── include
    │   └── hello.h
    └── main.c

but when I start emacs with irony for some file in project I get:

In ".":
error opening 'hello_world@exe/src_hello.c.o.d': No such file or directory

and such file appears:

.
├── build
│   ├── build.ninja
│   ├── compile_commands.json
│   ├── hello_world
│   ├── hello_world@exe
│   │   ├── src_hello.c.o
│   │   ├── src_hello.c.o.d
│   │   └── src_main.c.o
│   ├── meson-logs
│   │   └── meson-log.txt
│   └── meson-private
│       ├── build.dat
│       ├── coredata.dat
│       ├── install.dat
│       ├── meson_benchmark_setup.dat
│       ├── meson.lock
│       ├── meson_test_setup.dat
│       ├── sanitycheckc.c
│       └── sanitycheckc.exe
├── meson.build
└── src
    ├── hello.c
    ├── include
    │   └── hello.h
    └── main.c

but it contains only: hello_world@exe/src_hello.c.o: And completion doesn't work. compilation_database.json:

[
  {
    "directory": "/home/andrei/programming/hello_world/build",
    "command": "cc -Ihello_world@exe -I. -I.. -I../src/include -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g  -MD -MQ 'hello_world@exe/src_main.c.o' -MF 'hello_world@exe/src_main.c.o.d' -o 'hello_world@exe/src_main.c.o' -c ../src/main.c",
    "file": "../src/main.c"
  },
  {
    "directory": "/home/andrei/programming/hello_world/build",
    "command": "cc -Ihello_world@exe -I. -I.. -I../src/include -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g  -MD -MQ 'hello_world@exe/src_hello.c.o' -MF 'hello_world@exe/src_hello.c.o.d' -o 'hello_world@exe/src_hello.c.o' -c ../src/hello.c",
    "file": "../src/hello.c"
  }
]
Sarcasm commented 5 years ago

I think the issue comes from the -M options that should be stripped. CMake does not put them in the generated compilation database for example.