Skip to content

Commit 58cfbfc

Browse files
authored
Merge branch 'main' into hermetic
2 parents 0da7ddf + 4cf78f8 commit 58cfbfc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+2513
-741
lines changed

base/cvd/BUILD.dosfstools.bazel

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package(
2+
default_visibility = ["@//:android_cuttlefish"],
3+
)
4+
5+
cc_binary(
6+
name = "mkfs.fat",
7+
srcs = [
8+
"src/blkdev/blkdev.c",
9+
"src/blkdev/blkdev.h",
10+
"src/blkdev/linux_version.c",
11+
"src/blkdev/linux_version.h",
12+
"src/charconv.c",
13+
"src/charconv.h",
14+
"src/common.c",
15+
"src/common.h",
16+
"src/device_info.c",
17+
"src/device_info.h",
18+
"src/endian_compat.h",
19+
"src/fsck.fat.h",
20+
"src/mkfs.fat.c",
21+
"src/msdos_fs.h",
22+
],
23+
includes = [
24+
"src",
25+
"src/blkdev",
26+
],
27+
local_defines = [
28+
"HAVE_DECL_GETMNTENT",
29+
"HAVE_ENDIAN_H",
30+
"HAVE_LINUX_FD_H",
31+
"HAVE_LINUX_HDREG_H",
32+
"HAVE_LINUX_LOOP_H",
33+
"HAVE_LINUX_VERSION_H",
34+
"HAVE_SYS_QUEUE_H",
35+
"HAVE_SYS_SYSMACROS_H",
36+
],
37+
deps = [
38+
"@//build_external/dosfstools:dosfstools_version",
39+
],
40+
)

base/cvd/MODULE.bazel

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,3 +555,14 @@ git_repository(
555555
commit = "d8eac1f8699541416afdf93333772ef2e0509773",
556556
remote = "https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools",
557557
)
558+
559+
git_repository(
560+
name = "dosfstools",
561+
build_file = "@//:BUILD.dosfstools.bazel",
562+
commit = "289a48b9cb5b3c589391d28aa2515c325c932c7a",
563+
remote = "https://github.com/dosfstools/dosfstools",
564+
patch_strip = 1,
565+
patches = [
566+
"@//build_external/dosfstools:PATCH.vasprintf.patch",
567+
],
568+
)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package(
2+
default_visibility = ["@dosfstools//:__subpackages__"],
3+
)
4+
5+
cc_library(
6+
name = "dosfstools_version",
7+
hdrs = [
8+
"src/version.h",
9+
],
10+
strip_include_prefix = "//build_external/dosfstools/src",
11+
)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Older distros don't have it, but newer distros do. Normally this would be
2+
handled by autoconf, but that's unnecessarily complicated to integrate
3+
into the bazel build, and fortunately it's only used by xasprintf.
4+
5+
diff --git a/src/common.c b/src/common.c
6+
index aa3a02b..9ab7f09 100644
7+
--- a/src/common.c
8+
+++ b/src/common.c
9+
@@ -117,8 +117,7 @@ int min(int a, int b)
10+
}
11+
12+
13+
-#ifndef HAVE_VASPRINTF
14+
-static int vasprintf(char **strp, const char *fmt, va_list va)
15+
+static int dosfstools_vasprintf(char **strp, const char *fmt, va_list va)
16+
{
17+
int length;
18+
va_list vacopy;
19+
@@ -137,7 +136,6 @@ static int vasprintf(char **strp, const char *fmt, va_list va)
20+
21+
return vsnprintf(*strp, length + 1, fmt, va);
22+
}
23+
-#endif
24+
25+
int xasprintf(char **strp, const char *fmt, ...)
26+
{
27+
@@ -145,7 +143,7 @@ int xasprintf(char **strp, const char *fmt, ...)
28+
int retval;
29+
30+
va_start(va, fmt);
31+
- retval = vasprintf(strp, fmt, va);
32+
+ retval = dosfstools_vasprintf(strp, fmt, va);
33+
va_end(va);
34+
35+
if (retval < 0)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#ifndef _version_h
2+
#define _version_h
3+
4+
#define VERSION "cuttlefish"
5+
#define VERSION_DATE "common"
6+
7+
#endif

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ cc_binary(
4343
"//cuttlefish/host/commands/assemble_cvd:flags_defaults",
4444
"//cuttlefish/host/commands/assemble_cvd:touchpad",
4545
"//cuttlefish/host/libs/command_util",
46+
"//cuttlefish/host/libs/config:ap_boot_flow",
4647
"//cuttlefish/host/libs/config:config_flag",
4748
"//cuttlefish/host/libs/config:custom_actions",
4849
"//cuttlefish/host/libs/config:fetcher_config",
@@ -76,6 +77,8 @@ cc_library(
7677
"//cuttlefish/common/libs/utils:subprocess",
7778
"//cuttlefish/host/commands/assemble_cvd:bootconfig_args",
7879
"//cuttlefish/host/libs/avb",
80+
"//cuttlefish/host/libs/config:ap_boot_flow",
81+
"//cuttlefish/host/libs/config:boot_flow",
7982
"//cuttlefish/host/libs/config:cuttlefish_config",
8083
"//cuttlefish/host/libs/config:kernel_args",
8184
"//cuttlefish/host/libs/vm_manager",
@@ -211,6 +214,8 @@ cc_library(
211214
"//cuttlefish/host/commands/assemble_cvd:flags_defaults",
212215
"//cuttlefish/host/commands/assemble_cvd:super_image_mixer",
213216
"//cuttlefish/host/libs/avb",
217+
"//cuttlefish/host/libs/config:ap_boot_flow",
218+
"//cuttlefish/host/libs/config:boot_flow",
214219
"//cuttlefish/host/libs/config:cuttlefish_config",
215220
"//cuttlefish/host/libs/config:data_image",
216221
"//cuttlefish/host/libs/config:fetcher_config",
@@ -302,6 +307,7 @@ cc_library(
302307
"//cuttlefish/host/commands/assemble_cvd:misc_info",
303308
"//cuttlefish/host/commands/assemble_cvd:network_flags",
304309
"//cuttlefish/host/commands/assemble_cvd:touchpad",
310+
"//cuttlefish/host/libs/config:ap_boot_flow",
305311
"//cuttlefish/host/libs/config:config_constants",
306312
"//cuttlefish/host/libs/config:cuttlefish_config",
307313
"//cuttlefish/host/libs/config:display",

base/cvd/cuttlefish/host/commands/assemble_cvd/assemble_cvd.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ Result<const CuttlefishConfig*> InitFilesystemAndCreateConfig(
371371
for (const auto& instance : config.Instances()) {
372372
auto os_builder = OsCompositeDiskBuilder(config, instance);
373373
creating_os_disk |= CF_EXPECT(os_builder.WillRebuildCompositeDisk());
374-
if (instance.ap_boot_flow() != CuttlefishConfig::InstanceSpecific::APBootFlow::None) {
374+
if (instance.ap_boot_flow() != APBootFlow::None) {
375375
auto ap_builder = ApCompositeDiskBuilder(config, instance);
376376
creating_os_disk |= CF_EXPECT(ap_builder.WillRebuildCompositeDisk());
377377
}

base/cvd/cuttlefish/host/commands/assemble_cvd/boot_config.cc

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include "common/libs/utils/subprocess.h"
3333
#include "host/commands/assemble_cvd/bootconfig_args.h"
3434
#include "host/libs/avb/avb.h"
35+
#include "host/libs/config/ap_boot_flow.h"
36+
#include "host/libs/config/boot_flow.h"
3537
#include "host/libs/config/cuttlefish_config.h"
3638
#include "host/libs/config/kernel_args.h"
3739
#include "host/libs/vm_manager/crosvm_manager.h"
@@ -87,8 +89,7 @@ void WriteEFIEnvironment(const CuttlefishConfig::InstanceSpecific& instance,
8789
}
8890

8991
size_t WriteEnvironment(const CuttlefishConfig::InstanceSpecific& instance,
90-
const CuttlefishConfig::InstanceSpecific::BootFlow& flow,
91-
const std::string& kernel_args,
92+
const BootFlow& flow, const std::string& kernel_args,
9293
const std::string& env_path) {
9394
std::ostringstream env;
9495

@@ -100,20 +101,20 @@ size_t WriteEnvironment(const CuttlefishConfig::InstanceSpecific& instance,
100101
}
101102

102103
switch (flow) {
103-
case CuttlefishConfig::InstanceSpecific::BootFlow::Android:
104+
case BootFlow::Android:
104105
WriteAndroidEnvironment(env, instance);
105106
break;
106-
case CuttlefishConfig::InstanceSpecific::BootFlow::AndroidEfiLoader:
107+
case BootFlow::AndroidEfiLoader:
107108
WriteEFIEnvironment(instance, 1, env);
108109
break;
109-
case CuttlefishConfig::InstanceSpecific::BootFlow::ChromeOs:
110+
case BootFlow::ChromeOs:
110111
WriteEFIEnvironment(instance, 2, env);
111112
break;
112-
case CuttlefishConfig::InstanceSpecific::BootFlow::ChromeOsDisk:
113+
case BootFlow::ChromeOsDisk:
113114
WriteEFIEnvironment(instance, 12, env);
114115
break;
115-
case CuttlefishConfig::InstanceSpecific::BootFlow::Fuchsia:
116-
case CuttlefishConfig::InstanceSpecific::BootFlow::Linux:
116+
case BootFlow::Fuchsia:
117+
case BootFlow::Linux:
117118
WriteEFIEnvironment(instance, {}, env);
118119
break;
119120
}
@@ -146,8 +147,7 @@ std::unordered_map<std::string, std::string> ReplaceKernelBootArgs(
146147
Result<void> PrepareBootEnvImage(
147148
const CuttlefishConfig& config,
148149
const CuttlefishConfig::InstanceSpecific& instance,
149-
const std::string& image_path,
150-
const CuttlefishConfig::InstanceSpecific::BootFlow& flow) {
150+
const std::string& image_path, const BootFlow& flow) {
151151
auto tmp_boot_env_image_path = image_path + ".tmp";
152152
auto uboot_env_path = instance.PerInstancePath("mkenvimg_input");
153153
auto kernel_cmdline =
@@ -215,11 +215,9 @@ Result<void> PrepareBootEnvImage(
215215
Result<void> InitBootloaderEnvPartition(
216216
const CuttlefishConfig& config,
217217
const CuttlefishConfig::InstanceSpecific& instance) {
218-
if (instance.ap_boot_flow() ==
219-
CuttlefishConfig::InstanceSpecific::APBootFlow::Grub) {
218+
if (instance.ap_boot_flow() == APBootFlow::Grub) {
220219
CF_EXPECT(PrepareBootEnvImage(
221-
config, instance, instance.ap_uboot_env_image_path(),
222-
CuttlefishConfig::InstanceSpecific::BootFlow::Linux));
220+
config, instance, instance.ap_uboot_env_image_path(), BootFlow::Linux));
223221
}
224222
CF_EXPECT(PrepareBootEnvImage(
225223
config, instance, instance.uboot_env_image_path(), instance.boot_flow()));

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ cc_library(
6767
strip_include_prefix = "//cuttlefish",
6868
deps = [
6969
"//cuttlefish/common/libs/utils:files",
70+
"//cuttlefish/host/libs/config:ap_boot_flow",
71+
"//cuttlefish/host/libs/config:boot_flow",
7072
"//cuttlefish/host/libs/config:cuttlefish_config",
7173
"//cuttlefish/host/libs/image_aggregator",
7274
],
@@ -125,6 +127,7 @@ cc_library(
125127
deps = [
126128
"//cuttlefish/common/libs/utils:files",
127129
"//cuttlefish/common/libs/utils:result",
130+
"//cuttlefish/host/libs/config:boot_flow",
128131
"//cuttlefish/host/libs/config:cuttlefish_config",
129132
"//cuttlefish/host/libs/config:data_image",
130133
],
@@ -233,6 +236,7 @@ cc_library(
233236
"//cuttlefish/host/commands/assemble_cvd/disk:generate_persistent_bootconfig",
234237
"//cuttlefish/host/commands/assemble_cvd:boot_config",
235238
"//cuttlefish/host/commands/assemble_cvd:boot_image_utils",
239+
"//cuttlefish/host/libs/config:ap_boot_flow",
236240
"//cuttlefish/host/libs/config:cuttlefish_config",
237241
"//cuttlefish/host/libs/config:known_paths",
238242
"//cuttlefish/host/libs/feature",
@@ -278,6 +282,7 @@ cc_library(
278282
"//cuttlefish/host/commands/assemble_cvd/disk:factory_reset_protected",
279283
"//cuttlefish/host/commands/assemble_cvd/disk:generate_persistent_vbmeta",
280284
"//cuttlefish/host/commands/assemble_cvd:disk_builder",
285+
"//cuttlefish/host/libs/config:ap_boot_flow",
281286
"//cuttlefish/host/libs/config:cuttlefish_config",
282287
"//cuttlefish/host/libs/image_aggregator",
283288
"//cuttlefish/host/libs/vm_manager",
@@ -363,6 +368,7 @@ cc_library(
363368
"//cuttlefish/host/commands/assemble_cvd/disk:chromeos_composite_disk",
364369
"//cuttlefish/host/commands/assemble_cvd/disk:fuchsia_composite_disk",
365370
"//cuttlefish/host/commands/assemble_cvd/disk:linux_composite_disk",
371+
"//cuttlefish/host/libs/config:boot_flow",
366372
"//cuttlefish/host/libs/config:cuttlefish_config",
367373
"//cuttlefish/host/libs/image_aggregator",
368374
],

base/cvd/cuttlefish/host/commands/assemble_cvd/disk/ap_composite_disk.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919
#include <vector>
2020

2121
#include "cuttlefish/common/libs/utils/files.h"
22+
#include "cuttlefish/host/libs/config/ap_boot_flow.h"
2223
#include "cuttlefish/host/libs/config/cuttlefish_config.h"
2324
#include "cuttlefish/host/libs/image_aggregator/image_aggregator.h"
2425

2526
namespace cuttlefish {
2627

27-
using APBootFlow = CuttlefishConfig::InstanceSpecific::APBootFlow;
28-
2928
std::vector<ImagePartition> GetApCompositeDiskConfig(
3029
const CuttlefishConfig& config,
3130
const CuttlefishConfig::InstanceSpecific& instance) {

0 commit comments

Comments
 (0)