premake / premake-core

Premake
https://premake.github.io/
BSD 3-Clause "New" or "Revised" License
3.22k stars 620 forks source link

Visual Studio backend creates too many configurations. #767

Closed tvandijck closed 7 years ago

tvandijck commented 7 years ago
workspace 'premake-test'
    platforms { 'A', 'B' }
    configurations { 'Debug', 'Release' }

    filter { 'platforms:A' }
        system 'windows'
        architecture 'x86'

    filter { 'platforms:B' }
        system 'windows'
        architecture 'x86_64'

I end up with a project that has:

  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug A|Win32">
      <Configuration>Debug A</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug A|x64">
      <Configuration>Debug A</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug B|Win32">
      <Configuration>Debug B</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug B|x64">
      <Configuration>Debug B</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release A|Win32">
      <Configuration>Release A</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release A|x64">
      <Configuration>Release A</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release B|Win32">
      <Configuration>Release B</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release B|x64">
      <Configuration>Release B</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
  </ItemGroup>

while I expect half of those. Interestingly the rest of the vcxproj file seems to be correct, as is the .sln file.

samsinsane commented 7 years ago

It looks like there's quite a bit of code in the _vstudio.lua file that assumes that platform is either a system or architecture, which I'm guessing results in your issue. If you were to add those platforms into the vstudio.vs2010_architectures array, I imagine it would reduce the above list?

Perhaps we should try to remove those two lookup tables. They tend to impede module development, which isn't great, I think the first time I encountered this "if it's not in the list it's Win32" thing, it took me probably up to an hour to figure it out. I see how it got there, but it really should be a translation table (these platform values are Win32) instead of what it currently does (these platforms are these architectures, everything else is Win32).

starkos commented 7 years ago

While I don't remember the specifics exactly, Visual Studio will complain if you don't have an entry for every configuration/architecture pair. So even though "Debug A" can only ever build for Win32, you will encounter issues (again sorry I can't remember the specifics, might be a comment in the code) if you don't have a "Debug A|x64" entry.

tvandijck commented 7 years ago

Yeah, I just noticed this... I don't think this is a bug.... it's still stupid, and very unexpected... but not a premake issue...