Matt Spinler | d9c2fea | 2020-03-05 16:53:41 -0600 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Andrew Geissler | c830e0f | 2016-10-18 12:51:29 -0500 | [diff] [blame] | 2 | |
| 3 | r""" |
Deepak Kodihalli | 160d3e0 | 2017-01-17 04:25:22 -0600 | [diff] [blame] | 4 | This script will parse error log yaml file(s) and generate |
Andrew Geissler | c830e0f | 2016-10-18 12:51:29 -0500 | [diff] [blame] | 5 | a header file which will then be used by the error logging client and |
| 6 | server to collect and validate the error information generated by the |
| 7 | openbmc software components. |
| 8 | |
| 9 | This code uses a mako template to provide the basic template of the header |
| 10 | file we're going to generate. We then call it with information from the |
| 11 | yaml to generate the header file. |
Andrew Geissler | c830e0f | 2016-10-18 12:51:29 -0500 | [diff] [blame] | 12 | """ |
| 13 | |
Andrew Geissler | c830e0f | 2016-10-18 12:51:29 -0500 | [diff] [blame] | 14 | import os |
Patrick Williams | d27675d | 2022-12-08 06:18:00 -0600 | [diff] [blame] | 15 | import sys |
| 16 | from optparse import OptionParser |
| 17 | |
| 18 | from mako.template import Template |
| 19 | |
| 20 | import yaml |
Andrew Geissler | c830e0f | 2016-10-18 12:51:29 -0500 | [diff] [blame] | 21 | |
Andrew Geissler | 184690d | 2016-11-03 08:06:31 -0500 | [diff] [blame] | 22 | |
Deepak Kodihalli | 5d1aace | 2017-01-18 00:17:39 -0600 | [diff] [blame] | 23 | def order_inherited_errors(i_errors, i_parents): |
| 24 | # the ordered list of errors |
| 25 | errors = list() |
| 26 | has_inheritance = False |
| 27 | for error in i_errors: |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 28 | if i_parents[error] is not None: |
Deepak Kodihalli | 5d1aace | 2017-01-18 00:17:39 -0600 | [diff] [blame] | 29 | has_inheritance = True |
| 30 | break |
| 31 | |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 32 | if has_inheritance: |
Deepak Kodihalli | 5d1aace | 2017-01-18 00:17:39 -0600 | [diff] [blame] | 33 | # Order the error codes list such that an error is never placed |
| 34 | # before it's parent. This way generated code can ensure parent |
Gunnar Mills | deae3ca | 2017-10-25 17:22:22 -0500 | [diff] [blame] | 35 | # definitions precede child error definitions. |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 36 | while len(errors) < len(i_errors): |
Deepak Kodihalli | 5d1aace | 2017-01-18 00:17:39 -0600 | [diff] [blame] | 37 | for error in i_errors: |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 38 | if error in errors: |
Deepak Kodihalli | 5d1aace | 2017-01-18 00:17:39 -0600 | [diff] [blame] | 39 | # already ordererd |
| 40 | continue |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 41 | if (not i_parents[error]) or (i_parents[error] in errors): |
Deepak Kodihalli | 5d1aace | 2017-01-18 00:17:39 -0600 | [diff] [blame] | 42 | # parent present, or has no parent, either way this error |
| 43 | # can be added |
| 44 | errors.append(error) |
| 45 | else: |
| 46 | # no inherited errors |
| 47 | errors = i_errors |
| 48 | |
| 49 | return errors |
| 50 | |
| 51 | |
Deepak Kodihalli | cbd12c8 | 2017-01-17 08:50:55 -0600 | [diff] [blame] | 52 | def check_error_inheritance(i_errors, i_parents): |
Deepak Kodihalli | 5d1aace | 2017-01-18 00:17:39 -0600 | [diff] [blame] | 53 | for error in i_errors: |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 54 | if i_parents[error] and (i_parents[error] not in i_errors): |
| 55 | print( |
| 56 | error |
| 57 | + " inherits " |
| 58 | + i_parents[error] |
| 59 | + " but the latter is not defined" |
| 60 | ) |
Deepak Kodihalli | cbd12c8 | 2017-01-17 08:50:55 -0600 | [diff] [blame] | 61 | return False |
| 62 | return True |
| 63 | |
| 64 | |
Adriana Kobylak | 465aaec | 2017-02-20 11:58:03 -0600 | [diff] [blame] | 65 | # Return the yaml files with their directory structure plus the file name |
| 66 | # without the yaml extension, which will be used to set the namespaces. |
| 67 | # Ex: file xyz/openbmc_project/Error/Callout/Device.errors.yaml |
| 68 | # will have namespce xyz/openbmc_project/Error/Callout/Device |
Adriana Kobylak | 6a9db6e | 2017-02-21 12:58:05 -0600 | [diff] [blame] | 69 | def get_error_yaml_files(i_yaml_dir, i_test_dir): |
Adriana Kobylak | 371a38b | 2017-02-19 13:45:42 -0600 | [diff] [blame] | 70 | yaml_files = dict() |
Adriana Kobylak | 6a9db6e | 2017-02-21 12:58:05 -0600 | [diff] [blame] | 71 | if i_yaml_dir != "None": |
| 72 | for root, dirs, files in os.walk(i_yaml_dir): |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 73 | for files in [ |
| 74 | file for file in files if file.endswith(".errors.yaml") |
| 75 | ]: |
Adriana Kobylak | 465aaec | 2017-02-20 11:58:03 -0600 | [diff] [blame] | 76 | splitdir = root.split(i_yaml_dir)[1] + "/" + files[:-12] |
| 77 | if splitdir.startswith("/"): |
| 78 | splitdir = splitdir[1:] |
Adriana Kobylak | 371a38b | 2017-02-19 13:45:42 -0600 | [diff] [blame] | 79 | yaml_files[(os.path.join(root, files))] = splitdir |
Adriana Kobylak | 6a9db6e | 2017-02-21 12:58:05 -0600 | [diff] [blame] | 80 | for root, dirs, files in os.walk(i_test_dir): |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 81 | for files in [file for file in files if file.endswith(".errors.yaml")]: |
Adriana Kobylak | 465aaec | 2017-02-20 11:58:03 -0600 | [diff] [blame] | 82 | splitdir = root.split(i_test_dir)[1] + "/" + files[:-12] |
Adriana Kobylak | 371a38b | 2017-02-19 13:45:42 -0600 | [diff] [blame] | 83 | yaml_files[(os.path.join(root, files))] = splitdir |
Deepak Kodihalli | 160d3e0 | 2017-01-17 04:25:22 -0600 | [diff] [blame] | 84 | return yaml_files |
| 85 | |
| 86 | |
| 87 | def get_meta_yaml_file(i_error_yaml_file): |
| 88 | # the meta data will be defined in file name where we replace |
| 89 | # <Interface>.errors.yaml with <Interface>.metadata.yaml |
| 90 | meta_yaml = i_error_yaml_file.replace("errors", "metadata") |
| 91 | return meta_yaml |
| 92 | |
| 93 | |
Deepak Kodihalli | 9916119 | 2017-01-16 04:00:07 -0600 | [diff] [blame] | 94 | def get_cpp_type(i_type): |
| 95 | typeMap = { |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 96 | "boolean": "bool", |
| 97 | "int8": "int8_t", |
| 98 | "int16": "int16_t", |
| 99 | "int32": "int32_t", |
| 100 | "int64": "int64_t", |
| 101 | "uint8": "uint8_t", |
| 102 | "uint16": "uint16_t", |
| 103 | "uint32": "uint32_t", |
| 104 | "uint64": "uint64_t", |
| 105 | "double": "double", |
Deepak Kodihalli | 9916119 | 2017-01-16 04:00:07 -0600 | [diff] [blame] | 106 | # const char* aids usage of constexpr |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 107 | "string": "const char*", |
| 108 | } |
Deepak Kodihalli | 9916119 | 2017-01-16 04:00:07 -0600 | [diff] [blame] | 109 | |
| 110 | return typeMap[i_type] |
| 111 | |
| 112 | |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 113 | def gen_elog_hpp( |
| 114 | i_yaml_dir, i_test_dir, i_output_hpp, i_template_dir, i_elog_mako |
| 115 | ): |
Andrew Geissler | c830e0f | 2016-10-18 12:51:29 -0500 | [diff] [blame] | 116 | r""" |
Deepak Kodihalli | 160d3e0 | 2017-01-17 04:25:22 -0600 | [diff] [blame] | 117 | Read yaml file(s) under input yaml dir, grab the relevant data and call |
| 118 | the mako template to generate the output header file. |
Andrew Geissler | c830e0f | 2016-10-18 12:51:29 -0500 | [diff] [blame] | 119 | |
| 120 | Description of arguments: |
Adriana Kobylak | 6a9db6e | 2017-02-21 12:58:05 -0600 | [diff] [blame] | 121 | i_yaml_dir directory containing base error yaml files |
| 122 | i_test_dir directory containing test error yaml files |
Deepak Kodihalli | 160d3e0 | 2017-01-17 04:25:22 -0600 | [diff] [blame] | 123 | i_output_hpp name of the to be generated output hpp |
| 124 | i_template_dir directory containing error mako templates |
| 125 | i_elog_mako error mako template to render |
Andrew Geissler | c830e0f | 2016-10-18 12:51:29 -0500 | [diff] [blame] | 126 | """ |
| 127 | |
| 128 | # Input parameters to mako template |
Deepak Kodihalli | 160d3e0 | 2017-01-17 04:25:22 -0600 | [diff] [blame] | 129 | errors = list() # Main error codes |
Andrew Geissler | c830e0f | 2016-10-18 12:51:29 -0500 | [diff] [blame] | 130 | error_msg = dict() # Error msg that corresponds to error code |
| 131 | error_lvl = dict() # Error code log level (debug, info, error, ...) |
Deepak Kodihalli | 5d1aace | 2017-01-18 00:17:39 -0600 | [diff] [blame] | 132 | meta = dict() # The meta data names associated (ERRNO, FILE_NAME, ...) |
Andrew Geissler | c830e0f | 2016-10-18 12:51:29 -0500 | [diff] [blame] | 133 | meta_data = dict() # The meta data info (type, format) |
Deepak Kodihalli | 5d1aace | 2017-01-18 00:17:39 -0600 | [diff] [blame] | 134 | parents = dict() |
Deepak Kodihalli | 38f6974 | 2017-02-28 02:18:09 -0600 | [diff] [blame] | 135 | metadata_process = dict() # metadata that have the 'process' keyword set |
Andrew Geissler | c830e0f | 2016-10-18 12:51:29 -0500 | [diff] [blame] | 136 | |
Patrick Williams | 7dc8c3b | 2021-04-17 07:22:48 -0500 | [diff] [blame] | 137 | # Verify the input mako file |
| 138 | template_path = os.path.join(i_template_dir, i_elog_mako) |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 139 | if not (os.path.isfile(template_path)): |
Patrick Williams | 7dc8c3b | 2021-04-17 07:22:48 -0500 | [diff] [blame] | 140 | print("Cannot find input template file " + template_path) |
| 141 | exit(1) |
| 142 | template_path = os.path.abspath(template_path) |
| 143 | |
Adriana Kobylak | 6a9db6e | 2017-02-21 12:58:05 -0600 | [diff] [blame] | 144 | error_yamls = get_error_yaml_files(i_yaml_dir, i_test_dir) |
Deepak Kodihalli | 160d3e0 | 2017-01-17 04:25:22 -0600 | [diff] [blame] | 145 | |
| 146 | for error_yaml in error_yamls: |
| 147 | # Verify the error yaml file |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 148 | if not (os.path.isfile(error_yaml)): |
Marri Devender Rao | df7cb5c | 2017-05-14 08:30:40 -0500 | [diff] [blame] | 149 | print("Cannot find input yaml file " + error_yaml) |
Deepak Kodihalli | 160d3e0 | 2017-01-17 04:25:22 -0600 | [diff] [blame] | 150 | exit(1) |
| 151 | |
| 152 | # Verify the metadata yaml file |
| 153 | meta_yaml = get_meta_yaml_file(error_yaml) |
Deepak Kodihalli | 160d3e0 | 2017-01-17 04:25:22 -0600 | [diff] [blame] | 154 | |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 155 | get_elog_data( |
| 156 | error_yaml, |
| 157 | meta_yaml, |
| 158 | error_yamls[error_yaml], |
| 159 | # Last arg is a tuple |
| 160 | ( |
| 161 | errors, |
| 162 | error_msg, |
| 163 | error_lvl, |
| 164 | meta, |
| 165 | meta_data, |
| 166 | parents, |
| 167 | metadata_process, |
| 168 | ), |
| 169 | ) |
Deepak Kodihalli | 160d3e0 | 2017-01-17 04:25:22 -0600 | [diff] [blame] | 170 | |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 171 | if not check_error_inheritance(errors, parents): |
Patrick Williams | 6f29913 | 2017-02-16 13:27:39 -0600 | [diff] [blame] | 172 | print("Error - failed to validate error inheritance") |
Deepak Kodihalli | cbd12c8 | 2017-01-17 08:50:55 -0600 | [diff] [blame] | 173 | exit(1) |
| 174 | |
Deepak Kodihalli | 5d1aace | 2017-01-18 00:17:39 -0600 | [diff] [blame] | 175 | errors = order_inherited_errors(errors, parents) |
| 176 | |
Deepak Kodihalli | 160d3e0 | 2017-01-17 04:25:22 -0600 | [diff] [blame] | 177 | # Load the mako template and call it with the required data |
| 178 | yaml_dir = i_yaml_dir.strip("./") |
| 179 | yaml_dir = yaml_dir.strip("../") |
| 180 | template = Template(filename=template_path) |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 181 | f = open(i_output_hpp, "w") |
| 182 | f.write( |
| 183 | template.render( |
Deepak Kodihalli | 38f6974 | 2017-02-28 02:18:09 -0600 | [diff] [blame] | 184 | errors=errors, |
| 185 | error_msg=error_msg, |
| 186 | error_lvl=error_lvl, |
| 187 | meta=meta, |
Adriana Kobylak | 465aaec | 2017-02-20 11:58:03 -0600 | [diff] [blame] | 188 | meta_data=meta_data, |
Deepak Kodihalli | 38f6974 | 2017-02-28 02:18:09 -0600 | [diff] [blame] | 189 | parents=parents, |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 190 | metadata_process=metadata_process, |
| 191 | ) |
| 192 | ) |
Deepak Kodihalli | 160d3e0 | 2017-01-17 04:25:22 -0600 | [diff] [blame] | 193 | f.close() |
| 194 | |
Patrick Williams | bb6af86 | 2021-04-16 13:58:01 -0500 | [diff] [blame] | 195 | |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 196 | def get_elog_data(i_elog_yaml, i_elog_meta_yaml, i_namespace, o_elog_data): |
Deepak Kodihalli | 160d3e0 | 2017-01-17 04:25:22 -0600 | [diff] [blame] | 197 | r""" |
| 198 | Parse the error and metadata yaml files in order to pull out |
| 199 | error metadata. |
| 200 | |
Marri Devender Rao | df7cb5c | 2017-05-14 08:30:40 -0500 | [diff] [blame] | 201 | Use default values if metadata yaml file is not found. |
| 202 | |
Deepak Kodihalli | 160d3e0 | 2017-01-17 04:25:22 -0600 | [diff] [blame] | 203 | Description of arguments: |
| 204 | i_elog_yaml error yaml file |
| 205 | i_elog_meta_yaml metadata yaml file |
Adriana Kobylak | 371a38b | 2017-02-19 13:45:42 -0600 | [diff] [blame] | 206 | i_namespace namespace data |
Deepak Kodihalli | 160d3e0 | 2017-01-17 04:25:22 -0600 | [diff] [blame] | 207 | o_elog_data error metadata |
| 208 | """ |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 209 | ( |
| 210 | errors, |
| 211 | error_msg, |
| 212 | error_lvl, |
| 213 | meta, |
| 214 | meta_data, |
| 215 | parents, |
| 216 | metadata_process, |
| 217 | ) = o_elog_data |
Deepak Kodihalli | 160d3e0 | 2017-01-17 04:25:22 -0600 | [diff] [blame] | 218 | ifile = yaml.safe_load(open(i_elog_yaml)) |
Marri Devender Rao | df7cb5c | 2017-05-14 08:30:40 -0500 | [diff] [blame] | 219 | |
Patrick Williams | bb6af86 | 2021-04-16 13:58:01 -0500 | [diff] [blame] | 220 | # for all the errors in error yaml file |
Marri Devender Rao | df7cb5c | 2017-05-14 08:30:40 -0500 | [diff] [blame] | 221 | for error in ifile: |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 222 | if "name" not in error: |
| 223 | print( |
| 224 | "Error - Did not find name in entry %s in file %s " |
| 225 | % (str(error), i_elog_yaml) |
| 226 | ) |
Andrew Geissler | e859630 | 2016-11-21 16:06:53 -0600 | [diff] [blame] | 227 | exit(1) |
Patrick Williams | d27675d | 2022-12-08 06:18:00 -0600 | [diff] [blame] | 228 | fullname = i_namespace.replace("/", ".") + "." + error["name"] |
Adriana Kobylak | 465aaec | 2017-02-20 11:58:03 -0600 | [diff] [blame] | 229 | errors.append(fullname) |
Marri Devender Rao | df7cb5c | 2017-05-14 08:30:40 -0500 | [diff] [blame] | 230 | |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 231 | if "description" in error: |
| 232 | error_msg[fullname] = error["description"].strip() |
Marri Devender Rao | df7cb5c | 2017-05-14 08:30:40 -0500 | [diff] [blame] | 233 | |
Patrick Williams | bb6af86 | 2021-04-16 13:58:01 -0500 | [diff] [blame] | 234 | # set default values |
Marri Devender Rao | df7cb5c | 2017-05-14 08:30:40 -0500 | [diff] [blame] | 235 | error_lvl[fullname] = "ERR" |
| 236 | parents[fullname] = None |
| 237 | |
Patrick Williams | bb6af86 | 2021-04-16 13:58:01 -0500 | [diff] [blame] | 238 | # check if meta data yaml file is found |
Marri Devender Rao | df7cb5c | 2017-05-14 08:30:40 -0500 | [diff] [blame] | 239 | if not os.path.isfile(i_elog_meta_yaml): |
| 240 | continue |
| 241 | mfile = yaml.safe_load(open(i_elog_meta_yaml)) |
| 242 | |
| 243 | # Find the meta data entry |
| 244 | match = None |
| 245 | for meta_entry in mfile: |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 246 | if meta_entry["name"] == error["name"]: |
Marri Devender Rao | df7cb5c | 2017-05-14 08:30:40 -0500 | [diff] [blame] | 247 | match = meta_entry |
| 248 | break |
| 249 | |
| 250 | if match is None: |
Marri Devender Rao | df7cb5c | 2017-05-14 08:30:40 -0500 | [diff] [blame] | 251 | continue |
| 252 | |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 253 | error_lvl[fullname] = match.get("level", "ERR") |
Marri Devender Rao | df7cb5c | 2017-05-14 08:30:40 -0500 | [diff] [blame] | 254 | |
| 255 | # Get 0th inherited error (current support - single inheritance) |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 256 | if "inherits" in match: |
| 257 | parents[fullname] = match["inherits"][0] |
Marri Devender Rao | df7cb5c | 2017-05-14 08:30:40 -0500 | [diff] [blame] | 258 | |
Lei YU | 80aa476 | 2018-07-19 10:29:56 +0800 | [diff] [blame] | 259 | # Put all errors in meta[] even the meta is empty |
| 260 | # so that child errors could inherits such error without meta |
| 261 | tmp_meta = [] |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 262 | if "meta" in match: |
Marri Devender Rao | df7cb5c | 2017-05-14 08:30:40 -0500 | [diff] [blame] | 263 | # grab all the meta data fields and info |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 264 | for i in match["meta"]: |
| 265 | str_short = i["str"].split("=")[0] |
Deepak Kodihalli | 7924b17 | 2017-03-08 00:04:33 -0600 | [diff] [blame] | 266 | tmp_meta.append(str_short) |
| 267 | meta_data[str_short] = {} |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 268 | meta_data[str_short]["str"] = i["str"] |
| 269 | meta_data[str_short]["str_short"] = str_short |
| 270 | meta_data[str_short]["type"] = get_cpp_type(i["type"]) |
| 271 | if ("process" in i) and (i["process"] is True): |
Deepak Kodihalli | 38f6974 | 2017-02-28 02:18:09 -0600 | [diff] [blame] | 272 | metadata_process[str_short] = fullname + "." + str_short |
Lei YU | 80aa476 | 2018-07-19 10:29:56 +0800 | [diff] [blame] | 273 | meta[fullname] = tmp_meta |
Andrew Geissler | c830e0f | 2016-10-18 12:51:29 -0500 | [diff] [blame] | 274 | |
| 275 | # Debug |
Andrew Geissler | 184690d | 2016-11-03 08:06:31 -0500 | [diff] [blame] | 276 | # for i in errors: |
Andrew Geissler | df048c1 | 2016-11-10 16:50:35 -0600 | [diff] [blame] | 277 | # print "ERROR: " + errors[i] |
| 278 | # print " MSG: " + error_msg[errors[i]] |
| 279 | # print " LVL: " + error_lvl[errors[i]] |
| 280 | # print " META: " |
| 281 | # print meta[i] |
Andrew Geissler | c830e0f | 2016-10-18 12:51:29 -0500 | [diff] [blame] | 282 | |
Andrew Geissler | c830e0f | 2016-10-18 12:51:29 -0500 | [diff] [blame] | 283 | |
| 284 | def main(i_args): |
| 285 | parser = OptionParser() |
| 286 | |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 287 | parser.add_option( |
| 288 | "-m", |
| 289 | "--mako", |
| 290 | dest="elog_mako", |
| 291 | default="elog-gen-template.mako.hpp", |
| 292 | help="input mako template file to use", |
| 293 | ) |
Andrew Geissler | 184690d | 2016-11-03 08:06:31 -0500 | [diff] [blame] | 294 | |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 295 | parser.add_option( |
| 296 | "-o", |
| 297 | "--output", |
| 298 | dest="output_hpp", |
| 299 | default="elog-errors.hpp", |
| 300 | help="output hpp to generate, elog-errors.hpp default", |
| 301 | ) |
Andrew Geissler | c830e0f | 2016-10-18 12:51:29 -0500 | [diff] [blame] | 302 | |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 303 | parser.add_option( |
| 304 | "-y", |
| 305 | "--yamldir", |
| 306 | dest="yamldir", |
| 307 | default="None", |
| 308 | help="Base directory of yaml files to process", |
| 309 | ) |
Andrew Geissler | f1f2cfa | 2016-11-21 15:16:45 -0600 | [diff] [blame] | 310 | |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 311 | parser.add_option( |
| 312 | "-u", |
| 313 | "--testdir", |
| 314 | dest="testdir", |
| 315 | default="./tools/example/", |
| 316 | help="Unit test directory of yaml files to process", |
| 317 | ) |
Adriana Kobylak | 6a9db6e | 2017-02-21 12:58:05 -0600 | [diff] [blame] | 318 | |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 319 | parser.add_option( |
| 320 | "-t", |
| 321 | "--templatedir", |
| 322 | dest="templatedir", |
| 323 | default="phosphor-logging/templates/", |
| 324 | help="Base directory of files to process", |
| 325 | ) |
Andrew Geissler | f1f2cfa | 2016-11-21 15:16:45 -0600 | [diff] [blame] | 326 | |
Andrew Geissler | c830e0f | 2016-10-18 12:51:29 -0500 | [diff] [blame] | 327 | (options, args) = parser.parse_args(i_args) |
| 328 | |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 329 | gen_elog_hpp( |
| 330 | options.yamldir, |
| 331 | options.testdir, |
| 332 | options.output_hpp, |
| 333 | options.templatedir, |
| 334 | options.elog_mako, |
| 335 | ) |
Andrew Geissler | c830e0f | 2016-10-18 12:51:29 -0500 | [diff] [blame] | 336 | |
Patrick Williams | bb6af86 | 2021-04-16 13:58:01 -0500 | [diff] [blame] | 337 | |
Andrew Geissler | c830e0f | 2016-10-18 12:51:29 -0500 | [diff] [blame] | 338 | # Only run if it's a script |
Patrick Williams | e6555f5 | 2022-08-04 13:56:17 -0500 | [diff] [blame] | 339 | if __name__ == "__main__": |
Andrew Geissler | 184690d | 2016-11-03 08:06:31 -0500 | [diff] [blame] | 340 | main(sys.argv[1:]) |