RadiusNetworks / scanbeacon-gem

A Ruby gem for scanning beacons
MIT License
30 stars 9 forks source link

start on a CoreBluetooth ObjC extension #4

Closed syoder closed 9 years ago

syoder commented 9 years ago

Still a work in progress, but it works. Just need to wrap this up.

syoder commented 9 years ago

@csexton: not sure if you know how to properly do this, but I need a way to make it so my extension only compiles on a mac. So I added a section in the gemspec that makes a platform specific gem that includes the extension if there is an environment variable set. Then you have to build the gem twice: once for darwin and once for everything else. Do you know if this is the right way to do this?

csexton commented 9 years ago

This is rad. :100:

As for the platform specific build, I believe the right way to do this is with pre-compiler macros (like you already do with #ifdef __APPLE__). I can do a little more research tonight and see if I can find a proper approach. But you shouldn't have to build it twice, it should just build once for the current platform at install time.

We should be able to extend this to also look for BlueZ and support linux in a similar way.

syoder commented 9 years ago

The reason I wanted more than just the #ifdef is because I want to support platforms that don't have gcc (ie, OpenWRT). Even if it is ifdef'ed out, including the extension in the gemspec will mean that it wont install on platforms without a build system. Another option would be to build separate gems for different platforms. But even then, it looks like there is no way in the gemspec to define platform specific gem dependancies.

I would like to add BlueZ - that will be another PR once I do some research and figure out how to use it.