Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different results betweent "compiledb make" and "make | compiledb" #102

Open
J-keaper opened this issue Jun 30, 2020 · 1 comment
Open

Comments

@J-keaper
Copy link

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?

@J-keaper
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant