mono / CppSharp

Tools and libraries to glue C/C++ APIs to high-level languages
MIT License
3.14k stars 518 forks source link

Build of dependencies fails with VS 2017 only installed (and MS Build tools) #786

Closed realvictorprm closed 7 years ago

realvictorprm commented 7 years ago

Brief Description

The build of the dependencies with VS 2017 installed fails due to unrecognized ms build tools version. The error is located in the Lua script for LLVM simply because there isn't a handler for VS 2017.

See here:

function get_toolset_configuration_name()
  if os.is("windows") then
    local function get_vs_version(ver) -- No handler for version greater than 19!
      if     ver == "19" then return "vs2015"
      elseif ver == "18" then return "vs2013"
      elseif ver == "17" then return "vs2012"
      else error("Unknown MSVC compiler version, run in VS command prompt.") end
    end

    local vsver = _ACTION
    local arch = "x86"

    if not string.starts(vsver, "vs") then
      local out = outputof("cl")
      local ver, arch = string.match(out, '(%d+).%d+.%d+.?%d*%s+%w*%s+(%w+)')
      vsver = get_vs_version(ver)
    end

    return table.concat({vsver, arch}, "-")
  end
  -- FIXME: Implement for non-Windows platforms
  return nil
end

Experimental Workaround

The function for getting the vs version can be changed to following:

local function get_vs_version(ver) -- Act like VS 2017 would be VS  2015
      if     ver >= "19" then return "vs2015" -- change it to a >= and do like it's vs2015
      elseif ver == "18" then return "vs2013"
      elseif ver == "17" then return "vs2012"
      else error("Unknown MSVC compiler version, run in VS command prompt.") end
    end

Is this fine for building the dependencies? Can someone check whether it makes any problems? This worked at least for me.

ddobrev commented 7 years ago

@realvictorprm thank you very much for agreeing to help as written at https://github.com/mono/CppSharp/issues/785 . The workaround might... work but now that you've seriously got to adding this support, I think we'd better have it for real. That is, what's needed is a new entry for "vs2017" and everything else just as the existing entries for VS 2015 and behind have.

realvictorprm commented 7 years ago

Is there some place where I can dig into this whole stuff a bit? I don't know the impact of this. E.g the workaround doesn't work. I'm struggeling with lua, trying to find out where the version values is comming from.

Do we have gitter or something similar to talk about the stuff?

ddobrev commented 7 years ago

If Skype is fine by you, please get my e-mail from one of my commit messages and send me a letter. I'll reply to you with my Skype contact.

tritao commented 7 years ago

Closing since we have other issues tracking VS 2017.

realvictorprm commented 7 years ago

This issue is definitely fixed!