summaryrefslogtreecommitdiff
path: root/mpy-cross/main.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-05-02 09:59:21 +1000
committerDamien George <damien.p.george@gmail.com>2019-05-07 13:54:20 +1000
commit7e90e22ea52665e38138d1e704d5e527439b663c (patch)
tree37d16b07a80c3326759c63c27af485ef65ed7cc6 /mpy-cross/main.c
parent6323cbda4fd82f2396a19e18a224a2579a392303 (diff)
mpy-cross: Add --version command line option to print version info.
Prints something like: MicroPython v1.10-304-g8031b7a25 on 2019-05-02; mpy-cross emitting mpy v4
Diffstat (limited to 'mpy-cross/main.c')
-rw-r--r--mpy-cross/main.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/mpy-cross/main.c b/mpy-cross/main.c
index 7bf207596..970ad2d75 100644
--- a/mpy-cross/main.c
+++ b/mpy-cross/main.c
@@ -34,6 +34,7 @@
#include "py/runtime.h"
#include "py/gc.h"
#include "py/stackctrl.h"
+#include "genhdr/mpversion.h"
#ifdef _WIN32
#include "ports/windows/fmode.h"
#endif
@@ -98,6 +99,7 @@ STATIC int usage(char **argv) {
printf(
"usage: %s [<opts>] [-X <implopt>] <input filename>\n"
"Options:\n"
+"--version : show version information\n"
"-o : output file for compiled bytecode (defaults to input with .mpy extension)\n"
"-s : source filename to embed in the compiled bytecode (defaults to input file)\n"
"-v : verbose (trace various operations); can be multiple\n"
@@ -211,6 +213,10 @@ MP_NOINLINE int main_(int argc, char **argv) {
if (argv[a][0] == '-') {
if (strcmp(argv[a], "-X") == 0) {
a += 1;
+ } else if (strcmp(argv[a], "--version") == 0) {
+ printf("MicroPython " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE
+ "; mpy-cross emitting mpy v" MP_STRINGIFY(MPY_VERSION) "\n");
+ return 0;
} else if (strcmp(argv[a], "-v") == 0) {
mp_verbose_flag++;
} else if (strncmp(argv[a], "-O", 2) == 0) {