Adrian Herrera has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/55903 )
Change subject: scons: protobuf scanner, support source paths
......................................................................
scons: protobuf scanner, support source paths
Before this patch, the protobuf scanner would detect implicit
dependencies only if the import statement used a path relative to the
build directory. A path with a different format would result in a build
failure.
This is inconvenient because it impedes .proto files within a source
directory to import each other relative to that source.
Moreover, this is critical for EXTRAS directories with .proto files,
because the paths are forced to include the EXTRAS directory itself.
After this patch, the protobuf scanner uses the Classic scanner from
SCons to also detect implicit dependencies in the source path of the
importing .proto file. Regex management is also delegated to the Classic
scanner.
Change-Id: I1ad466813ef44947f3da07371805cb6376e392f0
Signed-off-by: Adrián Herrera Arcila <adrian.herr...@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/55903
Reviewed-by: Gabe Black <gabe.bl...@gmail.com>
Maintainer: Gabe Black <gabe.bl...@gmail.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/SConscript
1 file changed, 35 insertions(+), 9 deletions(-)
Approvals:
Gabe Black: Looks good to me, approved; Looks good to me, approved
kokoro: Regressions pass
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: 3
Gerrit-Owner: Adrian Herrera <adrian.herr...@arm.com>
Gerrit-Reviewer: Adrian Herrera <adrian.herr...@arm.com>
Gerrit-Reviewer: Gabe Black <gabe.bl...@gmail.com>
Gerrit-Reviewer: Jason Lowe-Power <power...@gmail.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-CC: Adrián Herrera Arcila <adr.her.arc...@gmail.com>
Gerrit-MessageType: merged
_______________________________________________
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