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
2b74fa54
Commit
2b74fa54
authored
Aug 09, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2503 from cremno/dont-always-generate-gem-functions
don't always generate gem functions
parents
f3f54cb6
6526bb10
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
8 deletions
+30
-8
tasks/mrbgem_spec.rake
tasks/mrbgem_spec.rake
+6
-2
tasks/mrbgems.rake
tasks/mrbgems.rake
+15
-6
tasks/ruby_ext.rake
tasks/ruby_ext.rake
+9
-0
No files found.
tasks/mrbgem_spec.rake
View file @
2b74fa54
...
@@ -36,6 +36,8 @@ module MRuby
...
@@ -36,6 +36,8 @@ module MRuby
attr_accessor
:export_include_paths
attr_accessor
:export_include_paths
attr_reader
:generate_functions
attr_block
MRuby
::
Build
::
COMMANDS
attr_block
MRuby
::
Build
::
COMMANDS
def
initialize
(
name
,
&
block
)
def
initialize
(
name
,
&
block
)
...
@@ -56,7 +58,9 @@ module MRuby
...
@@ -56,7 +58,9 @@ module MRuby
@objs
=
Dir
.
glob
(
"
#{
dir
}
/src/*.{c,cpp,cxx,cc,m,asm,s,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"
)
@generate_functions
=
!
(
@rbfiles
.
empty?
&&
@objs
.
empty?
)
@objs
<<
objfile
(
"
#{
build_dir
}
/gem_init"
)
if
@generate_functions
@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,S}"
).
map
do
|
f
|
@test_objs
=
Dir
.
glob
(
"
#{
dir
}
/test/*.{c,cpp,cxx,cc,m,asm,s,S}"
).
map
do
|
f
|
...
@@ -89,7 +93,7 @@ module MRuby
...
@@ -89,7 +93,7 @@ module MRuby
compiler
.
include_paths
<<
"
#{
dir
}
/include"
if
File
.
directory?
"
#{
dir
}
/include"
compiler
.
include_paths
<<
"
#{
dir
}
/include"
if
File
.
directory?
"
#{
dir
}
/include"
end
end
define_gem_init_builder
define_gem_init_builder
if
@generate_functions
end
end
def
add_dependency
(
name
,
*
requirements
)
def
add_dependency
(
name
,
*
requirements
)
...
...
tasks/mrbgems.rake
View file @
2b74fa54
...
@@ -10,6 +10,17 @@ MRuby.each_target do
...
@@ -10,6 +10,17 @@ MRuby.each_target do
file
"
#{
build_dir
}
/mrbgems/gem_init.c"
=>
[
MRUBY_CONFIG
,
__FILE__
]
do
|
t
|
file
"
#{
build_dir
}
/mrbgems/gem_init.c"
=>
[
MRUBY_CONFIG
,
__FILE__
]
do
|
t
|
FileUtils
.
mkdir_p
"
#{
build_dir
}
/mrbgems"
FileUtils
.
mkdir_p
"
#{
build_dir
}
/mrbgems"
open
(
t
.
name
,
'w'
)
do
|
f
|
open
(
t
.
name
,
'w'
)
do
|
f
|
gem_func_gems
=
gems
.
select
{
|
g
|
g
.
generate_functions
}
gem_func_decls
=
gem_func_gems
.
each_with_object
(
''
)
do
|
g
,
s
|
s
<<
"void GENERATED_TMP_mrb_
#{
g
.
funcname
}
_gem_init(mrb_state*);
\n
"
\
"void GENERATED_TMP_mrb_
#{
g
.
funcname
}
_gem_final(mrb_state*);
\n
"
end
gem_init_calls
=
gem_func_gems
.
each_with_object
(
''
)
do
|
g
,
s
|
s
<<
" GENERATED_TMP_mrb_
#{
g
.
funcname
}
_gem_init(mrb);
\n
"
end
gem_final_calls
=
gem_func_gems
.
each_with_object
(
''
)
do
|
g
,
s
|
s
<<
" GENERATED_TMP_mrb_
#{
g
.
funcname
}
_gem_final(mrb);
\n
"
end
f
.
puts
%Q[/*]
f
.
puts
%Q[/*]
f
.
puts
%Q[ * This file contains a list of all]
f
.
puts
%Q[ * This file contains a list of all]
f
.
puts
%Q[ * initializing methods which are]
f
.
puts
%Q[ * initializing methods which are]
...
@@ -22,19 +33,17 @@ MRuby.each_target do
...
@@ -22,19 +33,17 @@ MRuby.each_target do
f
.
puts
%Q[]
f
.
puts
%Q[]
f
.
puts
%Q[#include "mruby.h"]
f
.
puts
%Q[#include "mruby.h"]
f
.
puts
%Q[]
f
.
puts
%Q[]
f
.
puts
%Q[
#{
gems
.
map
{
|
g
|
"void GENERATED_TMP_mrb_%s_gem_init(mrb_state* mrb);"
%
g
.
funcname
}
.join("
\n
")}]
f
.
write
gem_func_decls
f
.
puts
%Q[]
f
.
puts
%Q[
#{
gems
.
map
{
|
g
|
"void GENERATED_TMP_mrb_%s_gem_final(mrb_state* mrb);"
%
g
.
funcname
}
.join("
\n
")}]
f
.
puts
%Q[]
f
.
puts
%Q[]
f
.
puts
%Q[static void]
f
.
puts
%Q[static void]
f
.
puts
%Q[mrb_final_mrbgems(mrb_state *mrb) {]
f
.
puts
%Q[mrb_final_mrbgems(mrb_state *mrb) {]
f
.
puts
%Q[
#{
gems
.
map
{
|
g
|
"GENERATED_TMP_mrb_%s_gem_final(mrb);"
%
g
.
funcname
}
.join("
\n
")}]
f
.
write
gem_final_calls
f
.
puts
%Q[}]
f
.
puts
%Q[}]
f
.
puts
%Q[]
f
.
puts
%Q[]
f
.
puts
%Q[void]
f
.
puts
%Q[void]
f
.
puts
%Q[mrb_init_mrbgems(mrb_state *mrb) {]
f
.
puts
%Q[mrb_init_mrbgems(mrb_state *mrb) {]
f
.
puts
%Q[
#{
gems
.
map
{
|
g
|
"GENERATED_TMP_mrb_%s_gem_init(mrb);"
%
g
.
funcname
}
.join("
\n
")}]
f
.
write
gem_init_calls
f
.
puts
%Q[
mrb_state_atexit(mrb, mrb_final_mrbgems);]
f
.
puts
%Q[
mrb_state_atexit(mrb, mrb_final_mrbgems);]
unless
gem_final_calls
.
empty?
f
.
puts
%Q[}]
f
.
puts
%Q[}]
end
end
end
end
...
...
tasks/ruby_ext.rake
View file @
2b74fa54
...
@@ -42,6 +42,15 @@ class Symbol
...
@@ -42,6 +42,15 @@ class Symbol
end
end
end
end
module
Enumerable
# Compatible with 1.9 on 1.8
def
each_with_object
(
memo
)
return
to_enum
:each_with_object
,
memo
unless
block_given?
each
{
|
obj
|
yield
obj
,
memo
}
memo
end
end
$pp_show
=
true
$pp_show
=
true
if
$verbose
.
nil?
if
$verbose
.
nil?
...
...
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