diff options
Diffstat (limited to 'scripts/yocto-bsp')
-rwxr-xr-x | scripts/yocto-bsp | 163 |
1 files changed, 0 insertions, 163 deletions
diff --git a/scripts/yocto-bsp b/scripts/yocto-bsp deleted file mode 100755 index 6fb1f419cc..0000000000 --- a/scripts/yocto-bsp +++ /dev/null | |||
@@ -1,163 +0,0 @@ | |||
1 | #!/usr/bin/env python3 | ||
2 | # ex:ts=4:sw=4:sts=4:et | ||
3 | # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- | ||
4 | # | ||
5 | # Copyright (c) 2012, Intel Corporation. | ||
6 | # All rights reserved. | ||
7 | # | ||
8 | # This program is free software; you can redistribute it and/or modify | ||
9 | # it under the terms of the GNU General Public License version 2 as | ||
10 | # published by the Free Software Foundation. | ||
11 | # | ||
12 | # This program is distributed in the hope that it will be useful, | ||
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | # GNU General Public License for more details. | ||
16 | # | ||
17 | # You should have received a copy of the GNU General Public License along | ||
18 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
19 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
20 | # | ||
21 | # DESCRIPTION | ||
22 | # 'yocto-bsp' is the Yocto BSP Tool that helps users create a new | ||
23 | # Yocto BSP. Invoking it without any arguments will display help | ||
24 | # screens for the 'yocto-bsp' command and list the available | ||
25 | # 'yocto-bsp' subcommands. Invoking a subcommand without any | ||
26 | # arguments will likewise display help screens for the specified | ||
27 | # subcommand. Please use that interface for detailed help. | ||
28 | # | ||
29 | # AUTHORS | ||
30 | # Tom Zanussi <tom.zanussi (at] intel.com> | ||
31 | # | ||
32 | |||
33 | import os | ||
34 | import sys | ||
35 | import argparse | ||
36 | import logging | ||
37 | |||
38 | scripts_path = os.path.dirname(os.path.realpath(__file__)) | ||
39 | sys.path.insert(0, scripts_path + '/lib') | ||
40 | import argparse_oe | ||
41 | |||
42 | from bsp.help import * | ||
43 | from bsp.engine import * | ||
44 | |||
45 | |||
46 | def do_create_bsp(args): | ||
47 | """ | ||
48 | Command-line handling for BSP creation. The real work is done by | ||
49 | bsp.engine.yocto_bsp_create() | ||
50 | """ | ||
51 | if args.outdir: | ||
52 | bsp_output_dir = args.outdir | ||
53 | else: | ||
54 | bsp_output_dir = "meta-" + args.bspname | ||
55 | |||
56 | if args.git_check and not args.properties_file: | ||
57 | print("Checking basic git connectivity...") | ||
58 | if not verify_git_repo(GIT_CHECK_URI): | ||
59 | print("Couldn't verify git connectivity, exiting\n") | ||
60 | print("Details: couldn't access %s" % GIT_CHECK_URI) | ||
61 | print(" (this most likely indicates a network connectivity problem or") | ||
62 | print(" a misconfigured git intallation)") | ||
63 | sys.exit(1) | ||
64 | else: | ||
65 | print("Done.\n") | ||
66 | |||
67 | yocto_bsp_create(args.bspname, args.karch, scripts_path, bsp_output_dir, args.codedump, args.properties_file) | ||
68 | |||
69 | |||
70 | def do_list_bsp(args): | ||
71 | """ | ||
72 | Command-line handling for listing available BSP properties and | ||
73 | values. The real work is done by bsp.engine.yocto_bsp_list() | ||
74 | """ | ||
75 | yocto_bsp_list(args, scripts_path) | ||
76 | |||
77 | def do_help_bsp(args): | ||
78 | """ | ||
79 | Command-line help tool | ||
80 | """ | ||
81 | help_text = command_help.get(args.subcommand) | ||
82 | pager = subprocess.Popen('less', stdin=subprocess.PIPE) | ||
83 | pager.communicate(bytes(help_text,'UTF-8')) | ||
84 | |||
85 | command_help = { | ||
86 | "create": yocto_bsp_create_help, | ||
87 | "list": yocto_bsp_list_help | ||
88 | } | ||
89 | |||
90 | |||
91 | def start_logging(loglevel): | ||
92 | logging.basicConfig(filename = 'yocto-bsp.log', filemode = 'w', level=loglevel) | ||
93 | |||
94 | |||
95 | def main(): | ||
96 | parser = argparse_oe.ArgumentParser(description='Create a customized Yocto BSP layer.', | ||
97 | epilog="See '%(prog)s help <subcommand>' for more information on a specific command.") | ||
98 | |||
99 | parser.add_argument("-D", "--debug", action = "store_true", | ||
100 | default = False, help = "output debug information") | ||
101 | subparsers = parser.add_subparsers(title='subcommands', metavar='<subcommand>') | ||
102 | subparsers.required = True | ||
103 | |||
104 | create_parser = subparsers.add_parser('create', help='Create a new Yocto BSP', | ||
105 | description='Create a new Yocto BSP') | ||
106 | create_parser.add_argument('bspname', metavar='bsp-name', help='name for the new BSP') | ||
107 | create_parser.add_argument('karch', help='kernel architecture') | ||
108 | create_parser.add_argument("-o", "--outdir", help = "name of BSP dir to create") | ||
109 | create_parser.add_argument("-i", "--infile", dest = "properties_file", | ||
110 | help = "name of file containing the values for BSP properties as a JSON file") | ||
111 | create_parser.add_argument("-c", "--codedump", action = "store_true", default = False, | ||
112 | help = "dump the generated code to bspgen.out") | ||
113 | create_parser.add_argument("-s", "--skip-git-check", dest = "git_check", action = "store_false", | ||
114 | default = True, help = "skip the git connectivity check") | ||
115 | create_parser.set_defaults(func=do_create_bsp) | ||
116 | |||
117 | |||
118 | list_parser = subparsers.add_parser('list', help='List available values for options and BSP properties') | ||
119 | list_parser.add_argument('karch', help='kernel architecture') | ||
120 | prop_group = list_parser.add_mutually_exclusive_group() | ||
121 | prop_group.add_argument("--properties", action = "store_true", default = False, | ||
122 | help = "list all properties for the kernel architecture") | ||
123 | prop_group.add_argument("--property", help = "list available values for the property") | ||
124 | list_parser.add_argument("-o", "--outfile", dest = "properties_file", | ||
125 | help = "dump the possible values for BSP properties to a JSON file") | ||
126 | |||
127 | list_parser.set_defaults(func=do_list_bsp) | ||
128 | |||
129 | help_parser = subparsers.add_parser('help', | ||
130 | description='This command displays detailed help for the specified subcommand.') | ||
131 | help_parser.add_argument('subcommand', nargs='?') | ||
132 | help_parser.set_defaults(func=do_help_bsp) | ||
133 | |||
134 | args = parser.parse_args() | ||
135 | |||
136 | loglevel = logging.INFO | ||
137 | if args.debug: | ||
138 | loglevel = logging.DEBUG | ||
139 | start_logging(loglevel) | ||
140 | |||
141 | if args._subparser_name == "list": | ||
142 | if not args.karch == "karch" and not args.properties and not args.property: | ||
143 | print ("yocto-bsp list: error: one of the arguments --properties --property is required") | ||
144 | list_parser.print_help() | ||
145 | |||
146 | if args._subparser_name == "help": | ||
147 | if not args.subcommand: | ||
148 | parser.print_help() | ||
149 | return 0 | ||
150 | elif not command_help.get(args.subcommand): | ||
151 | print ("yocto-bsp help: No manual entry for %s" % args.subcommand) | ||
152 | return 1 | ||
153 | |||
154 | return args.func(args) | ||
155 | |||
156 | if __name__ == "__main__": | ||
157 | try: | ||
158 | ret = main() | ||
159 | except Exception: | ||
160 | ret = 1 | ||
161 | import traceback | ||
162 | traceback.print_exc() | ||
163 | sys.exit(ret) | ||