My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

preflight-checks.py 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #
  2. # preflight-checks.py
  3. # Check for common issues prior to compiling
  4. #
  5. import os,re
  6. Import("env")
  7. def get_envs_for_board(board):
  8. if board.startswith("BOARD_"):
  9. board = board[6:]
  10. with open(os.path.join("Marlin", "src", "pins", "pins.h"),"r") as f:
  11. board_found = ""
  12. r=re.compile(r"if\s+MB\((.+)\)")
  13. for line in f.readlines():
  14. mbs = r.findall(line)
  15. if mbs:
  16. board_found = board if board in re.split(r",\s*", mbs[0]) else ""
  17. if board_found and "#include " in line and "env:" in line:
  18. return re.findall(r"env:\w+", line)
  19. return []
  20. def check_envs(build_env, base_envs, config):
  21. if build_env in base_envs:
  22. return True
  23. ext = config.get(build_env, 'extends', default=None)
  24. if ext:
  25. if isinstance(ext, str):
  26. return check_envs(ext, base_envs, config)
  27. elif isinstance(ext, list):
  28. for ext_env in ext:
  29. if check_envs(ext_env, base_envs, config):
  30. return True
  31. return False
  32. # Sanity checks:
  33. if 'PIOENV' not in env:
  34. raise SystemExit("Error: PIOENV is not defined. This script is intended to be used with PlatformIO")
  35. if 'MARLIN_FEATURES' not in env:
  36. raise SystemExit("Error: this script should be used after common Marlin scripts")
  37. if 'MOTHERBOARD' not in env['MARLIN_FEATURES']:
  38. raise SystemExit("Error: MOTHERBOARD is not defined in Configuration.h")
  39. build_env = env['PIOENV']
  40. motherboard = env['MARLIN_FEATURES']['MOTHERBOARD']
  41. base_envs = get_envs_for_board(motherboard)
  42. config = env.GetProjectConfig()
  43. result = check_envs("env:"+build_env, base_envs, config)
  44. if not result:
  45. err = "Error: Build environment '%s' is incompatible with %s. Use one of these: %s" % \
  46. (build_env, motherboard, ",".join([e[4:] for e in base_envs if e.startswith("env:")]))
  47. raise SystemExit(err)
  48. #
  49. # Check for Config files in two common incorrect places
  50. #
  51. for p in [ env['PROJECT_DIR'], os.path.join(env['PROJECT_DIR'], "config") ]:
  52. for f in [ "Configuration.h", "Configuration_adv.h" ]:
  53. if os.path.isfile(os.path.join(p, f)):
  54. err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p
  55. raise SystemExit(err)