Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.7 KiB

  1. #!/bin/python
  2. import json
  3. import commands
  4. import subprocess
  5. import os
  6. import sys
  7. def core_version(env):
  8. # Get the core folder
  9. fwdir = env["FRAMEWORK_ARDUINOESP8266_DIR"]
  10. # Get the core version
  11. with open(fwdir + '/package.json') as data_file:
  12. data = json.load(data_file)
  13. core_version = data["version"].upper().replace(".", "_").replace("-", "_")
  14. print "CORE VERSION: %s" % core_version
  15. # Get git version
  16. pr = subprocess.Popen(
  17. "git --git-dir .git rev-parse --short=8 HEAD 2>/dev/null || echo ffffffff",
  18. cwd = fwdir,
  19. shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE )
  20. (out, error) = pr.communicate()
  21. git_version = str(out).replace('\n', "")
  22. print "GIT VERSION: %s" % git_version
  23. #env["BUILD_FLAGS"][0] += str(" -DARDUINO_ESP8266_RELEASE=" + core_version)
  24. #env["BUILD_FLAGS"][0] += str(" -DARDUINO_ESP8266_RELEASE_" + core_version)
  25. #env["BUILD_FLAGS"][0] += str(" -DARDUINO_ESP8266_GIT_VER=" + git_version)
  26. with open('espurna/config/core_version.h', 'w') as the_file:
  27. the_file.write('#define ARDUINO_ESP8266_RELEASE "%s"\n' % core_version)
  28. the_file.write('#define ARDUINO_ESP8266_RELEASE_%s\n' % core_version)
  29. the_file.write('#define ARDUINO_ESP8266_GIT_VER "%s"\n' % git_version)
  30. #env.Append(
  31. # CFLAGS = [
  32. # str("-DARDUINO_ESP8266_RELEASE=" + core_version),
  33. # str("-DARDUINO_ESP8266_RELEASE_" + core_version),
  34. # str("-DARDUINO_ESP8266_GIT_VER=" + git_version)
  35. # ]
  36. #)
  37. #print " -DARDUINO_ESP8266_RELEASE=" + core_version +
  38. # " -DARDUINO_ESP8266_RELEASE_" + core_version +
  39. # " -DARDUINO_ESP8266_GIT_VER=" + git_version
  40. Import('env')
  41. core_version(env)