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

Fix D module compiler output for visual studio #1658

Merged
merged 3 commits into from
Jul 8, 2021

Conversation

nickclark2016
Copy link
Member

@nickclark2016 nickclark2016 commented Jun 24, 2021

What does this PR do?

This fixes the output for the D compiler. In Visual Studio, this forces a compiler to be set in the project file.

The problem was that the toolset for D projects was always being set to "msc-v142" for Visual Studio 2019 (did not check the value for previous versions of VS). If the toolset was defined in the premake script, it was not an allowed value. The only way for this to work previously was by using --dc=dmd (change dmd to your preferred D compiler).

How does this PR change Premake's behavior?

There are no breaking changes. All changes are to fix the "D" module (and allow for other module support). Premake now supports the "dmd", "gdc", and "ldc" toolset options for D projects. This was done by adding them to the allowed values in the "toolset" premake field.

Usage:

workspace "test"
    configurations { "debug" }

    project "t"
        kind "ConsoleApp"
        language "D"
        toolset "dmd"
        files "**.d"

| Module / Toolset | Old Output | New Output |
| --- | --- |
| VS 2019 / dmd | | 0 |
| VS 2019 / gdc | | 1 |
| VS 2019 / ldc | | 2 |

Anything else we should know?

Closes #1603

So what next? The gmake module still needs work to actually function. When running with "gmake" on the command line, it still attempts to go through the C++ module instead of the D module. In order to minimize the number of changes in the review, I will leave that for another day.

Did you check all the boxes?

  • Focus on a single fix or feature; remove any unrelated formatting or code changes
  • Add unit tests showing fix or feature works; all tests pass
  • Mention any related issues (put closes #XXXX in comment to auto-close issue when PR is merged)
  • Follow our coding conventions
  • Minimize the number of commits
  • Align documentation to your changes

You can now support Premake on our OpenCollective. Your contributions help us spend more time responding to requests like these!

Copy link
Member

@starkos starkos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, thanks for digging into this one, much appreciated.

I'm thinking that long term (like for v6) it probably makes sense to merge the ideas of "language" and "toolset". You specify the compiler/linker etc. which implicitly determines what language(s) can be used. That's probably a breaking change, so maybe not for v5. I'll open a discussion about it when I get closer to working it.

I'll also be using the v6 break to heavily rework the Gmake exporters in general, get it aligned with the way things are done in vstudio module currently. That's probably next on my to-do list. Check out the v6 branch if you're interested.

@nickclark2016
Copy link
Member Author

No problem! I'll go ahead and mark this ready once I make sure the documentation on the website is up to date.

@nickclark2016 nickclark2016 changed the title Fix D module compiler output for gmake and visual studio Fix D module compiler output for visual studio Jun 29, 2021
@nickclark2016 nickclark2016 marked this pull request as ready for review June 30, 2021 04:31
@starkos starkos merged commit 4be2a96 into premake:master Jul 8, 2021
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

Successfully merging this pull request may close these issues.

Generated solutions for D unreadable by Visual Studio
2 participants