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