Adrian Herrera has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/55903 )

Change subject: scons: protobuf scanner for EXTRAS
......................................................................

scons: protobuf scanner for EXTRAS

This solves the following issue:
- An EXTRAS directory "dir" contains a subdirectory "proto" with multiple
  .proto files. Some .proto files import other .proto files within "proto".
- "proto" contains a SConscript file loading the files through the ProtoBuf
  function.
- When SCons runs, it creates "dir/proto" under the $BUILDDIR directory.
- The protoc_scanner scans the .proto files under "dir/proto". Each
  "import a.proto" statement results in an implicit dependency
  "$BUILDDIR/a.proto", which does not exist, causing a build failure.

The correct implicit dependency should be "$BUILDDIR/dir/proto/a.proto". To
fix this, we use the Classic scanner from SCons, which also considers the
source directory of the .proto file that imports when looking for
dependencies. Regex management is also delegated to the Classic scanner.

Note: this still allows the use of paths relative to $BUILDDIR in
import statements by passing the BUILDDIR as a path_variable.

Change-Id: I1ad466813ef44947f3da07371805cb6376e392f0
Signed-off-by: Adrián Herrera Arcila <adrian.herr...@arm.com>
---
M src/SConscript
1 file changed, 33 insertions(+), 9 deletions(-)



diff --git a/src/SConscript b/src/SConscript
index 61585ec..e5b032c 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -229,15 +229,11 @@
# no whitespace at the end before or after the ;, and is all on one line. This
 # should still cover most cases, and a completely accurate scanner would be
 # MUCH more complex.
-protoc_import_re = re.compile(r'^import\s+\"(.*\.proto)\"\;$', re.M)
-
-def protoc_scanner(node, env, path):
-    deps = []
-    for imp in protoc_import_re.findall(node.get_text_contents()):
-        deps.append(Dir(env['BUILDDIR']).File(imp))
-    return deps
-
-env.Append(SCANNERS=Scanner(function=protoc_scanner, skeys=['.proto']))
+protoc_scanner = SCons.Scanner.Classic(name='ProtobufScanner',
+                                       suffixes=['.proto'],
+                                       path_variable='BUILDDIR',
+ regex=r'^import\s+\"(.*\.proto)\"\;$')
+env.Append(SCANNERS=protoc_scanner)

 def protoc_emitter(target, source, env):
     root, ext = os.path.splitext(source[0].get_abspath())

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/55903
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I1ad466813ef44947f3da07371805cb6376e392f0
Gerrit-Change-Number: 55903
Gerrit-PatchSet: 1
Gerrit-Owner: Adrian Herrera <adrian.herr...@arm.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to