From 27f2d44eb0cf2a0cb103bd2f8821d66c77c3a851 Mon Sep 17 00:00:00 2001 From: Paul David Date: Thu, 12 Jan 2017 21:36:40 -0500 Subject: RFNoC: Produce an accurate error for missing XML directory --- host/lib/rfnoc/blockdef_xml_impl.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/host/lib/rfnoc/blockdef_xml_impl.cpp b/host/lib/rfnoc/blockdef_xml_impl.cpp index 3de3a0ba0..78d1995d1 100644 --- a/host/lib/rfnoc/blockdef_xml_impl.cpp +++ b/host/lib/rfnoc/blockdef_xml_impl.cpp @@ -416,15 +416,30 @@ private: blockdef::sptr blockdef::make_from_noc_id(uint64_t noc_id) { std::vector paths = blockdef_xml_impl::get_xml_paths(); - // Iterate over all paths + std::vector valid; + + // Check if any of the paths exist BOOST_FOREACH(const fs::path &base_path, paths) { fs::path this_path = base_path / XML_BLOCKS_SUBDIR; - if (not fs::exists(this_path) or not fs::is_directory(this_path)) { - continue; + if (fs::exists(this_path) and fs::is_directory(this_path)) { + valid.push_back(this_path); } + } + + if (valid.empty()) + { + throw uhd::assertion_error( + "Failed to find a valid XML path for RFNoC blocks.\n" + "Try setting the enviroment variable UHD_RFNOC_DIR " + "to the correct location" + ); + } + + // Iterate over all paths + BOOST_FOREACH(const fs::path &path, valid) { // Iterate over all .xml files fs::directory_iterator end_itr; - for (fs::directory_iterator i(this_path); i != end_itr; ++i) { + for (fs::directory_iterator i(path); i != end_itr; ++i) { if (not fs::exists(*i) or fs::is_directory(*i) or fs::is_empty(*i)) { continue; } -- cgit v1.2.3