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

MSYS2: empty compile_commands.json when running from make target #125

Closed MerijnHendriks closed 2 years ago

MerijnHendriks commented 2 years ago

As the title says, when running from a make target using msys2's make package (https://packages.msys2.org/package/make), the compile_commands.json file is an empty array.

analyze:
    compiledb -n make

But when I run it from terminal directly, it produces a correct compile_commands.json:

$ compiledb -n make

I tried specifying the path directly (absolute, relative) and the file directly, but no dice.

MerijnHendriks commented 2 years ago

A more clear example.

Folder structure:

project/
  include/
    ext.h
  src/
    main.c
  obj/
    main.c.o
  makefile

The makefile:

analyze:
    $(MAKE) -Bnwk debug | compiledb -o- | cat

Running through the make target:

$ make analyze
make -Bnwk debug | compiledb -o- | cat
[]

Running from the command line directly:

$ make -Bnwk debug | compiledb -o- | cat
[
 {
  "directory": "C:/Users/User/Documents/Projects/vscodellvm/projects/app",
  "arguments": [
   "clang",
   "-Werror",
   "-Wall",
   "-Wextra",
   "-Wpedantic",
   "-Wdeprecated",
   "-std=c99",
   "-MMD",
   "-MP",
   "-Iinclude",
   "-DDEBUG",
   "-g",
   "-Wno-unused",
   "-c",
   "src/main.c",
   "-o",
   "obj/src/main.c.o"
  ],
  "file": "src/main.c"
 }
]
MerijnHendriks commented 2 years ago

Using the mingw32-make package (https://packages.msys2.org/base/mingw-w64-make) instead solved my issue!