]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
lib/oe/go: document map_arch, and raise an error on unknown architecture
authorRoss Burton <ross.burton@arm.com>
Fri, 20 Jun 2025 15:14:19 +0000 (16:14 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 23 Jun 2025 20:42:36 +0000 (21:42 +0100)
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>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oe/go.py

index dfd957d157a589305b486c8a6e2e3eee2435174e..4559dc63b285d383f6024a7ad1013e0a040143d3 100644 (file)
@@ -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}")