aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-04-18 17:17:32 -0700
committerJosh Blum <josh@joshknows.com>2011-04-19 14:20:37 -0700
commit06e10b5f469b8b06af33a8a95a6302a1e365b396 (patch)
tree6697efbaaa3b0295d1d00137440bfba9e71872f5 /host
parent8212f22075f5a1b8b1818d6e3df5a88a0a697713 (diff)
downloaduhd-06e10b5f469b8b06af33a8a95a6302a1e365b396.tar.gz
uhd-06e10b5f469b8b06af33a8a95a6302a1e365b396.tar.bz2
uhd-06e10b5f469b8b06af33a8a95a6302a1e365b396.zip
uhd: use UHD_PKG_DATA_PATH environment variable to override the one in constants
The installer sets UHD_PKG_DATA_PATH, we can can handle transplanted builds.
Diffstat (limited to 'host')
-rw-r--r--host/Modules/UHDPackage.cmake10
-rw-r--r--host/lib/utils/paths.cpp27
2 files changed, 21 insertions, 16 deletions
diff --git a/host/Modules/UHDPackage.cmake b/host/Modules/UHDPackage.cmake
index 1988c7f11..416d89998 100644
--- a/host/Modules/UHDPackage.cmake
+++ b/host/Modules/UHDPackage.cmake
@@ -144,5 +144,15 @@ SET(CPACK_RPM_PACKAGE_REQUIRES "boost-devel, libusb1")
########################################################################
SET(CPACK_NSIS_MODIFY_PATH ON)
+SET(HLKM_ENV "\\\"SYSTEM\\\\CurrentControlSet\\\\Control\\\\Session Manager\\\\Environment\\\"")
+
+SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
+ WriteRegStr HKLM ${HLKM_ENV} \\\"UHD_PKG_DATA_PATH\\\" \\\"$INSTDIR\\\\share\\\\uhd\\\"
+")
+
+SET(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "
+ DeleteRegValue HKLM ${HLKM_ENV} \\\"UHD_PKG_DATA_PATH\\\"
+")
+
########################################################################
INCLUDE(CPack) #include after setting vars
diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp
index 0ddc80d6e..a0e4da547 100644
--- a/host/lib/utils/paths.cpp
+++ b/host/lib/utils/paths.cpp
@@ -18,14 +18,13 @@
#include "constants.hpp"
#include <uhd/config.hpp>
#include <boost/tokenizer.hpp>
-#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <boost/bind.hpp>
+#include <cstdlib>
#include <string>
#include <vector>
-namespace po = boost::program_options;
namespace fs = boost::filesystem;
/***********************************************************************
@@ -44,22 +43,14 @@ namespace fs = boost::filesystem;
/***********************************************************************
* Get a list of paths for an environment variable
**********************************************************************/
-static std::string name_mapper(const std::string &key, const std::string &var_name){
- return (var_name == key)? var_name : "";
+static std::string get_env_var(const std::string &var_name, const std::string &def_val = ""){
+ const char *var_value_ptr = std::getenv(var_name.c_str());
+ return (var_value_ptr == NULL)? def_val : var_value_ptr;
}
static std::vector<fs::path> get_env_paths(const std::string &var_name){
- //register the options
- std::string var_value;
- po::options_description desc;
- desc.add_options()
- (var_name.c_str(), po::value<std::string>(&var_value)->default_value(""))
- ;
- //parse environment variables
- po::variables_map vm;
- po::store(po::parse_environment(desc, boost::bind(&name_mapper, var_name, _1)), vm);
- po::notify(vm);
+ std::string var_value = get_env_var(var_name);
//convert to filesystem path, filter blank paths
std::vector<fs::path> paths;
@@ -74,14 +65,18 @@ static std::vector<fs::path> get_env_paths(const std::string &var_name){
/***********************************************************************
* Get a list of special purpose paths
**********************************************************************/
+static fs::path get_uhd_pkg_data_path(void){
+ return fs::path(get_env_var("UHD_PKG_DATA_PATH", UHD_PKG_DATA_PATH));
+}
+
std::vector<fs::path> get_image_paths(void){
std::vector<fs::path> paths = get_env_paths("UHD_IMAGE_PATH");
- paths.push_back(fs::path(UHD_PKG_DATA_PATH) / "images");
+ paths.push_back(get_uhd_pkg_data_path() / "images");
return paths;
}
std::vector<fs::path> get_module_paths(void){
std::vector<fs::path> paths = get_env_paths("UHD_MODULE_PATH");
- paths.push_back(fs::path(UHD_PKG_DATA_PATH) / "modules");
+ paths.push_back(get_uhd_pkg_data_path() / "modules");
return paths;
}