[torque] Adds strip-v8-root flag

Change-Id: I116a25fe586491f1a3aff6a486e69724d82115ac
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2983207
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Nico Hartmann <nicohartmann@chromium.org>
Reviewed-by: Nico Hartmann <nicohartmann@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75381}
This commit is contained in:
Victor Gomes 2021-06-24 12:48:14 +02:00 committed by V8 LUCI CQ
parent 3161106e77
commit 243dad8fbe
2 changed files with 12 additions and 1 deletions

View File

@ -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 {

View File

@ -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")) {