summaryrefslogtreecommitdiffstats
path: root/scripts/lib/bsp
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/bsp')
-rw-r--r--scripts/lib/bsp/help.py31
-rw-r--r--scripts/lib/bsp/kernel.py107
2 files changed, 138 insertions, 0 deletions
diff --git a/scripts/lib/bsp/help.py b/scripts/lib/bsp/help.py
index 2d7b6fe..9ba6a93 100644
--- a/scripts/lib/bsp/help.py
+++ b/scripts/lib/bsp/help.py
@@ -386,6 +386,7 @@ yocto_kernel_usage = """
feature list List the features used by a BSP
feature add Have a BSP use a feature
feature rm Have a BSP stop using a feature
+ features list List the features available to BSPs
See 'yocto-kernel help COMMAND' for more information on a specific command.
@@ -692,6 +693,36 @@ DESCRIPTION
remove.
"""
+
+yocto_kernel_available_features_list_usage = """
+
+ List the set of kernel features available to a BSP
+
+ usage: yocto-kernel features list <bsp-name>
+
+ This command lists the complete set of kernel features available to a
+ BSP. This includes the features contained in linux-yocto meta
+ branches as well as recipe-space features defined locally to the BSP.
+"""
+
+
+yocto_kernel_available_features_list_help = """
+
+NAME
+ yocto-kernel features list - List the set of kernel features
+ available to a BSP
+
+SYNOPSIS
+ yocto-kernel features list <bsp-name>
+
+DESCRIPTION
+ This command lists the complete set of kernel features available
+ to a BSP. This includes the features contained in linux-yocto
+ meta branches as well as recipe-space features defined locally to
+ the BSP.
+"""
+
+
##
# yocto-layer help and usage strings
##
diff --git a/scripts/lib/bsp/kernel.py b/scripts/lib/bsp/kernel.py
index 0fa228a..0308600 100644
--- a/scripts/lib/bsp/kernel.py
+++ b/scripts/lib/bsp/kernel.py
@@ -32,6 +32,7 @@ import shutil
from tags import *
import glob
import subprocess
+from engine import create_context
def find_bblayers(scripts_path):
@@ -651,6 +652,112 @@ def yocto_kernel_feature_add(scripts_path, machine, features):
for n in new_items:
print "\t%s" % n
+
+def find_feature_url(git_url):
+ """
+ Find the url of the kern-features.rc kernel for the kernel repo
+ specified from the BSP's kernel recipe SRC_URI.
+ """
+ feature_url = ""
+ if git_url.startswith("git://"):
+ git_url = git_url[len("git://"):].strip()
+ s = git_url.split("/")
+ if s[1].endswith(".git"):
+ s[1] = s[1][:len(s[1]) - len(".git")]
+ feature_url = "http://" + s[0] + "/cgit/cgit.cgi/" + s[1] + \
+ "/plain/meta/cfg/kern-features.rc?h=meta"
+
+ return feature_url
+
+
+def find_feature_desc(lines):
+ """
+ Find the feature description and compatibility in the passed-in
+ set of lines. Returns a string string of the form 'desc
+ [compat]'.
+ """
+ desc = "no description available"
+ compat = "unknown"
+
+ for line in lines:
+ idx = line.find("KFEATURE_DESCRIPTION")
+ if idx != -1:
+ desc = line[idx + len("KFEATURE_DESCRIPTION"):].strip()
+ if desc.startswith("\""):
+ desc = desc[1:]
+ if desc.endswith("\""):
+ desc = desc[:-1]
+ else:
+ idx = line.find("KFEATURE_COMPATIBILITY")
+ if idx != -1:
+ compat = line[idx + len("KFEATURE_COMPATIBILITY"):].strip()
+
+ return desc + " [" + compat + "]"
+
+
+def print_feature_descs(layer, feature_dir):
+ """
+ Print the feature descriptions for the features in feature_dir.
+ """
+ kernel_files_features = os.path.join(layer, "recipes-kernel/linux/files/" +
+ feature_dir)
+ for root, dirs, files in os.walk(kernel_files_features):
+ for file in files:
+ if file.endswith("~") or file.endswith("#"):
+ continue
+ if file.endswith(".scc"):
+ fullpath = os.path.join(layer, "recipes-kernel/linux/files/" +
+ feature_dir + "/" + file)
+ f = open(fullpath)
+ feature_desc = find_feature_desc(f.readlines())
+ print feature_dir + "/" + file + ": " + feature_desc
+
+
+def yocto_kernel_available_features_list(scripts_path, machine):
+ """
+ Display the list of all the kernel features available for use in
+ BSPs, as gathered from the set of feature sources.
+ """
+ layer = find_bsp_layer(scripts_path, machine)
+ kernel = find_current_kernel(layer, machine)
+ if not kernel:
+ print "Couldn't determine the kernel for this BSP, exiting."
+ sys.exit(1)
+
+ context = create_context(machine, "arch", scripts_path)
+ context["name"] = "name"
+ context["filename"] = kernel
+ giturl = find_giturl(context)
+ feature_url = find_feature_url(giturl)
+
+ feature_cmd = "wget -q -O - " + feature_url
+ tmp = subprocess.Popen(feature_cmd, shell=True, stdout=subprocess.PIPE).stdout.read()
+
+ print "The current set of kernel features available to %s is:\n" % machine
+
+ if tmp:
+ tmpline = tmp.split("\n")
+ in_kernel_options = False
+ for line in tmpline:
+ if not "=" in line:
+ if in_kernel_options:
+ break
+ if "kernel-options" in line:
+ in_kernel_options = True
+ continue
+ if in_kernel_options:
+ feature_def = line.split("=")
+ feature_type = feature_def[0].strip()
+ feature = feature_def[1].strip()
+ desc = get_feature_desc(giturl, feature)
+ print "%s: %s" % (feature, desc)
+
+ print "[local]"
+
+ print_feature_descs(layer, "cfg")
+ print_feature_descs(layer, "features")
+
+
def base_branches(context):
"""
OpenPOWER on IntegriCloud