Last active
July 28, 2016 13:53
-
-
Save folkengine/a7c642119144ad108537 to your computer and use it in GitHub Desktop.
Example of a cross-platform ffi embed in Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rbconfig' | |
| require 'ffi' | |
| include RbConfig | |
| # Example of a cross-platform ffi embed in Ruby. | |
| module Hello | |
| extend FFI::Library | |
| if CONFIG['host_os'] =~ /linux/i | |
| ffi_lib 'target/release/libembed.so' | |
| elsif CONFIG['host_os'] =~ /mswin|windows|mingw/i | |
| fi_lib 'target/release/libembed.ddl' | |
| else | |
| ffi_lib 'target/release/libembed.dylib' | |
| end | |
| attach_function :process, [], :void | |
| end | |
| Hello.process | |
| puts 'Tis\' done!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment