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
1266ab65
Commit
1266ab65
authored
Feb 28, 2014
by
take_cheeze
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add mruby-strip tool to strip irep's debug info
parent
d1526b04
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
116 additions
and
0 deletions
+116
-0
mrbgems/mruby-bin-strip/bintest/mruby-strip.rb
mrbgems/mruby-bin-strip/bintest/mruby-strip.rb
+53
-0
mrbgems/mruby-bin-strip/mrbgem.rake
mrbgems/mruby-bin-strip/mrbgem.rake
+5
-0
mrbgems/mruby-bin-strip/tools/mruby-strip/mruby-strip.c
mrbgems/mruby-bin-strip/tools/mruby-strip/mruby-strip.c
+58
-0
No files found.
mrbgems/mruby-bin-strip/bintest/mruby-strip.rb
0 → 100644
View file @
1266ab65
require
'tempfile'
assert
(
'no files'
)
do
o
=
`bin/mruby-strip 2>&1`
assert_equal
1
,
$?
.
exitstatus
assert_equal
"no files to strip
\n
"
,
o
end
assert
(
'file not found'
)
do
o
=
`bin/mruby-strip not_found.mrb 2>&1`
assert_equal
1
,
$?
.
exitstatus
assert_equal
"can't open file not_found.mrb
\n
"
,
o
end
assert
(
'not irep file'
)
do
t
=
Tempfile
.
new
(
'script.rb'
)
t
.
write
'p test\n'
t
.
flush
o
=
`bin/mruby-strip
#{
t
.
path
}
2>&1`
assert_equal
1
,
$?
.
exitstatus
assert_equal
"can't read irep file
#{
t
.
path
}
\n
"
,
o
end
assert
(
'success'
)
do
script_file
,
compiled1
,
compiled2
=
Tempfile
.
new
(
'script.rb'
),
Tempfile
.
new
(
'c1.mrb'
),
Tempfile
.
new
(
'c2.mrb'
)
script_file
.
write
"p 'test'
\n
"
script_file
.
flush
`bin/mrbc -g -o
#{
compiled1
.
path
}
#{
script_file
.
path
}
`
`bin/mrbc -g -o
#{
compiled2
.
path
}
#{
script_file
.
path
}
`
o
=
`bin/mruby-strip
#{
compiled1
.
path
}
`
assert_equal
0
,
$?
.
exitstatus
assert_equal
""
,
o
o
=
`bin/mruby-strip
#{
compiled1
.
path
}
#{
compiled2
.
path
}
`
assert_equal
0
,
$?
.
exitstatus
assert_equal
""
,
o
end
assert
(
'check debug section'
)
do
script_file
,
with_debug
,
without_debug
=
Tempfile
.
new
(
'script.rb'
),
Tempfile
.
new
(
'c1.mrb'
),
Tempfile
.
new
(
'c2.mrb'
)
script_file
.
write
"p 'test'
\n
"
script_file
.
flush
`bin/mrbc -o
#{
without_debug
.
path
}
#{
script_file
.
path
}
`
`bin/mrbc -g -o
#{
with_debug
.
path
}
#{
script_file
.
path
}
`
assert_true
with_debug
.
size
>=
without_debug
.
size
`bin/mruby-strip
#{
with_debug
.
path
}
`
assert_equal
without_debug
.
size
,
with_debug
.
size
end
mrbgems/mruby-bin-strip/mrbgem.rake
0 → 100644
View file @
1266ab65
MRuby
::
Gem
::
Specification
.
new
(
'mruby-bin-strip'
)
do
|
spec
|
spec
.
license
=
'MIT'
spec
.
author
=
'mruby developers'
spec
.
bins
=
%w(mruby-strip)
end
mrbgems/mruby-bin-strip/tools/mruby-strip/mruby-strip.c
0 → 100644
View file @
1266ab65
#include <stdio.h>
#include <stdlib.h>
#include "mruby.h"
#include "mruby/irep.h"
#include "mruby/dump.h"
int
main
(
int
argc
,
char
**
argv
)
{
int
i
,
dump_result
;
FILE
**
files
;
mrb_irep
**
ireps
;
mrb_state
*
mrb
;
if
(
argc
<=
1
)
{
fprintf
(
stderr
,
"no files to strip
\n
"
);
return
EXIT_FAILURE
;
}
files
=
(
FILE
**
)
malloc
(
sizeof
(
FILE
*
)
*
argc
);
for
(
i
=
1
;
i
<
argc
;
++
i
)
{
files
[
i
]
=
fopen
(
argv
[
i
],
"rb"
);
if
(
!
files
[
i
])
{
fprintf
(
stderr
,
"can't open file %s
\n
"
,
argv
[
i
]);
return
EXIT_FAILURE
;
}
}
mrb
=
mrb_open
();
ireps
=
(
mrb_irep
**
)
malloc
(
sizeof
(
mrb_irep
*
)
*
argc
);
for
(
i
=
1
;
i
<
argc
;
++
i
)
{
ireps
[
i
]
=
mrb_read_irep_file
(
mrb
,
files
[
i
]);
if
(
!
ireps
[
i
])
{
fprintf
(
stderr
,
"can't read irep file %s
\n
"
,
argv
[
i
]);
return
EXIT_FAILURE
;
}
fclose
(
files
[
i
]);
files
[
i
]
=
fopen
(
argv
[
i
],
"wb"
);
if
(
!
ireps
[
i
])
{
fprintf
(
stderr
,
"can't reopen irep file %s
\n
"
,
argv
[
i
]);
return
EXIT_FAILURE
;
}
}
for
(
i
=
1
;
i
<
argc
;
++
i
)
{
/* debug flag must be alway false */
dump_result
=
mrb_dump_irep_binary
(
mrb
,
ireps
[
i
],
FALSE
,
files
[
i
]);
if
(
dump_result
!=
MRB_DUMP_OK
)
{
fprintf
(
stderr
,
"error occur when dumping %s"
,
argv
[
i
]);
return
EXIT_FAILURE
;
}
}
mrb_close
(
mrb
);
return
EXIT_SUCCESS
;
}
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