mirror of
https://github.com/saymrwulf/uhd.git
synced 2026-05-14 20:58:09 +00:00
lib: Purge all hard-coded references the share/uhd
- Add a new public API call get_pkg_data_path() which returns the location of the "share" data. On a Unix system, this will typically return "/usr/share/uhd" when doing a regular system install. - Purge all references to this path in UHD, and use the new API call instead. - Add --pkg-data-path as an option to uhd_config_info.
This commit is contained in:
parent
6091e5c730
commit
45a58b4541
7 changed files with 40 additions and 10 deletions
|
|
@ -40,6 +40,16 @@ UHD_API std::string get_lib_path(void);
|
|||
// returning the parent directory of the library path.
|
||||
UHD_API std::string get_pkg_path(void);
|
||||
|
||||
|
||||
//! Get a string representing the system's package data directory ("share")
|
||||
//
|
||||
// This path is typically identical with get_pkg_path()/share/uhd, but can be
|
||||
// overridden with the UHD_PKG_DATA_PATH environment variable.
|
||||
//
|
||||
// This path is where UHD stores data files that are not part of the library
|
||||
// itself, such as images, RFNoC YAML files, and calibration data.
|
||||
UHD_API std::string get_pkg_data_path(void);
|
||||
|
||||
//! Get a string representing the location of the calibration database
|
||||
UHD_API std::string get_cal_data_path(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
#include <uhd/utils/platform.hpp>
|
||||
#include <uhd/utils/safe_call.hpp>
|
||||
#include <uhd/utils/tasks.hpp>
|
||||
#include <uhdlib/utils/paths.hpp>
|
||||
#include <boost/asio.hpp> //used for htonl and ntohl
|
||||
#include <boost/assign/list_of.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
#include <uhd/utils/log.hpp>
|
||||
#include <uhd/utils/paths.hpp>
|
||||
#include <uhd/utils/static.hpp>
|
||||
#include <uhdlib/utils/paths.hpp>
|
||||
#include <stdint.h>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/assign.hpp>
|
||||
|
|
|
|||
|
|
@ -272,6 +272,15 @@ std::string uhd::get_pkg_path(void)
|
|||
return get_env_var("UHD_PKG_PATH", pkg_path.string());
|
||||
}
|
||||
|
||||
|
||||
std::string uhd::get_pkg_data_path()
|
||||
{
|
||||
return get_env_var("UHD_PKG_DATA_PATH",
|
||||
(fs::path(uhd::get_pkg_path() / fs::path(uhd::build_info::pkg_data_dir()))
|
||||
.string()));
|
||||
}
|
||||
|
||||
|
||||
std::string uhd::get_lib_path(void)
|
||||
{
|
||||
fs::path runtime_libfile_path = boost::dll::this_line_location();
|
||||
|
|
@ -302,8 +311,9 @@ std::vector<fs::path> uhd::get_module_paths(void)
|
|||
paths.push_back(str_path);
|
||||
}
|
||||
|
||||
paths.push_back(fs::path(uhd::get_lib_path()) / "uhd" / "modules");
|
||||
paths.push_back(fs::path(uhd::get_pkg_path()) / "share" / "uhd" / "modules");
|
||||
constexpr char module_dir[] = "modules";
|
||||
paths.push_back(fs::path(uhd::get_lib_path()) / "uhd" / module_dir);
|
||||
paths.push_back(fs::path(uhd::get_pkg_data_path()) / module_dir);
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
|
@ -319,7 +329,7 @@ std::vector<fs::path> uhd::get_module_d_paths(void)
|
|||
|
||||
constexpr char module_d_dir[] = "modules.d";
|
||||
paths.push_back(fs::path(uhd::get_lib_path()) / "uhd" / module_d_dir);
|
||||
paths.push_back(fs::path(uhd::get_pkg_path()) / "share" / "uhd" / module_d_dir);
|
||||
paths.push_back(fs::path(uhd::get_pkg_data_path()) / module_d_dir);
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
|
@ -466,11 +476,14 @@ std::string uhd::get_images_dir(const std::string& search_paths)
|
|||
}
|
||||
|
||||
/* Finally, check for the default UHD images installation paths */
|
||||
for (auto& prefix : {uhd::get_pkg_path(), uhd::build_info::install_prefix()}) {
|
||||
fs::path default_images_path = fs::path(prefix) / "share" / "uhd" / "images";
|
||||
if (fs::is_directory(default_images_path)) {
|
||||
return default_images_path.string();
|
||||
}
|
||||
const auto pkg_data_imgs_dir = fs::path(uhd::get_pkg_data_path()) / "images";
|
||||
if (fs::is_directory(pkg_data_imgs_dir)) {
|
||||
return pkg_data_imgs_dir.string();
|
||||
}
|
||||
const auto install_prefix_imgs_dir =
|
||||
fs::path(uhd::build_info::install_prefix()) / "share" / "uhd" / "images";
|
||||
if (fs::is_directory(install_prefix_imgs_dir)) {
|
||||
return install_prefix_imgs_dir.string();
|
||||
}
|
||||
|
||||
/* No luck. Return an empty string. */
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ BOOST_AUTO_TEST_CASE(test_get_paths)
|
|||
BOOST_CHECK(true);
|
||||
std::cout << "pkg_path: " << get_pkg_path() << std::endl;
|
||||
BOOST_CHECK(true);
|
||||
std::cout << "pkg_data_path: " << get_pkg_data_path() << std::endl;
|
||||
BOOST_CHECK(true);
|
||||
std::cout << "cal_path: " << get_cal_data_path() << std::endl;
|
||||
BOOST_CHECK(true);
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ int UHD_SAFE_MAIN(int argc, char* argv[])
|
|||
("dpdk-version", "Print DPDK version")
|
||||
("libusb-version", "Print libusb version")
|
||||
("pkg-path", "Print pkg path")
|
||||
("pkg-data-path", "Print package data path")
|
||||
("lib-path", "Print library path")
|
||||
("images-dir", "Print images dir")
|
||||
("abi-version", "Print ABI version string")
|
||||
|
|
@ -93,6 +94,9 @@ int UHD_SAFE_MAIN(int argc, char* argv[])
|
|||
if (vm.count("pkg-path") > 0 or print_all) {
|
||||
std::cout << "Package path: " << uhd::get_pkg_path() << std::endl;
|
||||
}
|
||||
if (vm.count("pkg-data-path") > 0 or print_all) {
|
||||
std::cout << "Package data path: " << uhd::get_pkg_data_path() << std::endl;
|
||||
}
|
||||
if (vm.count("images-dir") > 0 or print_all) {
|
||||
std::cout << "Images directory: " << uhd::get_images_dir("") << std::endl;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,8 +63,7 @@ except ImportError:
|
|||
_USERNAME_VARIABLE = "UHD_IMAGES_USER"
|
||||
_PASSWORD_VARIABLE = "UHD_IMAGES_PASSWORD"
|
||||
_DEFAULT_TARGET_REGEX = "(fpga|fw|windrv)_default"
|
||||
_BASE_DIR_STRUCTURE_PARTS = ["share", "uhd", "images"]
|
||||
_DEFAULT_INSTALL_PATH = os.path.join("@CMAKE_INSTALL_PREFIX@", *_BASE_DIR_STRUCTURE_PARTS)
|
||||
_DEFAULT_INSTALL_PATH = os.path.join("@CONFIG_PATH@", "images")
|
||||
_DEFAULT_BASE_URL = "https://files.ettus.com/binaries/cache/"
|
||||
_INVENTORY_FILENAME = "inventory.json"
|
||||
_DEFAULT_BUFFER_SIZE = 8192
|
||||
|
|
|
|||
Loading…
Reference in a new issue