Android-cuttlefish cvd tool
common.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 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
17#pragma once
18
19#include <string>
20#include <unordered_map>
21
22#include "absl/strings/string_view.h"
23
25
26namespace cuttlefish {
27
28// name of environment variable to mark the launch_cvd initiated by the cvd
29// server
30static constexpr char kCvdMarkEnv[] = "_STARTED_BY_CVD_SERVER_";
31
32constexpr char kServerExecPath[] = "/proc/self/exe";
33
34// The name of environment variable that points to the host out directory
35constexpr char kAndroidHostOut[] = "ANDROID_HOST_OUT";
36// kAndroidHostOut for old branches
37constexpr char kAndroidSoongHostOut[] = "ANDROID_SOONG_HOST_OUT";
38constexpr char kAndroidProductOut[] = "ANDROID_PRODUCT_OUT";
39
40std::string CvdDir();
41
42std::string PerUserDir();
43
44std::string PerUserCacheDir();
45
46std::string InstanceDatabasePath();
47
48std::string InstanceLocksPath();
49
50Result<std::string> GroupDirFromHome(absl::string_view group_home_dir);
51
52std::string AssemblyDirFromHome(const std::string& group_home_dir);
53
54// Returns the path to the directory containing the host binaries, shared
55// libraries and other files built with the Android build system. It searches,
56// in order, the ANDROID_HOST_OUT, ANDROID_SOONG_HOST_OUT and HOME environment
57// variables followed by the current directory.
59 const std::unordered_map<std::string, std::string>& env);
60
61} // namespace cuttlefish
Definition: alloc_driver.h:21
std::string AssemblyDirFromHome(const std::string &group_home_dir)
Definition: common.cpp:148
Result< std::string > AndroidHostPath(const std::unordered_map< std::string, std::string > &envs)
Definition: common.cpp:81
constexpr char kAndroidSoongHostOut[]
Definition: common.h:37
std::string CvdDir()
Definition: common.cpp:119
constexpr char kAndroidProductOut[]
Definition: common.h:38
std::string InstanceDatabasePath()
Definition: common.cpp:130
std::string PerUserDir()
Definition: common.cpp:126
std::string InstanceLocksPath()
Definition: common.cpp:134
Result< std::string > GroupDirFromHome(absl::string_view dir)
Definition: common.cpp:138
static constexpr char kCvdMarkEnv[]
Definition: common.h:30
tl::expected< T, StackTraceError< E > > Result
Definition: result_type.h:30
std::string PerUserCacheDir()
Definition: common.cpp:128
constexpr char kServerExecPath[]
Definition: common.h:32
constexpr char kAndroidHostOut[]
Definition: common.h:35