1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-29 23:07:42 +00:00
MarlinFirmware/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py

44 lines
1.3 KiB
Python
Raw Normal View History

2021-02-28 04:38:57 +00:00
#
# STM32F1_create_variant.py
#
import pioutil
if pioutil.is_pio_build():
from pathlib import Path
2021-04-02 02:54:34 +00:00
source_root_str = "buildroot/share/PlatformIO/variants"
source_root = Path(source_root_str)
assert source_root.is_dir()
2020-06-01 23:25:13 +00:00
env = pioutil.env
board = env.BoardConfig()
variant = board.get("build.variant")
2020-06-01 23:25:13 +00:00
source_dir = source_root / variant
assert source_dir.is_dir()
2020-06-01 23:25:13 +00:00
if True:
# Copying to the platform folder is still needed by STM32F1 (Maple).
# The alternative code below comes close. See if you can solve it!
platform = env.PioPlatform()
FRAMEWORK_DIR = Path(platform.get_package_dir("framework-arduinoststm32-maple"))
assert FRAMEWORK_DIR.is_dir()
variant_dir = FRAMEWORK_DIR / "STM32F1/variants" / variant
if variant_dir.is_dir():
import shutil
shutil.rmtree(variant_dir)
if not variant_dir.is_dir():
variant_dir.mkdir()
import marlin
marlin.copytree(source_dir, variant_dir)
else:
2020-06-01 23:25:13 +00:00
# The following almost works, but __start__ (from wirish/start.S) is not seen by common.inc
board.update("build.variants_dir", source_root_str);
src = str(source_dir)
env.Append(BUILD_FLAGS=[f"-I{src}", f"-L{src}/ld"]) # Add include path for variant