Configure default resource and data directories from CMake
As anbox is expected to installed in two ways (`snap` or `make install`), it should be enough to get `snap` ENV or configure by cmake.
This commit is contained in:
parent
7a8f1efab9
commit
202b556bea
4 changed files with 17 additions and 10 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -2,6 +2,8 @@ build*/
|
|||
parts/
|
||||
stage/
|
||||
prime/
|
||||
snap/
|
||||
android-images/
|
||||
*.snap
|
||||
CMakeLists.txt.user
|
||||
*.o.cmd
|
||||
|
|
@ -14,6 +16,8 @@ CMakeLists.txt.user
|
|||
modules.order
|
||||
.tmp_versions
|
||||
.idea
|
||||
src/anbox/config.h
|
||||
|
||||
|
||||
debian/anbox-modules-dkms.debhelper.log
|
||||
debian/anbox-modules-dkms.substvars
|
||||
|
|
|
|||
|
|
@ -108,6 +108,12 @@ endif()
|
|||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/anbox/build/version.h.in
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/anbox/build/version.h)
|
||||
|
||||
set(ANBOX_RESOURCE_DIR "${CMAKE_INSTALL_DATADIR}/anbox")
|
||||
set(ANBOX_RESOURCE_DIR_FULL "${CMAKE_INSTALL_FULL_DATADIR}/anbox")
|
||||
set(ANBOX_STATEDIR_FULL "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/anbox")
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/anbox/config.h.in
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/anbox/config.h)
|
||||
|
||||
add_subdirectory(external)
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(tests)
|
||||
|
|
@ -118,7 +124,7 @@ if (NOT "${HOST_CMAKE_C_COMPILER}" STREQUAL "")
|
|||
message(STATUS "Host C compiler: ${HOST_CMAKE_CXX_COMPILER}")
|
||||
endif()
|
||||
|
||||
install(FILES data/ui/loading-screen.png DESTINATION share/anbox/ui)
|
||||
install(FILES data/ui/loading-screen.png DESTINATION ${ANBOX_RESOURCE_DIR}/ui)
|
||||
|
||||
# uninstall target
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
|
||||
|
|
|
|||
|
|
@ -90,18 +90,11 @@ anbox::SystemConfiguration::SystemConfiguration() {
|
|||
const auto snap_path = utils::get_env_value("SNAP");
|
||||
if (!snap_path.empty()) {
|
||||
return fs::path(snap_path) / "usr/share/anbox";
|
||||
}
|
||||
|
||||
const std::string exe = utils::process_get_exe_path(::getpid());
|
||||
const std::size_t pos = exe.rfind("/bin/anbox");
|
||||
if (pos != std::string::npos) {
|
||||
const std::string leading_path = exe.substr(0, pos);
|
||||
return fs::path(leading_path) / "share/anbox";
|
||||
} else {
|
||||
return "/usr/local/share/anbox";
|
||||
return default_resource_path;
|
||||
}
|
||||
};
|
||||
|
||||
resource_path = gen_resource_path();
|
||||
data_path = "/var/local/lib/anbox";
|
||||
data_path = default_path_path;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,10 @@ class SystemConfiguration {
|
|||
boost::filesystem::path data_path;
|
||||
boost::filesystem::path resource_path;
|
||||
|
||||
private:
|
||||
static constexpr const char *default_resource_path{"@ANBOX_RESOURCE_DIR_FULL@"};
|
||||
static constexpr const char *default_path_path{"@ANBOX_STATEDIR_FULL@"};
|
||||
|
||||
};
|
||||
} // namespace anbox
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue