sim,misc: Move protobuf housekeeping out of gem5Main.
Put that code into a singleton class in src/proto, so that it gets called during initialization and teardown of gem5 without cluttering up gem5Main. This also removes the need to use #ifdefs to guard for actualling having protobuf support. Change-Id: I93b5d994eee478a9c159a3f3d02b3e996af02a3e Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/49416 Maintainer: Gabe Black <gabe.black@gmail.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -53,14 +53,8 @@
|
||||
#include "base/cprintf.hh"
|
||||
#include "base/logging.hh"
|
||||
#include "base/types.hh"
|
||||
#include "config/have_protobuf.hh"
|
||||
#include "python/pybind11/pybind.hh"
|
||||
|
||||
#if HAVE_PROTOBUF
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
|
||||
#endif
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
namespace gem5
|
||||
@@ -204,14 +198,6 @@ PYBIND11_EMBEDDED_MODULE(_m5, _m5)
|
||||
int
|
||||
gem5Main(int argc, char **argv)
|
||||
{
|
||||
#if HAVE_PROTOBUF
|
||||
// Verify that the version of the protobuf library that we linked
|
||||
// against is compatible with the version of the headers we
|
||||
// compiled against.
|
||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||
#endif
|
||||
|
||||
|
||||
// Embedded python doesn't set up sys.argv, so we'll do that ourselves.
|
||||
py::list py_argv;
|
||||
auto sys = py::module::import("sys");
|
||||
@@ -239,10 +225,6 @@ gem5Main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if HAVE_PROTOBUF
|
||||
google::protobuf::ShutdownProtobufLibrary();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user