2021-02-28 04:38:57 +00:00
|
|
|
#
|
|
|
|
# STM32F1_create_variant.py
|
|
|
|
#
|
2021-11-04 10:28:42 +00:00
|
|
|
import pioutil
|
|
|
|
if pioutil.is_pio_build():
|
2024-06-14 21:01:34 +00:00
|
|
|
import shutil, marlin
|
2022-10-12 22:52:56 +00:00
|
|
|
from pathlib import Path
|
2024-06-14 21:01:34 +00:00
|
|
|
env = pioutil.env
|
2022-10-12 22:52:56 +00:00
|
|
|
platform = env.PioPlatform()
|
|
|
|
board = env.BoardConfig()
|
2020-06-01 23:25:13 +00:00
|
|
|
|
2022-10-12 22:52:56 +00:00
|
|
|
FRAMEWORK_DIR = Path(platform.get_package_dir("framework-arduinoststm32-maple"))
|
|
|
|
assert FRAMEWORK_DIR.is_dir()
|
2021-04-02 02:54:34 +00:00
|
|
|
|
2022-10-12 22:52:56 +00:00
|
|
|
source_root = Path("buildroot/share/PlatformIO/variants")
|
|
|
|
assert source_root.is_dir()
|
2020-06-01 23:25:13 +00:00
|
|
|
|
2022-10-12 22:52:56 +00:00
|
|
|
variant = board.get("build.variant")
|
|
|
|
variant_dir = FRAMEWORK_DIR / "STM32F1/variants" / variant
|
2020-06-01 23:25:13 +00:00
|
|
|
|
2022-10-12 22:52:56 +00:00
|
|
|
source_dir = source_root / variant
|
|
|
|
assert source_dir.is_dir()
|
2020-06-01 23:25:13 +00:00
|
|
|
|
2022-10-12 22:52:56 +00:00
|
|
|
if variant_dir.is_dir():
|
|
|
|
shutil.rmtree(variant_dir)
|
2020-05-31 07:12:29 +00:00
|
|
|
|
2022-10-12 22:52:56 +00:00
|
|
|
if not variant_dir.is_dir():
|
|
|
|
variant_dir.mkdir()
|
2020-06-01 23:25:13 +00:00
|
|
|
|
2022-10-12 22:52:56 +00:00
|
|
|
marlin.copytree(source_dir, variant_dir)
|