diff options
| author | Daniel Bovensiepen <[email protected]> | 2012-12-08 17:37:35 +0800 |
|---|---|---|
| committer | Daniel Bovensiepen <[email protected]> | 2012-12-08 17:37:35 +0800 |
| commit | 88767c3d7188af54182c548fece1fbaa221c9e7d (patch) | |
| tree | 7acb8b6e2df039be5d240fad95f6449cd10935f8 /doc | |
| parent | 770974b53ea9d116bc22ffeec2e051223acd946e (diff) | |
| download | mruby-88767c3d7188af54182c548fece1fbaa221c9e7d.tar.gz mruby-88767c3d7188af54182c548fece1fbaa221c9e7d.zip | |
Improve documentation based on latest improvements
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/mrbgems/README.md | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/doc/mrbgems/README.md b/doc/mrbgems/README.md index 98ff44720..30bd28c01 100644 --- a/doc/mrbgems/README.md +++ b/doc/mrbgems/README.md @@ -9,13 +9,14 @@ By default mrbgems is currently deactivated. As long as mrbgems is deactivated there is no overhead inside of the mruby interpreter. To activate you have to make the following changes: -* set *ENABLE_GEMS* to *true* in *$(MRUBY_ROOT)/Makefile* -* define *ENABLE_GEMS* in *$(MRUBY_ROOT)/include/mrbconf.h* +* set ```ENABLE_GEMS``` to ```true``` in *$(MRUBY_ROOT)/Makefile* +* comment out ```DISABLE_GEMS``` in *$(MRUBY_ROOT)/include/mrbconf.h* * activate GEMs in *$(MRUBY_ROOT)/mrbgems/GEMS.active* -Every activated GEM has to be listed with his absolute path in *GEMS.active*. It -is possible to point to an alternative activate file: -* set *ACTIVE_GEMS* to your customized GEM list in *$(MRUBY_ROOT)/Makefile* +Every activated GEM has to be listed in *GEMS.active*. You have to point to +the GEM directory absolute or relative (based on *mrbgems/g*). It is possible +to point to an alternative activate file: +* set ```ACTIVE_GEMS``` to your customized GEM list in *$(MRUBY_ROOT)/Makefile* ## GEM Structure @@ -24,6 +25,8 @@ The maximal GEM structure looks like this: ``` +- GEM_NAME <- Name of GEM | + +- include/ <- Header files for C extension + | +- mrblib/ <- Source for Ruby extension | +- src/ <- Source for C extension @@ -37,23 +40,23 @@ The maximal GEM structure looks like this: The folder *mrblib* contains pure Ruby files to extend mruby. The folder *src* contains C files to extend mruby. The folder *test* contains pure Ruby files -for testing purposes which will be used by *mrbtest*. The *Makefile* contains -rules to build a *gem.a* file inside of the GEM directory. Which will be used -for integration into the normal mruby build process. *README.md* is a short -description of your GEM. +for testing purposes which will be used by ```mrbtest```. The *Makefile* contains +rules to build a *mrb-GEMNAME-gem.a* file inside of the GEM directory. Which +will be used for integration into the normal mruby build process. *README.md* +is a short description of your GEM. ## Build process -mrbgems will call *make* to build and *make clean* to clean your GEM. You +mrbgems will call ```make``` to build and *make clean* to clean your GEM. You have to build a *mrb-GEMNAME-gem.a* file during this build process. How you are going to do this is up to you. To make your build process more easier and more standardized we suggest to include *mrbgems/Makefile4gem* which defines some helper rules. In case you include this Makefile you have to define specific pre-defined -rules like *gem-all* for the build process and *gem-clean* for the clean -process. There are additional helper rules for specific GEM examples -below. +rules like ```gem-all``` for the build process and ```gem-clean``` for +the clean process. There are additional helper rules for specific GEM +examples below. ## C Extension @@ -61,16 +64,16 @@ mruby can be extended with C. It is possible by using the C API to integrate C libraries into mruby. The *Makefile* is used for building a C extension. You should -define *GEM* (GEM name), *GEM_C_FILES* (all C files) and -*GEM_OBJECTS* (all Object files). Pay also attention that your +define ```GEM``` (GEM name), ```GEM_C_FILES``` (all C files) and +```GEM_OBJECTS``` (all Object files). Pay also attention that your *Makefile* has to build the object files. You can use -*gem-c-files* to build a *mrb-GEMNAME-gem.a* out of your -Object code and use *gem-clean-c-files* to clean the object files. +```gem-c-files``` to build a *mrb-GEMNAME-gem.a* out of your +Object code and use ```gem-clean-c-files``` to clean the object files. ### Pre-Conditions 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. The directory name of your GEM is considered also as the name! If you call your GEM directory *c_extension_example*, your initialisation method could look like this: @@ -111,15 +114,15 @@ classes or add new ones in this way. Put all Ruby files into the *mrblib* folder. The *Makefile* is used for building a Ruby extension. You should define -*GEM* (GEM name) and *GEM_RB_FILES* (all Ruby files). You can use -*gem-rb-files* to build a *mrb-GEMNAME-gem.a* out of your Ruby code and use -*gem-clean-rb-files* to clean the generated C files. +```GEM``` (GEM name) and *GEM_RB_FILES* (all Ruby files). You can use +```gem-rb-files``` to build a *mrb-GEMNAME-gem.a* out of your Ruby code and use +```gem-clean-rb-files``` to clean the generated C files. ### Pre-Conditions -mrbgems will automatically call the *gem-all* make target of your GEM. +mrbgems will automatically call the ```gem-all``` make target of your GEM. -mrbgems will also use the *gem-clean* make target to clean up your GEM. Implement +mrbgems will also use the ```gem-clean``` make target to clean up your GEM. Implement this target with the necessary rules! ### Example @@ -147,11 +150,11 @@ override existing classes or add new ones in this way. Put all Ruby files into the *mrblib* folder and all C files into the *src* folder. The *Makefile* is used for building a C and Ruby extension. You should -define *GEM* (GEM name), *GEM_C_FILES* (all C files), *GEM_OBJECTS* -(all Object files) and *GEM_RB_FILES* (all Ruby files). You can use -*gem-c-and-rb-files* to build a *mrb-GEMNAME-gem.a* out of your Object -and Ruby code. Use *gem-clean-c-and-rb-files* to clean the generated -C files. +define ```GEM``` (GEM name), ```GEM_C_FILES``` (all C files), +```GEM_OBJECTS``` (all Object files) and ```GEM_RB_FILES``` (all Ruby +files). You can use ```gem-c-and-rb-files``` to build a +*mrb-GEMNAME-gem.a* out of your Object and Ruby code. Use +```gem-clean-c-and-rb-files``` to clean the generated C files. ### Pre-Conditions |
