79 lines
2.6 KiB
Python
79 lines
2.6 KiB
Python
#!/usr/bin/env python3
|
|
# vim: set syntax=python ts=4 :
|
|
#
|
|
# Copyright (c) 2018-2022 Intel Corporation
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
import os
|
|
import scl
|
|
from twisterlib.config_parser import TwisterConfigParser
|
|
from twisterlib.environment import ZEPHYR_BASE
|
|
|
|
class Platform:
|
|
"""Class representing metadata for a particular platform
|
|
|
|
Maps directly to BOARD when building"""
|
|
|
|
platform_schema = scl.yaml_load(os.path.join(ZEPHYR_BASE,
|
|
"scripts", "schemas", "twister", "platform-schema.yaml"))
|
|
|
|
def __init__(self):
|
|
"""Constructor.
|
|
|
|
"""
|
|
|
|
self.name = ""
|
|
self.twister = True
|
|
# if no RAM size is specified by the board, take a default of 128K
|
|
self.ram = 128
|
|
|
|
self.timeout_multiplier = 1.0
|
|
self.ignore_tags = []
|
|
self.only_tags = []
|
|
self.default = False
|
|
# if no flash size is specified by the board, take a default of 512K
|
|
self.flash = 512
|
|
self.supported = set()
|
|
|
|
self.arch = ""
|
|
self.type = "na"
|
|
self.simulation = "na"
|
|
self.supported_toolchains = []
|
|
self.env = []
|
|
self.env_satisfied = True
|
|
self.filter_data = dict()
|
|
|
|
def load(self, platform_file):
|
|
scp = TwisterConfigParser(platform_file, self.platform_schema)
|
|
scp.load()
|
|
data = scp.data
|
|
|
|
self.name = data['identifier']
|
|
self.twister = data.get("twister", True)
|
|
# if no RAM size is specified by the board, take a default of 128K
|
|
self.ram = data.get("ram", 128)
|
|
testing = data.get("testing", {})
|
|
self.timeout_multiplier = testing.get("timeout_multiplier", 1.0)
|
|
self.ignore_tags = testing.get("ignore_tags", [])
|
|
self.only_tags = testing.get("only_tags", [])
|
|
self.default = testing.get("default", False)
|
|
# if no flash size is specified by the board, take a default of 512K
|
|
self.flash = data.get("flash", 512)
|
|
self.supported = set()
|
|
for supp_feature in data.get("supported", []):
|
|
for item in supp_feature.split(":"):
|
|
self.supported.add(item)
|
|
|
|
self.arch = data['arch']
|
|
self.type = data.get('type', "na")
|
|
self.simulation = data.get('simulation', "na")
|
|
self.supported_toolchains = data.get("toolchain", [])
|
|
self.env = data.get("env", [])
|
|
self.env_satisfied = True
|
|
for env in self.env:
|
|
if not os.environ.get(env, None):
|
|
self.env_satisfied = False
|
|
|
|
def __repr__(self):
|
|
return "<%s on %s>" % (self.name, self.arch)
|