deplinenoise / tundra

Tundra is a code build system that tries to be accurate and fast for incremental builds
MIT License
438 stars 74 forks source link

Added msvc-clang tools #343

Closed leidegre closed 9 months ago

leidegre commented 10 months ago

Now that Microsoft is actually distributing Clang as part of Visual Studio you can use clang instead of Visual C++ when you want to. There's more than one way to do this and I've just taken the easy path here to get something going.

In this first iteration, I've used the clang-cl and lld-link frontends because it allowed me to reuse the msvc base. This might not be desirable as the whole point of using clang is to gain access to clang features while this could be nice to have I'm wondering if people wouldn't rather see a more native clang interface?

With that said, given the following tundra.lua:

Build {
  Configs = {
    {
      Name = "win64-clang",
      DefaultOnHost = "windows",
      Tools = {
        "msvc-clang"
      }
    }
  },
  Units = {
    function()
      Program {
        Name = "test",
        Sources = {
          "test.cc"
        }
      }

      Default("test")
    end
  }
}

...we can build this program:

#include <cstdio>

int main()
{
  printf("clang version %s\n", __clang_version__);
  return 0;
}

...which will output:

clang version 16.0.5

Toughts?

deplinenoise commented 10 months ago

I see no reason to not add this

leidegre commented 10 months ago

Okay, let's go! I've used this a little and it works well enough, if anyone runs into any issues using this let me know I'll happily fix 'em. Just let me figure out why there's a conflict, shouldn't be there...

leidegre commented 10 months ago

Okay, looks like the conflict is gone now.

Bare in mind that this will only work if the clang tools are installed with the Visual Studio version and product you are targeting. There's no nice error message if you forget about this, you just get a command clang-cl not found error or similar. And since it is based on the msvc-latest tools it can be configured the same way.

emoon commented 10 months ago

I will try to give this a spin as as I can get to it.

deplinenoise commented 9 months ago

Merged, thanks!