summaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2015-02-02 09:34:24 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2015-02-02 09:34:24 +0900
commitbc9c47d5180ab28e1a3db4dca80da7512aa6839a (patch)
tree7225a711463345e443d994833c13de817184f10c /tools
parent089f1f6c75d1642f96c84d12c3c2f4cb567343b9 (diff)
downloadmruby-bc9c47d5180ab28e1a3db4dca80da7512aa6839a.tar.gz
mruby-bc9c47d5180ab28e1a3db4dca80da7512aa6839a.zip
allow endian specification of mrb files by `mrbc -e/-E`
`mruby -b` now accepts both big/little endian mrb (compiled binary) files. `mrbc` generates mrb files in big endian for .mrb files and in native endian for C files (with -B option specified) by default. If you are cross compiling, you need to specify target endian by -e/-E options if it is different from host endian.
Diffstat (limited to 'tools')
-rw-r--r--tools/mrbc/mrbc.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/tools/mrbc/mrbc.c b/tools/mrbc/mrbc.c
index b51cc4da7..f27f87a5d 100644
--- a/tools/mrbc/mrbc.c
+++ b/tools/mrbc/mrbc.c
@@ -18,7 +18,7 @@ struct mrbc_args {
const char *initname;
mrb_bool check_syntax : 1;
mrb_bool verbose : 1;
- mrb_bool debug_info : 1;
+ unsigned int flags : 4;
};
static void
@@ -31,6 +31,8 @@ usage(const char *name)
"-v print version number, then turn on verbose mode",
"-g produce debugging information",
"-B<symbol> binary <symbol> output in C language format",
+ "-e generate little endian iseq data",
+ "-E generate big endian iseq data",
"--verbose run at verbose mode",
"--version print the version",
"--copyright print the copyright",
@@ -114,7 +116,13 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct mrbc_args *args)
args->verbose = TRUE;
break;
case 'g':
- args->debug_info = TRUE;
+ args->flags |= DUMP_DEBUG_INFO;
+ break;
+ case 'E':
+ args->flags = DUMP_ENDIAN_BIG | (args->flags & DUMP_DEBUG_INFO);
+ break;
+ case 'e':
+ args->flags = DUMP_ENDIAN_LIL | (args->flags & DUMP_DEBUG_INFO);
break;
case 'h':
return -1;
@@ -143,6 +151,10 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct mrbc_args *args)
break;
}
}
+ if (args->verbose && args->initname && (args->flags & DUMP_ENDIAN_MASK) == 0) {
+ fprintf(stderr, "%s: generating %s endian C file. specify -e/-E for cross compiling.\n",
+ args->prog, bigendian_p() ? "big" : "little");
+ }
return i;
}
@@ -222,13 +234,13 @@ dump_file(mrb_state *mrb, FILE *wfp, const char *outfile, struct RProc *proc, st
mrb_irep *irep = proc->body.irep;
if (args->initname) {
- n = mrb_dump_irep_cfunc(mrb, irep, args->debug_info, wfp, args->initname);
+ n = mrb_dump_irep_cfunc(mrb, irep, args->flags, wfp, args->initname);
if (n == MRB_DUMP_INVALID_ARGUMENT) {
fprintf(stderr, "%s: invalid C language symbol name\n", args->initname);
}
}
else {
- n = mrb_dump_irep_binary(mrb, irep, args->debug_info, wfp);
+ n = mrb_dump_irep_binary(mrb, irep, args->flags, wfp);
}
if (n != MRB_DUMP_OK) {
fprintf(stderr, "%s: error in mrb dump (%s) %d\n", args->prog, outfile, n);