Add a way to specify compact dex level for dexlayout

The option is '-x', which supports "fast" and "none" compact dex
generation. The default is "none".

Test: dexlayout -w out_dir -x fast classes.dex
Bug: 63756964

Change-Id: I77125d5148974d24a0808f80e2400f77f8b57a76
diff --git a/dexlayout/dexlayout_main.cc b/dexlayout/dexlayout_main.cc
index 5bb7196..83fb99a 100644
--- a/dexlayout/dexlayout_main.cc
+++ b/dexlayout/dexlayout_main.cc
@@ -62,6 +62,7 @@
   fprintf(stderr, " -t : display file section sizes\n");
   fprintf(stderr, " -v : verify output file is canonical to input (IR level comparison)\n");
   fprintf(stderr, " -w : output dex directory \n");
+  fprintf(stderr, " -x : compact dex generation level, either 'none' or 'fast'\n");
 }
 
 /*
@@ -79,7 +80,7 @@
 
   // Parse all arguments.
   while (1) {
-    const int ic = getopt(argc, argv, "abcdefghil:mo:p:stvw:");
+    const int ic = getopt(argc, argv, "abcdefghil:mo:p:stvw:x:");
     if (ic < 0) {
       break;  // done
     }
@@ -141,6 +142,15 @@
       case 'w':  // output dex files directory
         options.output_dex_directory_ = optarg;
         break;
+      case 'x':  // compact dex level
+        if (strcmp(optarg, "none") == 0) {
+          options.compact_dex_level_ = CompactDexLevel::kCompactDexLevelNone;
+        } else if (strcmp(optarg, "fast") == 0) {
+          options.compact_dex_level_ = CompactDexLevel::kCompactDexLevelFast;
+        } else {
+          want_usage = true;
+        }
+        break;
       default:
         want_usage = true;
         break;