From patchwork Thu Feb 20 16:56:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 2860 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 02537625B1 for ; Thu, 20 Feb 2020 17:57:08 +0100 (CET) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 76925E7C; Thu, 20 Feb 2020 17:57:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1582217827; bh=7KuIpS0hSgzefw/xKnhDvgRgggJ1uIYE/5Q7Ei2GHqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XKzs1Xg2azfQHel+irIedj5OBhFUFk7m6IJfiP5elAaIyPYLjcZBplChndVuYIdCg 3igb+eagF1HEOlI3fbAqh9lv2LbW3laG0L3GtC4WYU3znb0oGNQdv+mzu/ALq96rq1 3EvSFnFuVJ6IzyXGHfiwMoTuh0DsSgfag6t+GNVk= From: Kieran Bingham To: libcamera devel Date: Thu, 20 Feb 2020 16:56:59 +0000 Message-Id: <20200220165704.23600-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200220165704.23600-1-kieran.bingham@ideasonboard.com> References: <20200220165704.23600-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 1/6] libcamera: utils: Add an internal dirname helper X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Feb 2020 16:57:08 -0000 Provide a wrapped dirname call which returns a std::string. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/libcamera/include/utils.h | 1 + src/libcamera/utils.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h index 080ea6614de0..940597760ee2 100644 --- a/src/libcamera/include/utils.h +++ b/src/libcamera/include/utils.h @@ -33,6 +33,7 @@ namespace utils { const char *basename(const char *path); char *secure_getenv(const char *name); +std::string dirname(const std::string &path); template unsigned int set_overlap(InputIt1 first1, InputIt1 last1, diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp index 453e3b3b5995..3fd3aeaf822a 100644 --- a/src/libcamera/utils.cpp +++ b/src/libcamera/utils.cpp @@ -70,6 +70,23 @@ char *secure_getenv(const char *name) #endif } +/** + * \brief identify the dirname portion of a path + * \param[in] path The full path to parse + * + * \returns A string of the directory component of the path + */ +std::string dirname(const std::string &path) +{ + size_t pos = path.rfind('/', path.length()); + + if (pos != std::string::npos) { + return (path.substr(0, pos)); + } + + return path; +} + /** * \fn libcamera::utils::set_overlap(InputIt1 first1, InputIt1 last1, * InputIt2 first2, InputIt2 last2) From patchwork Thu Feb 20 16:57:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 2861 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2DEE0625C1 for ; Thu, 20 Feb 2020 17:57:08 +0100 (CET) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C7F3913C2; Thu, 20 Feb 2020 17:57:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1582217827; bh=4Vg9DJG9pZMz6SzWLMBp0i6D9Yk+BQOQBUkHlR1u4JI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qHcAMPW3AE4nHLgG76Lz9Zz2ZR+ON9wXjBum734kSwMh4bdbEZfqhAEuQOKXIw7Pr vmS7JQtWeaVqZNZO5k9hQVMzFb211AaKG6rS+lpv7CuUmAp5g5NEAKi5YgqZj8e4ev 1BjZ5UjSLNNbsK3+/iw5TulU9xrhLruIjoE2ngJk= From: Kieran Bingham To: libcamera devel Date: Thu, 20 Feb 2020 16:57:00 +0000 Message-Id: <20200220165704.23600-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200220165704.23600-1-kieran.bingham@ideasonboard.com> References: <20200220165704.23600-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/6] libcamera: ipa_manager: Split path handling X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Feb 2020 16:57:08 -0000 Move the iteration of a colon-separated path to its own function. This prepares for parsing extra path variables. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/libcamera/include/ipa_manager.h | 1 + src/libcamera/ipa_manager.cpp | 35 ++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/libcamera/include/ipa_manager.h b/src/libcamera/include/ipa_manager.h index 126f8babbc8f..94d35d9062e4 100644 --- a/src/libcamera/include/ipa_manager.h +++ b/src/libcamera/include/ipa_manager.h @@ -33,6 +33,7 @@ private: ~IPAManager(); int addDir(const char *libDir); + int addPath(const char *path); }; } /* namespace libcamera */ diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index 4ffbdd712ac2..d87f2221b00b 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -110,14 +110,7 @@ IPAManager::IPAManager() return; } - for (const auto &dir : utils::split(modulePaths, ":")) { - if (dir.empty()) - continue; - - int ret = addDir(dir.c_str()); - if (ret > 0) - ipaCount += ret; - } + ipaCount += addPath(modulePaths); if (!ipaCount) LOG(IPAManager, Warning) @@ -197,6 +190,32 @@ int IPAManager::addDir(const char *libDir) return count; } +/** + * \brief Load IPA modules from a search path + * \param[in] path The colon-separated list of directories to load IPA modules from + * + * This method tries to create an IPAModule instance for every shared object + * found in the directories listed in \a path. + * + * \return Number of modules loaded by this call, or a negative error code + * otherwise + */ +int IPAManager::addPath(const char *path) +{ + int ipaCount = 0; + + for (const auto &dir : utils::split(path, ":")) { + if (dir.empty()) + continue; + + int ret = addDir(dir.c_str()); + if (ret > 0) + ipaCount += ret; + } + + return ipaCount; +} + /** * \brief Create an IPA interface that matches a given pipeline handler * \param[in] pipe The pipeline handler that wants a matching IPA interface From patchwork Thu Feb 20 16:57:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 2862 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A29F9625C1 for ; Thu, 20 Feb 2020 17:57:08 +0100 (CET) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1BAFC13C7; Thu, 20 Feb 2020 17:57:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1582217828; bh=eCzZCVbPvJRe29BE5V9Smwp7Xg7gFtgIKdPaBqmAaBk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F5tZplKQTnEWtk9tOZufbdmuQGP6ilxnateEKbahBUIp5OrIgowdx8fbfXL19lCn+ zda1H+upNNTAhtK3HwjudolaUFHLfcdLU/5IzQQcFCZnla7sOmA3AjnTbq7Jwz0JUS M7bkSaqoMofDzR+PTHBv1o5PGWCD1ZhKUpf/Wq6E= From: Kieran Bingham To: libcamera devel Date: Thu, 20 Feb 2020 16:57:01 +0000 Message-Id: <20200220165704.23600-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200220165704.23600-1-kieran.bingham@ideasonboard.com> References: <20200220165704.23600-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/6] libcamera: ipa_manager: Allow recursive parsing X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Feb 2020 16:57:08 -0000 Provide an optional means to recurse into subdirectories to search for IPA libraries. This allows IPAs contained within their own build directory to be resolved when loading from a non-installed build. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/libcamera/include/ipa_manager.h | 6 ++- src/libcamera/ipa_manager.cpp | 69 ++++++++++++++++++++++------- 2 files changed, 58 insertions(+), 17 deletions(-) diff --git a/src/libcamera/include/ipa_manager.h b/src/libcamera/include/ipa_manager.h index 94d35d9062e4..5dca2c2a7d8d 100644 --- a/src/libcamera/include/ipa_manager.h +++ b/src/libcamera/include/ipa_manager.h @@ -32,8 +32,10 @@ private: IPAManager(); ~IPAManager(); - int addDir(const char *libDir); - int addPath(const char *path); + int parseDir(const char *libDir, std::vector &files, + unsigned int maxDepth); + int addDir(const char *libDir, unsigned int maxDepth = 0); + int addPath(const char *path, unsigned int maxDepth = 0); }; } /* namespace libcamera */ diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index d87f2221b00b..c30b4555290f 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -140,16 +140,20 @@ IPAManager *IPAManager::instance() } /** - * \brief Load IPA modules from a directory - * \param[in] libDir directory to search for IPA modules + * \brief Identify shared library objects within a directory + * \param[in] libDir The directory to search for IPA modules + * \param[in] files A vector of paths to shared object library files + * \param[in] maxDepth The maximum depth of sub-directories to parse * - * This method tries to create an IPAModule instance for every shared object - * found in \a libDir, and skips invalid IPA modules. + * Search a directory for .so files, allowing recursion down to + * subdirectories no further than the depth specified by \a maxDepth. * - * \return Number of modules loaded by this call, or a negative error code - * otherwise + * Discovered shared objects are added to the files vector. + * + * \return 0 on success or a negative error code otherwise */ -int IPAManager::addDir(const char *libDir) +int IPAManager::parseDir(const char *libDir, std::vector &files, + unsigned int maxDepth) { struct dirent *ent; DIR *dir; @@ -158,30 +162,64 @@ int IPAManager::addDir(const char *libDir) if (!dir) return -errno; - std::vector paths; while ((ent = readdir(dir)) != nullptr) { + if (ent->d_type == DT_DIR && maxDepth) { + if (strcmp(ent->d_name, ".") == 0 || + strcmp(ent->d_name, "..") == 0) + continue; + + std::string subdir = std::string(libDir) + "/" + ent->d_name; + + /* Recursion is limited to maxDepth. */ + parseDir(subdir.c_str(), files, maxDepth - 1); + + continue; + } + int offset = strlen(ent->d_name) - 3; if (offset < 0) continue; if (strcmp(&ent->d_name[offset], ".so")) continue; - paths.push_back(std::string(libDir) + "/" + ent->d_name); + files.push_back(std::string(libDir) + "/" + ent->d_name); } closedir(dir); + return 0; +} + +/** + * \brief Load IPA modules from a directory + * \param[in] libDir The directory to search for IPA modules + * \param[in] maxDepth The maximum depth of sub-directories to parse + * + * This method tries to create an IPAModule instance for every shared object + * found in \a libDir, and skips invalid IPA modules. + * + * \return Number of modules loaded by this call, or a negative error code + * otherwise + */ +int IPAManager::addDir(const char *libDir, unsigned int maxDepth) +{ + std::vector files; + + int ret = parseDir(libDir, files, maxDepth); + if (ret < 0) + return ret; + /* Ensure a stable ordering of modules. */ - std::sort(paths.begin(), paths.end()); + std::sort(files.begin(), files.end()); unsigned int count = 0; - for (const std::string &path : paths) { - IPAModule *ipaModule = new IPAModule(path); + for (const std::string &file : files) { + IPAModule *ipaModule = new IPAModule(file); if (!ipaModule->isValid()) { delete ipaModule; continue; } - LOG(IPAManager, Debug) << "Loaded IPA module '" << path << "'"; + LOG(IPAManager, Debug) << "Loaded IPA module '" << file << "'"; modules_.push_back(ipaModule); count++; @@ -193,6 +231,7 @@ int IPAManager::addDir(const char *libDir) /** * \brief Load IPA modules from a search path * \param[in] path The colon-separated list of directories to load IPA modules from + * \param[in] maxDepth The maximum number of sub-directories to parse * * This method tries to create an IPAModule instance for every shared object * found in the directories listed in \a path. @@ -200,7 +239,7 @@ int IPAManager::addDir(const char *libDir) * \return Number of modules loaded by this call, or a negative error code * otherwise */ -int IPAManager::addPath(const char *path) +int IPAManager::addPath(const char *path, unsigned int maxDepth) { int ipaCount = 0; @@ -208,7 +247,7 @@ int IPAManager::addPath(const char *path) if (dir.empty()) continue; - int ret = addDir(dir.c_str()); + int ret = addDir(dir.c_str(), maxDepth); if (ret > 0) ipaCount += ret; } From patchwork Thu Feb 20 16:57:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 2863 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F1BD6625D9 for ; Thu, 20 Feb 2020 17:57:08 +0100 (CET) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8D4A8563; Thu, 20 Feb 2020 17:57:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1582217828; bh=ZNskuW//of/1/WzEfpG0WFIem2r0UAGZQUoZy0P2d/0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=blXYgMI6dlnTyzzFK1zW7EY7jd2lKSNcTgwDytZ7UT0sS32dTcX8lhHYC9uSVsq4F xQ9JU+Vg6wjWjpSeCuTNDbgS/kFUaXlJKnsQcX0BHDRGMiWs6HL3aOT1/bN3XSGEzD hScAeVVmGwuM6XhTLWNDEEucZbAqy+R1ZbYgXUnQ= From: Kieran Bingham To: libcamera devel Date: Thu, 20 Feb 2020 16:57:02 +0000 Message-Id: <20200220165704.23600-5-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200220165704.23600-1-kieran.bingham@ideasonboard.com> References: <20200220165704.23600-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 4/6] libcamera: ipa_manager: Re-arrange IPA precedence X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Feb 2020 16:57:09 -0000 Setting a user environment path in LIBCAMERA_IPA_MODULE_PATH should take precedence over the system loading locations. Adjust the IPA search orders accordingly. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/libcamera/ipa_manager.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index c30b4555290f..3b1d4c0b295e 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -98,24 +98,24 @@ IPAManager::IPAManager() unsigned int ipaCount = 0; int ret; - ret = addDir(IPA_MODULE_DIR); - if (ret > 0) - ipaCount += ret; - + /* User specified paths take precedence. */ const char *modulePaths = utils::secure_getenv("LIBCAMERA_IPA_MODULE_PATH"); - if (!modulePaths) { + if (modulePaths) { + ipaCount += addPath(modulePaths); + if (!ipaCount) LOG(IPAManager, Warning) - << "No IPA found in '" IPA_MODULE_DIR "'"; - return; + << "No IPA found in '" << modulePaths << "'"; } - ipaCount += addPath(modulePaths); + /* Load IPAs from the installed system path. */ + ret = addDir(IPA_MODULE_DIR); + if (ret > 0) + ipaCount += ret; if (!ipaCount) LOG(IPAManager, Warning) - << "No IPA found in '" IPA_MODULE_DIR "' and '" - << modulePaths << "'"; + << "No IPA found in '" IPA_MODULE_DIR "'"; } IPAManager::~IPAManager() From patchwork Thu Feb 20 16:57:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 2864 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 47903625E5 for ; Thu, 20 Feb 2020 17:57:09 +0100 (CET) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D5BDEE7C; Thu, 20 Feb 2020 17:57:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1582217829; bh=kovIyEthjZxiQOgTA2fBWlo3ens78DeTuxlESMRYWMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u9WWJDXLN8o+HtdoYIO8Po7KMZoJ6YgIaMa1Ph5pxyMMo/sOu/2F/ZQAHKKLNI9EH dHr5YRw18mLaXVKg3XjEPTgkwdqIPmJ6aHXvN+huVaouu4taM7K2OMwB/+UC9cKJH2 J9/VOB5cWQjbQLA62YrqXmLBIdYw/9YBTKOpa7U4= From: Kieran Bingham To: libcamera devel Date: Thu, 20 Feb 2020 16:57:03 +0000 Message-Id: <20200220165704.23600-6-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200220165704.23600-1-kieran.bingham@ideasonboard.com> References: <20200220165704.23600-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 5/6] libcamera: ipa_manager: Search for IPA libraries in build tree X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Feb 2020 16:57:10 -0000 When libcamera is built and tested (or used at all) before installing to the configured prefix path, it will be unable to locate the IPA binaries, or IPA binaries previously installed in the system paths may be incorrect to load. Utilise the build_rpath dynamic tag which is stripped out by meson at install time to determine at runtime if the library currently executing has been installed or not. When not installed and running from a build tree, identify the location of that tree by finding the path of the active libcamera.so itself, and from that point add a relative path to be able to load the most recently built IPA modules. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- v2: - Move get_runpath to ipa_manager.c : libcamera::elfRunPath() - Minor fixes - Squash elfRunPath() into this patch v3: - Full rework. It's just all different :-) - Maybe this one is going to cut it ... --- src/libcamera/ipa_manager.cpp | 46 ++++++++++++++++++++++++++++++++++- src/libcamera/meson.build | 6 +++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index 3b1d4c0b295e..e60bf3dabebe 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -9,6 +9,9 @@ #include #include +#include +#include +#include #include #include @@ -24,6 +27,30 @@ * \brief Image Processing Algorithm module manager */ +static bool isLibcameraInstalled() +{ + extern ElfW(Dyn) _DYNAMIC[]; + /* DT_RUNPATH (DT_RPATH on musl) is removed on install. */ + for (const ElfW(Dyn) *dyn = _DYNAMIC; dyn->d_tag != DT_NULL; ++dyn) + if (dyn->d_tag == DT_RUNPATH || dyn->d_tag == DT_RPATH) + return false; + + return true; +} + +static const char *libcameraPath() +{ + Dl_info info; + int ret; + + /* look up our own symbol. */ + ret = dladdr(reinterpret_cast(libcameraPath), &info); + if (ret == 0) + return nullptr; + + return info.dli_fname; +} + namespace libcamera { LOG_DEFINE_CATEGORY(IPAManager) @@ -108,7 +135,24 @@ IPAManager::IPAManager() << "No IPA found in '" << modulePaths << "'"; } - /* Load IPAs from the installed system path. */ + /* + * When libcamera is used before it is installed, load IPAs from the + * same build directory as the libcamera library itself. This requires + * identifying the path of the libcamera.so, and referencing a relative + * path for the IPA from that point. + */ + if (!isLibcameraInstalled()) { + std::string ipaBuildPath = utils::dirname(libcameraPath()) + "/../ipa"; + constexpr int maxDepth = 1; + + LOG(IPAManager, Info) + << "libcamera is not installed. Adding '" + << ipaBuildPath << "' to the IPA search path"; + + ipaCount += addDir(ipaBuildPath.c_str(), maxDepth); + } + + /* Finally try to load IPAs from the installed system path. */ ret = addDir(IPA_MODULE_DIR); if (ret > 0) ipaCount += ret; diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 1e5b54b34078..88658ac563f7 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -107,11 +107,17 @@ if get_option('android') libcamera_link_with += android_camera_metadata endif +# We add '/' to the build_rpath as a 'safe' path to act as a boolean flag. +# The build_rpath is stripped at install time by meson, so we determine at +# runtime if the library is running from an installed location by checking +# for the presence or abscence of the dynamic tag. + libcamera = shared_library('camera', libcamera_sources, install : true, link_with : libcamera_link_with, include_directories : includes, + build_rpath : '/', dependencies : libcamera_deps) libcamera_dep = declare_dependency(sources : [libcamera_api, libcamera_ipa_api, libcamera_h], From patchwork Thu Feb 20 16:57:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 2865 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A4EAB625F2 for ; Thu, 20 Feb 2020 17:57:09 +0100 (CET) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2C638563; Thu, 20 Feb 2020 17:57:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1582217829; bh=o825z2mBmqGgfOlpAMuJrhE+WpWInSwjhg8rDuYV63k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t/z+9BaSBA1eBH8e5c8vk4EiuSlQDDJ2RgxIDGh3rNzzPICV6yb4SJR7P3XJl99YR TyT/JXlGluUL/yEM2az6luVvwTqLn0lnrQfPi3ixnn1sS9XvsbGJqKkhTUQJhhfB6R ehVhqbSWAWGaAYHo2C7QP3SY/LBjwOrAiFI+CJ8M= From: Kieran Bingham To: libcamera devel Date: Thu, 20 Feb 2020 16:57:04 +0000 Message-Id: <20200220165704.23600-7-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200220165704.23600-1-kieran.bingham@ideasonboard.com> References: <20200220165704.23600-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 6/6] tests: Remove IPA_MODULE_PATH environment variable X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Feb 2020 16:57:11 -0000 The tests declare a hard-coded LIBCAMERA_IPA_MODULE_PATH to allow tests to run from the test-suite. This requires tests to be run only from the root of the build directory, otherwise (for example, by running in their local directory) they will not be able to correctly locate the IPA modules. Now that the build path for the IPA manager is determined at runtime we can remove the redundant setting of the LIBCAMERA_IPA_MODULE_PATH for tests. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- test/libtest/test.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/libtest/test.cpp b/test/libtest/test.cpp index 333d2160e276..6cd3fbe6df06 100644 --- a/test/libtest/test.cpp +++ b/test/libtest/test.cpp @@ -21,10 +21,6 @@ int Test::execute() { int ret; - ret = setenv("LIBCAMERA_IPA_MODULE_PATH", "src/ipa", 1); - if (ret) - return errno; - ret = setenv("LIBCAMERA_IPA_PROXY_PATH", "src/libcamera/proxy/worker", 1); if (ret) return errno;