I have found a blog about how to package Ruby C extensions
According to the blog (
), it says
- Platform independent Ruby gems with native C extension
-
Add your C extension source files only: that is the .c and extconf.rb
files only. No need for Makefile and compiled files. -
Add ext directory to the required paths
-
Keep the platform as Ruby (independent)
-
Register the C extensions you are including: this will tell RubyGems
that there is a compilation step upon installation. This is done by
giving all the paths to extconf.rb files.
- Platform dependent Ruby gems with native C extension
-
Add your compiled C extension files (exactly the same way you do for
normal Ruby files) -
Add ext directory to the required paths
-
Set the platform as current
I have analyzed the Rhodes gem.
This gem contains native extensions ( There is a file directory for the
extensions, it has extconf.rb )
However, under the ext/ folder, there is no C source code. It only has
makefile and shared library files ( so and dll ) with extconf.rb
This gem is platform independent. According to the gemfile, it says
default to Ruby. It means it can run on any Ruby platform
If this is the case, this violates the rule 1: Add your C extension
source files only: that is the .c and extconf.rb files only. No need for
Makefile and compiled files for the Platform independent Ruby gems with
native C extension case.
Do those rules always apply to any gemfile?
Also, would you able to explain “Add your compiled C extension files
(exactly the same way you do for normal Ruby files)”?