summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Hoinkis <simon.hoinkis@codethink.co.uk>2015-04-10 11:04:23 +0100
committerBaserock Gerrit <gerrit@baserock.org>2015-04-10 11:12:28 +0000
commitf0263ff73fe3c539135683780e48e6153a193ef1 (patch)
treea77bda649ca71488eef2d2bbd7be5c86bac81b7a
parentc9500e35fd3fcabd8013c6d9d7841508f25e4a16 (diff)
downloadmorph-f0263ff73fe3c539135683780e48e6153a193ef1.tar.gz
Change build environment to support MIPS32/64 BE and LE
Change-Id: I9344b9b80a6ec008715559390b63c9003f34bf90
-rw-r--r--morphlib/__init__.py5
-rw-r--r--morphlib/buildenvironment.py22
-rw-r--r--morphlib/util.py15
3 files changed, 36 insertions, 6 deletions
diff --git a/morphlib/__init__.py b/morphlib/__init__.py
index 7c462aad..0c9284d8 100644
--- a/morphlib/__init__.py
+++ b/morphlib/__init__.py
@@ -37,8 +37,9 @@ __version__ = gitversion.version
# List of architectures that Morph supports
-valid_archs = ['armv7l', 'armv7lhf', 'armv7b', 'testarch',
- 'x86_32', 'x86_64', 'ppc64', 'armv8l64', 'armv8b64']
+valid_archs = ['armv7l', 'armv7lhf', 'armv7b', 'testarch', 'x86_32',
+ 'x86_64', 'ppc64', 'armv8l64', 'armv8b64', 'mips32l',
+ 'mips32b', 'mips64l', 'mips64b']
class Error(cliapp.AppException):
diff --git a/morphlib/buildenvironment.py b/morphlib/buildenvironment.py
index 6ec82d45..2f94f107 100644
--- a/morphlib/buildenvironment.py
+++ b/morphlib/buildenvironment.py
@@ -114,16 +114,30 @@ class BuildEnvironment():
# than leaving it up to individual morphologies.
if arch == 'x86_32':
cpu = 'i686'
+ abi = ''
+ elif arch.startswith('armv7'):
+ cpu = arch
+ abi = 'eabi'
elif arch == 'armv8l64': # pragma: no cover
cpu = 'aarch64'
+ abi = ''
elif arch == 'armv8b64': # pragma: no cover
cpu = 'aarch64_be'
+ abi = ''
+ elif arch == 'mips64b': # pragma: no cover
+ cpu = 'mips64'
+ abi = 'abi64'
+ elif arch == 'mips64l': # pragma: no cover
+ cpu = 'mips64el'
+ abi = 'abi64'
+ elif arch == 'mips32b': # pragma: no cover
+ cpu = 'mips'
+ abi = ''
+ elif arch == 'mips32l': # pragma: no cover
+ cpu == 'mipsel'
+ abi = ''
else:
cpu = arch
-
- if arch.startswith('armv7'):
- abi = 'eabi'
- else:
abi = ''
env['TARGET'] = cpu + '-baserock-linux-gnu' + abi
diff --git a/morphlib/util.py b/morphlib/util.py
index 9d90fdf3..904dc355 100644
--- a/morphlib/util.py
+++ b/morphlib/util.py
@@ -19,6 +19,7 @@ import pipes
import re
import subprocess
import textwrap
+import sys
import fs.osfs
@@ -450,6 +451,13 @@ def has_hardware_fp(): # pragma: no cover
output = subprocess.check_output(['readelf', '-A', '/proc/self/exe'])
return 'Tag_ABI_VFP_args: VFP registers' in output
+def determine_endianness(): # pragma: no cover
+ '''
+ This function returns whether the host is running
+ in big or little endian. This is needed for MIPS.
+ '''
+
+ return sys.byteorder
def get_host_architecture(): # pragma: no cover
'''Get the canonical Morph name for the host's architecture.'''
@@ -468,6 +476,8 @@ def get_host_architecture(): # pragma: no cover
'armv8b': 'armv8b',
'aarch64': 'armv8l64',
'aarch64_be': 'armv8b64',
+ 'mips': 'mips32',
+ 'mips64': 'mips64',
'ppc64': 'ppc64'
}
@@ -476,6 +486,11 @@ def get_host_architecture(): # pragma: no cover
if machine == 'armv7l' and has_hardware_fp():
return 'armv7lhf'
+ elif machine in ('mips', 'mips64'):
+ if determine_endianness() == 'big':
+ return table[machine]+'b'
+ else:
+ return table[machine]+'l'
return table[machine]