gem5 eclipse save and restore config files

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2020-10-14 01:00:00 +00:00
parent f6c3ba7c43
commit af92b11f82
3 changed files with 32 additions and 0 deletions

View File

@@ -14832,6 +14832,8 @@ To run and GDB step debug the executable, just copy the <<dry-run,full command l
and configure it into Eclipse as usual. and configure it into Eclipse as usual.
One downside of this setup is that if you want to nuke your build directory to get a clean build, then the Eclipse configuration files present in it might get deleted. Maybe it is possible to store configuration files outside of the directory, but we are now mitigating that by making a backup copy of those configuration files before removing the directory, and restoring it when you do `./build-gem --clean`.
==== gem5 Python C++ interaction ==== gem5 Python C++ interaction
The interaction uses the Python C extension interface https://docs.python.org/2/extending/extending.html interface through the <<pybind11>> helper library: https://github.com/pybind/pybind11 The interaction uses the Python C extension interface https://docs.python.org/2/extending/extending.html interface through the <<pybind11>> helper library: https://github.com/pybind/pybind11

View File

@@ -3,6 +3,7 @@
import os import os
import pathlib import pathlib
import subprocess import subprocess
import tempfile
import common import common
from shell_helpers import LF 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('--ldflags')
self._add_argument('extra_make_args') self._add_argument('extra_make_args')
self.eclipse_tmpdir = None
def build(self): def build(self):
build_dir = self.get_build_dir() 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 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): def get_build_dir(self):
return self.env['gem5_build_dir'] return self.env['gem5_build_dir']

View File

@@ -891,6 +891,13 @@ Incompatible archs are skipped.
env['gem5_test_binaries_dir'] = join(env['gem5_out_dir'], 'test_binaries') env['gem5_test_binaries_dir'] = join(env['gem5_out_dir'], 'test_binaries')
env['gem5_m5term'] = join(env['gem5_build_dir'], 'm5term') env['gem5_m5term'] = join(env['gem5_build_dir'], 'm5term')
env['gem5_build_build_dir'] = join(env['gem5_build_dir'], 'build') 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_dir'] = join(env['gem5_build_build_dir'], env['gem5_arch'])
env['gem5_executable_suffix'] = '.{}'.format(env['gem5_build_type']) env['gem5_executable_suffix'] = '.{}'.format(env['gem5_build_type'])
env['gem5_executable'] = self.get_gem5_target_path(env, 'gem5') 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 return ret
def clean_pre(self):
pass
def clean(self): def clean(self):
build_dir = self.get_build_dir() build_dir = self.get_build_dir()
self.clean_pre(build_dir)
if build_dir is not None: if build_dir is not None:
self.sh.rmrf(build_dir) self.sh.rmrf(build_dir)
self.clean_post(build_dir)
def clean_post(self):
pass
def build(self): def build(self):
''' '''