Skip to content

Commit 5b4ad17

Browse files
committed
Add pretty-printing for GuestConfig
Sample output: ``` Guest configs: { GuestConfig { target_arch: x86_64, device_type: phone, bootconfig_supported: 1, hctr2_supported: 1, android_version_number: "16", gfxstream_supported: 1, gfxstream_gl_program_binary_link_status_supported: 1, vhost_user_vsock: 0, supports_bgra_framebuffers: 0, prefer_drm_virgl_when_supported: 0, mouse_supported: 0, gamepad_supported: 0, ti50_emulator: "", custom_keyboard_config: (absent), domkey_mapping_config: (absent), output_audio_streams_count: 1, audio_settings: (absent), enforce_mac80211_hwsim: (absent), blank_data_image_mb: 0 } } ```
1 parent ed33e0a commit 5b4ad17

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ cf_cc_binary(
6868
"//cuttlefish/host/libs/config/fastboot",
6969
"//cuttlefish/host/libs/feature:inject",
7070
"//cuttlefish/posix:symlink",
71+
"//cuttlefish/pretty:vector",
7172
"//libbase",
7273
"@abseil-cpp//absl/log",
7374
"@abseil-cpp//absl/strings",
@@ -366,6 +367,10 @@ cf_cc_library(
366367
"//cuttlefish/host/commands/assemble_cvd/flags:system_image_dir",
367368
"//cuttlefish/host/libs/config:config_utils",
368369
"//cuttlefish/host/libs/config:display",
370+
"//cuttlefish/pretty",
371+
"//cuttlefish/pretty:optional",
372+
"//cuttlefish/pretty:string",
373+
"//cuttlefish/pretty:struct",
369374
"//libbase",
370375
"@abseil-cpp//absl/strings",
371376
"@fmt",

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
#include "cuttlefish/host/libs/config/fetcher_configs.h"
7171
#include "cuttlefish/host/libs/feature/inject.h"
7272
#include "cuttlefish/posix/symlink.h"
73+
#include "cuttlefish/pretty/vector.h"
7374

7475
namespace cuttlefish {
7576
namespace {
@@ -661,6 +662,8 @@ Result<int> AssembleCvdMain(int argc, char** argv) {
661662
std::vector<GuestConfig> guest_configs =
662663
CF_EXPECT(ReadGuestConfig(boot_image, kernel_path, system_image_dir));
663664

665+
VLOG(0) << "Guest configs: " << Pretty(guest_configs);
666+
664667
VmManagerFlag vm_manager_flag =
665668
CF_EXPECT(VmManagerFlag::FromGlobalGflags(guest_configs));
666669

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
#include "cuttlefish/host/commands/assemble_cvd/proto/guest_config.pb.h"
4545
#include "cuttlefish/host/libs/config/config_utils.h"
4646
#include "cuttlefish/host/libs/config/display.h"
47+
#include "cuttlefish/pretty/optional.h"
48+
#include "cuttlefish/pretty/string.h"
4749

4850
namespace cuttlefish {
4951
namespace {
@@ -224,6 +226,31 @@ Result<void> ParseGuestConfigTxt(const std::string& guest_config_path,
224226

225227
} // namespace
226228

229+
PrettyStruct Pretty(const GuestConfig& config, PrettyAdlPlaceholder) {
230+
return PrettyStruct("GuestConfig")
231+
.Member("target_arch", config.target_arch)
232+
.Member("device_type", config.device_type)
233+
.Member("bootconfig_supported", config.bootconfig_supported)
234+
.Member("hctr2_supported", config.hctr2_supported)
235+
.Member("android_version_number", config.android_version_number)
236+
.Member("gfxstream_supported", config.gfxstream_supported)
237+
.Member("gfxstream_gl_program_binary_link_status_supported",
238+
config.gfxstream_gl_program_binary_link_status_supported)
239+
.Member("vhost_user_vsock", config.vhost_user_vsock)
240+
.Member("supports_bgra_framebuffers", config.supports_bgra_framebuffers)
241+
.Member("prefer_drm_virgl_when_supported",
242+
config.prefer_drm_virgl_when_supported)
243+
.Member("mouse_supported", config.mouse_supported)
244+
.Member("gamepad_supported", config.gamepad_supported)
245+
.Member("ti50_emulator", config.ti50_emulator)
246+
.Member("custom_keyboard_config", config.custom_keyboard_config)
247+
.Member("domkey_mapping_config", config.domkey_mapping_config)
248+
.Member("output_audio_streams_count", config.output_audio_streams_count)
249+
.Member("audio_settings", config.audio_settings)
250+
.Member("enforce_mac80211_hwsim", config.enforce_mac80211_hwsim)
251+
.Member("blank_data_image_mb", config.blank_data_image_mb);
252+
}
253+
227254
Result<std::vector<GuestConfig>> ReadGuestConfig(
228255
const BootImageFlag& boot_image, const KernelPathFlag& kernel_path,
229256
const SystemImageDirFlag& system_image_dirs) {

base/cvd/cuttlefish/host/commands/assemble_cvd/guest_config.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
#include "cuttlefish/host/commands/assemble_cvd/flags/boot_image.h"
2525
#include "cuttlefish/host/commands/assemble_cvd/flags/kernel_path.h"
2626
#include "cuttlefish/host/commands/assemble_cvd/flags/system_image_dir.h"
27-
2827
#include "cuttlefish/host/commands/assemble_cvd/proto/guest_config.pb.h"
28+
#include "cuttlefish/pretty/pretty.h"
29+
#include "cuttlefish/pretty/struct.h"
2930

3031
namespace cuttlefish {
3132

@@ -51,6 +52,9 @@ struct GuestConfig {
5152
int blank_data_image_mb = 0;
5253
};
5354

55+
PrettyStruct Pretty(const GuestConfig&,
56+
PrettyAdlPlaceholder unused = PrettyAdlPlaceholder());
57+
5458
Result<std::vector<GuestConfig>> ReadGuestConfig(
5559
const BootImageFlag&, const KernelPathFlag& kernel_path,
5660
const SystemImageDirFlag& system_image_dir);

0 commit comments

Comments
 (0)