util: Add the ability to build a cross GDB to build_cross_gcc.py.
authorGabe Black <gabeblack@google.com>
Sun, 15 Mar 2020 11:12:38 +0000 (04:12 -0700)
committerGabe Black <gabeblack@google.com>
Fri, 20 Mar 2020 05:00:38 +0000 (05:00 +0000)
This is a very simple extension to what's already there.

Change-Id: I07e3711244e0de96b215f16ec05c660b19e462b5
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/26765
Tested-by: Gem5 Cloud Project GCB service account <345032938727@cloudbuild.gserviceaccount.com>
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Gabe Black <gabeblack@google.com>

util/build_cross_gcc/build_cross_gcc.py

index 9388632febe1177d1785bf031e557e7d62035788..e8497c36c9a64d4d903b74ca63ada5319cea2488 100755 (executable)
@@ -54,6 +54,7 @@ description_paragraphs = [
         '''2. gcc''',
         '''3. glibc''',
         '''4. linux kernel''',
+        '''5. gdb''',
         '',
         '''
         The entire process can be configured with a series of settings
@@ -373,6 +374,18 @@ class LinuxSourceDir(SourceDirSetting):
     def set_from_args(self, args):
         return self.set_arg(args.linux_src)
 
+class GdbSourceDir(SourceDirSetting):
+    key = 'GDB_SRC_DIR'
+    default = None
+    pattern = 'gdb-*'
+    project = 'gdb'
+
+    def add_to_argparser(self, parser):
+        parser.add_argument('--gdb-src', help=self.describe())
+
+    def set_from_args(self, args):
+        return self.set_arg(args.gdb_src)
+
 class Parallelism(Setting):
     key = 'J'
     default = None
@@ -646,9 +659,39 @@ class StandardCLib(Step):
                 'make install',
                 )
 
-class StandardCxxLib(Step):
+class BuildGdb(Step):
     number = 7
 
+    def describe(self):
+        return 'Build GDB.'
+
+    def run(self):
+        prefix = Prefix.setting()
+        target = Target.setting()
+        j = Parallelism.setting()
+        source_dir = GdbSourceDir.setting()
+        build_dir = setup_build_dir('gdb')
+
+        if not all((prefix, target, j, source_dir, build_dir)):
+            return False
+
+        prefix = prefix.get()
+        target = target.get()
+        j = j.get()
+        source_dir = os.path.abspath(source_dir.get())
+        build_dir = os.path.abspath(build_dir)
+
+        return run_commands(build_dir,
+                '{configure} --prefix={prefix} --target={target} '
+                '$MACHTYPE'.format(prefix=prefix, target=target,
+                    configure=os.path.join(source_dir, 'configure')),
+                'make -j{j}'.format(j=j),
+                'make install'
+                )
+
+class StandardCxxLib(Step):
+    number = 8
+
     def describe(self):
         return 'Install the standard C++ library.'