add override for build commands powerpc64-linux-gnu-{ENVVAR}
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 21 Mar 2021 11:07:59 +0000 (11:07 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 21 Mar 2021 11:07:59 +0000 (11:07 +0000)
src/soc/simulator/envcmds.py [new file with mode: 0644]
src/soc/simulator/program.py

diff --git a/src/soc/simulator/envcmds.py b/src/soc/simulator/envcmds.py
new file mode 100644 (file)
index 0000000..e6525c0
--- /dev/null
@@ -0,0 +1,9 @@
+import os
+
+# set up environment variable overrides, can use for different versions
+# as well as native (TALOS-II POWER9) builds.
+cmds = {}
+for cmd in ['objcopy', 'as', 'ld', 'gcc', 'ar', 'gdb']:
+    cmds[cmd] = os.environ.get(cmd.upper(), "powerpc64-linux-gnu-%s" % cmd)
+
+
index 47e873c69306d815e1a69f529fe1f2b8827a795b..1acd02daef367643422834f26595dd80a689b459 100644 (file)
@@ -15,6 +15,7 @@ import os
 import sys
 from io import BytesIO
 
+from soc.simulator.envcmds import cmds
 
 filedir = os.path.dirname(os.path.realpath(__file__))
 memmap = os.path.join(filedir, "memmap")
@@ -58,7 +59,7 @@ class Program:
 
     def _get_binary(self, elffile):
         self.binfile = tempfile.NamedTemporaryFile(suffix=".bin")
-        args = ["powerpc64-linux-gnu-objcopy",
+        args = [cmds['objcopy'],
                 "-O", "binary",
                 "-I", self.endian_fmt,
                 elffile.name,
@@ -67,7 +68,7 @@ class Program:
 
     def _link(self, ofile):
         with tempfile.NamedTemporaryFile(suffix=".elf") as elffile:
-            args = ["powerpc64-linux-gnu-ld",
+            args = [cmds['ld'],
                     self.ld_fmt,
                     "-o", elffile.name,
                     "-T", memmap,
@@ -77,7 +78,7 @@ class Program:
 
     def _assemble(self):
         with tempfile.NamedTemporaryFile(suffix=".o") as outfile:
-            args = ["powerpc64-linux-gnu-as",
+            args = [cmds['as'],
                     '-mpower9',
                     '-mregnames',
                     self.obj_fmt,