Commit b24d869a authored by Daniel Bovensiepen's avatar Daniel Bovensiepen

Modify code blocks

parent 437aa216
...@@ -23,11 +23,9 @@ Inside of the root directory of the mruby source exist a file ...@@ -23,11 +23,9 @@ Inside of the root directory of the mruby source exist a file
called *build_config.rb*. This file contains the build configuration called *build_config.rb*. This file contains the build configuration
of mruby and looks like this for example: of mruby and looks like this for example:
``` MRuby::Build.new do |conf|
MRuby::Build.new do |conf|
toolchain :gcc toolchain :gcc
end end
```
All tools necessary to compile mruby can be set or modified here. In case All tools necessary to compile mruby can be set or modified here. In case
you want to maintain an additional *build_config.rb* you can define a you want to maintain an additional *build_config.rb* you can define a
...@@ -51,26 +49,20 @@ configurates the build environment for specific compiler infrastructures. ...@@ -51,26 +49,20 @@ configurates the build environment for specific compiler infrastructures.
Toolchain configuration for the GNU C Compiler. Toolchain configuration for the GNU C Compiler.
``` toolchain :gcc
toolchain :gcc
```
#### clang #### clang
Toolchain configuration for the LLVM C Compiler clang. Mainly equal to the Toolchain configuration for the LLVM C Compiler clang. Mainly equal to the
GCC toolchain. GCC toolchain.
``` toolchain :clang
toolchain :clang
```
#### Visual Studio 2012 #### Visual Studio 2012
Toolchain configuration for Visual Studio 2012 on Windows. Toolchain configuration for Visual Studio 2012 on Windows.
``` toolchain :vs2012
toolchain :vs2012
```
### Binaries ### Binaries
...@@ -81,25 +73,21 @@ process. The following tools can be selected: ...@@ -81,25 +73,21 @@ process. The following tools can be selected:
* mirb (mruby interactive shell * mirb (mruby interactive shell
To select all define an array in ```conf.bins```: To select all define an array in ```conf.bins```:
```
conf.bins = %(mrbc mruby mirb) conf.bins = %(mrbc mruby mirb)
```
### File Separator ### File Separator
Some environments require a different file separator character. It is possible to Some environments require a different file separator character. It is possible to
set the character via ```conf.file_separator```. set the character via ```conf.file_separator```.
``` conf.file_separator = '/'
conf.file_separator = '/'
```
### C Compiler ### C Compiler
Configuration of the C compiler binary, flags and include paths. Configuration of the C compiler binary, flags and include paths.
``` conf.cc do |cc|
conf.cc do |cc|
cc.command = ... cc.command = ...
cc.flags = ... cc.flags = ...
cc.include_paths = ... cc.include_paths = ...
...@@ -107,15 +95,13 @@ conf.cc do |cc| ...@@ -107,15 +95,13 @@ conf.cc do |cc|
cc.option_include_path = ... cc.option_include_path = ...
cc.option_define = ... cc.option_define = ...
cc.compile_options = ... cc.compile_options = ...
end end
```
### Linker ### Linker
Configuration of the Linker binary, flags and library paths. Configuration of the Linker binary, flags and library paths.
``` conf.linker do |linker|
conf.linker do |linker|
linker.command = ... linker.command = ...
linker.flags = ... linker.flags = ...
linker.flags_before_libraries = ... linker.flags_before_libraries = ...
...@@ -125,64 +111,54 @@ conf.linker do |linker| ...@@ -125,64 +111,54 @@ conf.linker do |linker|
linker.option_library = ... linker.option_library = ...
linker.option_library_path = ... linker.option_library_path = ...
linker.link_options = ... linker.link_options = ...
end end
```
### Archiver ### Archiver
Configuration of the Archiver binary and flags. Configuration of the Archiver binary and flags.
``` conf.archiver do |archiver|
conf.archiver do |archiver|
archiver.command = ... archiver.command = ...
archiver.archive_options = ... archiver.archive_options = ...
end end
```
### Parser Generator ### Parser Generator
Configuration of the Parser Generator binary and flags. Configuration of the Parser Generator binary and flags.
``` conf.yacc do |yacc|
conf.yacc do |yacc|
yacc.command = ... yacc.command = ...
yacc.compile_options = ... yacc.compile_options = ...
end end
```
### GPerf ### GPerf
Configuration of the GPerf binary and flags. Configuration of the GPerf binary and flags.
```
conf.gperf do |gperf| conf.gperf do |gperf|
gperf.command = ... gperf.command = ...
gperf.compile_options = ... gperf.compile_options = ...
end end
```
### File Extensions ### File Extensions
``` conf.exts do |exts
conf.exts do |exts
exts.object = ... exts.object = ...
exts.executable = ... exts.executable = ...
exts.library = ... exts.library = ...
end end
```
### Mrbgems ### Mrbgems
Integrate GEMs in the build process. Integrate GEMs in the build process.
``` # Integrate GEM with additional configuration
# Integrate GEM with additional configuration conf.gem 'path/to/gem' do |g|
conf.gem 'path/to/gem' do |g|
g.cc.flags << ... g.cc.flags << ...
end end
# Integrate GEM without additional configuration # Integrate GEM without additional configuration
conf.gem 'path/to/another/gem' conf.gem 'path/to/another/gem'
```
## Cross-Compilation ## Cross-Compilation
...@@ -192,14 +168,12 @@ achive this the *build_config.rb* needs to contain an instance of ...@@ -192,14 +168,12 @@ achive this the *build_config.rb* needs to contain an instance of
tools and flags for the target platform. An example could look tools and flags for the target platform. An example could look
like this: like this:
``` MRuby::CrossBuild.new('32bit') do |conf|
MRuby::CrossBuild.new('32bit') do |conf|
toolchain :gcc toolchain :gcc
conf.cc.flags << "-m32" conf.cc.flags << "-m32"
conf.linker.flags << "-m32 conf.linker.flags << "-m32
end end
```
All configuration options of ```MRuby::Build``` can also be used All configuration options of ```MRuby::Build``` can also be used
in ```MRuby::CrossBuild```. in ```MRuby::CrossBuild```.
...@@ -209,8 +183,7 @@ in ```MRuby::CrossBuild```. ...@@ -209,8 +183,7 @@ in ```MRuby::CrossBuild```.
During the build process the directory *build* will be created in the During the build process the directory *build* will be created in the
root directory. The structure of this directory will look like this: root directory. The structure of this directory will look like this:
``` +- build
+- build
| |
+- host +- host
| |
...@@ -231,7 +204,6 @@ root directory. The structure of this directory will look like this: ...@@ -231,7 +204,6 @@ root directory. The structure of this directory will look like this:
+- mrbc +- mrbc
| |
+- mruby +- mruby
```
The compilation workflow will look like this: The compilation workflow will look like this:
* compile all files under *src* (object files will be stored * compile all files under *src* (object files will be stored
...@@ -251,20 +223,17 @@ link with *build/host/lib/libmruby.a* ...@@ -251,20 +223,17 @@ link with *build/host/lib/libmruby.a*
* create ```build/host/bin/mirb``` by compile *tools/mirb/mirb.c* and * create ```build/host/bin/mirb``` by compile *tools/mirb/mirb.c* and
link with *build/host/lib/libmruby.a* link with *build/host/lib/libmruby.a*
```
_____ _____ ______ ____ ____ _____ _____ ____ _____ _____ ______ ____ ____ _____ _____ ____
| CC |->|GEN |->|AR |->|CC |->|CC |->|AR |->|CC |->|CC | | CC |->|GEN |->|AR |->|CC |->|CC |->|AR |->|CC |->|CC |
| *.c | |y.tab| |core.a| |mrbc| |*.rb| |lib.a| |mruby| |mirb| | *.c | |y.tab| |core.a| |mrbc| |*.rb| |lib.a| |mruby| |mirb|
----- ----- ------ ---- ---- ----- ----- ---- ----- ----- ------ ---- ---- ----- ----- ----
```
### Cross-Compilation ### Cross-Compilation
In case of a cross-compilation to *i386* the *build* directory structure looks In case of a cross-compilation to *i386* the *build* directory structure looks
like this: like this:
``` +- build
+- build
| |
+- host +- host
| | | |
...@@ -304,7 +273,6 @@ like this: ...@@ -304,7 +273,6 @@ like this:
+- mrbc +- mrbc
| |
+- mruby +- mruby
```
An extra directory is created for the target platform. In case you An extra directory is created for the target platform. In case you
compile for *i386* a directory called *i386* is created under the compile for *i386* a directory called *i386* is created under the
...@@ -330,25 +298,23 @@ link with *build/i386/lib/libmruby.a* ...@@ -330,25 +298,23 @@ link with *build/i386/lib/libmruby.a*
* create ```build/i386/bin/mrbc``` by cross-compile *tools/mrbc/mrbc.c* and * create ```build/i386/bin/mrbc``` by cross-compile *tools/mrbc/mrbc.c* and
link with *build/i386/lib/libmruby_core.a* link with *build/i386/lib/libmruby_core.a*
```
_____________________________________________________________ _____________________________________________________________
| Native Compilation for Host System | | Native Compilation for Host System |
| _____ ______ _____ ____ ____ _____ | | _____ ______ _____ ____ ____ _____ |
|| CC | -> |AR | -> |GEN | -> |CC | -> |CC | -> |AR || || CC | -> |AR | -> |GEN | -> |CC | -> |CC | -> |AR ||
|| *.c | |core.a| |y.tab| |mrbc| |*.rb| |lib.a|| || *.c | |core.a| |y.tab| |mrbc| |*.rb| |lib.a||
| ----- ------ ----- ---- ---- ----- | | ----- ------ ----- ---- ---- ----- |
------------------------------------------------------------- -------------------------------------------------------------
|| ||
\||/ \||/
\/ \/
______________________________________________________________ ______________________________________________________________
| Cross Compilation for Target System | | Cross Compilation for Target System |
| _____ _____ _____ ____ ______ _____ | | _____ _____ _____ ____ ______ _____ |
|| CC | -> |AR | -> |CC | -> |CC | -> |AR | -> |CC || || CC | -> |AR | -> |CC | -> |CC | -> |AR | -> |CC ||
|| *.c | |lib.a| |mruby| |mirb| |core.a| |mrbc || || *.c | |lib.a| |mruby| |mirb| |core.a| |mrbc ||
| ----- ----- ----- ---- ------ ----- | | ----- ----- ----- ---- ------ ----- |
-------------------------------------------------------------- --------------------------------------------------------------
```
## Test Environment ## Test Environment
......
...@@ -99,13 +99,10 @@ mrbgems expects that you have implemented a C method called ...@@ -99,13 +99,10 @@ mrbgems expects that you have implemented a C method called
by the name of your GEM. If you call your GEM *c_extension_example*, your by the name of your GEM. If you call your GEM *c_extension_example*, your
finalizer method could look like this: finalizer method could look like this:
``` void
void mrb_c_extension_example_gem_final(mrb_state* mrb) {
mrb_c_extension_example_gem_final(mrb_state* mrb) {
free(someone); free(someone);
} }
```
### Example ### Example
......
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