dex2oat_options.cc revision 5573c37e795668eca81a8488078f798d977685c3
1097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe/*
2097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe * Copyright (C) 2017 The Android Open Source Project
3097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe *
4097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe * Licensed under the Apache License, Version 2.0 (the "License");
5097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe * you may not use this file except in compliance with the License.
6097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe * You may obtain a copy of the License at
7097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe *
8097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe *      http://www.apache.org/licenses/LICENSE-2.0
9097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe *
10097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe * Unless required by applicable law or agreed to in writing, software
11097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe * distributed under the License is distributed on an "AS IS" BASIS,
12097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe * See the License for the specific language governing permissions and
14097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe * limitations under the License.
15097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe */
16097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
17097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe#include "dex2oat_options.h"
18097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
19097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe#include <memory>
20097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
21097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe#include "cmdline_parser.h"
22097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe#include "driver/compiler_options_map-inl.h"
23097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
24097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampenamespace art {
25097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
26097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampetemplate<>
27097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampestruct CmdlineType<InstructionSet> : CmdlineTypeParser<InstructionSet> {
28097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  Result Parse(const std::string& option) {
29097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe    InstructionSet set = GetInstructionSetFromString(option.c_str());
3033bff25bcd7a02d35c54f63740eadb1a4833fc92Vladimir Marko    if (set == InstructionSet::kNone) {
31097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      return Result::Failure(std::string("Not a valid instruction set: '") + option + "'");
32097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe    }
33097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe    return Result::Success(set);
34097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  }
35097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
36097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  static const char* Name() { return "InstructionSet"; }
37097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe};
38097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
39097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe#define COMPILER_OPTIONS_MAP_TYPE Dex2oatArgumentMap
40097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe#define COMPILER_OPTIONS_MAP_KEY_TYPE Dex2oatArgumentMapKey
41097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe#include "driver/compiler_options_map-storage.h"
42097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
43097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe// Specify storage for the Dex2oatOptions keys.
44097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
45097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe#define DEX2OAT_OPTIONS_KEY(Type, Name, ...) \
465573c37e795668eca81a8488078f798d977685c3Igor Murashkin  const Dex2oatArgumentMap::Key<Type> Dex2oatArgumentMap::Name {__VA_ARGS__};
47097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe#include "dex2oat_options.def"
48097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
49097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe#pragma GCC diagnostic push
50097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe#pragma GCC diagnostic ignored "-Wframe-larger-than="
51097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
52097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampeusing M = Dex2oatArgumentMap;
53097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampeusing Parser = CmdlineParser<Dex2oatArgumentMap, Dex2oatArgumentMap::Key>;
54097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampeusing Builder = Parser::Builder;
55097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
56097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampestatic void AddInputMappings(Builder& builder) {
57097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  builder.
58097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      Define("--dex-file=_")
59097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::vector<std::string>>().AppendValues()
60097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::DexFiles)
61097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--dex-location=_")
62097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::vector<std::string>>().AppendValues()
63097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::DexLocations)
64097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--zip-fd=_")
65097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<int>()
66097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::ZipFd)
67097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--zip-location=_")
68097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
69097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::ZipLocation)
70097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--boot-image=_")
71097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
72097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::BootImage);
73097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe}
74097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
75097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampestatic void AddGeneratedArtifactMappings(Builder& builder) {
76097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  builder.
77097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      Define("--input-vdex-fd=_")
78097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<int>()
79097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::InputVdexFd)
80097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--input-vdex=_")
81097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
82097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::InputVdex)
83097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--output-vdex-fd=_")
84097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<int>()
85097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::OutputVdexFd)
86097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--output-vdex=_")
87097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
88097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::OutputVdex)
89097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--oat-file=_")
90097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::vector<std::string>>().AppendValues()
91097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::OatFiles)
92097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--oat-symbols=_")
93097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::vector<std::string>>().AppendValues()
94097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::OatSymbols)
95097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--oat-fd=_")
96097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<int>()
97097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::OatFd)
98097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--oat-location=_")
99097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
100097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::OatLocation);
101097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe}
102097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
103097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampestatic void AddImageMappings(Builder& builder) {
104097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  builder.
105097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      Define("--image=_")
106097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::vector<std::string>>().AppendValues()
107097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::ImageFilenames)
108097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--image-classes=_")
109097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
110097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::ImageClasses)
111097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--image-classes-zip=_")
112097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
113097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::ImageClassesZip)
114097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--base=_")
115097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
116097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::Base)
117097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--app-image-file=_")
118097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
119097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::AppImageFile)
120097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--app-image-fd=_")
121097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<int>()
122097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::AppImageFileFd)
123097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--multi-image")
124097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::MultiImage)
125097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--dirty-image-objects=_")
126097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
127097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::DirtyImageObjects)
128097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--image-format=_")
129097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<ImageHeader::StorageMode>()
130097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithValueMap({{"lz4", ImageHeader::kStorageModeLZ4},
131097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe                         {"lz4hc", ImageHeader::kStorageModeLZ4HC},
132097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe                         {"uncompressed", ImageHeader::kStorageModeUncompressed}})
133097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::ImageFormat);
134097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe}
135097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
136097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampestatic void AddSwapMappings(Builder& builder) {
137097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  builder.
138097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      Define("--swap-file=_")
139097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
140097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::SwapFile)
141097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--swap-fd=_")
142097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<int>()
143097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::SwapFileFd)
144097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--swap-dex-size-threshold=_")
145097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<unsigned int>()
146097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::SwapDexSizeThreshold)
147097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--swap-dex-count-threshold=_")
148097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<unsigned int>()
149097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::SwapDexCountThreshold);
150097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe}
151097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
152097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampestatic void AddCompilerMappings(Builder& builder) {
153097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  builder.
154097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      Define("--compiled-classes=_")
155097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
156097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::CompiledClasses)
157097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--compiled-classes-zip=_")
158097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
159097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::CompiledClassesZip)
160097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--compiled-methods=_")
161097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
162097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::CompiledMethods)
163097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--compiled-methods-zip=_")
164097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
165097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::CompiledMethodsZip)
166097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--run-passes=_")
167097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
168097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::Passes)
169097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--profile-file=_")
170097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
171097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::Profile)
172097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--profile-file-fd=_")
173097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<int>()
174097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::ProfileFd)
175097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--no-inline-from=_")
176097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
177097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::NoInlineFrom);
178097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe}
179097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
180097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampestatic void AddTargetMappings(Builder& builder) {
181097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  builder.
182097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      Define("--instruction-set=_")
183097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<InstructionSet>()
184097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::TargetInstructionSet)
185097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--instruction-set-variant=_")
186097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
187097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::TargetInstructionSetVariant)
188097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--instruction-set-features=_")
189097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
190097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::TargetInstructionSetFeatures);
191097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe}
192097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
193097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampestatic Parser CreateArgumentParser() {
194097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  std::unique_ptr<Builder> parser_builder = std::unique_ptr<Builder>(new Builder());
195097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
196097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  AddInputMappings(*parser_builder);
197097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  AddGeneratedArtifactMappings(*parser_builder);
198097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  AddImageMappings(*parser_builder);
199097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  AddSwapMappings(*parser_builder);
200097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  AddCompilerMappings(*parser_builder);
201097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  AddTargetMappings(*parser_builder);
202097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
203097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  parser_builder->
204097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      Define({"--watch-dog", "--no-watch-dog"})
205097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithValues({true, false})
206097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::Watchdog)
207097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--watchdog-timeout=_")
208097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<int>()
209097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::WatchdogTimeout)
210097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("-j_")
211097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<unsigned int>()
212097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::Threads)
213097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--android-root=_")
214097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
215097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::AndroidRoot)
216097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--compiler-backend=_")
217097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<Compiler::Kind>()
218097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithValueMap({{"Quick", Compiler::Kind::kQuick},
219097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe                         {"Optimizing", Compiler::Kind::kOptimizing}})
220097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::Backend)
221097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--host")
222097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::Host)
223097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--dump-timing")
224097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::DumpTiming)
225097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--dump-passes")
226097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::DumpPasses)
227097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--dump-stats")
228097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::DumpStats)
229097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--avoid-storing-invocation")
230097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::AvoidStoringInvocation)
231097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--very-large-app-threshold=_")
232097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<unsigned int>()
233097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::VeryLargeAppThreshold)
234097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--force-determinism")
235097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::ForceDeterminism)
236097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--classpath-dir=_")
237097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
238097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::ClasspathDir)
239097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--class-loader-context=_")
240097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::string>()
241097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::ClassLoaderContext)
242eafe2a5a057c32eaf972cb09fe447cfbffae71caMathieu Chartier      .Define("--compact-dex-level=_")
243eafe2a5a057c32eaf972cb09fe447cfbffae71caMathieu Chartier          .WithType<CompactDexLevel>()
244eafe2a5a057c32eaf972cb09fe447cfbffae71caMathieu Chartier          .WithValueMap({{"none", CompactDexLevel::kCompactDexLevelNone},
245eafe2a5a057c32eaf972cb09fe447cfbffae71caMathieu Chartier                         {"fast", CompactDexLevel::kCompactDexLevelFast}})
246eafe2a5a057c32eaf972cb09fe447cfbffae71caMathieu Chartier          .IntoKey(M::CompactDexLevel)
247097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe      .Define("--runtime-arg _")
248097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .WithType<std::vector<std::string>>().AppendValues()
249097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe          .IntoKey(M::RuntimeOptions);
250097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
251097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  AddCompilerOptionsArgumentParserOptions<Dex2oatArgumentMap>(*parser_builder);
252097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
253097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  parser_builder->IgnoreUnrecognized(false);
254097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
255097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  return parser_builder->Build();
256097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe}
257097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
258097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe#pragma GCC diagnostic pop
259097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
260097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampestd::unique_ptr<Dex2oatArgumentMap> Dex2oatArgumentMap::Parse(int argc,
261097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe                                                              const char** argv,
262097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe                                                              std::string* error_msg) {
263097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  Parser parser = CreateArgumentParser();
264097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  CmdlineResult parse_result = parser.Parse(argv, argc);
265097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  if (!parse_result.IsSuccess()) {
266097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe    *error_msg = parse_result.GetMessage();
267097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe    return nullptr;
268097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  }
269097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
270097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe  return std::unique_ptr<Dex2oatArgumentMap>(new Dex2oatArgumentMap(parser.ReleaseArgumentsMap()));
271097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe}
272097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe
273097f34cc09caf46945ec17e198f57ac9c156e904Andreas Gampe}  // namespace art
274