From 243dad8fbec1debd61b7665ffc8f588177b11ffa Mon Sep 17 00:00:00 2001 From: Victor Gomes Date: Thu, 24 Jun 2021 12:48:14 +0200 Subject: [PATCH] [torque] Adds strip-v8-root flag Change-Id: I116a25fe586491f1a3aff6a486e69724d82115ac Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2983207 Auto-Submit: Victor Gomes Commit-Queue: Nico Hartmann Reviewed-by: Nico Hartmann Cr-Commit-Position: refs/heads/master@{#75381} --- src/torque/torque-compiler.h | 3 +++ src/torque/torque.cc | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/torque/torque-compiler.h b/src/torque/torque-compiler.h index 0e8f3b42ae..32fa41ea9b 100644 --- a/src/torque/torque-compiler.h +++ b/src/torque/torque-compiler.h @@ -33,6 +33,9 @@ struct TorqueCompilerOptions { // Adds extra comments in output that show Torque intermediate representation. bool annotate_ir = false; + + // Strips the v8-root in case the source path contains it as a prefix. + bool strip_v8_root = false; }; struct TorqueCompilerResult { diff --git a/src/torque/torque.cc b/src/torque/torque.cc index ca16ce4ca6..dcc6b40678 100644 --- a/src/torque/torque.cc +++ b/src/torque/torque.cc @@ -27,7 +27,7 @@ int WrappedMain(int argc, const char** argv) { for (int i = 1; i < argc; ++i) { // Check for options - const std::string argument(argv[i]); + std::string argument(argv[i]); if (argument == "-o") { options.output_directory = argv[++i]; } else if (argument == "-v8-root") { @@ -41,7 +41,15 @@ int WrappedMain(int argc, const char** argv) { #endif } else if (argument == "-annotate-ir") { options.annotate_ir = true; + } else if (argument == "-strip-v8-root") { + options.strip_v8_root = true; } else { + // Strip the v8-root in case it is a prefix of the file path itself. + // This is used when building in Google3. + if (options.strip_v8_root && + argument.substr(0, options.v8_root.size()) == options.v8_root) { + argument = argument.substr(options.v8_root.size() + 1); + } // Otherwise it's a .tq file. Remember it for compilation. files.emplace_back(std::move(argument)); if (!StringEndsWith(files.back(), ".tq")) {