blob: 30932e21022dd19f7727fd649077cad77c2bc5de [file] [log] [blame]
Orion Hodson4c3ade62021-02-10 14:07:10 +00001/*
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
25namespace art {
26namespace odrefresh {
27
28// A grouping of odrefresh generated artifacts.
29class OdrArtifacts {
30 public:
Jiakai Zhang884e22f2021-12-23 20:04:46 +000031 static OdrArtifacts ForBootImage(const std::string& image_path) {
Orion Hodson4c3ade62021-02-10 14:07:10 +000032 return OdrArtifacts(image_path, "oat");
33 }
34
35 static OdrArtifacts ForSystemServer(const std::string& image_path) {
36 return OdrArtifacts(image_path, "odex");
37 }
38
39 const std::string& ImagePath() const { return image_path_; }
40 const std::string& OatPath() const { return oat_path_; }
41 const std::string& VdexPath() const { return vdex_path_; }
42
43 private:
44 OdrArtifacts(const std::string& image_path, const char* aot_extension)
45 : image_path_{image_path},
46 oat_path_{ReplaceFileExtension(image_path, aot_extension)},
47 vdex_path_{ReplaceFileExtension(image_path, "vdex")} {}
48
49 OdrArtifacts() = delete;
50 OdrArtifacts(const OdrArtifacts&) = delete;
51 OdrArtifacts& operator=(const OdrArtifacts&) = delete;
52
53 const std::string image_path_;
54 const std::string oat_path_;
55 const std::string vdex_path_;
56};
57
58} // namespace odrefresh
59} // namespace art
60
61#endif // ART_ODREFRESH_ODR_ARTIFACTS_H_