aboutsummaryrefslogtreecommitdiff
path: root/tools/binman/state.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-07-06 10:36:37 -0600
committerSimon Glass <sjg@chromium.org>2021-07-21 10:27:35 -0600
commitc69d19c8f829d3320db5224f9f28d13cfb16049e (patch)
treec13527b8a6aecf176f48ee6c0f8f657bb4dd303a /tools/binman/state.py
parent650ead1a4aac3010a029526d639682096c1d0469 (diff)
downloadu-boot-c69d19c8f829d3320db5224f9f28d13cfb16049e.zip
u-boot-c69d19c8f829d3320db5224f9f28d13cfb16049e.tar.gz
u-boot-c69d19c8f829d3320db5224f9f28d13cfb16049e.tar.bz2
binman: Support multithreading for building images
Some images may take a while to build, e.g. if they are large and use slow compression. Support compiling sections in parallel to speed things up. Signed-off-by: Simon Glass <sjg@chromium.org> (fixed to use a separate test file to fix flakiness)
Diffstat (limited to 'tools/binman/state.py')
-rw-r--r--tools/binman/state.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/binman/state.py b/tools/binman/state.py
index dfb1760..2f56758 100644
--- a/tools/binman/state.py
+++ b/tools/binman/state.py
@@ -7,6 +7,7 @@
import hashlib
import re
+import threading
from dtoc import fdt
import os
@@ -55,6 +56,9 @@ allow_entry_expansion = True
# to the new ones, the compressed size increases, etc.
allow_entry_contraction = False
+# Number of threads to use for binman (None means machine-dependent)
+num_threads = None
+
def GetFdtForEtype(etype):
"""Get the Fdt object for a particular device-tree entry
@@ -420,3 +424,22 @@ def AllowEntryContraction():
raised
"""
return allow_entry_contraction
+
+def SetThreads(threads):
+ """Set the number of threads to use when building sections
+
+ Args:
+ threads: Number of threads to use (None for default, 0 for
+ single-threaded)
+ """
+ global num_threads
+
+ num_threads = threads
+
+def GetThreads():
+ """Get the number of threads to use when building sections
+
+ Returns:
+ Number of threads to use (None for default, 0 for single-threaded)
+ """
+ return num_threads