aBothe / Mono-D

D Add-In for MonoDevelop
http://wiki.dlang.org/Mono-D
Other
113 stars 26 forks source link

Fix detection of Mac OS X. #616 #617

Closed nicolasjinchereau closed 9 years ago

nicolasjinchereau commented 9 years ago

reference to Mono.Posix.dll must be added to the project. The file must be copied to the Mono-D distribution (./ext/Mono.Posix.dll), because it is not present on the Windows distribution of Xamarin Studio. Mono.Posix.dll can be found here: /Applications/Xamarin Studio.app/Contents/Resources/lib/monodevelop/AddIns/Xamarin.Sketches/XamarinInteractiveAgentsMac.app/Contents/MonoBundle/Mono.Posix.dll

The initial check for Unix will prevent the posix code from trying to run on windows.

nicolasjinchereau commented 9 years ago

@aBothe Merge?

aBothe commented 9 years ago

I was just too lazy to make further checks - I fear that one needs to externalize Mono.Posix-calls

nicolasjinchereau commented 9 years ago

I'm not sure what you mean by "externalize".

I tested this on Mac OSX and Windows. Both worked as expected.

Finally, this will stop the posix functions from being called on windows:

if(Environment.OSVersion.Platform != PlatformID.Unix)
    return false;
aBothe commented 9 years ago

Well okay, I just thought that .Net/Mono will load Mono.Posix as soon as it tries to execute the getter function for the first time - and then throws some TypeNotFound-Error because it can't locate some OS-agnostic DLL or so..but okay.. :D

nicolasjinchereau commented 9 years ago

Ok thanks =)

nicolasjinchereau commented 9 years ago

Just for reference, the call to uname or any unix functions will be called using Pinvoke: http://www.mono-project.com/docs/advanced/pinvoke/

Inside the DLL, there will be something like this:

[DllImport("libc.so")]
private static extern int uname(UTSName *buf);

If you try to call uname on Windows, you will get a DllNotFoundException, but the runtime will not attempt to look up uname if you don't call it.

aBothe commented 9 years ago

That's what I meant - but yeah, good to have the Unix-Platform-check :)

nicolasjinchereau commented 9 years ago

Sorry, just a reminder to add the DLL mentioned in the first comment ;)

nicolasjinchereau commented 9 years ago

Warning: putting out Mono-D without the Posix dll will break the windows build!

aBothe commented 9 years ago

Sorry for my laziness, I've released a new version depending on Mono.Posix as well :)

etcimon commented 9 years ago

My build is broken on windows :/ any idea where I can find this DLL ?

nicolasjinchereau commented 9 years ago

Alex just added it to the Mono-D repo: https://github.com/aBothe/Mono-D/tree/master/ext

aBothe commented 9 years ago

Well.. no, I'm not gonna distribute an entire dll just for executing 'uname' - I'll let mono-d execute 'uname' as a system command, not as a Posix-something API call.

nicolasjinchereau commented 9 years ago

I don't understand.. You've already included it in the /ext folder and referenced it. When you build with Xamarin Studio, it will be copied to the output folder automatically, and when you run .../mdtool setup pack, it will automatically be packaged in.

nicolasjinchereau commented 9 years ago

Unless you've deleted it purposely, which would be pointless, because it's only 195kb.

aBothe commented 9 years ago

@bitwise-github no, I had to reference the dll explicitly in the addin manifesto - I'm gonna execute uname now.

nicolasjinchereau commented 9 years ago

eek! You're right. Sorry bout that. I must have accidentally copied it while debugging. Thanks for the fix ;)

aBothe commented 9 years ago

No problem :) - I hope @etcimon can build and run Mono-D again now :D

etcimon commented 9 years ago

Hmm i dont have the build Platform setup on my VMware instance can you update the repo?

aBothe commented 9 years ago

I've uploaded a new version (2.13.3), if you mean that.