(ikey)
| 392 | cmd_splitter = CommandSplitter() |
| 393 | |
| 394 | def count_lines_of_unit(ikey): |
| 395 | i, key = ikey |
| 396 | if not result.track(key['file']): |
| 397 | return |
| 398 | message = "[{}/{}] Counting LoCs of {}".format( |
| 399 | i, len(compile_commands), key['file']) |
| 400 | status.print(message, file=out) |
| 401 | clangcmd, infilename, infile, outfilename = cmd_splitter.process(key) |
| 402 | if not infile.is_file(): |
| 403 | return |
| 404 | |
| 405 | clangcmd = clangcmd + " -E -P " + \ |
| 406 | str(infile) + " -o /dev/stdout | sed '/^\\s*$/d' | wc -lc" |
| 407 | loccmd = ("cat {} | sed '\\;^\\s*//;d' | sed '\\;^/\\*;d'" |
| 408 | " | sed '/^\\*/d' | sed '/^\\s*$/d' | wc -lc") |
| 409 | loccmd = loccmd.format(infile) |
| 410 | runcmd = " {} ; {}".format(clangcmd, loccmd) |
| 411 | if ARGS['echocmd']: |
| 412 | print(runcmd) |
| 413 | process = subprocess.Popen( |
| 414 | runcmd, shell=True, cwd=key['directory'], stdout=subprocess.PIPE) |
| 415 | p = {'process': process, 'infile': infilename, 'outfile': outfilename} |
| 416 | output, _ = p['process'].communicate() |
| 417 | expanded, expanded_bytes, loc, in_bytes = list(map(int, output.split())) |
| 418 | result.recordFile(p['infile'], p['outfile'], loc, |
| 419 | in_bytes, expanded, expanded_bytes) |
| 420 | |
| 421 | with tempfile.TemporaryDirectory(dir='/tmp/', prefix="locs.") as temp: |
| 422 | start = time.time() |
nothing calls this directly
no test coverage detected
searching dependent graphs…