summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2017-10-04 19:43:51 -0700
committerGabe Black <gabeblack@google.com>2017-10-05 09:15:59 +0000
commitedc8cffbead0b76cf8ea537f5d612963d975aa56 (patch)
tree600c7d1f2f4802f25754669d2270742db7e3d9a7 /util
parentbb23c5075e7a247eaa452a5c7d9bae4c785f730e (diff)
downloadgem5-edc8cffbead0b76cf8ea537f5d612963d975aa56.tar.xz
misc: When building packet_pb2.py, don't assume a particular CWD.
Allow the script to be run from anywhere, and compute the paths relative to where the script is. The script is assumed to be in util. Change-Id: I8500ef959f2ff8119540c956f2b27789c96de60e Reviewed-on: https://gem5-review.googlesource.com/5004 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'util')
-rwxr-xr-xutil/decode_packet_trace.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/util/decode_packet_trace.py b/util/decode_packet_trace.py
index c21a150fa..dab43c314 100755
--- a/util/decode_packet_trace.py
+++ b/util/decode_packet_trace.py
@@ -52,15 +52,18 @@ import protolib
import sys
# Import the packet proto definitions. If they are not found, attempt
-# to generate them automatically. This assumes that the script is
-# executed from the gem5 root.
+# to generate them automatically.
try:
import packet_pb2
except:
print "Did not find packet proto definitions, attempting to generate"
+ import os
+ util_dir = os.path.dirname(os.path.realpath(__file__))
+ proto_dir = os.path.join(os.path.dirname(util_dir), 'src', 'proto')
+ proto_file = os.path.join(proto_dir, 'packet.proto')
from subprocess import call
- error = call(['protoc', '--python_out=util', '--proto_path=src/proto',
- 'src/proto/packet.proto'])
+ error = call(['protoc', '--python_out=' + util_dir,
+ '--proto_path=' + proto_dir, proto_file])
if not error:
print "Generated packet proto definitions"