Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion tools/export/iar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from tools.export.exporters import Exporter, FailedBuildException
import json
from tools.export.cmsis import DeviceCMSIS
from multiprocessing import cpu_count

class IAR(Exporter):
NAME = 'iar'
Expand Down Expand Up @@ -101,7 +102,7 @@ def generate(self):
flags['c_flags'].remove('--vla')
if '--no_static_destruction' in flags['c_flags']:
flags['c_flags'].remove('--no_static_destruction')
#Optimizations
#Optimizations
if '-Oh' in flags['c_flags']:
flags['c_flags'].remove('-Oh')
ctx = {
Expand Down Expand Up @@ -135,6 +136,17 @@ def build(self):
raise Exception("IarBuild.exe not found. Add to path.")

cmd = [iar_exe, proj_file, '-build', self.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)]

p = Popen(cmd, stdout=PIPE, stderr=PIPE)
num_errors = 0
#Parse the output for printing and errors
Expand Down