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
2e7de03f
Commit
2e7de03f
authored
Jun 10, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:mruby/mruby
parents
c2f6c33f
87038c2c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
11 deletions
+48
-11
doc/mrbgems/README.md
doc/mrbgems/README.md
+19
-4
tasks/mrbgem_spec.rake
tasks/mrbgem_spec.rake
+26
-5
tasks/mruby_build_gem.rake
tasks/mruby_build_gem.rake
+3
-2
No files found.
doc/mrbgems/README.md
View file @
2e7de03f
...
@@ -75,6 +75,8 @@ contains every gem found in the *mrbgems* directory.
...
@@ -75,6 +75,8 @@ contains every gem found in the *mrbgems* directory.
The maximal GEM structure looks like this:
The maximal GEM structure looks like this:
+- GEM_NAME <- Name of GEM
+- GEM_NAME <- Name of GEM
|
+- include/ <- Header for Ruby extension (will exported)
|
|
+- mrblib/ <- Source for Ruby extension
+- mrblib/ <- Source for Ruby extension
|
|
...
@@ -87,10 +89,10 @@ The maximal GEM structure looks like this:
...
@@ -87,10 +89,10 @@ The maximal GEM structure looks like this:
+- README.md <- Readme for GEM
+- README.md <- Readme for GEM
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
/C++ files to extend mruby. The folder
*include*
contains C/C++ header
f
or testing purposes which will be used by
`mrbtest`
.
*mrbgem.rake*
contain
s
f
iles. The folder
*test*
contains C/C++ and pure Ruby files for testing purpose
s
the specification to compile C and Ruby files.
*README.md*
is a short descrip
tion
which will be used by
`mrbtest`
.
*mrbgem.rake*
contains the specifica
tion
of your GEM.
to compile C and Ruby files.
*README.md*
is a short description
of your GEM.
## Build process
## Build process
...
@@ -173,6 +175,19 @@ the following options additionally inside of your GEM specification:
...
@@ -173,6 +175,19 @@ the following options additionally inside of your GEM specification:
*
`spec.test_objs`
(Object test files for integration into mrbtest)
*
`spec.test_objs`
(Object test files for integration into mrbtest)
*
`spec.test_preload`
(Initialization files for mrbtest)
*
`spec.test_preload`
(Initialization files for mrbtest)
### include_paths and depencency
Your GEM can export include paths to another GEMs that depends on your GEM.
By default,
`/...absolute path.../{GEM_NAME}/include`
will be exported.
So it is recommended not to put GEM's local header files on include/.
These exports are retroactive.
For example: when B depends to C and A depends to B, A will get include paths exported by C.
Exported include_paths are automatically appended to GEM local include_paths by Minirake.
You can use
`spec.export_include_paths`
accessor if you want more complex build.
## C Extension
## C Extension
mruby can be extended with C. This is possible by using the C API to
mruby can be extended with C. This is possible by using the C API to
...
...
tasks/mrbgem_spec.rake
View file @
2e7de03f
...
@@ -34,6 +34,8 @@ module MRuby
...
@@ -34,6 +34,8 @@ module MRuby
attr_accessor
:requirements
attr_accessor
:requirements
attr_reader
:dependencies
attr_reader
:dependencies
attr_accessor
:export_include_paths
attr_block
MRuby
::
Build
::
COMMANDS
attr_block
MRuby
::
Build
::
COMMANDS
def
initialize
(
name
,
&
block
)
def
initialize
(
name
,
&
block
)
...
@@ -49,22 +51,19 @@ module MRuby
...
@@ -49,22 +51,19 @@ module MRuby
def
setup
def
setup
MRuby
::
Gem
.
current
=
self
MRuby
::
Gem
.
current
=
self
@build
.
compilers
.
each
do
|
compiler
|
compiler
.
include_paths
<<
"
#{
dir
}
/include"
end
if
File
.
directory?
"
#{
dir
}
/include"
MRuby
::
Build
::
COMMANDS
.
each
do
|
command
|
MRuby
::
Build
::
COMMANDS
.
each
do
|
command
|
instance_variable_set
(
"@
#{
command
}
"
,
@build
.
send
(
command
).
clone
)
instance_variable_set
(
"@
#{
command
}
"
,
@build
.
send
(
command
).
clone
)
end
end
@linker
=
LinkerConfig
.
new
([],
[],
[],
[])
@linker
=
LinkerConfig
.
new
([],
[],
[],
[])
@rbfiles
=
Dir
.
glob
(
"
#{
dir
}
/mrblib/*.rb"
).
sort
@rbfiles
=
Dir
.
glob
(
"
#{
dir
}
/mrblib/*.rb"
).
sort
@objs
=
Dir
.
glob
(
"
#{
dir
}
/src/*.{c,cpp,cxx,cc,m,asm,S}"
).
map
do
|
f
|
@objs
=
Dir
.
glob
(
"
#{
dir
}
/src/*.{c,cpp,cxx,cc,m,asm,
s,
S}"
).
map
do
|
f
|
objfile
(
f
.
relative_path_from
(
@dir
).
to_s
.
pathmap
(
"
#{
build_dir
}
/%X"
))
objfile
(
f
.
relative_path_from
(
@dir
).
to_s
.
pathmap
(
"
#{
build_dir
}
/%X"
))
end
end
@objs
<<
objfile
(
"
#{
build_dir
}
/gem_init"
)
@objs
<<
objfile
(
"
#{
build_dir
}
/gem_init"
)
@test_rbfiles
=
Dir
.
glob
(
"
#{
dir
}
/test/*.rb"
)
@test_rbfiles
=
Dir
.
glob
(
"
#{
dir
}
/test/*.rb"
)
@test_objs
=
Dir
.
glob
(
"
#{
dir
}
/test/*.{c,cpp,cxx,cc,m,asm,S}"
).
map
do
|
f
|
@test_objs
=
Dir
.
glob
(
"
#{
dir
}
/test/*.{c,cpp,cxx,cc,m,asm,
s,
S}"
).
map
do
|
f
|
objfile
(
f
.
relative_path_from
(
dir
).
to_s
.
pathmap
(
"
#{
build_dir
}
/%X"
))
objfile
(
f
.
relative_path_from
(
dir
).
to_s
.
pathmap
(
"
#{
build_dir
}
/%X"
))
end
end
@test_preload
=
nil
# 'test/assert.rb'
@test_preload
=
nil
# 'test/assert.rb'
...
@@ -74,6 +73,8 @@ module MRuby
...
@@ -74,6 +73,8 @@ module MRuby
@requirements
=
[]
@requirements
=
[]
@dependencies
=
[]
@dependencies
=
[]
@export_include_paths
=
[]
@export_include_paths
<<
"
#{
dir
}
/include"
if
File
.
directory?
"
#{
dir
}
/include"
instance_eval
(
&
@initializer
)
instance_eval
(
&
@initializer
)
...
@@ -88,6 +89,7 @@ module MRuby
...
@@ -88,6 +89,7 @@ module MRuby
compilers
.
each
do
|
compiler
|
compilers
.
each
do
|
compiler
|
compiler
.
define_rules
build_dir
,
"
#{
dir
}
"
compiler
.
define_rules
build_dir
,
"
#{
dir
}
"
compiler
.
defines
<<
%Q[MRBGEM_
#{
funcname
.
upcase
}
_VERSION=
#{
version
}
]
compiler
.
defines
<<
%Q[MRBGEM_
#{
funcname
.
upcase
}
_VERSION=
#{
version
}
]
compiler
.
include_paths
<<
"
#{
dir
}
/include"
if
File
.
directory?
"
#{
dir
}
/include"
end
end
define_gem_init_builder
define_gem_init_builder
...
@@ -338,6 +340,25 @@ module MRuby
...
@@ -338,6 +340,25 @@ module MRuby
rescue
TSort
::
Cyclic
=>
e
rescue
TSort
::
Cyclic
=>
e
fail
"Circular mrbgem dependency found:
#{
e
.
message
}
"
fail
"Circular mrbgem dependency found:
#{
e
.
message
}
"
end
end
each
do
|
g
|
import_include_paths
(
g
)
end
end
def
import_include_paths
(
g
)
gem_table
=
@ary
.
reduce
({})
{
|
res
,
v
|
res
[
v
.
name
]
=
v
;
res
}
g
.
dependencies
.
each
do
|
dep
|
dep_g
=
gem_table
[
dep
[
:gem
]]
# We can do recursive call safely
# as circular dependency has already detected in the caller.
import_include_paths
(
dep_g
)
g
.
compilers
.
each
do
|
compiler
|
compiler
.
include_paths
+=
dep_g
.
export_include_paths
g
.
export_include_paths
+=
dep_g
.
export_include_paths
end
end
end
end
end
# List
end
# List
end
# Gem
end
# Gem
...
...
tasks/mruby_build_gem.rake
View file @
2e7de03f
...
@@ -35,8 +35,9 @@ module MRuby
...
@@ -35,8 +35,9 @@ module MRuby
Gem
.
current
.
build_config_initializer
=
block
Gem
.
current
.
build_config_initializer
=
block
gems
<<
Gem
.
current
gems
<<
Gem
.
current
cxx_srcs
=
Dir
.
glob
(
"
#{
Gem
.
current
.
dir
}
/src/*.{cpp,cxx,cc}"
)
cxx_srcs
=
[
'src'
,
'test'
,
'tools'
].
map
do
|
subdir
|
cxx_srcs
+=
Dir
.
glob
(
"
#{
Gem
.
current
.
dir
}
/test/*.{cpp,cxx,cc}"
)
Dir
.
glob
(
"
#{
Gem
.
current
.
dir
}
/
#{
subdir
}
/*.{cpp,cxx,cc}"
)
end
.
flatten
enable_cxx_abi
unless
cxx_srcs
.
empty?
enable_cxx_abi
unless
cxx_srcs
.
empty?
Gem
.
current
Gem
.
current
...
...
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