File tree Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ git_hash=" $( git rev-parse --short HEAD 2> /dev/null || echo unknown) "
4
+ git_files_are_clean=1
5
+ # Check if there are any modified files.
6
+ git diff --no-ext-diff --quiet --exit-code 2> /dev/null || git_files_are_clean=0
7
+ # Check if there are any staged files.
8
+ git diff-index --cached --quiet HEAD -- 2> /dev/null || git_files_are_clean=0
9
+ if [ " ${git_files_are_clean} " != " 1" ]; then
10
+ git_hash=" ${git_hash} -dirty"
11
+ fi
12
+ cat << EOF
13
+ // This file was generated by py/py-version.sh
14
+ #define MICROPY_GIT_HASH "${git_hash} "
15
+ #define MICROPY_BUILD_DATE "$( date ' +%Y-%m-%d' ) "
16
+ EOF
Original file line number Diff line number Diff line change @@ -90,6 +90,14 @@ PY_O_BASENAME = \
90
90
# prepend the build destination prefix to the py object files
91
91
PY_O = $(addprefix $(PY_BUILD ) /, $(PY_O_BASENAME ) )
92
92
93
+ # Anything that depends on FORCE will be considered out-of-date
94
+ FORCE :
95
+ .PHONY : FORCE
96
+
97
+ $(PY_BUILD ) /py-version.h : FORCE
98
+ $(Q )$(PY_SRC ) /py-version.sh > $@ .tmp
99
+ $(Q ) if [ -f " $@ " ] && cmp -s $@ $@ .tmp; then rm $@ .tmp; else echo " Generating $@ " ; mv $@ .tmp $@ ; fi
100
+
93
101
# qstr data
94
102
95
103
# Adding an order only dependency on $(PY_BUILD) causes $(PY_BUILD) to get
@@ -104,7 +112,7 @@ $(PY_BUILD)/qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(PY_SRC)/makeqst
104
112
# the right .o's to get recompiled if the generated.h file changes. Adding
105
113
# an order-only dependendency to all of the .o's will cause the generated .h
106
114
# to get built before we try to compile any of them.
107
- $(PY_O ) : | $(PY_BUILD ) /qstrdefs.generated.h
115
+ $(PY_O ) : | $(PY_BUILD ) /qstrdefs.generated.h $( PY_BUILD ) /py-version.h
108
116
109
117
# emitters
110
118
Original file line number Diff line number Diff line change 23
23
#include "pyexec.h"
24
24
#include "storage.h"
25
25
#include "usb.h"
26
+ #include "build/py/py-version.h"
26
27
27
28
pyexec_mode_kind_t pyexec_mode_kind = PYEXEC_MODE_FRIENDLY_REPL ;
28
29
STATIC bool repl_display_debugging_info = 0 ;
@@ -155,7 +156,7 @@ int pyexec_friendly_repl(void) {
155
156
#endif
156
157
157
158
friendly_repl_reset :
158
- stdout_tx_str ("Micro Python build <git hash> on 25/1/2014 ; " MICROPY_HW_BOARD_NAME " with STM32F405RG\r\n" );
159
+ stdout_tx_str ("Micro Python build " MICROPY_GIT_HASH " on " MICROPY_BUILD_DATE " ; " MICROPY_HW_BOARD_NAME " with STM32F405RG\r\n" );
159
160
stdout_tx_str ("Type \"help()\" for more information.\r\n" );
160
161
161
162
// to test ctrl-C
You can’t perform that action at this time.
0 commit comments