Changeset 91462f6 in rtems-source-builder
- Timestamp:
- 08/09/14 13:51:19 (8 years ago)
- Branches:
- 4.10, 4.11, 4.9, 5, master
- Children:
- 8db5212
- Parents:
- c21f09e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source-builder/sb/reports.py
rc21f09e r91462f6 38 38 import path 39 39 import setbuilder 40 import sources 40 41 import version 41 42 except KeyboardInterrupt: … … 63 64 self.out = '' 64 65 self.asciidoc = None 66 if self.is_ini(): 67 self.cini = ';' 68 else: 69 self.cini = '' 70 self.files = { 'buildsets':[], 'configs':[] } 71 self.sources = {} 72 self.patches = {} 65 73 66 74 def _sbpath(self, *args): … … 79 87 return self.format == 'asciidoc' or self.format == 'html' 80 88 89 def is_html(self): 90 return self.format == 'html' 91 92 def is_ini(self): 93 return self.format == 'ini' 94 81 95 def setup(self): 82 if self. format == 'html':96 if self.is_html(): 83 97 try: 84 98 import asciidocapi … … 104 118 self.output('') 105 119 self.output('.%s' % (text)) 120 elif self.is_ini(): 121 self.output(';') 122 self.output('; %s' % (text)) 123 self.output(';') 106 124 else: 107 125 self.output('-' * self.line_len) … … 113 131 self.output('*Remotes*:;;') 114 132 else: 115 self.output(' Remotes:')133 self.output('%s Remotes:' % (self.cini)) 116 134 repo_remotes = repo.remotes() 117 135 rc = 0 … … 126 144 self.output('. %s' % (text)) 127 145 else: 128 self.output(' %2d: %s' % (rc, text))146 self.output('%s %2d: %s' % (self.cini, rc, text)) 129 147 if self.is_asciidoc(): 130 148 self.output('*Status*:;;') 131 149 else: 132 self.output(' Status:') 133 if repo.clean(): 150 self.output('%s Status:' % (self.cini)) 151 if repo.dirty(): 152 if self.is_asciidoc(): 153 self.output('_Repository is dirty_') 154 else: 155 self.output('%s Repository is dirty' % (self.cini)) 156 else: 134 157 if self.is_asciidoc(): 135 158 self.output('Clean') 136 159 else: 137 self.output(' Clean') 138 else: 139 if self.is_asciidoc(): 140 self.output('_Repository is dirty_') 141 else: 142 self.output(' Repository is dirty') 160 self.output('%s Clean' % (self.cini)) 143 161 repo_head = repo.head() 144 162 if self.is_asciidoc(): … … 146 164 self.output('Commit: %s' % (repo_head)) 147 165 else: 148 self.output(' Head:') 149 self.output(' Commit: %s' % (repo_head)) 150 else: 151 self.output('_Not a valid GIT repository_') 166 self.output('%s Head:' % (self.cini)) 167 self.output('%s Commit: %s' % (self.cini, repo_head)) 168 else: 169 if self.is_asciidoc(): 170 self.output('_Not a valid GIT repository_') 171 else: 172 self.output('%s Not a valid GIT repository' % (self.cini)) 152 173 if self.is_asciidoc(): 153 174 self.output('') … … 156 177 157 178 def introduction(self, name, intro_text = None): 179 now = datetime.datetime.now().ctime() 158 180 if self.is_asciidoc(): 159 181 h = 'RTEMS Source Builder Report' … … 175 197 if intro_text: 176 198 self.output('%s' % ('\n'.join(intro_text))) 199 elif self.is_ini(): 200 self.output(';') 201 self.output('; RTEMS Tools Project <rtems-users@rtems.org> %s' % now) 202 if intro_text: 203 self.output(';') 204 self.output('; %s' % ('\n; '.join(intro_text))) 205 self.output(';') 177 206 else: 178 207 self.output('=' * self.line_len) 179 self.output('RTEMS Tools Project <rtems-users@rtems.org> %s' % datetime.datetime.now().ctime())208 self.output('RTEMS Tools Project <rtems-users@rtems.org> %s' % now) 180 209 if intro_text: 181 210 self.output('') … … 185 214 self.git_status() 186 215 187 def config_start(self, name): 216 def config_start(self, name, _config): 217 self.files['configs'] += [name] 218 for cf in _config.includes(): 219 cfbn = path.basename(cf) 220 if cfbn not in self.files['configs']: 221 self.files['configs'] += [cfbn] 188 222 first = not self.configs_active 189 223 self.configs_active = True 190 224 191 def config_end(self, name ):225 def config_end(self, name, _config): 192 226 if self.is_asciidoc(): 193 227 self.output('') … … 196 230 197 231 def buildset_start(self, name): 232 self.files['buildsets'] += [name] 198 233 if self.is_asciidoc(): 199 234 h = '%s' % (name) 200 235 self.output('=%s %s' % ('=' * self.bset_nesting, h)) 236 elif self.is_ini(): 237 pass 201 238 else: 202 239 self.output('=-' * (self.line_len / 2)) … … 206 243 self.configs_active = False 207 244 208 def source(self, package, source_tag): 209 return package.sources() 210 211 def patch(self, package, args): 212 return package.patches() 245 def source(self, macros): 246 def err(msg): 247 raise error.general('%s' % (msg)) 248 srcs = {} 249 for n in sources.get_source_names(macros, err): 250 srcs[n] = sources.get_sources(n, macros, err) 251 return srcs 252 253 def patch(self, macros): 254 def err(msg): 255 raise error.general('%s' % (msg)) 256 _patches = {} 257 for n in sources.get_patch_names(macros, err): 258 _patches[n] = sources.get_patches(n, macros, err) 259 patches = {} 260 for n in _patches: 261 pl = [] 262 for p in _patches[n]: 263 pl += [p.split()[-1]] 264 patches[n] = pl 265 return patches 266 267 def hash(self, name, macros): 268 return sources.get_hash(name, macros) 213 269 214 270 def output_info(self, name, info, separated = False): … … 246 302 self.output('--------------------------------------------') 247 303 304 def get_sources_patches(self, macros): 305 def _merge(src, dst): 306 for name in src: 307 if name not in dst: 308 dst[name] = [] 309 for s in src[name]: 310 dst[name] += [s] 311 dst[name] = dst[name] 312 sources = self.source(macros) 313 _merge(sources, self.sources) 314 patches = self.patch(macros) 315 _merge(patches, self.patches) 316 return sources, patches 317 248 318 def config(self, _config, opts, macros): 249 250 319 packages = _config.packages() 251 320 package = packages['main'] 252 321 name = package.name() 253 self.config_start(name) 322 sources, patches = self.get_sources_patches(macros) 323 self.config_start(name, _config) 324 if self.is_ini(): 325 return 254 326 if self.is_asciidoc(): 255 327 self.output('*Package*: _%s_ +' % (name)) … … 267 339 if self.is_asciidoc(): 268 340 self.output('') 269 sources = package.sources()270 341 if self.is_asciidoc(): 271 342 self.output('*Sources:*::') … … 275 346 self.output(' Sources: %d' % (len(sources))) 276 347 c = 0 277 for s in sources: 278 c += 1 279 if self.is_asciidoc(): 280 self.output('. %s' % (sources[s][0])) 281 else: 282 self.output(' %2d: %s' % (c, sources[s][0])) 283 patches = package.patches() 348 for name in sources: 349 for s in sources[name]: 350 c += 1 351 if self.is_asciidoc(): 352 self.output('. %s' % (s)) 353 else: 354 self.output(' %2d: %s' % (c, s)) 355 hash = self.hash(path.basename(s).lower(), macros) 356 if hash is None: 357 h = 'No checksum' 358 else: 359 hash = hash.split() 360 h = '%s: %s' % (hash[0], hash[1]) 361 if self.is_asciidoc(): 362 self.output(' %s' % (h)) 363 else: 364 self.output(' %s' % (h)) 284 365 if self.is_asciidoc(): 285 366 self.output('') … … 296 377 else: 297 378 self.output(' %2d: %s' % (c, patches[p][0])) 379 hash = self.hash(path.basename(s).lower(), macros) 380 if hash is None: 381 h = 'No checksum' 382 else: 383 hash = hash.split() 384 h = '%s: %s' % (hash[0], hash[1]) 385 if self.is_asciidoc(): 386 self.output(' %s' % (h)) 387 else: 388 self.output(' %s' % (h)) 298 389 self.output_directive('Preparation', package.prep()) 299 390 self.output_directive('Build', package.build()) 300 391 self.output_directive('Install', package.install()) 301 392 self.output_directive('Clean', package.clean()) 302 self.config_end(name) 303 304 def write(self, name): 305 if self.format == 'html': 393 self.config_end(name, _config) 394 395 def generate_ini(self, sysname): 396 self.output(';') 397 self.output('; Buildset File(s):') 398 for bf in sorted(self.files['buildsets']): 399 self.output('; %s' % (bf)) 400 self.output(';') 401 self.output('; Configuration File(s):') 402 for cf in sorted(self.files['configs']): 403 self.output('; %s' % (cf)) 404 names = sorted(set(self.sources.keys() + self.patches.keys())) 405 self.output(';') 406 self.output('') 407 self.output('[%s]' % (sysname)) 408 for name in names: 409 self.output('%s = rtems-%s' % (name, name)) 410 for name in names: 411 self.output('') 412 self.output('[%s-%s]' % (sysname, name)) 413 if name in self.sources: 414 self.output('sources = %s' % (', '.join(set(self.sources[name])))) 415 if name in self.patches: 416 self.output('patches = %s' % (', '.join(set(self.patches[name])))) 417 418 def write(self, sysname, name): 419 if self.is_html(): 306 420 if self.asciidoc is None: 307 421 raise error.general('asciidoc not initialised') … … 313 427 infile.close() 314 428 outfile.close() 429 elif self.is_ini(): 430 self.generate_ini(sysname) 315 431 if name is not None: 316 432 try: … … 332 448 for c in bset.load(): 333 449 if c.endswith('.bset'): 334 self. buildset(c, bset.opts, bset.macros)450 self.generate(c, bset.opts, bset.macros) 335 451 elif c.endswith('.cfg'): 336 452 self.config(config.file(c, bset.opts, bset.macros), … … 341 457 self.bset_nesting -= 1 342 458 343 def create(self, inname, outname = None, intro_text = None):459 def create(self, sysname, inname, outname = None, intro_text = None): 344 460 self.setup() 345 461 self.introduction(inname, intro_text) 346 462 self.generate(inname) 347 self.write( outname)463 self.write(sysname, outname) 348 464 349 465 def run(args): 350 466 try: 467 sysname = 'rtems' 351 468 optargs = { '--list-bsets': 'List available build sets', 352 469 '--list-configs': 'List available configurations', 353 '--format': 'Output format (text, html, asciidoc )',470 '--format': 'Output format (text, html, asciidoc, ini)', 354 471 '--output': 'File name to output the report' } 355 472 opts = options.load(args, optargs) … … 379 496 format = 'html' 380 497 ext = '.html' 498 elif format_opt[1] == 'ini': 499 format = 'ini' 500 ext = '.ini' 381 501 else: 382 502 raise error.general('invalid format: %s' % (format_opt[1])) … … 391 511 if config is None: 392 512 raise error.general('config file not found: %s' % (inname)) 393 r.create( config, outname)513 r.create(sysname, config, outname) 394 514 del r 395 515 else:
Note: See TracChangeset
for help on using the changeset viewer.