diff options
| author | Paolo Bosetti <[email protected]> | 2012-08-06 15:02:03 +0200 |
|---|---|---|
| committer | Paolo Bosetti <[email protected]> | 2012-08-06 15:02:56 +0200 |
| commit | aa0d2f91447c49363059f2e95cb9023f65a6fbef (patch) | |
| tree | 2cfa325956e62648f2161564adfdf6dddc45b737 /tools/mrbc | |
| parent | fd097b8aff7b91bd105fc1daec5a4050a947b763 (diff) | |
| parent | 193c98ae540d43d082795fd77ea81a4f6f7fd0f6 (diff) | |
| download | mruby-aa0d2f91447c49363059f2e95cb9023f65a6fbef.tar.gz mruby-aa0d2f91447c49363059f2e95cb9023f65a6fbef.zip | |
Updated Xcode project build settings in conformity with 10.8/Xcode 4.4
Diffstat (limited to 'tools/mrbc')
| -rw-r--r-- | tools/mrbc/Makefile | 17 | ||||
| -rw-r--r-- | tools/mrbc/mrbc.c | 60 |
2 files changed, 42 insertions, 35 deletions
diff --git a/tools/mrbc/Makefile b/tools/mrbc/Makefile index 99f5830e6..eea0c02cb 100644 --- a/tools/mrbc/Makefile +++ b/tools/mrbc/Makefile @@ -23,12 +23,19 @@ LIBS = -lm INCLUDES = -I$(BASEDIR) -I$(BASEDIR)/../include # compiler, linker (gcc) -DEBUG_MODE = 1 -ifeq ($(DEBUG_MODE),1) -CFLAGS = -g -O3 -else -CFLAGS = -O3 +ifeq ($(strip $(COMPILE_MODE)),) + # default compile option + COMPILE_MODE = debug +endif + +ifeq ($(COMPILE_MODE),debug) + CFLAGS = -g -O3 +else ifeq ($(COMPILE_MODE),release) + CFLAGS = -O3 +else ifeq ($(COMPILE_MODE),small) + CFLAGS = -Os endif + ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS) ifeq ($(OS),Windows_NT) MAKE_FLAGS = CC=$(CC) LL=$(LL) ALL_CFLAGS="$(ALL_CFLAGS)" diff --git a/tools/mrbc/mrbc.c b/tools/mrbc/mrbc.c index 3553fe646..f9810aa4f 100644 --- a/tools/mrbc/mrbc.c +++ b/tools/mrbc/mrbc.c @@ -114,6 +114,8 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args) } else return -3; return 0; + default: + break; } } else if (args->rfp == NULL) { @@ -133,7 +135,10 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args) if (outfile == NULL) outfile = get_outfilename(infile, args->ext); - if ((args->wfp = fopen(outfile, "wb")) == NULL) { + if (strcmp("-", outfile) == 0) { + args->wfp = stdout; + } + else if ((args->wfp = fopen(outfile, "wb")) == NULL) { printf("%s: Cannot open output file. (%s)\n", *origargv, outfile); return 0; } @@ -142,12 +147,13 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args) } static void -cleanup(struct _args *args) +cleanup(mrb_state *mrb, struct _args *args) { if (args->rfp) fclose(args->rfp); if (args->wfp) fclose(args->wfp); + mrb_close(mrb); } int @@ -156,37 +162,34 @@ main(int argc, char **argv) mrb_state *mrb = mrb_open(); int n = -1; struct _args args; - struct mrb_parser_state *p; + mrbc_context *c; + mrb_value result; - n = parse_args(mrb, argc, argv, &args); + if (mrb == NULL) { + fprintf(stderr, "Invalid mrb_state, exiting mrbc"); + return EXIT_FAILURE; + } + n = parse_args(mrb, argc, argv, &args); if (n < 0 || args.rfp == NULL) { - cleanup(&args); + cleanup(mrb, &args); usage(argv[0]); - mrb_close(mrb); return n; } - p = mrb_parse_file(mrb, args.rfp); - if (!p || !p->tree || p->nerr) { - cleanup(&args); - mrb_close(mrb); - return -1; - } - - if (args.verbose) - parser_dump(mrb, p->tree, 0); - - n = mrb_generate_code(mrb, p->tree); - mrb_pool_close(p->pool); - + c = mrbc_context_new(mrb); if (args.verbose) - codedump_all(mrb, n); - - if (n < 0 || args.check_syntax) { - cleanup(&args); - mrb_close(mrb); - return n; + c->dump_result = 1; + c->no_exec = 1; + result = mrb_load_file_cxt(mrb, args.rfp, c); + if (mrb_undef_p(result) || mrb_fixnum(result) < 0) { + cleanup(mrb, &args); + return EXIT_FAILURE; + } + if (args.check_syntax) { + printf("Syntax OK\n"); + cleanup(mrb, &args); + return EXIT_SUCCESS; } if (args.initname) { if (args.dump_type == DUMP_TYPE_BIN) @@ -198,14 +201,11 @@ main(int argc, char **argv) n = mrb_dump_irep(mrb, n, args.wfp); } - cleanup(&args); - mrb_close(mrb); - - return n; + cleanup(mrb, &args); + return EXIT_SUCCESS; } void mrb_init_mrblib(mrb_state *mrb) { } - |
