Android-cuttlefish cvd tool
android_build.h
Go to the documentation of this file.
1//
2// Copyright (C) 2025 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#pragma once
17
18#include <functional>
19#include <ostream>
20#include <set>
21
22#include "absl/strings/string_view.h"
23
27
28namespace cuttlefish {
29
50 public:
51 virtual ~AndroidBuild() = default;
52
54 virtual std::string Name() const = 0;
55
56 virtual PrettyStruct Pretty() = 0;
57
68 /*
69 * A file on the host that represents an image. If the file is not already
70 * stored in a distinct file on the host and `extract` is `true`, it is first
71 * saved to the directory provided in `SetExtractDir` and the path to the
72 * generated file is returned. If `SetExtractDir` was never called and the
73 * file needs to be extracted, returns an error.
74 *
75 * It's possible for there to be an image file in `Images()` that cannot be
76 * extracted to the filesystem, if a metadata file reports that an image or
77 * partition should exist, but it's not actually present anywhere.
78 *
79 * In general callers should rely on the default `extract = true`, it is used
80 * inside the implementation to scan all `AndroidBuild` implementations for
81 * any that can provide the file without extracting it.
82 */
83 virtual Result<std::string> ImageFile(absl::string_view name,
84 bool extract = true);
85
91 virtual Result<void> SetExtractDir(absl::string_view);
92
94
103
108
109 friend std::ostream& operator<<(std::ostream&, const AndroidBuild&);
110
111 // For libfmt
112 friend std::string format_as(const AndroidBuild&);
113};
114
117
118} // namespace cuttlefish
Definition: android_build.h:49
virtual Result< std::set< std::string, std::less< void > > > LogicalPartitions()
Definition: android_build.cc:58
friend std::ostream & operator<<(std::ostream &, const AndroidBuild &)
Definition: android_build.cc:67
virtual Result< std::set< std::string, std::less< void > > > AbPartitions()
Definition: android_build.cc:43
friend std::string format_as(const AndroidBuild &)
Definition: android_build.cc:71
virtual Result< std::set< std::string, std::less< void > > > Images()
Definition: android_build.cc:31
virtual PrettyStruct Pretty()=0
virtual std::string Name() const =0
virtual Result< std::set< std::string, std::less< void > > > VendorPartitions()
Definition: android_build.cc:53
virtual Result< void > SetExtractDir(absl::string_view)
Definition: android_build.cc:41
virtual Result< std::string > ImageFile(absl::string_view name, bool extract=true)
Definition: android_build.cc:35
virtual Result< std::set< std::string, std::less< void > > > PhysicalPartitions()
Definition: android_build.cc:63
virtual Result< std::set< std::string, std::less< void > > > SystemPartitions()
Definition: android_build.cc:48
virtual ~AndroidBuild()=default
Definition: struct.h:60
Definition: alloc_driver.h:21
PrettyStruct Pretty(AndroidBuild &build, PrettyAdlPlaceholder)
Definition: android_build.cc:73
tl::expected< T, StackTraceError< E > > Result
Definition: result_type.h:30
Definition: pretty.h:20