• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ART_ODREFRESH_ODR_ARTIFACTS_H_
18 #define ART_ODREFRESH_ODR_ARTIFACTS_H_
19 
20 #include <iosfwd>
21 #include <string>
22 
23 #include <base/file_utils.h>
24 
25 namespace art {
26 namespace odrefresh {
27 
28 // A grouping of odrefresh generated artifacts.
29 class OdrArtifacts {
30  public:
ForBootImage(const std::string & image_path)31   static OdrArtifacts ForBootImage(const std::string& image_path) {
32     return OdrArtifacts(image_path, /*image_kind=*/"image", /*aot_extension=*/"oat");
33   }
34 
ForSystemServer(const std::string & image_path)35   static OdrArtifacts ForSystemServer(const std::string& image_path) {
36     return OdrArtifacts(image_path, /*image_kind=*/"app-image", /*aot_extension=*/"odex");
37   }
38 
ImagePath()39   const std::string& ImagePath() const { return image_path_; }
ImageKind()40   const char* ImageKind() const { return image_kind_; }
OatPath()41   const std::string& OatPath() const { return oat_path_; }
VdexPath()42   const std::string& VdexPath() const { return vdex_path_; }
43 
44  private:
OdrArtifacts(const std::string & image_path,const char * image_kind,const char * aot_extension)45   OdrArtifacts(const std::string& image_path, const char* image_kind, const char* aot_extension)
46       : image_path_{image_path},
47         image_kind_{image_kind},
48         oat_path_{ReplaceFileExtension(image_path, aot_extension)},
49         vdex_path_{ReplaceFileExtension(image_path, "vdex")} {}
50 
51   OdrArtifacts() = delete;
52   OdrArtifacts(const OdrArtifacts&) = delete;
53   OdrArtifacts& operator=(const OdrArtifacts&) = delete;
54 
55   const std::string image_path_;
56   const char* image_kind_;
57   const std::string oat_path_;
58   const std::string vdex_path_;
59 };
60 
61 }  // namespace odrefresh
62 }  // namespace art
63 
64 #endif  // ART_ODREFRESH_ODR_ARTIFACTS_H_
65