[core] Allow using external framework parts
This commit is contained in:
49
builder/libs/lwip.py
Normal file
49
builder/libs/lwip.py
Normal file
@@ -0,0 +1,49 @@
|
||||
# Copyright (c) Kuba Szczodrzyński 2022-05-18.
|
||||
|
||||
from SCons.Script import DefaultEnvironment
|
||||
|
||||
env = DefaultEnvironment()
|
||||
platform = env.PioPlatform()
|
||||
|
||||
|
||||
def env_add_lwip(
|
||||
env,
|
||||
version: str,
|
||||
port: str,
|
||||
):
|
||||
# version = env["LIB_LWIP_VERSION"] if "LIB_LWIP_VERSION" in env else version_default
|
||||
package_dir = platform.get_package_dir(f"library-lwip@{version}-{port}")
|
||||
port_srcs = []
|
||||
port_includes = []
|
||||
|
||||
if port in ["amb1"]:
|
||||
port_srcs = [
|
||||
"+<port/realtek/freertos/ethernetif.c>",
|
||||
"+<port/realtek/freertos/sys_arch.c>",
|
||||
]
|
||||
port_includes = [
|
||||
"+<port/realtek>",
|
||||
"+<port/realtek/freertos>",
|
||||
]
|
||||
|
||||
env.AddLibrary(
|
||||
name=f"lwip{version}_{port}",
|
||||
base_dir=package_dir,
|
||||
srcs=[
|
||||
"+<src/api/*.c>",
|
||||
"+<src/core/*.c>",
|
||||
"+<src/core/ipv4/*.c>",
|
||||
"+<src/netif/ethernet.c>", # 2.0.x
|
||||
"+<src/netif/etharp.c>", # 1.4.x
|
||||
*port_srcs,
|
||||
],
|
||||
includes=[
|
||||
"+<src/include>",
|
||||
"+<src/include/lwip>",
|
||||
"+<src/include/ipv4>",
|
||||
*port_includes,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
env.AddMethod(env_add_lwip, "AddLibraryLwIP")
|
||||
@@ -7,6 +7,8 @@ board = env.BoardConfig()
|
||||
|
||||
# Utilities
|
||||
env.SConscript("utils.py", exports="env")
|
||||
# Vendor-specific library ports
|
||||
env.SConscript("libs/lwip.py", exports="env")
|
||||
|
||||
# Firmware name
|
||||
if env.get("PROGNAME", "program") == "program":
|
||||
|
||||
@@ -40,6 +40,14 @@
|
||||
"description": "Hardware independent layer of the Arduino cores"
|
||||
}
|
||||
},
|
||||
"library-lwip": {
|
||||
"type": "framework",
|
||||
"optional": true,
|
||||
"base_url": "https://github.com/libretuya/lwip",
|
||||
"manifest": {
|
||||
"description": "lwIP - A Lightweight TCPIP stack"
|
||||
}
|
||||
},
|
||||
"toolchain-gccarmnoneeabi": {
|
||||
"type": "toolchain",
|
||||
"optionalVersions": [
|
||||
|
||||
22
platform.py
22
platform.py
@@ -99,6 +99,28 @@ class LibretuyaPlatform(PlatformBase):
|
||||
if framework.startswith("realtek-ambz"):
|
||||
self.packages["toolchain-gccarmnoneeabi"]["version"] = "~1.50401.0"
|
||||
|
||||
# use appropriate vendor library versions
|
||||
sdk_package_name = self.frameworks[framework]["package"]
|
||||
sdk_package = self.packages[sdk_package_name]
|
||||
sdk_libraries = sdk_package["libraries"] if "libraries" in sdk_package else {}
|
||||
packages_new = {}
|
||||
for name, package in self.packages.items():
|
||||
if not name.startswith("library-"):
|
||||
continue
|
||||
name = name[8:] # strip "library-"
|
||||
if name not in sdk_libraries:
|
||||
continue
|
||||
lib_version = sdk_libraries[name][-1] # get latest version tag
|
||||
package = dict(**package) # clone the base package
|
||||
package["version"] = (
|
||||
package["base_url"] + "#" + lib_version
|
||||
) # use the specific version
|
||||
package["optional"] = False # make it required
|
||||
lib_version = lib_version.lstrip("v") # strip "v" in target name
|
||||
name = f"library-{name}@{lib_version}"
|
||||
packages_new[name] = package # put the package under a new name
|
||||
self.packages.update(packages_new)
|
||||
|
||||
# make ArduinoCore-API required
|
||||
if "arduino" in framework:
|
||||
self.packages["framework-arduino-api"]["optional"] = False
|
||||
|
||||
Reference in New Issue
Block a user