blob: 42474ef6a5854762def09e607d7a764dca354895 [file] [log] [blame]
Dave Hylandsbf7d6902014-04-03 16:32:58 -07001#!/bin/bash
2
Damien George349e4c42014-05-03 21:15:32 +01003git_tag="$(git describe --dirty || echo unknown)"
Dave Hylandsbf7d6902014-04-03 16:32:58 -07004git_hash="$(git rev-parse --short HEAD 2> /dev/null || echo unknown)"
5git_files_are_clean=1
6# Check if there are any modified files.
7git diff --no-ext-diff --quiet --exit-code 2> /dev/null || git_files_are_clean=0
8# Check if there are any staged files.
9git diff-index --cached --quiet HEAD -- 2> /dev/null || git_files_are_clean=0
10if [ "${git_files_are_clean}" != "1" ]; then
11 git_hash="${git_hash}-dirty"
12fi
13cat <<EOF
14// This file was generated by py/py-version.sh
Damien George977a0ce2014-05-03 19:02:14 +010015#define MICROPY_GIT_TAG "${git_tag}"
Dave Hylandsbf7d6902014-04-03 16:32:58 -070016#define MICROPY_GIT_HASH "${git_hash}"
17#define MICROPY_BUILD_DATE "$(date '+%Y-%m-%d')"
18EOF