My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

generate_version_header_for_marlin 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #/usr/bin/env python -
  2. from SCons.Script import DefaultEnvironment
  3. env = DefaultEnvironment()
  4. import os
  5. import errno
  6. def make_sure_path_exists(path):
  7. try:
  8. os.makedirs(path)
  9. except OSError as exception:
  10. if exception.errno != errno.EEXIST:
  11. raise
  12. import subprocess
  13. make_sure_path_exists(env.subst('$BUILDSRC_DIR'))
  14. from datetime import datetime
  15. import time
  16. import string
  17. import re
  18. p = subprocess.Popen(['git', 'symbolic-ref', '-q', '--short', 'HEAD'], stdout=subprocess.PIPE)
  19. BRANCH = p.stdout.readline().rstrip()
  20. p = subprocess.Popen(['git', 'describe', '--tags', '--first-parent'], stdout=subprocess.PIPE)
  21. RAW_VERSION = p.stdout.readline().rstrip()
  22. s = re.search('(.*)(-.*)(-.*)',RAW_VERSION)
  23. SHORT_VERSION = s.group(1)+' '+BRANCH
  24. DETAILED_VERSION = string.replace(RAW_VERSION,'-',' '+BRANCH+'-',1)
  25. p = subprocess.Popen(['git', 'config', '--local', '--get', 'remote.origin.url'], stdout=subprocess.PIPE)
  26. try:
  27. s = re.search('(.*github.com:)(.*)', p.stdout.readline().rstrip())
  28. URL = string.replace("https://github.com/"+s.group(2), ".git", "/")
  29. url_text = """#define SOURCE_CODE_URL "%s"
  30. // Deprecated URL definition
  31. #define FIRMWARE_URL "%s"
  32. """ % (URL, URL)
  33. except Exception, e:
  34. url_text = ""
  35. version_header_text = """/* This file is automatically generated by a compile time hook
  36. * Do not manually edit it
  37. * It does not get committed to the repository
  38. */
  39. #define BUILD_UNIX_DATETIME %s
  40. #define STRING_DISTRIBUTION_DATE "%s"
  41. #define SHORT_BUILD_VERSION "%s"
  42. #define DETAILED_BUILD_VERSION "%s"
  43. %s""" % (int(time.time()), datetime.now().strftime('%Y-%m-%d %H:%M'),SHORT_VERSION, DETAILED_VERSION, url_text)
  44. open(env.subst('$BUILDSRC_DIR/_Version.h'), 'w').write(version_header_text)