diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2013-05-30 12:53:53 -0400 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2013-05-30 12:53:53 -0400 |
commit | cc8911261e11d67f2b8745289ed5ecbb89c9d917 (patch) | |
tree | d3c337c3586c9566eb5660b307ece4d3804a62ec /util | |
parent | 4c7a283e55b635417b71d4de2a34c8528a207967 (diff) | |
download | gem5-cc8911261e11d67f2b8745289ed5ecbb89c9d917.tar.xz |
util: Auto generate the packet proto definitions
This patch simplifies the usage of the packet trace encoder/decoder by
attempting to automatically generating the packet proto definitions in
case they cannot be found.
Diffstat (limited to 'util')
-rwxr-xr-x | util/decode_packet_trace.py | 18 | ||||
-rwxr-xr-x | util/encode_packet_trace.py | 18 |
2 files changed, 34 insertions, 2 deletions
diff --git a/util/decode_packet_trace.py b/util/decode_packet_trace.py index 9ee877e39..fa0ea9604 100755 --- a/util/decode_packet_trace.py +++ b/util/decode_packet_trace.py @@ -80,7 +80,23 @@ import struct import sys -import packet_pb2 + +# 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. +try: + import packet_pb2 +except: + print "Did not find packet proto definitions, attempting to generate" + from subprocess import call + error = call(['protoc', '--python_out=util', '--proto_path=src/proto', + 'src/proto/packet.proto']) + if not error: + import packet_pb2 + print "Generated packet proto definitions" + else: + print "Failed to import packet proto definitions" + exit(-1) def DecodeVarint(in_file): """ diff --git a/util/encode_packet_trace.py b/util/encode_packet_trace.py index cbfc7d921..fc6ddf7fd 100755 --- a/util/encode_packet_trace.py +++ b/util/encode_packet_trace.py @@ -85,7 +85,23 @@ import struct import sys -import packet_pb2 + +# 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. +try: + import packet_pb2 +except: + print "Did not find packet proto definitions, attempting to generate" + from subprocess import call + error = call(['protoc', '--python_out=util', '--proto_path=src/proto', + 'src/proto/packet.proto']) + if not error: + import packet_pb2 + print "Generated packet proto definitions" + else: + print "Failed to import packet proto definitions" + exit(-1) def EncodeVarint(out_file, value): """ |