LORgames / premake-winrt

4 stars 3 forks source link

winrt.lua:30: attempt to index a nil value (field 'vc2010') #6

Open sagamusix opened 5 years ago

sagamusix commented 5 years ago

I'm currently trying to set this module up to work with premake5 beta13. The error message cited in the title shows up when doing a simple require("winrt"). Is this module still supported with the latest premake5 beta?

samsinsane commented 5 years ago

Sorry for taking so long to get back to you, I think all you need is require "vstudio" before require "winrt".

sagamusix commented 5 years ago

Ah yes, that did the trick. A short usage notice in the readme would be excellent to have.

Now there's a different issue: Error: invalid value 'windowsuniversal' for system I suppose this might be due to the fact that universal apps are listed as only partially supported in the readme? At this point my premake file is pretty minimal:

require("vstudio")
require("winrt")

 solution "OpenMPT"
 project "winrtmidi"
  uuid "E5656EB6-6148-4D79-AE2A-5C25E85A2FFC"
  system "windowsuniversal"
  language "C++"
  consumewinrtextension "true"

My goal is to compile a WinRT DLL making use of some Win10 APIs that are not available in regular C++.

samsinsane commented 5 years ago

Ah yes, that did the trick. A short usage notice in the readme would be excellent to have.

I believe this requirement came with alpha13, and I haven't updated the module since it came out.

I suppose this might be due to the fact that universal apps are listed as only partially supported in the readme?

Looks like there was a small issue that I never fixed in the module (strangely, it's fixed in my VSLinux module), so you'll need:

require "vstudio"
dofile "tools/premake/modules/winrt/_preload.lua"
require "winrt"

My goal is to compile a WinRT DLL making use of some Win10 APIs that are not available in regular C++.

I have not tried to do that with this module, but if you need to make any changes I'd be happy to review and accept PRs for them. Otherwise, I might eventually get around to setting this kind of thing up for my project and push the various changes and fixes back.

sagamusix commented 5 years ago

With that modification, the project can now be generated. It's unable to load in VS2017 though. As I'm completely new to this WinRT stuff and only have time available, I'm not sure if I will be able to contribute anything to fix this anytime soon.

samsinsane commented 5 years ago

I set up an empty test project and it seems to generate the Universal Project and load in VS2017 for me. Once I installed the "Universal Windows Platform development" workload, I attempted to create a Universal C++ project via the VS2017 Create Project Wizard. This required C++ specific UWP components to be installed and clicking OK started the installer and prompted to begin the installation, once that was all done it worked fine. Prior to this, I was getting the unable to load errors, so perhaps you're also missing these C++ specific components?

sagamusix commented 5 years ago

Maybe I am missing some components for the premake-generated projects, but in general I can compile WinRT DLLs. For the reference, I am trying to make https://github.com/stammen/winrtmidi/ into a premake-based project and not use its provided solution. The provided solution works but only if I hardcode a specific path in the "Additional #using Directories" project setting (most likely there is a constant to use for that path but I didn't get that far, I just wanted it to compile).

samsinsane commented 5 years ago

Those projects don't have ApplicationType or ApplicationTypeRevision, so I'm guessing Microsoft changed how WinRT projects work between VS2013 and VS2015 or something. To generate those projects, I think you just target Windows like normal but add something like this:

premake.override(premake.vstudio.vc2010, "compileAs", function(base, cfg)
    base(cfg)
    premake.vstudio.vc2010.element("CompileAsWinRT", nil, true)
end)

I haven't tested this at all, but that's the only thing that stood out to me.

sagamusix commented 5 years ago

Thanks, I'm getting there. true needs to be put in quotes, and I also had to override runtimeLibrary to not output anything. Now I'm as far as before, but with premake. :)

The problem now is that the compiler cannot find Windows.winmd, and when I solved this issue the first time (without premake) I pretty much followed this blog post which also just hardcodes those paths - but I cannot believe that this is the official way to make this work...

samsinsane commented 5 years ago

I'm glad you got it working, I'm not sure I can provide any insight into the WinMD paths though.