From: Gabe Black Date: Sat, 7 Nov 2020 14:26:03 +0000 (-0800) Subject: scons: Fix how directories are handled for protobuf files. X-Git-Tag: develop-gem5-snapshot~474 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=598f15cf24532dce5b3bf1e0b6052aa0ff114778;p=gem5.git scons: Fix how directories are handled for protobuf files. There were two issues with how paths were handled for these files. 1. The code in the ProtoBuf class would drop the subdirectory part of the path name when generating the name of the .cc and .h files the protoc compiler would output. Since protoc wouldn't generate files where scons expected, it would fail when it tried to build the .cc. 2. protoc will use the --proto_path and --cpp_out settings to figure out what path to use for generated files. It will remove the --proto_path prefix it found the .proto file with from the files path, and then add the rest to the --cpp_out prefix. The input files should come from the build directory using symlinks set up by scons, and the output files should end up alongside them. That means the --proto_path setting should be the build directory, and so should --cpp_out. That's fortunately simpler than what was there before, since it doesn't depend on what the source or targets are. Change-Id: I69692d2fe3813011982f0c1c9824589a132f93ed Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/37218 Reviewed-by: Nikos Nikoleris Maintainer: Gabe Black Tested-by: kokoro --- diff --git a/src/SConscript b/src/SConscript index 9f82bdc70..9797be38e 100644 --- a/src/SConscript +++ b/src/SConscript @@ -399,8 +399,8 @@ class ProtoBuf(SourceFile): # Currently, we stick to generating the C++ headers, so we # only need to track the source and header. - self.cc_file = File(modname + '.pb.cc') - self.hh_file = File(modname + '.pb.h') + self.cc_file = self.tnode.dir.File(modname + '.pb.cc') + self.hh_file = self.tnode.dir.File(modname + '.pb.h') exectuable_classes = [] @@ -1024,8 +1024,9 @@ if env['HAVE_PROTOC'] and env['HAVE_PROTOBUF']: # specify the proto_path to avoid having the generated files # include the path. env.Command([proto.cc_file, proto.hh_file], proto.tnode, - MakeAction('${PROTOC} --cpp_out ${TARGET.dir} ' - '--proto_path ${SOURCE.dir} $SOURCE', + MakeAction('${PROTOC} --cpp_out ${BUILDDIR} ' + '--proto_path ${BUILDDIR} ' + '${SOURCE.get_abspath()}', Transform("PROTOC"))) # Add the C++ source file