<div dir="auto"><div>Please ignore. </div><div dir="auto">Sent wrong version.<br><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">On Thu, 19 Mar, 2020, 20:49 Kaaira Gupta, <<a href="mailto:kgupta@es.iitr.ac.in">kgupta@es.iitr.ac.in</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The two callers of functions libcameraPath() and isLibcameraInstalled()<br>
end up using the same process and finally use the path with<br>
libcamera.so. Hence write a function libcameraBuildPath() which<br>
combines their functions and returns the root of the build sources<br>
when the library has not been installed, but is running, thereby making<br>
call sites simpler.<br>
<br>
When the library is installed, libcameraBuildPath() will return an empty<br>
string.<br>
<br>
Make changes in the call sites accordingly.<br>
<br>
Signed-off-by: Kaaira Gupta <<a href="mailto:kgupta@es.iitr.ac.in" target="_blank" rel="noreferrer">kgupta@es.iitr.ac.in</a>><br>
---<br>
Changes since v3:<br>
- removed isLibcameraInstalled() from utils.h<br>
- reformatted the code to reduce indentation of the code that<br>
implements actual logic, also, to catch the errors<br>
immediately.<br>
- changes in spellings and whitespaces in commit messages.<br>
<br>
Changes since v2:<br>
- rename subject line and add necessary details in commit<br>
message.<br>
- Solve whitespace issues.<br>
- specify the final 'slash' for directory path in return<br>
statement itself.<br>
<br>
Changes since v1:<br>
- rename function to libcameraBuildPath() instead, and return<br>
the root of libcamera source, and not the source directory<br>
root.<br>
- Return empty string instead of nullptr when ret==0<br>
<br>
src/libcamera/include/utils.h | 2 +-<br>
src/libcamera/ipa_manager.cpp | 5 +++--<br>
src/libcamera/ipa_proxy.cpp | 6 +++---<br>
src/libcamera/utils.cpp | 16 +++++++++-------<br>
4 files changed, 16 insertions(+), 13 deletions(-)<br>
<br>
diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h<br>
index bc96e79..5dea8d2 100644<br>
--- a/src/libcamera/include/utils.h<br>
+++ b/src/libcamera/include/utils.h<br>
@@ -145,7 +145,7 @@ details::StringSplitter split(const std::string &str, const std::string &delim);<br>
<br>
bool isLibcameraInstalled();<br>
<br>
-std::string libcameraPath();<br>
+std::string libcameraBuildPath();<br>
<br>
} /* namespace utils */<br>
<br>
diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp<br>
index 0bd280c..bcaae35 100644<br>
--- a/src/libcamera/ipa_manager.cpp<br>
+++ b/src/libcamera/ipa_manager.cpp<br>
@@ -119,8 +119,9 @@ IPAManager::IPAManager()<br>
* path for the IPA from that point. We need to recurse one level of<br>
* sub-directories to match the build tree.<br>
*/<br>
- if (!utils::isLibcameraInstalled()) {<br>
- std::string ipaBuildPath = utils::dirname(utils::libcameraPath()) + "/../ipa";<br>
+ std::string root = utils::libcameraBuildPath();<br>
+ if (!root.empty()) {<br>
+ std::string ipaBuildPath = root + "src/ipa";<br>
constexpr int maxDepth = 1;<br>
<br>
LOG(IPAManager, Info)<br>
diff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp<br>
index 2f866cc..5fd88a4 100644<br>
--- a/src/libcamera/ipa_proxy.cpp<br>
+++ b/src/libcamera/ipa_proxy.cpp<br>
@@ -97,9 +97,9 @@ std::string IPAProxy::resolvePath(const std::string &file) const<br>
* This requires identifying the path of the libcamera.so, and<br>
* referencing a relative path for the proxy workers from that point.<br>
*/<br>
- if (!utils::isLibcameraInstalled()) {<br>
- std::string ipaProxyDir = utils::dirname(utils::libcameraPath())<br>
- + "/proxy/worker";<br>
+ std::string root = utils::libcameraBuildPath();<br>
+ if (!root.empty()) {<br>
+ std::string ipaProxyDir = root + "src/libcamera/proxy/worker";<br>
<br>
LOG(IPAProxy, Info)<br>
<< "libcamera is not installed. Loading proxy workers from'"<br>
diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp<br>
index 7e118fa..42c5c76 100644<br>
--- a/src/libcamera/utils.cpp<br>
+++ b/src/libcamera/utils.cpp<br>
@@ -347,16 +347,18 @@ bool isLibcameraInstalled()<br>
*<br>
* \return A string stating the path<br>
*/<br>
-std::string libcameraPath()<br>
+std::string libcameraBuildPath()<br>
{<br>
- Dl_info info;<br>
+ if (!isLibcameraInstalled()) {<br>
+ Dl_info info;<br>
<br>
- /* Look up our own symbol. */<br>
- int ret = dladdr(reinterpret_cast<void *>(libcameraPath), &info);<br>
- if (ret == 0)<br>
- return nullptr;<br>
+ /* Look up our own symbol. */<br>
+ int ret = dladdr(reinterpret_cast<void *>(libcameraBuildPath), &info);<br>
+ if (ret)<br>
+ return dirname(info.dli_fname) + "/../../";<br>
+ }<br>
<br>
- return info.dli_fname;<br>
+ return std::string();<br>
}<br>
<br>
} /* namespace utils */<br>
-- <br>
2.17.1<br>
<br>
</blockquote></div></div></div>