xref: /aosp_15_r20/art/odrefresh/odr_config.h (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1*795d594fSAndroid Build Coastguard Worker /*
2*795d594fSAndroid Build Coastguard Worker  * Copyright (C) 2021 The Android Open Source Project
3*795d594fSAndroid Build Coastguard Worker  *
4*795d594fSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*795d594fSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*795d594fSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*795d594fSAndroid Build Coastguard Worker  *
8*795d594fSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*795d594fSAndroid Build Coastguard Worker  *
10*795d594fSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*795d594fSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*795d594fSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*795d594fSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*795d594fSAndroid Build Coastguard Worker  * limitations under the License.
15*795d594fSAndroid Build Coastguard Worker  */
16*795d594fSAndroid Build Coastguard Worker 
17*795d594fSAndroid Build Coastguard Worker #ifndef ART_ODREFRESH_ODR_CONFIG_H_
18*795d594fSAndroid Build Coastguard Worker #define ART_ODREFRESH_ODR_CONFIG_H_
19*795d594fSAndroid Build Coastguard Worker 
20*795d594fSAndroid Build Coastguard Worker #include <algorithm>
21*795d594fSAndroid Build Coastguard Worker #include <optional>
22*795d594fSAndroid Build Coastguard Worker #include <string>
23*795d594fSAndroid Build Coastguard Worker #include <unordered_map>
24*795d594fSAndroid Build Coastguard Worker #include <unordered_set>
25*795d594fSAndroid Build Coastguard Worker #include <vector>
26*795d594fSAndroid Build Coastguard Worker 
27*795d594fSAndroid Build Coastguard Worker #include "android-base/file.h"
28*795d594fSAndroid Build Coastguard Worker #include "android-base/no_destructor.h"
29*795d594fSAndroid Build Coastguard Worker #include "android-base/strings.h"
30*795d594fSAndroid Build Coastguard Worker #include "arch/instruction_set.h"
31*795d594fSAndroid Build Coastguard Worker #include "base/file_utils.h"
32*795d594fSAndroid Build Coastguard Worker #include "base/globals.h"
33*795d594fSAndroid Build Coastguard Worker #include "log/log.h"
34*795d594fSAndroid Build Coastguard Worker #include "odr_common.h"
35*795d594fSAndroid Build Coastguard Worker #include "odrefresh/odrefresh.h"
36*795d594fSAndroid Build Coastguard Worker #include "tools/system_properties.h"
37*795d594fSAndroid Build Coastguard Worker 
38*795d594fSAndroid Build Coastguard Worker namespace art {
39*795d594fSAndroid Build Coastguard Worker namespace odrefresh {
40*795d594fSAndroid Build Coastguard Worker 
41*795d594fSAndroid Build Coastguard Worker // The prefixes of system properties that odrefresh keeps track of. Odrefresh will recompile
42*795d594fSAndroid Build Coastguard Worker // everything if any property matching a prefix changes.
43*795d594fSAndroid Build Coastguard Worker constexpr const char* kCheckedSystemPropertyPrefixes[]{"dalvik.vm.", "ro.dalvik.vm."};
44*795d594fSAndroid Build Coastguard Worker 
45*795d594fSAndroid Build Coastguard Worker // System property for the phenotype flag to override the device or default-configured
46*795d594fSAndroid Build Coastguard Worker // system server compiler filter setting.
47*795d594fSAndroid Build Coastguard Worker static constexpr char kSystemPropertySystemServerCompilerFilterOverride[] =
48*795d594fSAndroid Build Coastguard Worker     "persist.device_config.runtime_native_boot.systemservercompilerfilter_override";
49*795d594fSAndroid Build Coastguard Worker 
50*795d594fSAndroid Build Coastguard Worker // The list of system properties that odrefresh ignores. They don't affect compilation results.
51*795d594fSAndroid Build Coastguard Worker const std::unordered_set<std::string> kIgnoredSystemProperties{
52*795d594fSAndroid Build Coastguard Worker     "dalvik.vm.dex2oat-cpu-set",
53*795d594fSAndroid Build Coastguard Worker     "dalvik.vm.dex2oat-threads",
54*795d594fSAndroid Build Coastguard Worker     "dalvik.vm.boot-dex2oat-cpu-set",
55*795d594fSAndroid Build Coastguard Worker     "dalvik.vm.boot-dex2oat-threads",
56*795d594fSAndroid Build Coastguard Worker     "dalvik.vm.restore-dex2oat-cpu-set",
57*795d594fSAndroid Build Coastguard Worker     "dalvik.vm.restore-dex2oat-threads",
58*795d594fSAndroid Build Coastguard Worker     "dalvik.vm.background-dex2oat-cpu-set",
59*795d594fSAndroid Build Coastguard Worker     "dalvik.vm.background-dex2oat-threads"};
60*795d594fSAndroid Build Coastguard Worker 
61*795d594fSAndroid Build Coastguard Worker struct SystemPropertyConfig {
62*795d594fSAndroid Build Coastguard Worker   const char* name;
63*795d594fSAndroid Build Coastguard Worker   const char* default_value;
64*795d594fSAndroid Build Coastguard Worker };
65*795d594fSAndroid Build Coastguard Worker 
66*795d594fSAndroid Build Coastguard Worker // The system properties that odrefresh keeps track of, in addition to the ones matching the
67*795d594fSAndroid Build Coastguard Worker // prefixes in `kCheckedSystemPropertyPrefixes`. Odrefresh will recompile everything if any property
68*795d594fSAndroid Build Coastguard Worker // changes.
69*795d594fSAndroid Build Coastguard Worker // All phenotype flags under the `runtime_native_boot` namespace that affects the compiler's
70*795d594fSAndroid Build Coastguard Worker // behavior must be explicitly listed below. We cannot use a prefix to match all phenotype flags
71*795d594fSAndroid Build Coastguard Worker // because a default value is required for each flag. Changing the flag value from empty to the
72*795d594fSAndroid Build Coastguard Worker // default value should not trigger re-compilation. This is to comply with the phenotype flag
73*795d594fSAndroid Build Coastguard Worker // requirement (go/platform-experiments-flags#pre-requisites).
74*795d594fSAndroid Build Coastguard Worker const android::base::NoDestructor<std::vector<SystemPropertyConfig>> kSystemProperties{
75*795d594fSAndroid Build Coastguard Worker     {SystemPropertyConfig{.name = "persist.device_config.runtime_native_boot.enable_uffd_gc_2",
76*795d594fSAndroid Build Coastguard Worker                           .default_value = "false"},
77*795d594fSAndroid Build Coastguard Worker      SystemPropertyConfig{.name = "persist.device_config.runtime_native_boot.force_disable_uffd_gc",
78*795d594fSAndroid Build Coastguard Worker                           .default_value = "false"},
79*795d594fSAndroid Build Coastguard Worker      SystemPropertyConfig{.name = kSystemPropertySystemServerCompilerFilterOverride,
80*795d594fSAndroid Build Coastguard Worker                           .default_value = ""},
81*795d594fSAndroid Build Coastguard Worker      // For testing only (cf. odsign_e2e_tests_full).
82*795d594fSAndroid Build Coastguard Worker      SystemPropertyConfig{.name = "persist.device_config.runtime_native_boot.odrefresh_test_toggle",
83*795d594fSAndroid Build Coastguard Worker                           .default_value = "false"}}};
84*795d594fSAndroid Build Coastguard Worker 
85*795d594fSAndroid Build Coastguard Worker // An enumeration of the possible zygote configurations on Android.
86*795d594fSAndroid Build Coastguard Worker enum class ZygoteKind : uint8_t {
87*795d594fSAndroid Build Coastguard Worker   // 32-bit primary zygote, no secondary zygote.
88*795d594fSAndroid Build Coastguard Worker   kZygote32 = 0,
89*795d594fSAndroid Build Coastguard Worker   // 32-bit primary zygote, 64-bit secondary zygote.
90*795d594fSAndroid Build Coastguard Worker   kZygote32_64 = 1,
91*795d594fSAndroid Build Coastguard Worker   // 64-bit primary zygote, 32-bit secondary zygote.
92*795d594fSAndroid Build Coastguard Worker   kZygote64_32 = 2,
93*795d594fSAndroid Build Coastguard Worker   // 64-bit primary zygote, no secondary zygote.
94*795d594fSAndroid Build Coastguard Worker   kZygote64 = 3
95*795d594fSAndroid Build Coastguard Worker };
96*795d594fSAndroid Build Coastguard Worker 
97*795d594fSAndroid Build Coastguard Worker class OdrSystemProperties : public tools::SystemProperties {
98*795d594fSAndroid Build Coastguard Worker  public:
OdrSystemProperties(const std::unordered_map<std::string,std::string> * system_properties)99*795d594fSAndroid Build Coastguard Worker   explicit OdrSystemProperties(
100*795d594fSAndroid Build Coastguard Worker       const std::unordered_map<std::string, std::string>* system_properties)
101*795d594fSAndroid Build Coastguard Worker       : system_properties_(system_properties) {}
102*795d594fSAndroid Build Coastguard Worker 
103*795d594fSAndroid Build Coastguard Worker   // For supporting foreach loops.
begin()104*795d594fSAndroid Build Coastguard Worker   auto begin() const { return system_properties_->begin(); }
end()105*795d594fSAndroid Build Coastguard Worker   auto end() const { return system_properties_->end(); }
106*795d594fSAndroid Build Coastguard Worker 
107*795d594fSAndroid Build Coastguard Worker   // Return a given property's value if it exists in the map.
GetOrNull(const std::string & key)108*795d594fSAndroid Build Coastguard Worker   std::optional<std::string> GetOrNull(const std::string& key) const {
109*795d594fSAndroid Build Coastguard Worker     auto it = system_properties_->find(key);
110*795d594fSAndroid Build Coastguard Worker     return it != system_properties_->end() ? std::make_optional(it->second) : std::nullopt;
111*795d594fSAndroid Build Coastguard Worker   }
112*795d594fSAndroid Build Coastguard Worker 
113*795d594fSAndroid Build Coastguard Worker  protected:
GetProperty(const std::string & key)114*795d594fSAndroid Build Coastguard Worker   std::string GetProperty(const std::string& key) const override {
115*795d594fSAndroid Build Coastguard Worker     auto it = system_properties_->find(key);
116*795d594fSAndroid Build Coastguard Worker     return it != system_properties_->end() ? it->second : "";
117*795d594fSAndroid Build Coastguard Worker   }
118*795d594fSAndroid Build Coastguard Worker 
119*795d594fSAndroid Build Coastguard Worker  private:
120*795d594fSAndroid Build Coastguard Worker   const std::unordered_map<std::string, std::string>* system_properties_;
121*795d594fSAndroid Build Coastguard Worker };
122*795d594fSAndroid Build Coastguard Worker 
123*795d594fSAndroid Build Coastguard Worker // Configuration class for odrefresh. Exists to enable abstracting environment variables and
124*795d594fSAndroid Build Coastguard Worker // system properties into a configuration class for development and testing purposes.
125*795d594fSAndroid Build Coastguard Worker class OdrConfig final {
126*795d594fSAndroid Build Coastguard Worker  private:
127*795d594fSAndroid Build Coastguard Worker   std::string apex_info_list_file_;
128*795d594fSAndroid Build Coastguard Worker   std::string art_bin_dir_;
129*795d594fSAndroid Build Coastguard Worker   std::string dex2oat_;
130*795d594fSAndroid Build Coastguard Worker   std::string dex2oat_boot_classpath_;
131*795d594fSAndroid Build Coastguard Worker   bool dry_run_;
132*795d594fSAndroid Build Coastguard Worker   std::optional<bool> refresh_;
133*795d594fSAndroid Build Coastguard Worker   std::optional<bool> partial_compilation_;
134*795d594fSAndroid Build Coastguard Worker   InstructionSet isa_;
135*795d594fSAndroid Build Coastguard Worker   std::string program_name_;
136*795d594fSAndroid Build Coastguard Worker   std::string system_server_classpath_;
137*795d594fSAndroid Build Coastguard Worker   std::string boot_image_compiler_filter_;
138*795d594fSAndroid Build Coastguard Worker   std::string system_server_compiler_filter_;
139*795d594fSAndroid Build Coastguard Worker   ZygoteKind zygote_kind_;
140*795d594fSAndroid Build Coastguard Worker   std::string boot_classpath_;
141*795d594fSAndroid Build Coastguard Worker   std::string artifact_dir_;
142*795d594fSAndroid Build Coastguard Worker   std::string standalone_system_server_jars_;
143*795d594fSAndroid Build Coastguard Worker   bool compilation_os_mode_ = false;
144*795d594fSAndroid Build Coastguard Worker   bool minimal_ = false;
145*795d594fSAndroid Build Coastguard Worker   bool only_boot_images_ = false;
146*795d594fSAndroid Build Coastguard Worker 
147*795d594fSAndroid Build Coastguard Worker   // The current values of system properties listed in `kSystemProperties`.
148*795d594fSAndroid Build Coastguard Worker   std::unordered_map<std::string, std::string> system_properties_;
149*795d594fSAndroid Build Coastguard Worker 
150*795d594fSAndroid Build Coastguard Worker   // A helper for reading from `system_properties_`.
151*795d594fSAndroid Build Coastguard Worker   OdrSystemProperties odr_system_properties_;
152*795d594fSAndroid Build Coastguard Worker 
153*795d594fSAndroid Build Coastguard Worker  public:
OdrConfig(const char * program_name)154*795d594fSAndroid Build Coastguard Worker   explicit OdrConfig(const char* program_name)
155*795d594fSAndroid Build Coastguard Worker       : dry_run_(false),
156*795d594fSAndroid Build Coastguard Worker         isa_(InstructionSet::kNone),
157*795d594fSAndroid Build Coastguard Worker         program_name_(android::base::Basename(program_name)),
158*795d594fSAndroid Build Coastguard Worker         artifact_dir_(GetApexDataDalvikCacheDirectory(InstructionSet::kNone)),
159*795d594fSAndroid Build Coastguard Worker         odr_system_properties_(&system_properties_) {}
160*795d594fSAndroid Build Coastguard Worker 
GetApexInfoListFile()161*795d594fSAndroid Build Coastguard Worker   const std::string& GetApexInfoListFile() const { return apex_info_list_file_; }
162*795d594fSAndroid Build Coastguard Worker 
GetBootClasspathIsas()163*795d594fSAndroid Build Coastguard Worker   std::vector<InstructionSet> GetBootClasspathIsas() const {
164*795d594fSAndroid Build Coastguard Worker     const auto [isa32, isa64] = GetPotentialInstructionSets();
165*795d594fSAndroid Build Coastguard Worker     switch (zygote_kind_) {
166*795d594fSAndroid Build Coastguard Worker       case ZygoteKind::kZygote32:
167*795d594fSAndroid Build Coastguard Worker         CHECK_NE(isa32, art::InstructionSet::kNone);
168*795d594fSAndroid Build Coastguard Worker         return {isa32};
169*795d594fSAndroid Build Coastguard Worker       case ZygoteKind::kZygote32_64:
170*795d594fSAndroid Build Coastguard Worker         CHECK_NE(isa32, art::InstructionSet::kNone);
171*795d594fSAndroid Build Coastguard Worker         CHECK_NE(isa64, art::InstructionSet::kNone);
172*795d594fSAndroid Build Coastguard Worker         return {isa32, isa64};
173*795d594fSAndroid Build Coastguard Worker       case ZygoteKind::kZygote64_32:
174*795d594fSAndroid Build Coastguard Worker         CHECK_NE(isa32, art::InstructionSet::kNone);
175*795d594fSAndroid Build Coastguard Worker         CHECK_NE(isa64, art::InstructionSet::kNone);
176*795d594fSAndroid Build Coastguard Worker         return {isa64, isa32};
177*795d594fSAndroid Build Coastguard Worker       case ZygoteKind::kZygote64:
178*795d594fSAndroid Build Coastguard Worker         CHECK_NE(isa64, art::InstructionSet::kNone);
179*795d594fSAndroid Build Coastguard Worker         return {isa64};
180*795d594fSAndroid Build Coastguard Worker     }
181*795d594fSAndroid Build Coastguard Worker   }
182*795d594fSAndroid Build Coastguard Worker 
GetSystemServerIsa()183*795d594fSAndroid Build Coastguard Worker   InstructionSet GetSystemServerIsa() const {
184*795d594fSAndroid Build Coastguard Worker     const auto [isa32, isa64] = GetPotentialInstructionSets();
185*795d594fSAndroid Build Coastguard Worker     switch (zygote_kind_) {
186*795d594fSAndroid Build Coastguard Worker       case ZygoteKind::kZygote32:
187*795d594fSAndroid Build Coastguard Worker       case ZygoteKind::kZygote32_64:
188*795d594fSAndroid Build Coastguard Worker         CHECK_NE(isa32, art::InstructionSet::kNone);
189*795d594fSAndroid Build Coastguard Worker         return isa32;
190*795d594fSAndroid Build Coastguard Worker       case ZygoteKind::kZygote64_32:
191*795d594fSAndroid Build Coastguard Worker       case ZygoteKind::kZygote64:
192*795d594fSAndroid Build Coastguard Worker         CHECK_NE(isa64, art::InstructionSet::kNone);
193*795d594fSAndroid Build Coastguard Worker         return isa64;
194*795d594fSAndroid Build Coastguard Worker     }
195*795d594fSAndroid Build Coastguard Worker   }
196*795d594fSAndroid Build Coastguard Worker 
GetDex2oatBootClasspath()197*795d594fSAndroid Build Coastguard Worker   const std::string& GetDex2oatBootClasspath() const { return dex2oat_boot_classpath_; }
198*795d594fSAndroid Build Coastguard Worker 
GetArtifactDirectory()199*795d594fSAndroid Build Coastguard Worker   const std::string& GetArtifactDirectory() const { return artifact_dir_; }
200*795d594fSAndroid Build Coastguard Worker 
GetDex2Oat()201*795d594fSAndroid Build Coastguard Worker   std::string GetDex2Oat() const {
202*795d594fSAndroid Build Coastguard Worker     const char* prefix = UseDebugBinaries() ? "dex2oatd" : "dex2oat";
203*795d594fSAndroid Build Coastguard Worker     const char* suffix = "";
204*795d594fSAndroid Build Coastguard Worker     if (kIsTargetBuild) {
205*795d594fSAndroid Build Coastguard Worker       switch (zygote_kind_) {
206*795d594fSAndroid Build Coastguard Worker         case ZygoteKind::kZygote32:
207*795d594fSAndroid Build Coastguard Worker           suffix = "32";
208*795d594fSAndroid Build Coastguard Worker           break;
209*795d594fSAndroid Build Coastguard Worker         case ZygoteKind::kZygote32_64:
210*795d594fSAndroid Build Coastguard Worker         case ZygoteKind::kZygote64_32:
211*795d594fSAndroid Build Coastguard Worker         case ZygoteKind::kZygote64:
212*795d594fSAndroid Build Coastguard Worker           suffix = "64";
213*795d594fSAndroid Build Coastguard Worker           break;
214*795d594fSAndroid Build Coastguard Worker       }
215*795d594fSAndroid Build Coastguard Worker     }
216*795d594fSAndroid Build Coastguard Worker     return art_bin_dir_ + '/' + prefix + suffix;
217*795d594fSAndroid Build Coastguard Worker   }
218*795d594fSAndroid Build Coastguard Worker 
GetDryRun()219*795d594fSAndroid Build Coastguard Worker   bool GetDryRun() const { return dry_run_; }
HasPartialCompilation()220*795d594fSAndroid Build Coastguard Worker   bool HasPartialCompilation() const {
221*795d594fSAndroid Build Coastguard Worker     return partial_compilation_.has_value();
222*795d594fSAndroid Build Coastguard Worker   }
GetPartialCompilation()223*795d594fSAndroid Build Coastguard Worker   bool GetPartialCompilation() const {
224*795d594fSAndroid Build Coastguard Worker     return partial_compilation_.value_or(true);
225*795d594fSAndroid Build Coastguard Worker   }
GetRefresh()226*795d594fSAndroid Build Coastguard Worker   bool GetRefresh() const {
227*795d594fSAndroid Build Coastguard Worker     return refresh_.value_or(true);
228*795d594fSAndroid Build Coastguard Worker   }
GetSystemServerClasspath()229*795d594fSAndroid Build Coastguard Worker   const std::string& GetSystemServerClasspath() const {
230*795d594fSAndroid Build Coastguard Worker     return system_server_classpath_;
231*795d594fSAndroid Build Coastguard Worker   }
GetBootImageCompilerFilter()232*795d594fSAndroid Build Coastguard Worker   const std::string& GetBootImageCompilerFilter() const {
233*795d594fSAndroid Build Coastguard Worker     return boot_image_compiler_filter_;
234*795d594fSAndroid Build Coastguard Worker   }
GetSystemServerCompilerFilter()235*795d594fSAndroid Build Coastguard Worker   const std::string& GetSystemServerCompilerFilter() const {
236*795d594fSAndroid Build Coastguard Worker     return system_server_compiler_filter_;
237*795d594fSAndroid Build Coastguard Worker   }
GetCompilationOsMode()238*795d594fSAndroid Build Coastguard Worker   bool GetCompilationOsMode() const { return compilation_os_mode_; }
GetMinimal()239*795d594fSAndroid Build Coastguard Worker   bool GetMinimal() const { return minimal_; }
GetOnlyBootImages()240*795d594fSAndroid Build Coastguard Worker   bool GetOnlyBootImages() const { return only_boot_images_; }
GetSystemProperties()241*795d594fSAndroid Build Coastguard Worker   const OdrSystemProperties& GetSystemProperties() const { return odr_system_properties_; }
242*795d594fSAndroid Build Coastguard Worker 
SetApexInfoListFile(const std::string & file_path)243*795d594fSAndroid Build Coastguard Worker   void SetApexInfoListFile(const std::string& file_path) { apex_info_list_file_ = file_path; }
SetArtBinDir(const std::string & art_bin_dir)244*795d594fSAndroid Build Coastguard Worker   void SetArtBinDir(const std::string& art_bin_dir) { art_bin_dir_ = art_bin_dir; }
245*795d594fSAndroid Build Coastguard Worker 
SetDex2oatBootclasspath(const std::string & classpath)246*795d594fSAndroid Build Coastguard Worker   void SetDex2oatBootclasspath(const std::string& classpath) {
247*795d594fSAndroid Build Coastguard Worker     dex2oat_boot_classpath_ = classpath;
248*795d594fSAndroid Build Coastguard Worker   }
249*795d594fSAndroid Build Coastguard Worker 
SetArtifactDirectory(const std::string & artifact_dir)250*795d594fSAndroid Build Coastguard Worker   void SetArtifactDirectory(const std::string& artifact_dir) {
251*795d594fSAndroid Build Coastguard Worker     artifact_dir_ = artifact_dir;
252*795d594fSAndroid Build Coastguard Worker   }
253*795d594fSAndroid Build Coastguard Worker 
SetDryRun()254*795d594fSAndroid Build Coastguard Worker   void SetDryRun() { dry_run_ = true; }
SetPartialCompilation(bool value)255*795d594fSAndroid Build Coastguard Worker   void SetPartialCompilation(bool value) {
256*795d594fSAndroid Build Coastguard Worker     partial_compilation_ = value;
257*795d594fSAndroid Build Coastguard Worker   }
SetRefresh(bool value)258*795d594fSAndroid Build Coastguard Worker   void SetRefresh(bool value) {
259*795d594fSAndroid Build Coastguard Worker     refresh_ = value;
260*795d594fSAndroid Build Coastguard Worker   }
SetIsa(const InstructionSet isa)261*795d594fSAndroid Build Coastguard Worker   void SetIsa(const InstructionSet isa) { isa_ = isa; }
262*795d594fSAndroid Build Coastguard Worker 
SetSystemServerClasspath(const std::string & classpath)263*795d594fSAndroid Build Coastguard Worker   void SetSystemServerClasspath(const std::string& classpath) {
264*795d594fSAndroid Build Coastguard Worker     system_server_classpath_ = classpath;
265*795d594fSAndroid Build Coastguard Worker   }
266*795d594fSAndroid Build Coastguard Worker 
SetBootImageCompilerFilter(const std::string & filter)267*795d594fSAndroid Build Coastguard Worker   void SetBootImageCompilerFilter(const std::string& filter) {
268*795d594fSAndroid Build Coastguard Worker     boot_image_compiler_filter_ = filter;
269*795d594fSAndroid Build Coastguard Worker   }
SetSystemServerCompilerFilter(const std::string & filter)270*795d594fSAndroid Build Coastguard Worker   void SetSystemServerCompilerFilter(const std::string& filter) {
271*795d594fSAndroid Build Coastguard Worker     system_server_compiler_filter_ = filter;
272*795d594fSAndroid Build Coastguard Worker   }
273*795d594fSAndroid Build Coastguard Worker 
SetZygoteKind(ZygoteKind zygote_kind)274*795d594fSAndroid Build Coastguard Worker   void SetZygoteKind(ZygoteKind zygote_kind) { zygote_kind_ = zygote_kind; }
275*795d594fSAndroid Build Coastguard Worker 
GetBootClasspath()276*795d594fSAndroid Build Coastguard Worker   const std::string& GetBootClasspath() const { return boot_classpath_; }
277*795d594fSAndroid Build Coastguard Worker 
SetBootClasspath(const std::string & classpath)278*795d594fSAndroid Build Coastguard Worker   void SetBootClasspath(const std::string& classpath) { boot_classpath_ = classpath; }
279*795d594fSAndroid Build Coastguard Worker 
GetStandaloneSystemServerJars()280*795d594fSAndroid Build Coastguard Worker   const std::string& GetStandaloneSystemServerJars() const {
281*795d594fSAndroid Build Coastguard Worker     return standalone_system_server_jars_;
282*795d594fSAndroid Build Coastguard Worker   }
283*795d594fSAndroid Build Coastguard Worker 
SetStandaloneSystemServerJars(const std::string & jars)284*795d594fSAndroid Build Coastguard Worker   void SetStandaloneSystemServerJars(const std::string& jars) {
285*795d594fSAndroid Build Coastguard Worker     standalone_system_server_jars_ = jars;
286*795d594fSAndroid Build Coastguard Worker   }
287*795d594fSAndroid Build Coastguard Worker 
SetCompilationOsMode(bool value)288*795d594fSAndroid Build Coastguard Worker   void SetCompilationOsMode(bool value) { compilation_os_mode_ = value; }
289*795d594fSAndroid Build Coastguard Worker 
SetMinimal(bool value)290*795d594fSAndroid Build Coastguard Worker   void SetMinimal(bool value) { minimal_ = value; }
291*795d594fSAndroid Build Coastguard Worker 
SetOnlyBootImages(bool value)292*795d594fSAndroid Build Coastguard Worker   void SetOnlyBootImages(bool value) { only_boot_images_ = value; }
293*795d594fSAndroid Build Coastguard Worker 
MutableSystemProperties()294*795d594fSAndroid Build Coastguard Worker   std::unordered_map<std::string, std::string>* MutableSystemProperties() {
295*795d594fSAndroid Build Coastguard Worker     return &system_properties_;
296*795d594fSAndroid Build Coastguard Worker   }
297*795d594fSAndroid Build Coastguard Worker 
298*795d594fSAndroid Build Coastguard Worker  private:
299*795d594fSAndroid Build Coastguard Worker   // Returns a pair for the possible instruction sets for the configured instruction set
300*795d594fSAndroid Build Coastguard Worker   // architecture. The first item is the 32-bit architecture and the second item is the 64-bit
301*795d594fSAndroid Build Coastguard Worker   // architecture. The current `isa` is based on `kRuntimeISA` on target, odrefresh is compiled
302*795d594fSAndroid Build Coastguard Worker   // 32-bit by default so this method returns all options which are finessed based on the
303*795d594fSAndroid Build Coastguard Worker   // `ro.zygote` property.
GetPotentialInstructionSets()304*795d594fSAndroid Build Coastguard Worker   std::pair<InstructionSet, InstructionSet> GetPotentialInstructionSets() const {
305*795d594fSAndroid Build Coastguard Worker     switch (isa_) {
306*795d594fSAndroid Build Coastguard Worker       case art::InstructionSet::kArm:
307*795d594fSAndroid Build Coastguard Worker       case art::InstructionSet::kArm64:
308*795d594fSAndroid Build Coastguard Worker         return std::make_pair(art::InstructionSet::kArm, art::InstructionSet::kArm64);
309*795d594fSAndroid Build Coastguard Worker       case art::InstructionSet::kX86:
310*795d594fSAndroid Build Coastguard Worker       case art::InstructionSet::kX86_64:
311*795d594fSAndroid Build Coastguard Worker         return std::make_pair(art::InstructionSet::kX86, art::InstructionSet::kX86_64);
312*795d594fSAndroid Build Coastguard Worker       case art::InstructionSet::kRiscv64:
313*795d594fSAndroid Build Coastguard Worker         return std::make_pair(art::InstructionSet::kNone, art::InstructionSet::kRiscv64);
314*795d594fSAndroid Build Coastguard Worker       case art::InstructionSet::kThumb2:
315*795d594fSAndroid Build Coastguard Worker       case art::InstructionSet::kNone:
316*795d594fSAndroid Build Coastguard Worker         LOG(FATAL) << "Invalid instruction set " << isa_;
317*795d594fSAndroid Build Coastguard Worker         return std::make_pair(art::InstructionSet::kNone, art::InstructionSet::kNone);
318*795d594fSAndroid Build Coastguard Worker     }
319*795d594fSAndroid Build Coastguard Worker   }
320*795d594fSAndroid Build Coastguard Worker 
UseDebugBinaries()321*795d594fSAndroid Build Coastguard Worker   bool UseDebugBinaries() const { return program_name_ == "odrefreshd"; }
322*795d594fSAndroid Build Coastguard Worker 
323*795d594fSAndroid Build Coastguard Worker   OdrConfig() = delete;
324*795d594fSAndroid Build Coastguard Worker   OdrConfig(const OdrConfig&) = delete;
325*795d594fSAndroid Build Coastguard Worker   OdrConfig& operator=(const OdrConfig&) = delete;
326*795d594fSAndroid Build Coastguard Worker };
327*795d594fSAndroid Build Coastguard Worker 
328*795d594fSAndroid Build Coastguard Worker }  // namespace odrefresh
329*795d594fSAndroid Build Coastguard Worker }  // namespace art
330*795d594fSAndroid Build Coastguard Worker 
331*795d594fSAndroid Build Coastguard Worker #endif  // ART_ODREFRESH_ODR_CONFIG_H_
332