def parse_make_output()

in memory_statistics/memory_statistics.py [0:0]


def parse_make_output(output, values, key):
    '''
    output expects the output of the makefile, which ends in a call to
    arm-none-eabi-size The output of size is expected to be the Berkley output
    format: text data bss dec hex filename

    values is an input defaultdict which maps filenames to dicts of opt level
    to sizes. This function adds each file's size to the file's dict with the
    key provided by the key parameter.
    '''
    output = output.splitlines()

    # Skip to size output
    while output:
        line = output[0]
        output = output[1:]
        if line.startswith('arm-none-eabi-size'):
            break
    # Skip header
    output = output[1:]

    for line in output:
        parts = line.split()

        # parts[5] is the filename of the object
        filename = str(parts[5].replace('.o','.c').strip())

        # parts[0] is the text size
        text_size = int(parts[0].strip())
        # parts[1] is the data size
        data_size = int(parts[1].strip())

        total_size_in_kb = convert_size_to_kb(text_size + data_size)

        values[filename][key] = total_size_in_kb