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_ARTIFACTS_H_ 18*795d594fSAndroid Build Coastguard Worker #define ART_ODREFRESH_ODR_ARTIFACTS_H_ 19*795d594fSAndroid Build Coastguard Worker 20*795d594fSAndroid Build Coastguard Worker #include <iosfwd> 21*795d594fSAndroid Build Coastguard Worker #include <string> 22*795d594fSAndroid Build Coastguard Worker 23*795d594fSAndroid Build Coastguard Worker #include "base/file_utils.h" 24*795d594fSAndroid Build Coastguard Worker 25*795d594fSAndroid Build Coastguard Worker namespace art { 26*795d594fSAndroid Build Coastguard Worker namespace odrefresh { 27*795d594fSAndroid Build Coastguard Worker 28*795d594fSAndroid Build Coastguard Worker // A grouping of odrefresh generated artifacts. 29*795d594fSAndroid Build Coastguard Worker class OdrArtifacts { 30*795d594fSAndroid Build Coastguard Worker public: ForBootImage(const std::string & image_path)31*795d594fSAndroid Build Coastguard Worker static OdrArtifacts ForBootImage(const std::string& image_path) { 32*795d594fSAndroid Build Coastguard Worker return OdrArtifacts(image_path, /*image_kind=*/"image", /*aot_extension=*/kOatExtension); 33*795d594fSAndroid Build Coastguard Worker } 34*795d594fSAndroid Build Coastguard Worker ForSystemServer(const std::string & image_path)35*795d594fSAndroid Build Coastguard Worker static OdrArtifacts ForSystemServer(const std::string& image_path) { 36*795d594fSAndroid Build Coastguard Worker return OdrArtifacts(image_path, /*image_kind=*/"app-image", /*aot_extension=*/kOdexExtension); 37*795d594fSAndroid Build Coastguard Worker } 38*795d594fSAndroid Build Coastguard Worker ImagePath()39*795d594fSAndroid Build Coastguard Worker const std::string& ImagePath() const { return image_path_; } ImageKind()40*795d594fSAndroid Build Coastguard Worker const char* ImageKind() const { return image_kind_; } OatPath()41*795d594fSAndroid Build Coastguard Worker const std::string& OatPath() const { return oat_path_; } VdexPath()42*795d594fSAndroid Build Coastguard Worker const std::string& VdexPath() const { return vdex_path_; } 43*795d594fSAndroid Build Coastguard Worker 44*795d594fSAndroid Build Coastguard Worker private: OdrArtifacts(const std::string & image_path,const char * image_kind,const char * aot_extension)45*795d594fSAndroid Build Coastguard Worker OdrArtifacts(const std::string& image_path, const char* image_kind, const char* aot_extension) 46*795d594fSAndroid Build Coastguard Worker : image_path_{image_path}, 47*795d594fSAndroid Build Coastguard Worker image_kind_{image_kind}, 48*795d594fSAndroid Build Coastguard Worker oat_path_{ReplaceFileExtension(image_path, aot_extension)}, 49*795d594fSAndroid Build Coastguard Worker vdex_path_{ReplaceFileExtension(image_path, kVdexExtension)} {} 50*795d594fSAndroid Build Coastguard Worker 51*795d594fSAndroid Build Coastguard Worker OdrArtifacts() = delete; 52*795d594fSAndroid Build Coastguard Worker OdrArtifacts(const OdrArtifacts&) = delete; 53*795d594fSAndroid Build Coastguard Worker OdrArtifacts& operator=(const OdrArtifacts&) = delete; 54*795d594fSAndroid Build Coastguard Worker 55*795d594fSAndroid Build Coastguard Worker const std::string image_path_; 56*795d594fSAndroid Build Coastguard Worker const char* image_kind_; 57*795d594fSAndroid Build Coastguard Worker const std::string oat_path_; 58*795d594fSAndroid Build Coastguard Worker const std::string vdex_path_; 59*795d594fSAndroid Build Coastguard Worker }; 60*795d594fSAndroid Build Coastguard Worker 61*795d594fSAndroid Build Coastguard Worker } // namespace odrefresh 62*795d594fSAndroid Build Coastguard Worker } // namespace art 63*795d594fSAndroid Build Coastguard Worker 64*795d594fSAndroid Build Coastguard Worker #endif // ART_ODREFRESH_ODR_ARTIFACTS_H_ 65