blob: 88c3ebb986b6f48ce2d27e0092c6446029d4dbcc [file] [log] [blame]
Marcus von Appen8ffc0242014-06-07 09:16:42 +02001#!/bin/sh
Dave Hylandsbf7d6902014-04-03 16:32:58 -07002
Paul Sokolovsky22a0d672014-05-05 01:00:21 +03003# Note: git describe doesn't work if no tag is available
Paul Sokolovsky179977a2014-05-05 21:27:22 +03004git_tag="$(git describe --dirty --always)"
Dave Hylandsbf7d6902014-04-03 16:32:58 -07005git_hash="$(git rev-parse --short HEAD 2> /dev/null || echo unknown)"
6git_files_are_clean=1
7# Check if there are any modified files.
8git diff --no-ext-diff --quiet --exit-code 2> /dev/null || git_files_are_clean=0
9# Check if there are any staged files.
10git diff-index --cached --quiet HEAD -- 2> /dev/null || git_files_are_clean=0
11if [ "${git_files_are_clean}" != "1" ]; then
12 git_hash="${git_hash}-dirty"
13fi
14cat <<EOF
15// This file was generated by py/py-version.sh
Damien George977a0ce2014-05-03 19:02:14 +010016#define MICROPY_GIT_TAG "${git_tag}"
Dave Hylandsbf7d6902014-04-03 16:32:58 -070017#define MICROPY_GIT_HASH "${git_hash}"
18#define MICROPY_BUILD_DATE "$(date '+%Y-%m-%d')"
19EOF