diff --git a/.project b/.project
index 6605278..abe4261 100755
--- a/.project
+++ b/.project
@@ -5,6 +5,11 @@
+
+ org.python.pydev.PyDevBuilder
+
+
+
org.eclipse.cdt.managedbuilder.core.genmakebuilder
clean,full,incremental,
@@ -23,5 +28,6 @@
org.eclipse.cdt.core.ccnature
org.eclipse.cdt.managedbuilder.core.managedBuildNature
org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ org.python.pydev.pythonNature
diff --git a/.pydevproject b/.pydevproject
new file mode 100644
index 0000000..40e9f40
--- /dev/null
+++ b/.pydevproject
@@ -0,0 +1,5 @@
+
+
+Default
+python 2.7
+
diff --git a/source/firmware/git_commit.h b/source/firmware/git_commit.h
new file mode 100644
index 0000000..279eb67
--- /dev/null
+++ b/source/firmware/git_commit.h
@@ -0,0 +1,12 @@
+/* Generated include file */
+
+#ifndef GIT_COMMIT_H
+#define GIT_COMMIT_H
+
+#define CURRENT_COMMIT "0"
+#define AUTHOR "tkl "
+#define LOCAL_CHANGES "NO"
+#define UNTRACKED_FILES "NO"
+
+#endif /* GIT_COMMIT_H */
+
diff --git a/source/scripts/.gitignore b/source/scripts/.gitignore
new file mode 100644
index 0000000..75c249c
--- /dev/null
+++ b/source/scripts/.gitignore
@@ -0,0 +1,2 @@
+commit.pyc
+
diff --git a/source/scripts/commit.py b/source/scripts/commit.py
new file mode 100644
index 0000000..33b878f
--- /dev/null
+++ b/source/scripts/commit.py
@@ -0,0 +1,46 @@
+from re import match, sub
+
+class commit:
+ def __init__(self, commit_list):
+ self.__hash = ""
+ self.__merge = ""
+ self.__author = ""
+ self.__date = ""
+ self.__message = []
+
+ for line in commit_list:
+ if match("^commit", line):
+ line = sub("^commit", "", line)
+ line = line.strip()
+ self.__hash = line
+ elif match("^Merge:", line):
+ line = sub("^Merge:", "", line)
+ line = line.strip()
+ self.__merge = line
+ elif match("^Author:", line):
+ line = sub("^Author:", "", line)
+ line = line.strip()
+ self.__author = line
+ elif match("^Date:", line):
+ line = sub("^Date:", "", line)
+ line = line.strip()
+ self.__date = line
+ else:
+ line = line.strip()
+ self.__message.append(line)
+
+ def hash(self):
+ return self.__hash
+
+ def merge(self):
+ return self.__merge
+
+ def author(self):
+ return self.__author
+
+ def date(self):
+ return self.__date
+
+ def message(self):
+ return self.__message
+
diff --git a/source/scripts/get_history.py b/source/scripts/get_history.py
new file mode 100755
index 0000000..86d9533
--- /dev/null
+++ b/source/scripts/get_history.py
@@ -0,0 +1,90 @@
+#!/usr/bin/python2
+from subprocess import Popen, PIPE
+from re import match, sub
+from sys import argv, getfilesystemencoding
+from getopt import getopt
+from commit import commit
+
+def check_for_untracked():
+ cmd = ["git", "status"]
+ p = Popen(cmd, stdout=PIPE, stderr=PIPE)
+ stdout, stderr = p.communicate()
+ res = stdout.split("\n")
+ for line in res:
+ line = line.strip()
+ if(match("Untracked files:", line)):
+ return True
+ return False
+
+def check_for_changes():
+ cmd = ["git", "status"]
+ p = Popen(cmd, stdout=PIPE, stderr=PIPE)
+ stdout, stderr = p.communicate()
+ res = stdout.split("\n")
+ for line in res:
+ line = line.strip()
+ if(match("Changes not staged for commit:", line)):
+ return True
+ return False
+
+
+def get_git_log():
+ cmd = ["git", "log", "--encoding=UTF-8", "-1"]
+ p = Popen(cmd, stdout=PIPE, stderr=PIPE)
+ stdout, stderr = p.communicate()
+ res = stdout.split("\n")
+ ret = []
+ for line in res:
+ line = line.strip()
+ ret.append(line)
+ return ret
+
+def get_commit_list(git_log):
+ ret = []
+ git_commit = []
+ first_run = True
+ for line in git_log:
+ if match("^commit ", line):
+ if first_run:
+ first_run = False
+ else:
+ ret.append(commit(git_commit))
+ git_commit = []
+ if len(line) > 0:
+ git_commit.append(line)
+ ret.append(commit(git_commit))
+ return ret
+
+def generate_include_file(file_name, commit_list, local_changes, untracked_files):
+ if(len(commit_list) > 0):
+ f = open(file_name, "w")
+ f.write("/* Generated include file */\n\n")
+ f.write("#ifndef GIT_COMMIT_H\n")
+ f.write("#define GIT_COMMIT_H\n\n")
+ f.write("#define CURRENT_COMMIT\t")
+ f.write("\"" + commit_list[0].hash() + "\"\n")
+ f.write("#define AUTHOR\t\t")
+ f.write("\"" + commit_list[0].author() + "\"\n")
+ f.write("#define LOCAL_CHANGES\t")
+ if(local_changes):
+ f.write("\"YES\"\n")
+ else:
+ f.write("\"NO\"\n")
+ f.write("#define UNTRACKED_FILES\t")
+ if(untracked_files):
+ f.write("\"YES\"\n")
+ else:
+ f.write("\"NO\"\n")
+ f.write("\n#endif /* GIT_COMMIT_H */\n")
+ f.close()
+
+def main(argv):
+ local_changes = check_for_changes()
+ untracked_files = check_for_untracked()
+ log_list = get_git_log()
+ commit_list = get_commit_list(log_list)
+ generate_include_file("source/firmware/git_commit.h", commit_list, local_changes, untracked_files)
+
+if __name__ == "__main__":
+ main(argv[1:])
+