From af92b11f82f0f018a47bffb22a4df534a7ebab11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Wed, 14 Oct 2020 01:00:00 +0000 Subject: [PATCH] gem5 eclipse save and restore config files --- README.adoc | 2 ++ build-gem5 | 15 +++++++++++++++ common.py | 15 +++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/README.adoc b/README.adoc index 8601bba..afc5339 100644 --- a/README.adoc +++ b/README.adoc @@ -14832,6 +14832,8 @@ To run and GDB step debug the executable, just copy the <> helper library: https://github.com/pybind/pybind11 diff --git a/build-gem5 b/build-gem5 index c7105bf..9a06982 100755 --- a/build-gem5 +++ b/build-gem5 @@ -3,6 +3,7 @@ import os import pathlib import subprocess +import tempfile import common from shell_helpers import LF @@ -35,6 +36,7 @@ https://github.com/cirosantilli/linux-kernel-module-cheat-regression#gem5-unit-t ) self._add_argument('--ldflags') self._add_argument('extra_make_args') + self.eclipse_tmpdir = None def build(self): build_dir = self.get_build_dir() @@ -143,6 +145,19 @@ https://github.com/cirosantilli/linux-kernel-module-cheat-regression#gem5-unit-t ) return exit_status + def clean_pre(self, builddir): + if os.path.exists(self.env['gem5_eclipse_cproject_path']): + self.eclipse_tmpdir = tempfile.mkdtemp() + self.sh.mv(self.env['gem5_eclipse_cproject_path'], self.eclipse_tmpdir) + self.sh.mv(self.env['gem5_eclipse_project_path'], self.eclipse_tmpdir) + + def clean_post(self, builddir): + if self.eclipse_tmpdir is not None: + self.sh.mkdir_p(self.env['gem5_build_build_dir']) + self.sh.mv(os.path.join(self.eclipse_tmpdir, self.env['gem5_eclipse_cproject_basename']), self.env['gem5_build_build_dir']) + self.sh.mv(os.path.join(self.eclipse_tmpdir, self.env['gem5_eclipse_project_basename']), self.env['gem5_build_build_dir']) + self.sh.rmrf(self.eclipse_tmpdir) + def get_build_dir(self): return self.env['gem5_build_dir'] diff --git a/common.py b/common.py index fc40263..3042c55 100644 --- a/common.py +++ b/common.py @@ -891,6 +891,13 @@ Incompatible archs are skipped. env['gem5_test_binaries_dir'] = join(env['gem5_out_dir'], 'test_binaries') env['gem5_m5term'] = join(env['gem5_build_dir'], 'm5term') env['gem5_build_build_dir'] = join(env['gem5_build_dir'], 'build') + + # https://cirosantilli.com/linux-kernel-module-cheat#gem5-eclipse-configuration + env['gem5_eclipse_cproject_basename'] = '.cproject' + env['gem5_eclipse_project_basename'] = '.project' + env['gem5_eclipse_cproject_path'] = join(env['gem5_build_build_dir'], env['gem5_eclipse_cproject_basename']) + env['gem5_eclipse_project_path'] = join(env['gem5_build_build_dir'], env['gem5_eclipse_project_basename']) + env['gem5_executable_dir'] = join(env['gem5_build_build_dir'], env['gem5_arch']) env['gem5_executable_suffix'] = '.{}'.format(env['gem5_build_type']) env['gem5_executable'] = self.get_gem5_target_path(env, 'gem5') @@ -1963,10 +1970,18 @@ after configure, e.g. SCons. Usually contains specific targets or other build fl ) return ret + def clean_pre(self): + pass + def clean(self): build_dir = self.get_build_dir() + self.clean_pre(build_dir) if build_dir is not None: self.sh.rmrf(build_dir) + self.clean_post(build_dir) + + def clean_post(self): + pass def build(self): '''