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