summaryrefslogtreecommitdiffstats
path: root/scripts/lib/bsp/help.py
blob: bbb7b317d7abaccdb7974f97e11fa77a8e5e2244 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
# ex:ts=4:sw=4:sts=4:et
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
#
# Copyright (c) 2012, Intel Corporation.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# DESCRIPTION
# This module implements some basic help invocation functions along
# with the bulk of the help topic text for the Yocto BSP Tools.
#
# AUTHORS
# Tom Zanussi <tom.zanussi (at] intel.com>
#

import subprocess
import logging


def subcommand_error(args):
    logging.info("invalid subcommand %s" % args[0])


def display_help(subcommand, subcommands):
    """
    Display help for subcommand.
    """
    if subcommand not in subcommands:
        return False

    help = subcommands.get(subcommand, subcommand_error)[2]
    pager = subprocess.Popen('less', stdin=subprocess.PIPE)
    pager.communicate(help)

    return True


def yocto_help(args, usage_str, subcommands):
    """
    Subcommand help dispatcher.
    """
    if len(args) == 1 or not display_help(args[1], subcommands):
        print(usage_str)


def invoke_subcommand(args, parser, main_command_usage, subcommands):
    """
    Dispatch to subcommand handler borrowed from combo-layer.
    Should use argparse, but has to work in 2.6.
    """
    if not args:
        logging.error("No subcommand specified, exiting")
        parser.print_help()
    elif args[0] == "help":
        yocto_help(args, main_command_usage, subcommands)
    elif args[0] not in subcommands:
        logging.error("Unsupported subcommand %s, exiting\n" % (args[0]))
        parser.print_help()
    else:
        usage = subcommands.get(args[0], subcommand_error)[1]
        subcommands.get(args[0], subcommand_error)[0](args[1:], usage)


##
# yocto-bsp help and usage strings
##

yocto_bsp_usage = """

 Create a customized Yocto BSP layer.

 usage: yocto-bsp [--version] [--help] COMMAND [ARGS]

 Current 'yocto-bsp' commands are:
    create            Create a new Yocto BSP
    list              List available values for options and BSP properties

 See 'yocto-bsp help COMMAND' for more information on a specific command.
"""

yocto_bsp_help_usage = """

 usage: yocto-bsp help <subcommand>

 This command displays detailed help for the specified subcommand.
"""

yocto_bsp_create_usage = """

 Create a new Yocto BSP

 usage: yocto-bsp create <bsp-name> <karch> [-o <DIRNAME> | --outdir <DIRNAME>]
            [-i <JSON PROPERTY FILE> | --infile <JSON PROPERTY_FILE>]

 This command creates a Yocto BSP based on the specified parameters.
 The new BSP will be a new Yocto BSP layer contained by default within
 the top-level directory specified as 'meta-bsp-name'.  The -o option
 can be used to place the BSP layer in a directory with a different
 name and location.

 The value of the 'karch' parameter determines the set of files that
 will be generated for the BSP, along with the specific set of
 'properties' that will be used to fill out the BSP-specific portions
 of the BSP.  The possible values for the 'karch' paramter can be
 listed via 'yocto-bsp list karch'.

 NOTE: Once created, you should add your new layer to your
 bblayers.conf file in order for it to be subsequently seen and
 modified by the yocto-kernel tool.

 See 'yocto bsp help create' for more detailed instructions.
"""

yocto_bsp_create_help = """

NAME
    yocto-bsp create - Create a new Yocto BSP

SYNOPSIS
    yocto-bsp create <bsp-name> <karch> [-o <DIRNAME> | --outdir <DIRNAME>]
        [-i <JSON PROPERTY FILE> | --infile <JSON PROPERTY_FILE>]

DESCRIPTION
    This command creates a Yocto BSP based on the specified
    parameters.  The new BSP will be a new Yocto BSP layer contained
    by default within the top-level directory specified as
    'meta-bsp-name'.  The -o option can be used to place the BSP layer
    in a directory with a different name and location.

    The value of the 'karch' parameter determines the set of files
    that will be generated for the BSP, along with the specific set of
    'properties' that will be used to fill out the BSP-specific
    portions of the BSP.  The possible values for the 'karch' paramter
    can be listed via 'yocto-bsp list karch'.

    The BSP-specific properties that define the values that will be
    used to generate a particular BSP can be specified on the
    command-line using the -i option and supplying a JSON object
    consisting of the set of name:value pairs needed by the BSP.

    If the -i option is not used, the user will be interactively
    prompted for each of the required property values, which will then
    be used as values for BSP generation.

    The set of properties available for a given architecture can be
    listed using the 'yocto-bsp list' command.

    Specifying -c causes the Python code generated and executed to
    create the BSP to be dumped to the 'bspgen.out' file in the
    current directory, and is useful for debugging.

    NOTE: Once created, you should add your new layer to your
    bblayers.conf file in order for it to be subsequently seen and
    modified by the yocto-kernel tool.

    For example, assuming your poky repo is at /path/to/poky, your new
    BSP layer is at /path/to/poky/meta-mybsp, and your build directory
    is /path/to/build:

    $ gedit /path/to/build/conf/bblayers.conf

    BBLAYERS ?= " \\
      /path/to/poky/meta \\
      /path/to/poky/meta-poky \\
      /path/to/poky/meta-mybsp \\
      "
"""

yocto_bsp_list_usage = """

 usage: yocto-bsp list karch
        yocto-bsp list <karch> properties
                [-o <JSON PROPERTY FILE> | --outfile <JSON PROPERTY_FILE>]
        yocto-bsp list <karch> property <xxx>
                [-o <JSON PROPERTY FILE> | --outfile <JSON PROPERTY_FILE>]

 This command enumerates the complete set of possible values for a
 specified option or property needed by the BSP creation process.

 The first form enumerates all the possible values that exist and can
 be specified for the 'karch' parameter to the 'yocto bsp create'
 command.

 The second form enumerates all the possible properties that exist and
 must have values specified for them in the 'yocto bsp create' command
 for the given 'karch'.

 The third form enumerates all the possible values that exist and can
 be specified for any of the enumerable properties of the given
 'karch' in the 'yocto bsp create' command.

 See 'yocto-bsp help list' for more details.
"""

yocto_bsp_list_help = """

NAME
    yocto-bsp list - List available values for options and BSP properties

SYNOPSIS
    yocto-bsp list karch
    yocto-bsp list <karch> properties
            [--o <JSON PROPERTY FILE> | -outfile <JSON PROPERTY_FILE>]
    yocto-bsp list <karch> property <xxx>
            [--o <JSON PROPERTY FILE> | -outfile <JSON PROPERTY_FILE>]

DESCRIPTION
    This command enumerates the complete set of possible values for a
    specified option or property needed by the BSP creation process.

    The first form enumerates all the possible values that exist and
    can be specified for the 'karch' parameter to the 'yocto bsp
    create' command.  Example output for the 'list karch' command:

    $ yocto-bsp list karch
    Architectures available:
        arm
        powerpc
        i386
        mips
        mips64
        x86_64
        qemu

    The second form enumerates all the possible properties that exist
    and must have values specified for them in the 'yocto bsp create'
    command for the given 'karch'.  This command is mainly meant to
    allow the development user interface alternatives to the default
    text-based prompting interface.  If the -o option is specified,
    the list of properties, in addition to being displayed, will be
    written to the specified file as a JSON object.  In this case, the
    object will consist of the set of name:value pairs corresponding
    to the (possibly nested) dictionary of properties defined by the
    input statements used by the BSP.  Some example output for the
    'list properties' command:

    $ yocto-bsp list arm properties
    "touchscreen" : {
        "msg" : Does your BSP have a touchscreen? (y/N)
        "default" : n
        "type" : boolean
    }
    "uboot_loadaddress" : {
        "msg" : Please specify a value for UBOOT_LOADADDRESS.
        "default" : 0x80008000
        "type" : edit
        "prio" : 40
    }
    "kernel_choice" : {
        "prio" : 10
        "default" : linux-yocto_3.2
        "depends-on" : use_default_kernel
        "depends-on-val" : n
        "msg" : Please choose the kernel to use in this BSP =>
        "type" : choicelist
        "gen" : bsp.kernel.kernels
    }
    "if kernel_choice == "linux-yocto_3.0":" : {
        "base_kbranch_linux_yocto_3_0" : {
            "prio" : 20
            "default" : yocto/standard
            "depends-on" : new_kbranch_linux_yocto_3_0
            "depends-on-val" : y
            "msg" : Please choose a machine branch to base this BSP on =>
            "type" : choicelist
            "gen" : bsp.kernel.all_branches
    }
    .
    .
    .

    Each entry in the output consists of the name of the input element
    e.g. "touchscreen", followed by the properties defined for that
    element enclosed in braces.  This information should provide
    sufficient information to create a complete user interface with.
    Two features of the scheme provide for conditional input.  First,
    if a Python "if" statement appears in place of an input element
    name, the set of enclosed input elements apply and should be
    presented to the user only if the 'if' statement evaluates to
    true.  The test in the if statement will always reference another
    input element in the list, which means that the element being
    tested should be presented to the user before the elements
    enclosed by the if block.  Secondly, in a similar way, some
    elements contain "depends-on" and depends-on-val" tags, which mean
    that the affected input element should only be presented to the
    user if the element it depends on has already been presented to
    the user and the user has selected the specified value for that
    element.

    The third form enumerates all the possible values that exist and
    can be specified for any of the enumerable properties of the given
    'karch' in the 'yocto bsp create' command.  If the -o option is
    specified, the list of values for the given property, in addition
    to being displayed, will be written to the specified file as a
    JSON object.  In this case, the object will consist of the set of
    name:value pairs corresponding to the array of property values
    associated with the property.

    $ yocto-bsp list i386 property xserver_choice
        ["xserver_vesa", "VESA xserver support"]
        ["xserver_i915", "i915 xserver support"]

    $ yocto-bsp list arm property base_kbranch_linux_yocto_3_0
        Getting branches from remote repo git://git.yoctoproject.org/linux-yocto-3.0...
        ["yocto/base", "yocto/base"]
        ["yocto/eg20t", "yocto/eg20t"]
        ["yocto/gma500", "yocto/gma500"]
        ["yocto/pvr", "yocto/pvr"]
        ["yocto/standard/arm-versatile-926ejs", "yocto/standard/arm-versatile-926ejs"]
        ["yocto/standard/base", "yocto/standard/base"]
        ["yocto/standard/cedartrail", "yocto/standard/cedartrail"]
        .
        .
        .
        ["yocto/standard/qemu-ppc32", "yocto/standard/qemu-ppc32"]
        ["yocto/standard/routerstationpro", "yocto/standard/routerstationpro"]

    The third form as well is meant mainly for developers of
    alternative interfaces - it allows the developer to fetch the
    possible values for a given input element on-demand.  This
    on-demand capability is especially valuable for elements that
    require relatively expensive remote operations to fulfill, such as
    the example that returns the set of branches available in a remote
    git tree above.

"""

##
# yocto-kernel help and usage strings
##

yocto_kernel_usage = """

 Modify and list Yocto BSP kernel config items and patches.

 usage: yocto-kernel [--version] [--help] COMMAND [ARGS]

 Current 'yocto-kernel' commands are:
   config list       List the modifiable set of bare kernel config options for a BSP
   config add        Add or modify bare kernel config options for a BSP
   config rm         Remove bare kernel config options from a BSP
   patch list        List the patches associated with a BSP
   patch add         Patch the Yocto kernel for a BSP
   patch rm          Remove patches from a BSP
   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
   feature describe  Describe a particular feature
   feature create    Create a new BSP-local feature
   feature destroy   Remove a BSP-local feature

 See 'yocto-kernel help COMMAND' for more information on a specific command.

"""


yocto_kernel_help_usage = """

 usage: yocto-kernel help <subcommand>

 This command displays detailed help for the specified subcommand.
"""

yocto_kernel_config_list_usage = """

 List the modifiable set of bare kernel config options for a BSP

 usage: yocto-kernel config list <bsp-name>

 This command lists the 'modifiable' config items for a BSP i.e. the
 items which are eligible for modification or removal by other
 yocto-kernel commands.

 'modifiable' config items are the config items contained a BSP's
 user-config.cfg base config.
"""


yocto_kernel_config_list_help = """

NAME
    yocto-kernel config list - List the modifiable set of bare kernel
    config options for a BSP

SYNOPSIS
    yocto-kernel config list <bsp-name>

DESCRIPTION
    This command lists the 'modifiable' config items for a BSP
    i.e. the items which are eligible for modification or removal by
    other yocto-kernel commands.
"""


yocto_kernel_config_add_usage = """

 Add or modify bare kernel config options for a BSP

 usage: yocto-kernel config add <bsp-name> [<CONFIG_XXX=x> ...]

 This command adds one or more CONFIG_XXX=x items to a BSP's user-config.cfg
 base config.
"""


yocto_kernel_config_add_help = """

NAME
    yocto-kernel config add - Add or modify bare kernel config options
    for a BSP

SYNOPSIS
    yocto-kernel config add <bsp-name> [<CONFIG_XXX=x> ...]

DESCRIPTION
    This command adds one or more CONFIG_XXX=x items to a BSP's
    foo.cfg base config.

    NOTE: It's up to the user to determine whether or not the config
    options being added make sense or not - this command does no
    sanity checking or verification of any kind to ensure that a
    config option really makes sense and will actually be set in in
    the final config.  For example, if a config option depends on
    other config options, it will be turned off by kconfig if the
    other options aren't set correctly.
"""


yocto_kernel_config_rm_usage = """

 Remove bare kernel config options from a BSP

 usage: yocto-kernel config rm <bsp-name>

 This command removes (turns off) one or more CONFIG_XXX items from a
 BSP's user-config.cfg base config.

 The set of config items available to be removed by this command for a
 BSP is listed and the user prompted for the specific items to remove.
"""


yocto_kernel_config_rm_help = """

NAME
    yocto-kernel config rm - Remove bare kernel config options from a
    BSP

SYNOPSIS
    yocto-kernel config rm <bsp-name>

DESCRIPTION
    This command removes (turns off) one or more CONFIG_XXX items from a
    BSP's user-config.cfg base config.

    The set of config items available to be removed by this command
    for a BSP is listed and the user prompted for the specific items
    to remove.
"""


yocto_kernel_patch_list_usage = """

 List the patches associated with the kernel for a BSP

 usage: yocto-kernel patch list <bsp-name>

 This command lists the patches associated with a BSP.

 NOTE: this only applies to patches listed in the kernel recipe's
 user-patches.scc file (and currently repeated in its SRC_URI).
"""


yocto_kernel_patch_list_help = """

NAME
    yocto-kernel patch list - List the patches associated with the kernel
    for a BSP

SYNOPSIS
    yocto-kernel patch list <bsp-name>

DESCRIPTION
    This command lists the patches associated with a BSP.

    NOTE: this only applies to patches listed in the kernel recipe's
    user-patches.scc file (and currently repeated in its SRC_URI).
"""


yocto_kernel_patch_add_usage = """

 Patch the Yocto kernel for a specific BSP

 usage: yocto-kernel patch add <bsp-name> [<PATCH> ...]

 This command adds one or more patches to a BSP's machine branch.  The
 patch will be added to the BSP's linux-yocto kernel user-patches.scc
 file (and currently repeated in its SRC_URI) and will be guaranteed
 to be applied in the order specified.
"""


yocto_kernel_patch_add_help = """

NAME
    yocto-kernel patch add - Patch the Yocto kernel for a specific BSP

SYNOPSIS
    yocto-kernel patch add <bsp-name> [<PATCH> ...]

DESCRIPTION
    This command adds one or more patches to a BSP's machine branch.
    The patch will be added to the BSP's linux-yocto kernel
    user-patches.scc file (and currently repeated in its SRC_URI) and
    will be guaranteed to be applied in the order specified.

    NOTE: It's up to the user to determine whether or not the patches
    being added makes sense or not - this command does no sanity
    checking or verification of any kind to ensure that a patch can
    actually be applied to the BSP's kernel branch; it's assumed that
    the user has already done that.
"""


yocto_kernel_patch_rm_usage = """

 Remove a patch from the Yocto kernel for a specific BSP

 usage: yocto-kernel patch rm <bsp-name>

 This command removes one or more patches from a BSP's machine branch.
 The patch will be removed from the BSP's linux-yocto kernel
 user-patches.scc file (and currently repeated in its SRC_URI) and
 kernel SRC_URI dir.

 The set of patches available to be removed by this command for a BSP
 is listed and the user prompted for the specific patches to remove.
"""


yocto_kernel_patch_rm_help = """

NAME
    yocto-kernel patch rm - Remove a patch from the Yocto kernel for a specific BSP

SYNOPSIS
    yocto-kernel patch rm <bsp-name>

DESCRIPTION
    This command removes one or more patches from a BSP's machine
    branch.  The patch will be removed from the BSP's linux-yocto
    kernel user-patches.scc file (and currently repeated in its
    SRC_URI).

    The set of patches available to be removed by this command for a
    BSP is listed and the user prompted for the specific patches to
    remove.
"""

yocto_kernel_feature_list_usage = """

 List the BSP features that are being used by a BSP

 usage: yocto-kernel feature list <bsp-name>

 This command lists the features being used by a BSP i.e. the features
 which are eligible for modification or removal by other yocto-kernel
 commands.

 'modifiable' features are the features listed in a BSP's
 user-features.scc file.
"""


yocto_kernel_feature_list_help = """

NAME
    yocto-kernel feature list - List the modifiable set of features
    being used by a BSP

SYNOPSIS
    yocto-kernel feature list <bsp-name>

DESCRIPTION
    This command lists the 'modifiable' features being used by a BSP
    i.e. the features which are eligible for modification or removal
    by other yocto-kernel commands.
"""


yocto_kernel_feature_add_usage = """

 Add to or modify the list of features being used for a BSP

 usage: yocto-kernel feature add <bsp-name> [/xxxx/yyyy/feature.scc ...]

 This command adds one or more feature items to a BSP's kernel
 user-features.scc file, which is the file used to manage features in
 a yocto-bsp-generated BSP.  Features to be added must be specified as
 fully-qualified feature names.
"""


yocto_kernel_feature_add_help = """

NAME
    yocto-kernel feature add - Add to or modify the list of features
    being used for a BSP

SYNOPSIS
    yocto-kernel feature add <bsp-name> [/xxxx/yyyy/feature.scc ...]

DESCRIPTION
    This command adds one or more feature items to a BSP's
    user-features.scc file, which is the file used to manage features
    in a yocto-bsp-generated BSP.  Features to be added must be
    specified as fully-qualified feature names.
"""


yocto_kernel_feature_rm_usage = """

 Remove a feature from the list of features being used for a BSP

 usage: yocto-kernel feature rm <bsp-name>

 This command removes (turns off) one or more features from a BSP's
 user-features.scc file, which is the file used to manage features in
 a yocto-bsp-generated BSP.

 The set of features available to be removed by this command for a BSP
 is listed and the user prompted for the specific items to remove.
"""


yocto_kernel_feature_rm_help = """

NAME
    yocto-kernel feature rm - Remove a feature from the list of
    features being used for a BSP

SYNOPSIS
    yocto-kernel feature rm <bsp-name>

DESCRIPTION
    This command removes (turns off) one or more features from a BSP's
    user-features.scc file, which is the file used to manage features
    in a yocto-bsp-generated BSP.

    The set of features available to be removed by this command for a
    BSP is listed and the user prompted for the specific items to
    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_kernel_feature_describe_usage = """

 Print the description and compatibility information for a given kernel feature

 usage: yocto-kernel feature describe <bsp-name> [/xxxx/yyyy/feature.scc ...]

 This command prints the description and compatibility of a specific
 feature in the format 'description [compatibility].
"""


yocto_kernel_feature_describe_help = """

NAME
    yocto-kernel feature describe - print the description and
    compatibility information for a given kernel feature

SYNOPSIS
    yocto-kernel feature describe <bsp-name> [/xxxx/yyyy/feature.scc ...]

DESCRIPTION
    This command prints the description and compatibility of a
    specific feature in the format 'description [compatibility].  If
    the feature doesn't define a description or compatibility, a
    string with generic unknown values will be printed.
"""


yocto_kernel_feature_create_usage = """

 Create a recipe-space kernel feature in a BSP

 usage: yocto-kernel feature create <bsp-name> newfeature.scc \
        "Feature Description" capabilities [<CONFIG_XXX=x> ...] [<PATCH> ...]

 This command creates a new kernel feature from the bare config
 options and patches specified on the command-line.
"""


yocto_kernel_feature_create_help = """

NAME
    yocto-kernel feature create - create a recipe-space kernel feature
    in a BSP

SYNOPSIS
    yocto-kernel feature create <bsp-name> newfeature.scc \
        "Feature Description" capabilities [<CONFIG_XXX=x> ...] [<PATCH> ...]

DESCRIPTION
    This command creates a new kernel feature from the bare config
    options and patches specified on the command-line.  The new
    feature will be created in recipe-space, specifically in either
    the kernel .bbappend's /files/cfg or /files/features subdirectory,
    depending on whether or not the feature contains config items only
    or config items along with patches.  The named feature must end
    with .scc and must not contain a feature directory to contain the
    feature (this will be determined automatically), and a feature
    decription in double-quotes along with a capabilities string
    (which for the time being can be one of: 'all' or 'board').
"""


yocto_kernel_feature_destroy_usage = """

 Destroy a recipe-space kernel feature in a BSP

 usage: yocto-kernel feature destroy <bsp-name> feature.scc

 This command destroys a kernel feature defined in the specified BSP's
 recipe-space kernel definition.
"""


yocto_kernel_feature_destroy_help = """

NAME
    yocto-kernel feature destroy <bsp-name> feature.scc - destroy a
    recipe-space kernel feature in a BSP

SYNOPSIS
    yocto-kernel feature destroy <bsp-name> feature.scc

DESCRIPTION
    This command destroys a kernel feature defined in the specified
    BSP's recipe-space kernel definition.  The named feature must end
    with .scc and must not contain a feature directory to contain the
    feature (this will be determined automatically).  If the kernel
    feature is in use by a BSP, it can't be removed until the BSP
    stops using it (see yocto-kernel feature rm to stop using it).
"""

##
# yocto-layer help and usage strings
##

yocto_layer_usage = """

 Create a generic Yocto layer.

 usage: yocto-layer [--version] [--help] COMMAND [ARGS]

 Current 'yocto-layer' commands are:
    create            Create a new generic Yocto layer
    list              List available values for input options and properties

 See 'yocto-layer help COMMAND' for more information on a specific command.
"""

yocto_layer_help_usage = """

 usage: yocto-layer help <subcommand>

 This command displays detailed help for the specified subcommand.
"""

yocto_layer_create_usage = """

 Create a new generic Yocto layer

 usage: yocto-layer create <layer-name> [layer_priority]
            [-o <DIRNAME> | --outdir <DIRNAME>]
            [-i <JSON PROPERTY FILE> | --infile <JSON PROPERTY_FILE>]

 This command creates a generic Yocto layer based on the specified
 parameters.  The new layer will be a new Yocto layer contained by
 default within the top-level directory specified as
 'meta-layer-name'.  The -o option can be used to place the layer in a
 directory with a different name and location.

 If layer_priority is specified, a simple layer will be created using
 the given layer priority, and the user will not be prompted for
 further input.

 NOTE: Once created, you should add your new layer to your
 bblayers.conf file in order for it to be subsequently seen and
 modified by the yocto-kernel tool.  Instructions for doing this can
 be found in the README file generated in the layer's top-level
 directory.

 See 'yocto layer help create' for more detailed instructions.
"""

yocto_layer_create_help = """

NAME
    yocto-layer create - Create a new generic Yocto layer

SYNOPSIS
    yocto-layer create <layer-name> [layer_priority]
        [-o <DIRNAME> | --outdir <DIRNAME>]
        [-i <JSON PROPERTY FILE> | --infile <JSON PROPERTY_FILE>]

DESCRIPTION
    This command creates a generic Yocto layer based on the specified
    parameters.  The new layer will be a new Yocto layer contained by
    default within the top-level directory specified as
    'meta-layer-name'.  The -o option can be used to place the layer
    in a directory with a different name and location.

    If layer_priority is specified, a simple layer will be created
    using the given layer priority, and the user will not be prompted
    for further input.

    The layer-specific properties that define the values that will be
    used to generate the layer can be specified on the command-line
    using the -i option and supplying a JSON object consisting of the
    set of name:value pairs needed by the layer.

    If the -i option is not used, the user will be interactively
    prompted for each of the required property values, which will then
    be used as values for layer generation.

    The set of properties available can be listed using the
    'yocto-layer list' command.

    Specifying -c causes the Python code generated and executed to
    create the layer to be dumped to the 'bspgen.out' file in the
    current directory, and is useful for debugging.

    NOTE: Once created, you should add your new layer to your
    bblayers.conf file in order for it to be subsequently seen and
    modified by the yocto-kernel tool.  Instructions for doing this
    can be found in the README file generated in the layer's top-level
    directory.

    For example, assuming your poky repo is at /path/to/poky, your new
    layer is at /path/to/poky/meta-mylayer, and your build directory
    is /path/to/build:

    $ gedit /path/to/build/conf/bblayers.conf

    BBLAYERS ?= " \\
      /path/to/poky/meta \\
      /path/to/poky/meta-yocto \\
      /path/to/poky/meta-mylayer \\
      "
"""

yocto_layer_list_usage = """

 usage: yocto-layer list properties
                [-o <JSON PROPERTY FILE> | --outfile <JSON PROPERTY_FILE>]
        yocto-layer list property <xxx>
                [-o <JSON PROPERTY FILE> | --outfile <JSON PROPERTY_FILE>]

 This command enumerates the complete set of possible values for a
 specified option or property needed by the layer creation process.

 The first form enumerates all the possible properties that exist and
 must have values specified for them in the 'yocto-layer create'
 command.

 The second form enumerates all the possible values that exist and can
 be specified for any of the enumerable properties in the 'yocto-layer
 create' command.

 See 'yocto-layer help list' for more details.
"""

yocto_layer_list_help = """

NAME
    yocto-layer list - List available values for layer input options and properties

SYNOPSIS
    yocto-layer list properties
            [--o <JSON PROPERTY FILE> | -outfile <JSON PROPERTY_FILE>]
    yocto-layer list property <xxx>
            [--o <JSON PROPERTY FILE> | -outfile <JSON PROPERTY_FILE>]

DESCRIPTION
    This command enumerates the complete set of possible values for a
    specified option or property needed by the layer creation process.

    The first form enumerates all the possible properties that exist
    and must have values specified for them in the 'yocto-layer
    create' command.  This command is mainly meant to aid the
    development of user interface alternatives to the default
    text-based prompting interface.  If the -o option is specified,
    the list of properties, in addition to being displayed, will be
    written to the specified file as a JSON object.  In this case, the
    object will consist of the set of name:value pairs corresponding
    to the (possibly nested) dictionary of properties defined by the
    input statements used by the BSP.  Some example output for the
    'list properties' command:

    $ yocto-layer list properties
    "example_bbappend_name" : {
        "default" : example
        "msg" : Please enter the name you'd like to use for your bbappend file:
        "type" : edit
        "prio" : 20
        "filename" : /home/trz/yocto/yocto-layer-dev/scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall
    }
    "create_example_recipe" : {
        "default" : n
        "msg" : Would you like to have an example recipe created? (y/n)
        "type" : boolean
        "prio" : 20
        "filename" : /home/trz/yocto/yocto-layer-dev/scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall
    }
    "example_recipe_name" : {
        "default" : example
        "msg" : Please enter the name you'd like to use for your example recipe:
        "type" : edit
        "prio" : 20
        "filename" : /home/trz/yocto/yocto-layer-dev/scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall
    }
    "layer_priority" : {
        "default" : 6
        "msg" : Please enter the layer priority you'd like to use for the layer:
        "type" : edit
        "prio" : 20
        "filename" : /home/trz/yocto/yocto-layer-dev/scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall
    }
    "create_example_bbappend" : {
        "default" : n
        "msg" : Would you like to have an example bbappend file created? (y/n)
        "type" : boolean
        "prio" : 20
        "filename" : /home/trz/yocto/yocto-layer-dev/scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall
    }
    "example_bbappend_version" : {
        "default" : 0.1
        "msg" : Please enter the version number you'd like to use for your bbappend file (this should match the recipe you're appending to):
        "type" : edit
        "prio" : 20
        "filename" : /home/trz/yocto/yocto-layer-dev/scripts/lib/bsp/substrate/target/arch/layer/layer-questions.noinstall
    }

    Each entry in the output consists of the name of the input element
    e.g. "layer_priority", followed by the properties defined for that
    element enclosed in braces.  This information should provide
    sufficient information to create a complete user interface.  Two
    features of the scheme provide for conditional input.  First, if a
    Python "if" statement appears in place of an input element name,
    the set of enclosed input elements apply and should be presented
    to the user only if the 'if' statement evaluates to true.  The
    test in the if statement will always reference another input
    element in the list, which means that the element being tested
    should be presented to the user before the elements enclosed by
    the if block.  Secondly, in a similar way, some elements contain
    "depends-on" and depends-on-val" tags, which mean that the
    affected input element should only be presented to the user if the
    element it depends on has already been presented to the user and
    the user has selected the specified value for that element.

    The second form enumerates all the possible values that exist and
    can be specified for any of the enumerable properties in the
    'yocto-layer create' command.  If the -o option is specified, the
    list of values for the given property, in addition to being
    displayed, will be written to the specified file as a JSON object.
    In this case, the object will consist of the set of name:value
    pairs corresponding to the array of property values associated
    with the property.

    $ yocto-layer list property layer_priority
     [no output - layer_priority is a text field that has no enumerable values]

    The second form as well is meant mainly for developers of
    alternative interfaces - it allows the developer to fetch the
    possible values for a given input element on-demand.  This
    on-demand capability is especially valuable for elements that
    require relatively expensive remote operations to fulfill, such as
    the example that returns the set of branches available in a remote
    git tree above.

"""

##
# test code
##

test_bsp_properties = {
    'smp': 'yes',
    'touchscreen': 'yes',
    'keyboard': 'no',
    'xserver': 'yes',
    'xserver_choice': 'xserver-i915',
    'features': ['goodfeature', 'greatfeature'],
    'tunefile': 'tune-quark',
}