Skip to content

Commit c7c3009

Browse files
committed
Add an AndroidBuild implementation for cvd fetch-ed builds
Bug: b/471835731
1 parent dd74a71 commit c7c3009

File tree

3 files changed

+103
-0
lines changed

3 files changed

+103
-0
lines changed

base/cvd/cuttlefish/host/commands/assemble_cvd/android_build/BUILD.bazel

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,25 @@ cf_cc_library(
2929
],
3030
)
3131

32+
cf_cc_library(
33+
name = "fetched_android_build",
34+
srcs = ["fetched_android_build.cc"],
35+
hdrs = ["fetched_android_build.h"],
36+
deps = [
37+
"//cuttlefish/common/libs/key_equals_value",
38+
"//cuttlefish/host/commands/assemble_cvd/android_build",
39+
"//cuttlefish/host/commands/assemble_cvd/android_build:combined_android_build",
40+
"//cuttlefish/host/commands/assemble_cvd/android_build:img_zip",
41+
"//cuttlefish/host/commands/assemble_cvd/android_build:target_files",
42+
"//cuttlefish/host/libs/config:fetcher_config",
43+
"//cuttlefish/host/libs/config:file_source",
44+
"//cuttlefish/result",
45+
"//libbase",
46+
"@abseil-cpp//absl/strings:str_format",
47+
"@fmt",
48+
],
49+
)
50+
3251
cf_cc_library(
3352
name = "find_build_archive",
3453
srcs = ["find_build_archive.cc"],
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
#include "cuttlefish/host/commands/assemble_cvd/android_build/fetched_android_build.h"
17+
18+
#include <memory>
19+
#include <utility>
20+
#include <vector>
21+
22+
#include "cuttlefish/host/commands/assemble_cvd/android_build/android_build.h"
23+
#include "cuttlefish/host/commands/assemble_cvd/android_build/combined_android_build.h"
24+
#include "cuttlefish/host/commands/assemble_cvd/android_build/img_zip.h"
25+
#include "cuttlefish/host/commands/assemble_cvd/android_build/target_files.h"
26+
#include "cuttlefish/host/libs/config/fetcher_config.h"
27+
#include "cuttlefish/host/libs/config/file_source.h"
28+
#include "cuttlefish/result/result.h"
29+
30+
namespace cuttlefish {
31+
32+
Result<std::unique_ptr<AndroidBuild>> FetchedAndroidBuild(
33+
const FetcherConfig& config, FileSource source) {
34+
Result<std::unique_ptr<AndroidBuild>> img_zip = ImgZip(config, source);
35+
Result<std::unique_ptr<AndroidBuild>> target = TargetFiles(config, source);
36+
37+
if (!img_zip.ok() && !target.ok()) {
38+
CF_EXPECT(std::move(img_zip));
39+
return CF_ERR("unreachable");
40+
}
41+
42+
std::vector<std::unique_ptr<AndroidBuild>> builds;
43+
if (img_zip.ok()) {
44+
builds.emplace_back(std::move(*img_zip));
45+
}
46+
if (target.ok()) {
47+
builds.emplace_back(std::move(*target));
48+
}
49+
return CF_EXPECT(
50+
CombinedAndroidBuild("FetchedAndroidBuild", std::move(builds)));
51+
}
52+
53+
} // namespace cuttlefish
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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 <memory>
19+
20+
#include "cuttlefish/host/commands/assemble_cvd/android_build/android_build.h"
21+
#include "cuttlefish/host/libs/config/fetcher_config.h"
22+
#include "cuttlefish/host/libs/config/file_source.h"
23+
#include "cuttlefish/result/result.h"
24+
25+
namespace cuttlefish {
26+
27+
/** Represents a build downloaded by `cvd fetch`. */
28+
Result<std::unique_ptr<AndroidBuild>> FetchedAndroidBuild(const FetcherConfig&,
29+
FileSource);
30+
31+
} // namespace cuttlefish

0 commit comments

Comments
 (0)