compiledb
compiledb copied to clipboard
Different results betweent "compiledb make" and "make | compiledb"
I have these following files.
➜ test-compiledb$ tree
.
├── Makefile
├── main.c
└── subdir
├── Makefile
└── main.c
➜ test-compiledb$ cat Makefile
default:
make -w -C subdir
gcc main.c -o main.o
clean:
rm -rf subdir/main.o main.o
➜ test-compiledb$ cat subdir/Makefile
default:
gcc main.c -o main.o
I found the different results between compiledb make
and make | compiledb
.
➜ test-compiledb$ compiledb make
## Building [make]...
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$ cat compile_commands.json
[
{
"directory": "/Users/jiajiawang/Workspace/test-compiledb",
"arguments": [
"gcc",
"main.c",
"-o",
"main.o"
],
"file": "main.c"
}
]
One entry correspond to main.c
in subdir
is missing.
It's confusing that if you use make | compiledb
, everything is ok.
➜ test-compiledb$ make | compiledb
➜ 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"
}
]
Can someone tell me why?
Add more detail message.
Verbose message for compiledb make
:
➜ test-compiledb$ compiledb -v make
## Building [make]...
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
## Processing build commands from <stdout>
Line 1: Failed to parse build command [Details: (<class 'bashlex.tokenizer.MatchedPairError'>) unexpected EOF while looking for matching '`' (position 69)]. Ignoring: 'make: Entering directory `/Users/jiajiawang/Workspace/test-compiledb''
New command: make -w -C subdir
New command: gcc main.c -o main.o
Adding command 0: gcc main.c -o main.o
Line 4: Failed to parse build command [Details: (<class 'bashlex.tokenizer.MatchedPairError'>) unexpected EOF while looking for matching '`' (position 68)]. Ignoring: 'make: Leaving directory `/Users/jiajiawang/Workspace/test-compiledb''
## Failed to read previous compile_commands.json: Expecting value: line 1 column 1 (char 0)
## Writing compilation database with 1 entries to compile_commands.json
## Done.
Verbose message for make | compiledb
:
➜ test-compiledb$ make | compiledb -v
## Processing build commands from <stdin>
New command: make -w -C subdir
New command: gcc main.c -o main.o
Adding command 0: gcc main.c -o main.o
New command: gcc main.c -o main.o
Adding command 1: gcc main.c -o main.o
## Loaded compilation database with 2 entries from compile_commands.json
## Writing compilation database with 2 entries to compile_commands.json
## Done.
Hope this is helpful.