Pure-D / workspace-d

CLI deprecated, API + functionality moved into https://github.com/Pure-D/serve-d
MIT License
75 stars 15 forks source link

Support compile_commands.json #110

Closed rtbo closed 2 years ago

rtbo commented 3 years ago

Some build systems such as CMake and Meson issue a compile_commands.json file intended to be read by linters. This could be used as alternative to Dub to provide the import paths and other options.

The compile_commands.json provide one entry per source file with the build options:

[
  {
    "directory": "C:\\sdk\\gfx-d\\builddir",
    "command": "\"ldc2\" \"-I=vulkan\\libgfxd_vulkan.a.p\" \"-I=vulkan\" \"-I=..\\vulkan\" \"-I=..\\vulkan\\source\" \"-I=..\\graal\\source\" \"-I=..\\core\\source\" \"-I=..\\math\\source\" \"-enable-color\" \"-wi\" \"-m64\" \"-g\" \"-d-debug\" \"-relocation-model=pic\" -of=vulkan/libgfxd_vulkan.a.p/source_gfx_vulkan_device.d.obj \"-c\" ../vulkan/source/gfx/vulkan/device.d",
    "file": "../vulkan/source/gfx/vulkan/device.d",
    "output": "vulkan/libgfxd_vulkan.a.p/source_gfx_vulkan_device.d.obj"
  },
  ...
]

It should be quite easy to parse the command field and extract the relevant import dirs, versions, debug flags etc.

WebFreak001 commented 3 years ago

see also: #101