File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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 = \
9090# prepend the build destination prefix to the py object files
9191PY_O = $(addprefix $(PY_BUILD ) /, $(PY_O_BASENAME ) )
9292
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+
93101# qstr data
94102
95103# 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
104112# the right .o's to get recompiled if the generated.h file changes. Adding
105113# an order-only dependendency to all of the .o's will cause the generated .h
106114# 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
108116
109117# emitters
110118
Original file line number Diff line number Diff line change 2323#include "pyexec.h"
2424#include "storage.h"
2525#include "usb.h"
26+ #include "build/py/py-version.h"
2627
2728pyexec_mode_kind_t pyexec_mode_kind = PYEXEC_MODE_FRIENDLY_REPL ;
2829STATIC bool repl_display_debugging_info = 0 ;
@@ -155,7 +156,7 @@ int pyexec_friendly_repl(void) {
155156#endif
156157
157158friendly_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" );
159160 stdout_tx_str ("Type \"help()\" for more information.\r\n" );
160161
161162 // to test ctrl-C
You can’t perform that action at this time.
0 commit comments