Commit da558251 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #682 from bovi/doc-rake

Fix documentation for mrbgems
parents 67541a3d 5d0ada45
...@@ -5,11 +5,11 @@ standardised way into mruby. ...@@ -5,11 +5,11 @@ standardised way into mruby.
## Usage ## Usage
By default mrbgems is currently deactivated. As soon as you add a GEM to the By default mrbgems is currently deactivated. As soon as you add a GEM to your
build configuration (build_config.rb), mrbgems will be activated and the build configuration (*build_config.rb*), mrbgems will be activated and the
extension will be integrated. extension integrated.
To add a GEM into the build_config.rb add the following line: To add a GEM into the build_config.rb add the following line for example:
``` ```
conf.gem '/path/to/your/gem/dir' conf.gem '/path/to/your/gem/dir'
...@@ -49,14 +49,13 @@ The maximal GEM structure looks like this: ...@@ -49,14 +49,13 @@ The maximal GEM structure looks like this:
The folder *mrblib* contains pure Ruby files to extend mruby. The folder *src* The folder *mrblib* contains pure Ruby files to extend mruby. The folder *src*
contains C files to extend mruby. The folder *test* contains C and pure Ruby files contains C files to extend mruby. The folder *test* contains C and pure Ruby files
for testing purposes which will be used by ```mrbtest```. *mrbgem.rake* contains for testing purposes which will be used by ```mrbtest```. *mrbgem.rake* contains
rules to build a *libmrb-GEMNAME-gem.a* file inside of the GEM directory. Which the specification to compile C and Ruby files. *README.md* is a short description
will be used for integration into the normal mruby build process. *README.md* of your GEM.
is a short description of your GEM.
## Build process ## Build process
mrbgems expects a file called *mrbgem.rake* inside of your GEM directory. A mrbgems expects a specifcation file called *mrbgem.rake* inside of your
typical file could for example look like this: GEM direcotry. A typical GEM specification could look like this for example:
``` ```
MRuby::Gem::Specification.new('c_and_ruby_extension_example') do |spec| MRuby::Gem::Specification.new('c_and_ruby_extension_example') do |spec|
...@@ -65,35 +64,35 @@ MRuby::Gem::Specification.new('c_and_ruby_extension_example') do |spec| ...@@ -65,35 +64,35 @@ MRuby::Gem::Specification.new('c_and_ruby_extension_example') do |spec|
end end
``` ```
The mrbgems build process will use this file to create a archive file The mrbgems build process will use this specification to compile Object and Ruby
*libmrb-GEMNAME-gem.a* during the build process. This file will be used files. The compilation results will be add to *lib/libmruby.a*. This file is used
by tools like *mruby* and *mirb* to integrate the GEM functionality. by tools like ```mruby``` and ```mirb``` to empower the GEM functionality.
In case your GEM has more complex build requirements you can empower In case your GEM has more complex build requirements you can use
the following options additionally inside of your GEM specification: the following options additionally inside of your GEM specification:
* spec.cflags (flags for the C compiler) * spec.cflags (C compiler flags for this GEM)
* spec.mruby_cflags (flags for the C compiler) * spec.mruby_cflags (global C compiler flags for everything)
* spec.mruby_ldflags (flags for the linker) * spec.mruby_ldflags (global linker flags for everything)
* spec.mruby_libs (Libraries to include) * spec.mruby_libs (global libraries for everything)
* spec.mruby_includes (Directories for include) * spec.mruby_includes (global includes for everything)
* spec.rbfiles (Ruby files to compile) * spec.rbfiles (Ruby files to compile)
* spec.objs * spec.objs (Object files to compile)
* spec.test_rbfiles (Ruby test files for integration into mrbtest) * spec.test_rbfiles (Ruby test files for integration into mrbtest)
* spec.test_objs * spec.test_objs (Object test files for integration into mrbtest)
* spec.test_preload (Initialization files for mrbtest) * spec.test_preload (Initialization files for mrbtest)
## C Extension ## C Extension
mruby can be extended with C. It is possible by using the C API to mruby can be extended with C. This is possible by using the C API to
integrate C libraries into mruby. integrate C libraries into mruby.
### Pre-Conditions ### Pre-Conditions
mrbgems expects that you have implemented a C method called mrbgems expects that you have implemented a C method called
```mrb_YOURGEMNAME_gem_init(mrb_state)```. ```YOURGEMNAME``` will be replaced ```mrb_YOURGEMNAME_gem_init(mrb_state)```. ```YOURGEMNAME``` will be replaced
by the name of you GEM. If you call your GEM directory *c_extension_example*, by the name of your GEM. If you call your GEM *c_extension_example*, your
your initialisation method could look like this: initialisation method could look like this:
``` ```
void void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment