Skip to content

Commit f22626e

Browse files
committed
unix: Add option to only compile, and not execute code.
1 parent 87bb093 commit f22626e

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

unix/main.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
#include <readline/history.h>
3030
#endif
3131

32-
// Default emit options
32+
// Command line options, with their defaults
33+
bool compile_only = false;
3334
uint emit_opt = MP_EMIT_OPT_NONE;
3435

3536
#if MICROPY_ENABLE_GC
@@ -87,6 +88,10 @@ STATIC void execute_from_lexer(mp_lexer_t *lex, mp_parse_input_kind_t input_kind
8788
return;
8889
}
8990

91+
if (compile_only) {
92+
return;
93+
}
94+
9095
// execute it
9196
nlr_buf_t nlr;
9297
if (nlr_push(&nlr) == 0) {
@@ -226,6 +231,7 @@ int usage(char **argv) {
226231
);
227232
int impl_opts_cnt = 0;
228233
printf(
234+
" compile-only -- parse and compile only\n"
229235
" emit={bytecode,native,viper} -- set the default code emitter\n"
230236
);
231237
impl_opts_cnt++;
@@ -273,6 +279,8 @@ void pre_process_options(int argc, char **argv) {
273279
exit(usage(argv));
274280
}
275281
if (0) {
282+
} else if (strcmp(argv[a + 1], "compile-only") == 0) {
283+
compile_only = true;
276284
} else if (strcmp(argv[a + 1], "emit=bytecode") == 0) {
277285
emit_opt = MP_EMIT_OPT_BYTE_CODE;
278286
} else if (strcmp(argv[a + 1], "emit=native") == 0) {

0 commit comments

Comments
 (0)