Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
a7cb9737
Commit
a7cb9737
authored
Sep 24, 2012
by
Daniel Bovensiepen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve Gem Readme file
parent
3fb943e4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
doc/mrbgems/README.md
doc/mrbgems/README.md
+44
-0
No files found.
doc/mrbgems/README.md
View file @
a7cb9737
...
@@ -5,6 +5,8 @@ standardized way into mruby.
...
@@ -5,6 +5,8 @@ standardized way into mruby.
## GEM Structure
## GEM Structure
The maximal Gem structure looks like this:
+- GEM_NAME <- Name of Gem
+- GEM_NAME <- Name of Gem
|
|
+- mrblib/ <- Source for Ruby extension
+- mrblib/ <- Source for Ruby extension
...
@@ -17,8 +19,40 @@ standardized way into mruby.
...
@@ -17,8 +19,40 @@ standardized way into mruby.
|
|
+- README.md <- Readme for Gem
+- README.md <- Readme for Gem
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 all C files and integrates them into the normal mruby
build process. +README.md+ is a short description for the Gem.
## C Extension
## C Extension
mruby can be extended with C. It is possible by using the C API to integrate C
libraries into mruby. You need to use the folder
*src*
for all C files. Pay
attention that your
*Makefile*
has to build the source and also add the object
files to libmruby.a
### Pre-Conditions
mrbgems will automatically call the +gem-all+ make target of your Gem. Make
sure that you build all files in this target and that you add you object
files to libmruby.a
mrbgems expects that you have implemented a C method called
*mrb_YOURGEMNAME_gem_init(mrb_state*
mrb)
*
. 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:
void
mrb_c_extension_example_gem_init(mrb_state
*
mrb) {
_class_cextension = mrb_define_module(mrb, "CExtension");
mrb_define_class_method(mrb, _class_cextension, "c_method", mrb_c_method, ARGS_NONE());
}
mrbgems will also use the
*gem-clean*
make target to clean up your Gem. Implement
this target with the necessary rules!
### Example
### Example
+- c_extension_example/
+- c_extension_example/
...
@@ -37,6 +71,16 @@ standardized way into mruby.
...
@@ -37,6 +71,16 @@ standardized way into mruby.
## Ruby Extension
## Ruby Extension
mruby can be extended with pure Ruby. It is possible to override existing
classes or add new ones in this way. Put all Ruby files into the
*mrblib*
folder. At the moment only one directory layer is supported. So don't
use a deeper structure for now!
The
*Makefile*
is not used for building a Ruby extension. But you still
should maintain this file so that during the build process the progress
can be visualized. If you want to do additional things during the build
process of your Ruby extension you can use the
*Makefile*
too.
### Example
### Example
+- ruby_extension_example/
+- ruby_extension_example/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment