def METHOD_NAME(project_name, log_name="build_log.txt", cleanup=True):
    """ Build IAR project """
    # > IarBuild [project_path] -build [project_name]
    proj_file = project_name + ".ewp"
    cmd = ["IarBuild", proj_file, '-build', project_name]
    # IAR does not support a '0' option to automatically use all
    # available CPUs, so we use Python's multiprocessing library
    # to detect the number of CPUs available
    cpus_available = cpu_count()
    jobs = cpus_available if cpus_available else None
    # Only add the parallel flag if we're using more than one CPU
    if jobs:
        cmd += ['-parallel', str(jobs)]
    # Build the project
    p = Popen(cmd, stdout=PIPE, stderr=PIPE)
    out, err = p.communicate()
    ret_code = p.returncode
    out_string = "=" * 10 + "STDOUT" + "=" * 10 + "\n"
    out_string += out
    out_string += "=" * 10 + "STDERR" + "=" * 10 + "\n"
    out_string += err
    if ret_code == 0:
        out_string += "SUCCESS"
    else:
        out_string += "FAILURE"
    print(out_string)
    if log_name:
        # Write the output to the log file
        with open(log_name, 'w+') as f:
            f.write(out_string)
    # Cleanup the exported and built files
    if cleanup:
        IAR.clean(project_name)
    if ret_code !=0:
        # Seems like something went wrong.
        return -1
    else:
        return 0