diff mbox series

[02/12] lib/oe/go: document map_arch, and raise an error on unknown architecture

Message ID 20250620151429.3210879-2-ross.burton@arm.com
State New
Headers show
Series [01/12] tinfoil: add wait_for decorator and build_file_sync() helper | expand

Commit Message

Ross Burton June 20, 2025, 3:14 p.m. UTC
Add a comment explaining what this function does and where the values
come from.

If the architecture isn't know, instead of returning an empty string
which could fail mysteriously, raise a KeyError so it fails quickly.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 meta/lib/oe/go.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/lib/oe/go.py b/meta/lib/oe/go.py
index dfd957d157a..4559dc63b28 100644
--- a/meta/lib/oe/go.py
+++ b/meta/lib/oe/go.py
@@ -7,6 +7,10 @@ 
 import re
 
 def map_arch(a):
+    """
+    Map our architecture names to Go's GOARCH names.
+    See https://github.com/golang/go/blob/master/src/internal/syslist/syslist.go for the complete list.
+    """
     if re.match('i.86', a):
         return '386'
     elif a == 'x86_64':
@@ -31,4 +35,4 @@  def map_arch(a):
         return 'riscv64'
     elif a == 'loongarch64':
         return 'loong64'
-    return ''
+    raise KeyError(f"Cannot map architecture {a}")