Skip to content

Commit 1c28b71

Browse files
committed
Make flags_defaults.h dependencies explicit
Remove some using statements in favor of fully qualified names. Needed to move `GetSeccompPolicyDir` earlier in the dependency chain so `flags_defaults.h` could depend on it. Note: This actually leaves out 5 constant variable references, but those will be handled in a follow-up commit. The values are declared+defined in `cuttlefish_config.h/cpp`, which is in a target that depends on `flags_defaults.h`'s target. Will unwrap that separately.
1 parent 519d5ac commit 1c28b71

File tree

6 files changed

+51
-44
lines changed

6 files changed

+51
-44
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
@@ -12,6 +12,11 @@ cc_library(
1212
],
1313
copts = COPTS + [ "-Werror=sign-compare" ],
1414
strip_include_prefix = "//cuttlefish",
15+
deps = [
16+
"//cuttlefish/common/libs/utils:environment",
17+
"//cuttlefish/host/libs/config:config_constants",
18+
"//cuttlefish/host/libs/config:config_utils",
19+
],
1520
)
1621

1722
clang_tidy_test(

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

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,6 @@
7575
#include "host/libs/vm_manager/qemu_manager.h"
7676
#include "host/libs/vm_manager/vm_manager.h"
7777

78-
using cuttlefish::DefaultHostArtifactsPath;
79-
using cuttlefish::HostBinaryPath;
80-
using cuttlefish::TempDir;
81-
using cuttlefish::vm_manager::CrosvmManager;
82-
using google::FlagSettingMode::SET_FLAGS_DEFAULT;
83-
using google::FlagSettingMode::SET_FLAGS_VALUE;
84-
85-
// https://cs.android.com/android/platform/superproject/main/+/main:device/google/cuttlefish/Android.bp;l=122;drc=6f7d6a4db58efcc2ddd09eda07e009c6329414cd
86-
#define USERDATA_FILE_SYSTEM_TYPE "f2fs"
87-
8878
#define DEFINE_vec DEFINE_string
8979
#define DEFINE_proto DEFINE_string
9080
#define GET_FLAG_STR_VALUE(name) GetFlagStrValueForInstances(FLAGS_ ##name, instances_size, #name, name_to_default_value)
@@ -551,7 +541,7 @@ DEFINE_vec(
551541
DEFINE_vec(vhost_user_block, CF_DEFAULTS_VHOST_USER_BLOCK ? "true" : "false",
552542
"(experimental) use crosvm vhost-user block device implementation ");
553543

554-
DEFINE_string(early_tmp_dir, TempDir(),
544+
DEFINE_string(early_tmp_dir, cuttlefish::TempDir(),
555545
"Parent directory to use for temporary files in early startup");
556546

557547
DEFINE_vec(enable_tap_devices, "true",
@@ -2150,13 +2140,13 @@ Result<void> SetDefaultFlagsForQemu(
21502140
// This is the 1st place to set "start_webrtc" flag value
21512141
// for now, we don't set non-default options for QEMU
21522142
SetCommandLineOptionWithMode("start_webrtc", default_start_webrtc.c_str(),
2153-
SET_FLAGS_DEFAULT);
2143+
google::FlagSettingMode::SET_FLAGS_DEFAULT);
21542144

21552145
SetCommandLineOptionWithMode("bootloader", default_bootloader.c_str(),
2156-
SET_FLAGS_DEFAULT);
2146+
google::FlagSettingMode::SET_FLAGS_DEFAULT);
21572147
SetCommandLineOptionWithMode("android_efi_loader",
21582148
default_android_efi_loader.c_str(),
2159-
SET_FLAGS_DEFAULT);
2149+
google::FlagSettingMode::SET_FLAGS_DEFAULT);
21602150
return {};
21612151
}
21622152

@@ -2231,35 +2221,39 @@ Result<void> SetDefaultFlagsForCrosvm(
22312221
}
22322222
}
22332223
SetCommandLineOptionWithMode("bootloader", default_bootloader.c_str(),
2234-
SET_FLAGS_DEFAULT);
2224+
google::FlagSettingMode::SET_FLAGS_DEFAULT);
22352225
SetCommandLineOptionWithMode("android_efi_loader",
22362226
default_android_efi_loader.c_str(),
2237-
SET_FLAGS_DEFAULT);
2227+
google::FlagSettingMode::SET_FLAGS_DEFAULT);
22382228
// This is the 1st place to set "start_webrtc" flag value
22392229
SetCommandLineOptionWithMode("start_webrtc", default_start_webrtc.c_str(),
2240-
SET_FLAGS_DEFAULT);
2230+
google::FlagSettingMode::SET_FLAGS_DEFAULT);
22412231
// This is the 1st place to set "enable_sandbox" flag value
2242-
SetCommandLineOptionWithMode(
2243-
"enable_sandbox", default_enable_sandbox_str.c_str(), SET_FLAGS_DEFAULT);
2244-
SetCommandLineOptionWithMode(
2245-
"enable_virtiofs", default_enable_sandbox_str.c_str(), SET_FLAGS_DEFAULT);
2232+
SetCommandLineOptionWithMode("enable_sandbox",
2233+
default_enable_sandbox_str.c_str(),
2234+
google::FlagSettingMode::SET_FLAGS_DEFAULT);
2235+
SetCommandLineOptionWithMode("enable_virtiofs",
2236+
default_enable_sandbox_str.c_str(),
2237+
google::FlagSettingMode::SET_FLAGS_DEFAULT);
22462238
return {};
22472239
}
22482240

22492241
void SetDefaultFlagsForGem5() {
22502242
// TODO: Add support for gem5 gpu models
22512243
SetCommandLineOptionWithMode("gpu_mode", kGpuModeGuestSwiftshader,
2252-
SET_FLAGS_DEFAULT);
2244+
google::FlagSettingMode::SET_FLAGS_DEFAULT);
22532245

2254-
SetCommandLineOptionWithMode("cpus", "1", SET_FLAGS_DEFAULT);
2246+
SetCommandLineOptionWithMode("cpus", "1",
2247+
google::FlagSettingMode::SET_FLAGS_DEFAULT);
22552248
}
22562249

22572250
void SetDefaultFlagsForMcu() {
22582251
auto path = DefaultHostArtifactsPath("etc/mcu_config.json");
22592252
if (!CanAccess(path, R_OK)) {
22602253
return;
22612254
}
2262-
SetCommandLineOptionWithMode("mcu_config_path", path.c_str(), SET_FLAGS_DEFAULT);
2255+
SetCommandLineOptionWithMode("mcu_config_path", path.c_str(),
2256+
google::FlagSettingMode::SET_FLAGS_DEFAULT);
22632257
}
22642258

22652259
void SetDefaultFlagsForOpenwrt(Arch target_arch) {
@@ -2268,23 +2262,23 @@ void SetDefaultFlagsForOpenwrt(Arch target_arch) {
22682262
"ap_kernel_image",
22692263
DefaultHostArtifactsPath("etc/openwrt/images/openwrt_kernel_x86_64")
22702264
.c_str(),
2271-
SET_FLAGS_DEFAULT);
2265+
google::FlagSettingMode::SET_FLAGS_DEFAULT);
22722266
SetCommandLineOptionWithMode(
22732267
"ap_rootfs_image",
22742268
DefaultHostArtifactsPath("etc/openwrt/images/openwrt_rootfs_x86_64")
22752269
.c_str(),
2276-
SET_FLAGS_DEFAULT);
2270+
google::FlagSettingMode::SET_FLAGS_DEFAULT);
22772271
} else if (target_arch == Arch::Arm64) {
22782272
SetCommandLineOptionWithMode(
22792273
"ap_kernel_image",
22802274
DefaultHostArtifactsPath("etc/openwrt/images/openwrt_kernel_aarch64")
22812275
.c_str(),
2282-
SET_FLAGS_DEFAULT);
2276+
google::FlagSettingMode::SET_FLAGS_DEFAULT);
22832277
SetCommandLineOptionWithMode(
22842278
"ap_rootfs_image",
22852279
DefaultHostArtifactsPath("etc/openwrt/images/openwrt_rootfs_aarch64")
22862280
.c_str(),
2287-
SET_FLAGS_DEFAULT);
2281+
google::FlagSettingMode::SET_FLAGS_DEFAULT);
22882282
}
22892283
}
22902284

@@ -2355,11 +2349,11 @@ Result<std::vector<GuestConfig>> GetGuestConfigAndSetDefaults() {
23552349
SetCommandLineOptionWithMode(
23562350
"start_webrtc_sig_server",
23572351
start_webrtc && !host_operator_present ? "true" : "false",
2358-
SET_FLAGS_DEFAULT);
2352+
google::FlagSettingMode::SET_FLAGS_DEFAULT);
23592353
SetCommandLineOptionWithMode(
23602354
"webrtc_sig_server_addr",
23612355
host_operator_present ? HOST_OPERATOR_SOCKET_PATH : "0.0.0.0",
2362-
SET_FLAGS_DEFAULT);
2356+
google::FlagSettingMode::SET_FLAGS_DEFAULT);
23632357
}
23642358

23652359
SetDefaultFlagsForOpenwrt(guest_configs[0].target_arch);
@@ -2376,10 +2370,4 @@ std::string GetConfigFilePath(const CuttlefishConfig& config) {
23762370
return config.AssemblyPath("cuttlefish_config.json");
23772371
}
23782372

2379-
std::string GetSeccompPolicyDir() {
2380-
std::string kSeccompDir =
2381-
"usr/share/crosvm/" + HostArchStr() + "-linux-gnu/seccomp";
2382-
return DefaultHostArtifactsPath(kSeccompDir);
2383-
}
2384-
23852373
} // namespace cuttlefish

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,5 @@ Result<CuttlefishConfig> InitializeCuttlefishConfiguration(
5353
fruit::Injector<>& injector, const FetcherConfig& fetcher_config);
5454

5555
std::string GetConfigFilePath(const CuttlefishConfig& config);
56-
std::string GetSeccompPolicyDir();
5756

5857
} // namespace cuttlefish

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,24 @@
1515
*/
1616
#pragma once
1717

18+
#include "common/libs/utils/environment.h"
19+
#include "host/libs/config/config_constants.h"
20+
#include "host/libs/config/config_utils.h"
21+
1822
#define CF_DEFAULTS_DYNAMIC_STRING ""
1923
#define CF_DEFAULTS_DYNAMIC_INT 0
2024

21-
// Common configs paramneters
25+
// https://cs.android.com/android/platform/superproject/main/+/main:device/google/cuttlefish/Android.bp;l=122;drc=6f7d6a4db58efcc2ddd09eda07e009c6329414cd
26+
#define USERDATA_FILE_SYSTEM_TYPE "f2fs"
27+
28+
// Common configs parameters
2229
#define CF_DEFAULTS_NUM_INSTANCES 1
2330
#define CF_DEFAULTS_INSTANCE_NUMS CF_DEFAULTS_DYNAMIC_STRING
2431
#define CF_DEFAULTS_BASE_INSTANCE_NUM cuttlefish::GetInstance()
2532
#define CF_DEFAULTS_ASSEMBLY_DIR \
26-
(StringFromEnv("HOME", ".") + "/cuttlefish_assembly")
27-
#define CF_DEFAULTS_INSTANCE_DIR (StringFromEnv("HOME", ".") + "/cuttlefish")
33+
(cuttlefish::StringFromEnv("HOME", ".") + "/cuttlefish_assembly")
34+
#define CF_DEFAULTS_INSTANCE_DIR \
35+
(cuttlefish::StringFromEnv("HOME", ".") + "/cuttlefish")
2836

2937
#define CF_DEFAULTS_SYSTEM_IMAGE_DIR CF_DEFAULTS_DYNAMIC_STRING
3038

@@ -59,7 +67,7 @@
5967
#define CF_DEFAULTS_DEVICE_EXTERNAL_NETWORK "tap"
6068

6169
// crosvm default parameters
62-
#define CF_DEFAULTS_CROSVM_BINARY HostBinaryPath("crosvm")
70+
#define CF_DEFAULTS_CROSVM_BINARY cuttlefish::HostBinaryPath("crosvm")
6371
#define CF_DEFAULTS_SECCOMP_POLICY_DIR cuttlefish::GetSeccompPolicyDir()
6472
#define CF_DEFAULTS_ENABLE_SANDBOX false
6573
#define CF_DEFAULTS_ENABLE_VIRTIOFS false
@@ -69,7 +77,7 @@
6977
#define CF_DEFAULTS_QEMU_BINARY_DIR cuttlefish::DefaultQemuBinaryDir()
7078

7179
// Gem5 default parameters
72-
#define CF_DEFAULTS_GEM5_BINARY_DIR HostBinaryPath("gem5")
80+
#define CF_DEFAULTS_GEM5_BINARY_DIR cuttlefish::HostBinaryPath("gem5")
7381
#define CF_DEFAULTS_GEM5_CHECKPOINT_DIR CF_DEFAULTS_DYNAMIC_STRING
7482
#define CF_DEFAULTS_GEM5_DEBUG_FILE CF_DEFAULTS_DYNAMIC_STRING
7583
#define CF_DEFAULTS_GEM5_DEBUG_FLAGS CF_DEFAULTS_DYNAMIC_STRING
@@ -214,9 +222,9 @@
214222
#define CF_DEFAULTS_WEBRTC_DEVICE_ID "cvd-{num}"
215223
#define CF_DEFAULTS_VERIFY_SIG_SERVER_CERTIFICATE false
216224
#define CF_DEFAULTS_WEBRTC_ASSETS_DIR \
217-
DefaultHostArtifactsPath("usr/share/webrtc/assets")
225+
cuttlefish::DefaultHostArtifactsPath("usr/share/webrtc/assets")
218226
#define CF_DEFAULTS_WEBRTC_CERTS_DIR \
219-
DefaultHostArtifactsPath("usr/share/webrtc/certs")
227+
cuttlefish::DefaultHostArtifactsPath("usr/share/webrtc/certs")
220228
#define CF_DEFAULTS_WEBRTC_SIG_SERVER_ADDR CF_DEFAULTS_DYNAMIC_STRING
221229
#define CF_DEFAULTS_WEBRTC_SIG_SERVER_PATH "/register_device"
222230
#define CF_DEFAULTS_WEBRTC_SIG_SERVER_PORT 443

base/cvd/cuttlefish/host/libs/config/config_utils.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,9 @@ bool HostSupportsQemuCli() {
171171
return supported;
172172
}
173173

174+
std::string GetSeccompPolicyDir() {
175+
std::string kSeccompDir =
176+
"usr/share/crosvm/" + HostArchStr() + "-linux-gnu/seccomp";
177+
return DefaultHostArtifactsPath(kSeccompDir);
178+
}
174179
}

base/cvd/cuttlefish/host/libs/config/config_utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,6 @@ bool HostSupportsQemuCli();
6161

6262
// Whether to use our local QEMU prebuilt
6363
bool UseQemuPrebuilt();
64+
65+
std::string GetSeccompPolicyDir();
6466
}

0 commit comments

Comments
 (0)