diff --git a/smocore/include/opts.h b/smocore/include/opts.h index 22b597d..9bec880 100644 --- a/smocore/include/opts.h +++ b/smocore/include/opts.h @@ -24,7 +24,7 @@ public: public: std::string argv0; - std::string senseApiLibPath; + std::vector senseApiLibPath; std::vector senseApiLibs; std::string deviceSpecs; std::vector deviceSpecFiles; diff --git a/smocore/opts.cpp b/smocore/opts.cpp index 53e4623..00fa184 100644 --- a/smocore/opts.cpp +++ b/smocore/opts.cpp @@ -52,13 +52,6 @@ void OptionParser::parseArguments(int argc, char *argv[], char **envp) { struct stat info; - if (!senseApiLibPath.empty()) - { - std::cerr << std::string(__func__) - + " - Overwriting previous sense-api-path with: " << optarg - << '\n'; - } - if (stat(optarg, &info) != 0 || !(info.st_mode & S_IFDIR)) { throw std::invalid_argument( @@ -66,7 +59,7 @@ void OptionParser::parseArguments(int argc, char *argv[], char **envp) "directory: " + optarg); } - senseApiLibPath = optarg; + senseApiLibPath.push_back(optarg); break; } case 'v': @@ -109,7 +102,11 @@ std::string OptionParser::stringifyOptions(void) const } oss << std::endl; - oss << "Sense API Library Path: " << senseApiLibPath << std::endl; + oss << "Sense API Library Paths: "; + for (const auto& path : senseApiLibPath) { + oss << path << " "; + } + oss << std::endl; oss << "Sense API Libraries: "; for (const auto& lib : senseApiLibs) { oss << lib << " "; diff --git a/smocore/senseApis/senseApiManager.cpp b/smocore/senseApis/senseApiManager.cpp index 15dc42c..9b780df 100644 --- a/smocore/senseApis/senseApiManager.cpp +++ b/smocore/senseApis/senseApiManager.cpp @@ -35,10 +35,14 @@ static std::optional findLibraryPath( fs::path("/proc/self/exe").parent_path().string() }; - if (!OptionParser::getOptions().senseApiLibPath.empty()) + const auto& options = OptionParser::getOptions(); + if (!options.senseApiLibPath.empty()) { + // Insert all sense API library paths at the beginning of search paths searchPaths.insert( - searchPaths.begin(), OptionParser::getOptions().senseApiLibPath); + searchPaths.begin(), + options.senseApiLibPath.begin(), + options.senseApiLibPath.end()); } for (const auto& path : searchPaths)