generic_create_variant.py 872 B

123456789101112131415161718192021222324252627
  1. import os,shutil
  2. from SCons.Script import DefaultEnvironment
  3. from platformio import util
  4. env = DefaultEnvironment()
  5. platform = env.PioPlatform()
  6. board = env.BoardConfig()
  7. FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoststm32")
  8. assert os.path.isdir(FRAMEWORK_DIR)
  9. assert os.path.isdir("buildroot/share/PlatformIO/variants")
  10. mcu_type = board.get("build.mcu")[:-2]
  11. variant = board.get("build.variant")
  12. series = mcu_type[:7].upper() + "xx"
  13. variant_dir = os.path.join(FRAMEWORK_DIR, "variants", variant)
  14. source_dir = os.path.join("buildroot/share/PlatformIO/variants", variant)
  15. assert os.path.isdir(source_dir)
  16. if not os.path.isdir(variant_dir):
  17. os.mkdir(variant_dir)
  18. for file_name in os.listdir(source_dir):
  19. full_file_name = os.path.join(source_dir, file_name)
  20. if os.path.isfile(full_file_name):
  21. shutil.copy(full_file_name, variant_dir)