py: Add MICROPY_ENABLE_COMPILER and MICROPY_PY_BUILTINS_EVAL_EXEC opts.
MICROPY_ENABLE_COMPILER can be used to enable/disable the entire compiler,
which is useful when only loading of pre-compiled bytecode is supported.
It is enabled by default.
MICROPY_PY_BUILTINS_EVAL_EXEC controls support of eval and exec builtin
functions. By default they are only included if MICROPY_ENABLE_COMPILER
is enabled.
Disabling both options saves about 40k of code size on 32-bit x86.
diff --git a/py/compile.c b/py/compile.c
index 4b929d5..f349dca 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -35,6 +35,8 @@
#include "py/compile.h"
#include "py/runtime.h"
+#if MICROPY_ENABLE_COMPILER
+
// TODO need to mangle __attr names
typedef enum {
@@ -3310,3 +3312,5 @@
// return function that executes the outer module
return mp_make_function_from_raw_code(rc, MP_OBJ_NULL, MP_OBJ_NULL);
}
+
+#endif // MICROPY_ENABLE_COMPILER