summaryrefslogtreecommitdiff
path: root/unix
diff options
context:
space:
mode:
authorbvernoux <bvernoux@gmail.com>2014-06-03 19:26:34 +0200
committerbvernoux <bvernoux@gmail.com>2014-06-03 19:26:34 +0200
commit82560fce75ab0307182c943d564202e55fca6c09 (patch)
treed20162c8647ddb2451fdb76024761821b43149e8 /unix
parent0a1dbfe02f4a693c202b97aafcf0b5d0ba050812 (diff)
parentb294a7e3c9b84aad6c331128a51e0d69e7845141 (diff)
Merge branch 'master' of https://github.com/micropython/micropython
Diffstat (limited to 'unix')
-rw-r--r--unix/main.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/unix/main.c b/unix/main.c
index c9f38d613..7c3fbf6aa 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -30,6 +30,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
+#include <ctype.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
@@ -188,6 +189,7 @@ int usage(char **argv) {
"usage: %s [<opts>] [-X <implopt>] [-c <command>] [<filename>]\n"
"Options:\n"
"-v : verbose (trace various operations); can be multiple\n"
+"-O[N] : apply bytecode optimizations of level N\n"
"\n"
"Implementation specific options:\n", argv[0]
);
@@ -346,16 +348,20 @@ int main(int argc, char **argv) {
a += 1;
} else if (strcmp(argv[a], "-v") == 0) {
mp_verbose_flag++;
- } else if (strcmp(argv[a], "-O") == 0) {
- // optimisation; sets __debug__ to False
- mp_set_debug(false);
+ } else if (strncmp(argv[a], "-O", 2) == 0) {
+ if (isdigit(argv[a][2])) {
+ mp_optimise_value = argv[a][2] & 0xf;
+ } else {
+ mp_optimise_value = 0;
+ for (char *p = argv[a] + 1; *p && *p == 'O'; p++, mp_optimise_value++);
+ }
} else {
return usage(argv);
}
} else {
char *basedir = realpath(argv[a], NULL);
if (basedir == NULL) {
- fprintf(stderr, "%s: can't open file '%s': [Errno %d] ", argv[0], argv[1], errno);
+ fprintf(stderr, "%s: can't open file '%s': [Errno %d] ", argv[0], argv[a], errno);
perror("");
// CPython exits with 2 in such case
ret = 2;