summaryrefslogtreecommitdiffstats
path: root/scripts/lib/bsp/kernel.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/bsp/kernel.py')
-rw-r--r--scripts/lib/bsp/kernel.py99
1 files changed, 99 insertions, 0 deletions
diff --git a/scripts/lib/bsp/kernel.py b/scripts/lib/bsp/kernel.py
index dabb9cf3f0..0fa228a58a 100644
--- a/scripts/lib/bsp/kernel.py
+++ b/scripts/lib/bsp/kernel.py
@@ -552,6 +552,105 @@ def find_giturl(context):
552 552
553 return None 553 return None
554 554
555
556def read_features(scripts_path, machine):
557 """
558 Find and return a list of features in a machine's user-defined
559 features fragment [${machine}-user-features.scc].
560 """
561 features = []
562
563 f = open_user_file(scripts_path, machine, machine+"-user-features.scc", "r")
564 lines = f.readlines()
565 for line in lines:
566 s = line.strip()
567 if s and not s.startswith("#"):
568 feature_include = s.split()
569 features.append(feature_include[1].strip())
570 f.close()
571
572 return features
573
574
575def write_features(scripts_path, machine, features):
576 """
577 Write (replace) the list of feature items in a
578 machine's user-defined features fragment [${machine}=user-features.cfg].
579 """
580 f = open_user_file(scripts_path, machine, machine+"-user-features.scc", "w")
581 for item in features:
582 f.write("include " + item + "\n")
583 f.close()
584
585 kernel_contents_changed(scripts_path, machine)
586
587
588def yocto_kernel_feature_list(scripts_path, machine):
589 """
590 Display the list of features used in a machine's user-defined
591 features fragment [${machine}-user-features.scc].
592 """
593 features = read_features(scripts_path, machine)
594
595 print "The current set of machine-specific features for %s is:" % machine
596 print gen_choices_str(features)
597
598
599def yocto_kernel_feature_rm(scripts_path, machine):
600 """
601 Display the list of features used in a machine's user-defined
602 features fragment [${machine}-user-features.scc], prompt the user
603 for one or more to remove, and remove them.
604 """
605 features = read_features(scripts_path, machine)
606
607 print "Specify the features to remove:"
608 input = raw_input(gen_choices_str(features))
609 rm_choices = input.split()
610 rm_choices.sort()
611
612 removed = []
613
614 for choice in reversed(rm_choices):
615 try:
616 idx = int(choice) - 1
617 except ValueError:
618 print "Invalid choice (%s), exiting" % choice
619 sys.exit(1)
620 if idx < 0 or idx >= len(features):
621 print "Invalid choice (%d), exiting" % (idx + 1)
622 sys.exit(1)
623 removed.append(features.pop(idx))
624
625 write_features(scripts_path, machine, features)
626
627 print "Removed features:"
628 for r in removed:
629 print "\t%s" % r
630
631
632def yocto_kernel_feature_add(scripts_path, machine, features):
633 """
634 Add one or more features a machine's user-defined features
635 fragment [${machine}-user-features.scc].
636 """
637 new_items = []
638
639 for item in features:
640 if not item.endswith(".scc"):
641 print "Invalid feature (%s), exiting" % item
642 sys.exit(1)
643 new_items.append(item)
644
645 cur_items = read_features(scripts_path, machine)
646 cur_items.extend(new_items)
647
648 write_features(scripts_path, machine, cur_items)
649
650 print "Added features:"
651 for n in new_items:
652 print "\t%s" % n
653
555 654
556def base_branches(context): 655def base_branches(context):
557 """ 656 """