diff options
Diffstat (limited to 'scripts/lib/bsp')
-rw-r--r-- | scripts/lib/bsp/help.py | 98 | ||||
-rw-r--r-- | scripts/lib/bsp/kernel.py | 99 |
2 files changed, 197 insertions, 0 deletions
diff --git a/scripts/lib/bsp/help.py b/scripts/lib/bsp/help.py index 346bf0f2bd..2d7b6fe6d2 100644 --- a/scripts/lib/bsp/help.py +++ b/scripts/lib/bsp/help.py | |||
@@ -383,6 +383,9 @@ yocto_kernel_usage = """ | |||
383 | patch list List the patches associated with a BSP | 383 | patch list List the patches associated with a BSP |
384 | patch add Patch the Yocto kernel for a BSP | 384 | patch add Patch the Yocto kernel for a BSP |
385 | patch rm Remove patches from a BSP | 385 | patch rm Remove patches from a BSP |
386 | feature list List the features used by a BSP | ||
387 | feature add Have a BSP use a feature | ||
388 | feature rm Have a BSP stop using a feature | ||
386 | 389 | ||
387 | See 'yocto-kernel help COMMAND' for more information on a specific command. | 390 | See 'yocto-kernel help COMMAND' for more information on a specific command. |
388 | 391 | ||
@@ -594,6 +597,101 @@ DESCRIPTION | |||
594 | remove. | 597 | remove. |
595 | """ | 598 | """ |
596 | 599 | ||
600 | yocto_kernel_feature_list_usage = """ | ||
601 | |||
602 | List the BSP features that are being used by a BSP | ||
603 | |||
604 | usage: yocto-kernel feature list <bsp-name> | ||
605 | |||
606 | This command lists the features being used by a BSP i.e. the features | ||
607 | which are eligible for modification or removal by other yocto-kernel | ||
608 | commands. | ||
609 | |||
610 | 'modifiable' features are the features listed in a BSP's | ||
611 | user-features.scc file. | ||
612 | """ | ||
613 | |||
614 | |||
615 | yocto_kernel_feature_list_help = """ | ||
616 | |||
617 | NAME | ||
618 | yocto-kernel feature list - List the modifiable set of features | ||
619 | being used by a BSP | ||
620 | |||
621 | SYNOPSIS | ||
622 | yocto-kernel feature list <bsp-name> | ||
623 | |||
624 | DESCRIPTION | ||
625 | This command lists the 'modifiable' features being used by a BSP | ||
626 | i.e. the features which are eligible for modification or removal | ||
627 | by other yocto-kernel commands. | ||
628 | """ | ||
629 | |||
630 | |||
631 | yocto_kernel_feature_add_usage = """ | ||
632 | |||
633 | Add to or modify the list of features being used for a BSP | ||
634 | |||
635 | usage: yocto-kernel feature add <bsp-name> [/xxxx/yyyy/feature.scc ...] | ||
636 | |||
637 | This command adds one or more feature items to a BSP's kernel | ||
638 | user-features.scc file, which is the file used to manage features in | ||
639 | a yocto-bsp-generated BSP. Features to be added must be specified as | ||
640 | fully-qualified feature names. | ||
641 | """ | ||
642 | |||
643 | |||
644 | yocto_kernel_feature_add_help = """ | ||
645 | |||
646 | NAME | ||
647 | yocto-kernel feature add - Add to or modify the list of features | ||
648 | being used for a BSP | ||
649 | |||
650 | SYNOPSIS | ||
651 | yocto-kernel feature add <bsp-name> [/xxxx/yyyy/feature.scc ...] | ||
652 | |||
653 | DESCRIPTION | ||
654 | This command adds one or more feature items to a BSP's | ||
655 | user-features.scc file, which is the file used to manage features | ||
656 | in a yocto-bsp-generated BSP. Features to be added must be | ||
657 | specified as fully-qualified feature names. | ||
658 | """ | ||
659 | |||
660 | |||
661 | yocto_kernel_feature_rm_usage = """ | ||
662 | |||
663 | Remove a feature from the list of features being used for a BSP | ||
664 | |||
665 | usage: yocto-kernel feature rm <bsp-name> | ||
666 | |||
667 | This command removes (turns off) one or more features from a BSP's | ||
668 | user-features.scc file, which is the file used to manage features in | ||
669 | a yocto-bsp-generated BSP. | ||
670 | |||
671 | The set of features available to be removed by this command for a BSP | ||
672 | is listed and the user prompted for the specific items to remove. | ||
673 | """ | ||
674 | |||
675 | |||
676 | yocto_kernel_feature_rm_help = """ | ||
677 | |||
678 | NAME | ||
679 | yocto-kernel feature rm - Remove a feature from the list of | ||
680 | features being used for a BSP | ||
681 | |||
682 | SYNOPSIS | ||
683 | yocto-kernel feature rm <bsp-name> | ||
684 | |||
685 | DESCRIPTION | ||
686 | This command removes (turns off) one or more features from a BSP's | ||
687 | user-features.scc file, which is the file used to manage features | ||
688 | in a yocto-bsp-generated BSP. | ||
689 | |||
690 | The set of features available to be removed by this command for a | ||
691 | BSP is listed and the user prompted for the specific items to | ||
692 | remove. | ||
693 | """ | ||
694 | |||
597 | ## | 695 | ## |
598 | # yocto-layer help and usage strings | 696 | # yocto-layer help and usage strings |
599 | ## | 697 | ## |
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 | |||
556 | def 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 | |||
575 | def 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 | |||
588 | def 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 | |||
599 | def 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 | |||
632 | def 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 | ||
556 | def base_branches(context): | 655 | def base_branches(context): |
557 | """ | 656 | """ |