From 344bbe18dd4d8d5cb844223e029073cade88c8e9 Mon Sep 17 00:00:00 2001 From: Tom Ball Date: Wed, 24 Mar 2021 14:23:42 -0700 Subject: [PATCH] Adds -Xprint-args internal flag to tree_shaker, only needed for debugging build rules. PiperOrigin-RevId: 364890336 --- .../main/java/com/google/devtools/treeshaker/Options.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tree_shaker/src/main/java/com/google/devtools/treeshaker/Options.java b/tree_shaker/src/main/java/com/google/devtools/treeshaker/Options.java index 69443ebeff..40773de6c8 100644 --- a/tree_shaker/src/main/java/com/google/devtools/treeshaker/Options.java +++ b/tree_shaker/src/main/java/com/google/devtools/treeshaker/Options.java @@ -153,6 +153,7 @@ public static void version() { public static Options parse(String[] args) throws IOException { Options options = new Options(); + boolean printArgs = false; int nArg = 0; while (nArg < args.length) { @@ -204,6 +205,8 @@ public static Options parse(String[] args) throws IOException { version(); } else if (arg.equals("-Werror")) { options.treatWarningsAsErrors = true; + } else if (arg.equals("-Xprint-args")) { + printArgs = true; } else if (arg.startsWith("-h") || arg.equals("--help")) { help(false); } else if (arg.startsWith("-")) { @@ -220,6 +223,10 @@ public static Options parse(String[] args) throws IOException { if (options.sourceFiles.isEmpty()) { usage("no source files"); } + if (printArgs) { + System.err.print("tree_shaker "); + System.err.println(String.join(" ", args)); + } return options; }