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#include <string_view>
22
26
27namespace cuttlefish {
28
49 public:
50 virtual ~AndroidBuild() = default;
51
53 virtual std::string Name() const = 0;
54
55 virtual PrettyStruct Pretty() = 0;
56
67 /*
68 * A file on the host that represents an image. If the file is not already
69 * stored in a distinct file on the host and `extract` is `true`, it is first
70 * saved to the directory provided in `SetExtractDir` and the path to the
71 * generated file is returned. If `SetExtractDir` was never called and the
72 * file needs to be extracted, returns an error.
73 *
74 * It's possible for there to be an image file in `Images()` that cannot be
75 * extracted to the filesystem, if a metadata file reports that an image or
76 * partition should exist, but it's not actually present anywhere.
77 *
78 * In general callers should rely on the default `extract = true`, it is used
79 * inside the implementation to scan all `AndroidBuild` implementations for
80 * any that can provide the file without extracting it.
81 */
82 virtual Result<std::string> ImageFile(std::string_view name,
83 bool extract = true);
84
90 virtual Result<void> SetExtractDir(std::string_view);
91
93
102
107
108 friend std::ostream& operator<<(std::ostream&, const AndroidBuild&);
109
110 // For libfmt
111 friend std::string format_as(const AndroidBuild&);
112};
113
116
117} // namespace cuttlefish
Definition: android_build.h:48
virtual Result< std::set< std::string, std::less< void > > > LogicalPartitions()
Definition: android_build.cc:57
virtual Result< std::string > ImageFile(std::string_view name, bool extract=true)
Definition: android_build.cc:34
friend std::ostream & operator<<(std::ostream &, const AndroidBuild &)
Definition: android_build.cc:66
virtual Result< std::set< std::string, std::less< void > > > AbPartitions()
Definition: android_build.cc:42
friend std::string format_as(const AndroidBuild &)
Definition: android_build.cc:70
virtual Result< std::set< std::string, std::less< void > > > Images()
Definition: android_build.cc:30
virtual PrettyStruct Pretty()=0
virtual std::string Name() const =0
virtual Result< std::set< std::string, std::less< void > > > VendorPartitions()
Definition: android_build.cc:52
virtual Result< void > SetExtractDir(std::string_view)
Definition: android_build.cc:40
virtual Result< std::set< std::string, std::less< void > > > PhysicalPartitions()
Definition: android_build.cc:62
virtual Result< std::set< std::string, std::less< void > > > SystemPartitions()
Definition: android_build.cc:47
virtual ~AndroidBuild()=default
Definition: struct.h:60
char * name
Definition: libf2fs.c:1403
Definition: alloc_driver.h:20
PrettyStruct Pretty(AndroidBuild &build, PrettyAdlPlaceholder)
Definition: android_build.cc:72
tl::expected< T, StackTraceError > Result
Definition: result_type.h:30
Definition: pretty.h:20