2021-02-27 22:38:57 -06:00
|
|
|
#
|
|
|
|
# STM32F1_create_variant.py
|
|
|
|
#
|
2021-11-04 05:28:42 -05:00
|
|
|
import pioutil
|
|
|
|
if pioutil.is_pio_build():
|
|
|
|
import os,shutil,marlin
|
|
|
|
from SCons.Script import DefaultEnvironment
|
|
|
|
from platformio import util
|
2020-06-01 18:25:13 -05:00
|
|
|
|
2021-11-04 05:28:42 -05:00
|
|
|
env = DefaultEnvironment()
|
|
|
|
platform = env.PioPlatform()
|
|
|
|
board = env.BoardConfig()
|
2020-06-01 18:25:13 -05:00
|
|
|
|
2021-11-04 05:28:42 -05:00
|
|
|
FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoststm32-maple")
|
|
|
|
assert os.path.isdir(FRAMEWORK_DIR)
|
2021-04-01 21:54:34 -05:00
|
|
|
|
2021-11-04 05:28:42 -05:00
|
|
|
source_root = os.path.join("buildroot", "share", "PlatformIO", "variants")
|
|
|
|
assert os.path.isdir(source_root)
|
2020-06-01 18:25:13 -05:00
|
|
|
|
2021-11-04 05:28:42 -05:00
|
|
|
variant = board.get("build.variant")
|
|
|
|
variant_dir = os.path.join(FRAMEWORK_DIR, "STM32F1", "variants", variant)
|
2020-06-01 18:25:13 -05:00
|
|
|
|
2021-11-04 05:28:42 -05:00
|
|
|
source_dir = os.path.join(source_root, variant)
|
|
|
|
assert os.path.isdir(source_dir)
|
2020-06-01 18:25:13 -05:00
|
|
|
|
2021-11-04 05:28:42 -05:00
|
|
|
if os.path.isdir(variant_dir):
|
|
|
|
shutil.rmtree(variant_dir)
|
2020-05-31 02:12:29 -05:00
|
|
|
|
2021-11-04 05:28:42 -05:00
|
|
|
if not os.path.isdir(variant_dir):
|
|
|
|
os.mkdir(variant_dir)
|
2020-06-01 18:25:13 -05:00
|
|
|
|
2021-11-04 05:28:42 -05:00
|
|
|
marlin.copytree(source_dir, variant_dir)
|