0xabu / MsBuildCompileCommandsJson

An MSBuild logger that emits compile_commands.json for C++ projects
MIT License
43 stars 8 forks source link

[Help] support turn msvc compile commands to clang compile commands? #1

Closed roachsinai closed 2 years ago

roachsinai commented 2 years ago

Hi, @0xabu this repo is very useful to export msvc compile commands.

But could it support export change cl.exe to clang++?

Thanks again for this repo!

0xabu commented 2 years ago

You have a project that builds with MSVC but want to have a compilation database with clang commands. Why would that be useful?

It sounds like a messy problem that is probably impossible to solve in a general sense. It would involve mapping command-line arguments between compilers. Obviously that mapping is not complete (some MSVC flags have no Clang equivalent), but even if it were, it would not make sense to pass the same parameters (e.g. system headers, libc/STL headers, will differ between the compilers).

roachsinai commented 2 years ago

You have a project that builds with MSVC but want to have a compilation database with clang commands. Why would that be useful?

Yes, I'm trying use vim in Windows with some MSVC project, most needed function is intelligence completion provided by language server protocol. Your repo give me the hope.

It sounds like a messy problem that is probably impossible to solve in a general sense. It would involve mapping command-line arguments between compilers. Obviously that mapping is not complete (some MSVC flags have no Clang equivalent), but even if it were, it would not make sense to pass the same parameters (e.g. system headers, libc/STL headers, will differ between the compilers).

Agree with this, too. Maybe no need to add too much compile flag/arguments to let lsp works. I'll check whether this is possible when absolute perfect mapping not must.

Thanks for your quick reply!

0xabu commented 2 years ago

Ah, ok. In that case it probably just cares about a few specific flags (e.g. CPP defines, include paths, forced includes, language standards, etc.), so it may be practical to build a bunch of replacements to handle those. I'm not sure it makes sense as part of this project however.

roachsinai commented 2 years ago

@0xabu Yes, agree with the last sentence. Thanks!