summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/lib/bsp/help.py36
-rw-r--r--scripts/lib/bsp/kernel.py103
-rwxr-xr-xscripts/yocto-kernel24
3 files changed, 162 insertions, 1 deletions
diff --git a/scripts/lib/bsp/help.py b/scripts/lib/bsp/help.py
index 91de60017e..d7c0360a7a 100644
--- a/scripts/lib/bsp/help.py
+++ b/scripts/lib/bsp/help.py
@@ -388,6 +388,7 @@ yocto_kernel_usage = """
388 feature rm Have a BSP stop using a feature 388 feature rm Have a BSP stop using a feature
389 features list List the features available to BSPs 389 features list List the features available to BSPs
390 feature describe Describe a particular feature 390 feature describe Describe a particular feature
391 feature create Create a new BSP-local feature
391 392
392 See 'yocto-kernel help COMMAND' for more information on a specific command. 393 See 'yocto-kernel help COMMAND' for more information on a specific command.
393 394
@@ -752,6 +753,41 @@ DESCRIPTION
752""" 753"""
753 754
754 755
756yocto_kernel_feature_create_usage = """
757
758 Create a recipe-space kernel feature in a BSP
759
760 usage: yocto-kernel feature create <bsp-name> newfeature.scc \
761 "Feature Description" capabilities [<CONFIG_XXX=x> ...] [<PATCH> ...]
762
763 This command creates a new kernel feature from the bare config
764 options and patches specified on the command-line.
765"""
766
767
768yocto_kernel_feature_create_help = """
769
770NAME
771 yocto-kernel feature create - create a recipe-space kernel feature
772 in a BSP
773
774SYNOPSIS
775 yocto-kernel feature create <bsp-name> newfeature.scc \
776 "Feature Description" capabilities [<CONFIG_XXX=x> ...] [<PATCH> ...]
777
778DESCRIPTION
779 This command creates a new kernel feature from the bare config
780 options and patches specified on the command-line. The new
781 feature will be created in recipe-space, specifically in either
782 the kernel .bbappend's /files/cfg or /files/features subdirectory,
783 depending on whether or not the feature contains config items only
784 or config items along with patches. The named feature must end
785 with .scc and must not contain a feature directory to contain the
786 feature (this will be determined automatically), and a feature
787 decription in double-quotes along with a capabilities string
788 (which for the time being can be one of: 'all' or 'board').
789"""
790
755## 791##
756# yocto-layer help and usage strings 792# yocto-layer help and usage strings
757## 793##
diff --git a/scripts/lib/bsp/kernel.py b/scripts/lib/bsp/kernel.py
index ac0b074b5d..ac6861e14b 100644
--- a/scripts/lib/bsp/kernel.py
+++ b/scripts/lib/bsp/kernel.py
@@ -808,7 +808,108 @@ def yocto_kernel_feature_describe(scripts_path, machine, feature):
808 808
809 print desc 809 print desc
810 810
811 811
812def check_feature_name(feature_name):
813 """
814 Sanity-check the feature name for create/destroy. Return False if not OK.
815 """
816 if not feature_name.endswith(".scc"):
817 print "Invalid feature name (must end with .scc) [%s], exiting" % feature_name
818 return False
819
820 if "/" in feature_name:
821 print "Invalid feature name (don't specify directory) [%s], exiting" % feature_name
822 return False
823
824 return True
825
826
827def check_create_input(feature_items):
828 """
829 Sanity-check the create input. Return False if not OK.
830 """
831 if not check_feature_name(feature_items[0]):
832 return False
833
834 if feature_items[1].endswith(".patch") or feature_items[1].startswith("CONFIG_"):
835 print "Missing description and/or compatibilty [%s], exiting" % feature_items[1]
836 return False
837
838 if feature_items[2].endswith(".patch") or feature_items[2].startswith("CONFIG_"):
839 print "Missing description and/or compatibility [%s], exiting" % feature_items[1]
840 return False
841
842 return True
843
844
845def yocto_kernel_feature_create(scripts_path, machine, feature_items):
846 """
847 Create a recipe-space kernel feature in a BSP.
848 """
849 if not check_create_input(feature_items):
850 sys.exit(1)
851
852 feature = feature_items[0]
853 feature_basename = feature.split(".")[0]
854 feature_description = feature_items[1]
855 feature_compat = feature_items[2]
856
857 patches = []
858 cfg_items = []
859
860 for item in feature_items[3:]:
861 if item.endswith(".patch"):
862 patches.append(item)
863 elif item.startswith("CONFIG"):
864 if ("=y" in item or "=m" in item):
865 cfg_items.append(item)
866 else:
867 print "Invalid feature item (must be .patch or CONFIG_*) [%s], exiting" % item
868 sys.exit(1)
869
870 feature_dirname = "cfg"
871 if patches:
872 feature_dirname = "features"
873
874 filesdir = find_filesdir(scripts_path, machine)
875 if not filesdir:
876 print "Couldn't add feature (%s), no 'files' dir found" % feature
877 sys.exit(1)
878
879 featdir = os.path.join(filesdir, feature_dirname)
880 if not os.path.exists(featdir):
881 os.mkdir(featdir)
882
883 for patch in patches:
884 if not os.path.isfile(patch):
885 print "Couldn't find patch (%s), exiting" % patch
886 sys.exit(1)
887 basename = os.path.basename(patch)
888 featdir_patch = os.path.join(featdir, basename)
889 shutil.copyfile(patch, featdir_patch)
890
891 new_cfg_filename = os.path.join(featdir, feature_basename + ".cfg")
892 new_cfg_file = open(new_cfg_filename, "w")
893 for cfg_item in cfg_items:
894 new_cfg_file.write(cfg_item + "\n")
895 new_cfg_file.close()
896
897 new_feature_filename = os.path.join(featdir, feature_basename + ".scc")
898 new_feature_file = open(new_feature_filename, "w")
899 new_feature_file.write("define KFEATURE_DESCRIPTION \"" + feature_description + "\"\n")
900 new_feature_file.write("define KFEATURE_COMPATIBILITY " + feature_compat + "\n\n")
901
902 for patch in patches:
903 patch_dir, patch_file = os.path.split(patch)
904 new_feature_file.write("patch " + patch_file + "\n")
905
906 new_feature_file.write("kconf non-hardware " + feature_basename + ".cfg\n")
907 new_feature_file.close()
908
909 print "Added feature:"
910 print "\t%s" % feature_dirname + "/" + feature
911
912
812def base_branches(context): 913def base_branches(context):
813 """ 914 """
814 Return a list of the base branches found in the kernel git repo. 915 Return a list of the base branches found in the kernel git repo.
diff --git a/scripts/yocto-kernel b/scripts/yocto-kernel
index 1f6ed67c04..69fe344d8d 100755
--- a/scripts/yocto-kernel
+++ b/scripts/yocto-kernel
@@ -266,6 +266,27 @@ def yocto_kernel_feature_describe_subcommand(args, usage_str):
266 yocto_kernel_feature_describe(scripts_path, args[0], args[1]) 266 yocto_kernel_feature_describe(scripts_path, args[0], args[1])
267 267
268 268
269def yocto_kernel_feature_create_subcommand(args, usage_str):
270 """
271 Command-line handling for creating a recipe-space kernel feature
272 in a BSP. The real work is done by
273 bsp.kernel.yocto_kernel_feature_create().
274 """
275 logging.debug("yocto_kernel_feature_create_subcommand")
276
277 parser = optparse.OptionParser(usage = usage_str)
278
279 (options, args) = parser.parse_args(args)
280
281 if len(args) < 4:
282 logging.error("Wrong number of arguments, exiting\n")
283 parser.print_help()
284 sys.exit(1)
285
286 machine = args.pop(0)
287 yocto_kernel_feature_create(scripts_path, machine, args)
288
289
269subcommands = { 290subcommands = {
270 "config-list": [yocto_kernel_config_list_subcommand, 291 "config-list": [yocto_kernel_config_list_subcommand,
271 yocto_kernel_config_list_usage, 292 yocto_kernel_config_list_usage,
@@ -300,6 +321,9 @@ subcommands = {
300 "feature-describe": [yocto_kernel_feature_describe_subcommand, 321 "feature-describe": [yocto_kernel_feature_describe_subcommand,
301 yocto_kernel_feature_describe_usage, 322 yocto_kernel_feature_describe_usage,
302 yocto_kernel_feature_describe_help], 323 yocto_kernel_feature_describe_help],
324 "feature-create": [yocto_kernel_feature_create_subcommand,
325 yocto_kernel_feature_create_usage,
326 yocto_kernel_feature_create_help],
303} 327}
304 328
305 329