nickdiego / compiledb

Tool for generating Clang's JSON Compilation Database files for make-based build systems.
GNU General Public License v3.0
1.38k stars 123 forks source link

It seems that compiledb cannot parse gmake's change directory message #101

Open J-keaper opened 4 years ago

J-keaper commented 4 years ago

I have the following two files: make.log is build log for make; gmake.log is build log for gmake; There is no difference except build tool( make/gmake) in the build. But the output of parsing the two files using compiledb are different. Please see the following operation:

➜  test-compiledb$ cat make.log              
make -w -C subdir
make[1]: Entering directory `/Users/jiajiawang/Workspace/test-compiledb/subdir'
gcc main.c -o main.o
make[1]: Leaving directory `/Users/jiajiawang/Workspace/test-compiledb/subdir'
gcc main.c -o main.o
➜  test-compiledb$ compiledb -p make.log 
➜  test-compiledb$ cat compile_commands.json 
[
 {
  "directory": "/Users/jiajiawang/Workspace/test-compiledb/subdir",
  "arguments": [
   "gcc",
   "main.c",
   "-o",
   "main.o"
  ],
  "file": "main.c"
 },
 {
  "directory": "/Users/jiajiawang/Workspace/test-compiledb",
  "arguments": [
   "gcc",
   "main.c",
   "-o",
   "main.o"
  ],
  "file": "main.c"
 }
]

It's perfect, but when it meet gmake, something is wrong.

➜  test-compiledb$ cat gmake.log 
gmake -w -C subdir
gmake[1]: Entering directory '/Users/jiajiawang/Workspace/test-compiledb/subdir'
gcc main.c -o main.o
gmake[1]: Leaving directory '/Users/jiajiawang/Workspace/test-compiledb/subdir'
gcc main.c -o main.o
➜  test-compiledb$ compiledb -p gmake.log   
➜  test-compiledb$ cat compile_commands.json   
[
 {
  "directory": "/Users/jiajiawang/Workspace/test-compiledb",
  "arguments": [
   "gcc",
   "main.c",
   "-o",
   "main.o"
  ],
  "file": "main.c"
 }
]

There is only one entry, other one entry is missing. Missing entry correspond to main.c in subdir. So i guess compiledb cannot parse gmake's change directory message.

And I read parser.py,i saw these following two lines code:

make_enter_dir = re.compile(r"^\s*make\[\d+\]: Entering directory [`\'\"](?P<dir>.*)[`\'\"]\s*$")
make_leave_dir = re.compile(r"^\s*make\[\d+\]: Leaving directory .*$")

Indeed these two regular expression cannot successfully match the change directory message in gmake.log above.

Is my statement above correct? Am I missing something? If it is true, can you support this?