summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2023-10-17 07:59:02 -0600
committerSteve Sakoman <steve@sakoman.com>2023-11-24 05:01:37 -1000
commit45736b12e117326583140a1307347180249ff1f9 (patch)
treeef3bb250a6e6c177e17e1930776c6945b6cf7e9d
parent006a8f18915bb72a212434b39f3790f11d20f140 (diff)
downloadpoky-45736b12e117326583140a1307347180249ff1f9.tar.gz
goarch: Move Go architecture mapping to a library
Other spaces uses the Go architecture definitions as their own (for example, container arches are defined to be Go arches). To make it easier for other places to use this mapping, move the code that does the translation of OpenEmbedded arches to Go arches to a library. (From OE-Core rev: 5e0267aeb7d9f575f270f6856a67ac62ce8a0f71) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 3e86f72fc2e1cc2e5ea4b4499722d736941167ce) Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/classes-recipe/goarch.bbclass29
-rw-r--r--meta/lib/oe/__init__.py2
-rw-r--r--meta/lib/oe/go.py34
3 files changed, 38 insertions, 27 deletions
diff --git a/meta/classes-recipe/goarch.bbclass b/meta/classes-recipe/goarch.bbclass
index 5fb6051bde..1ebe03864f 100644
--- a/meta/classes-recipe/goarch.bbclass
+++ b/meta/classes-recipe/goarch.bbclass
@@ -68,33 +68,10 @@ SECURITY_NOPIE_CFLAGS ??= ""
68CCACHE_DISABLE ?= "1" 68CCACHE_DISABLE ?= "1"
69 69
70def go_map_arch(a, d): 70def go_map_arch(a, d):
71 import re 71 arch = oe.go.map_arch(a)
72 if re.match('i.86', a): 72 if not arch:
73 return '386'
74 elif a == 'x86_64':
75 return 'amd64'
76 elif re.match('arm.*', a):
77 return 'arm'
78 elif re.match('aarch64.*', a):
79 return 'arm64'
80 elif re.match('mips64el.*', a):
81 return 'mips64le'
82 elif re.match('mips64.*', a):
83 return 'mips64'
84 elif a == 'mips':
85 return 'mips'
86 elif a == 'mipsel':
87 return 'mipsle'
88 elif re.match('p(pc|owerpc)(64le)', a):
89 return 'ppc64le'
90 elif re.match('p(pc|owerpc)(64)', a):
91 return 'ppc64'
92 elif a == 'riscv64':
93 return 'riscv64'
94 elif a == 'loongarch64':
95 return 'loong64'
96 else:
97 raise bb.parse.SkipRecipe("Unsupported CPU architecture: %s" % a) 73 raise bb.parse.SkipRecipe("Unsupported CPU architecture: %s" % a)
74 return arch
98 75
99def go_map_arm(a, d): 76def go_map_arm(a, d):
100 if a.startswith("arm"): 77 if a.startswith("arm"):
diff --git a/meta/lib/oe/__init__.py b/meta/lib/oe/__init__.py
index da7cbab308..6eb536ad28 100644
--- a/meta/lib/oe/__init__.py
+++ b/meta/lib/oe/__init__.py
@@ -9,4 +9,4 @@ __path__ = extend_path(__path__, __name__)
9 9
10BBIMPORTS = ["data", "path", "utils", "types", "package", "packagedata", \ 10BBIMPORTS = ["data", "path", "utils", "types", "package", "packagedata", \
11 "packagegroup", "sstatesig", "lsb", "cachedpath", "license", \ 11 "packagegroup", "sstatesig", "lsb", "cachedpath", "license", \
12 "qa", "reproducible", "rust", "buildcfg"] 12 "qa", "reproducible", "rust", "buildcfg", "go"]
diff --git a/meta/lib/oe/go.py b/meta/lib/oe/go.py
new file mode 100644
index 0000000000..dfd957d157
--- /dev/null
+++ b/meta/lib/oe/go.py
@@ -0,0 +1,34 @@
1#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7import re
8
9def map_arch(a):
10 if re.match('i.86', a):
11 return '386'
12 elif a == 'x86_64':
13 return 'amd64'
14 elif re.match('arm.*', a):
15 return 'arm'
16 elif re.match('aarch64.*', a):
17 return 'arm64'
18 elif re.match('mips64el.*', a):
19 return 'mips64le'
20 elif re.match('mips64.*', a):
21 return 'mips64'
22 elif a == 'mips':
23 return 'mips'
24 elif a == 'mipsel':
25 return 'mipsle'
26 elif re.match('p(pc|owerpc)(64le)', a):
27 return 'ppc64le'
28 elif re.match('p(pc|owerpc)(64)', a):
29 return 'ppc64'
30 elif a == 'riscv64':
31 return 'riscv64'
32 elif a == 'loongarch64':
33 return 'loong64'
34 return ''