From 694c06e7f528f27df728ab0b6586f9161ee557ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Mon, 16 May 2022 15:53:51 +0200 Subject: [PATCH] [core] Allow using "arduino" as framework --- builder/frameworks/arduino.py | 14 ++++++++++++++ platform.json | 4 ++++ platform.py | 12 ++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 builder/frameworks/arduino.py diff --git a/builder/frameworks/arduino.py b/builder/frameworks/arduino.py new file mode 100644 index 0000000..0d37e48 --- /dev/null +++ b/builder/frameworks/arduino.py @@ -0,0 +1,14 @@ +# Copyright (c) Kuba SzczodrzyƄski 2022-05-16. + +from SCons.Script import DefaultEnvironment + +env = DefaultEnvironment() +board = env.BoardConfig() +platform = env.PioPlatform() + +# support passing "arduino" as framework +frameworks = board.get("frameworks") +framework = next(fw for fw in frameworks if "arduino" in fw) +builder = platform.frameworks[framework]["script"] +builder = builder.rpartition("/")[2] +env.SConscript(builder, exports="env") diff --git a/platform.json b/platform.json index 93ca014..5e8f954 100644 --- a/platform.json +++ b/platform.json @@ -8,6 +8,10 @@ }, "version": "0.3.0", "frameworks": { + "arduino": { + "title": "Generic Arduino framework", + "script": "builder/frameworks/arduino.py" + }, "realtek-ambz-sdk": { "tilte": "Realtek AmebaZ - SDK", "package": "framework-realtek-amb1", diff --git a/platform.py b/platform.py index 2db06d0..7e07584 100644 --- a/platform.py +++ b/platform.py @@ -83,6 +83,13 @@ class LibretuyaPlatform(PlatformBase): BasePackageManager._load_manifest = BasePackageManager.load_manifest BasePackageManager.load_manifest = load_manifest + # allow using "arduino" as framework + if framework == "arduino": + board = self.get_boards(options.get("board")) + frameworks = board.get("frameworks") + framework = next(fw for fw in frameworks if framework in fw) + options.get("pioframework")[0] = framework + # set specific compiler versions if framework.startswith("realtek-ambz"): self.packages["toolchain-gccarmnoneeabi"]["version"] = "~1.50401.0" @@ -131,6 +138,11 @@ class LibretuyaPlatform(PlatformBase): util.merge_dicts(result, board._manifest) board._manifest = result + # add "arduino" framework + has_arduino = any("arduino" in fw for fw in board.manifest["frameworks"]) + if has_arduino: + board.manifest["frameworks"].append("arduino") + # inspired by platform-ststm32/platform.py debug = board.manifest.get("debug", {}) if not debug: