[libcamera-devel,v4,4/5] libcamera: ipa_proxy: search for proxy in build tree

Message ID 20200318152427.13126-5-kgupta@es.iitr.ac.in
State Accepted
Commit 250df52bd914ac6af287035e1adcd497c36a38f0
Headers show
Series
  • libcamera: determine IPA_PROXY_PATH at runtime
Related show

Commit Message

Kaaira Gupta March 18, 2020, 3:24 p.m. UTC
When libcamera is built and tested before installing, it will
be unable to locate the path to proxy workers, or previously
installed files in the system path may be incorrect to load.

Hence, when libcamera is not installed, but is running from a build
tree, identify the location of that tree by using libcameraPath(), and
from that point add relative path to the proxy workers directory.

Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>
---
 src/libcamera/ipa_proxy.cpp | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart March 18, 2020, 3:45 p.m. UTC | #1
Hi Kaaira,

Thank you for the patch.

On Wed, Mar 18, 2020 at 08:54:26PM +0530, Kaaira Gupta wrote:
> When libcamera is built and tested before installing, it will
> be unable to locate the path to proxy workers, or previously
> installed files in the system path may be incorrect to load.
> 
> Hence, when libcamera is not installed, but is running from a build
> tree, identify the location of that tree by using libcameraPath(), and
> from that point add relative path to the proxy workers directory.
> 
> Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/libcamera/ipa_proxy.cpp | 23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp
> index b409e1d..2f866cc 100644
> --- a/src/libcamera/ipa_proxy.cpp
> +++ b/src/libcamera/ipa_proxy.cpp
> @@ -91,7 +91,28 @@ std::string IPAProxy::resolvePath(const std::string &file) const
>  		}
>  	}
>  
> -	/* Try finding the exec target from the install directory. */
> +	/*
> +	 * When libcamera is used before it is installed, load proxy workers
> +	 * from the same build directory as the libcamera directory itself.
> +	 * This requires identifying the path of the libcamera.so, and
> +	 * referencing a relative path for the proxy workers from that point.
> +	 */
> +	if (!utils::isLibcameraInstalled()) {
> +		std::string ipaProxyDir = utils::dirname(utils::libcameraPath())
> +					  + "/proxy/worker";
> +
> +		LOG(IPAProxy, Info)
> +			<< "libcamera is not installed. Loading proxy workers from'"
> +			<< ipaProxyDir << "'";
> +
> +		std::string proxyPath = ipaProxyDir + proxyFile;
> +		if (!access(proxyPath.c_str(), X_OK))
> +			return proxyPath;
> +
> +		return std::string();
> +	}
> +
> +	/* Else try finding the exec target from the install directory. */
>  	std::string proxyPath = std::string(IPA_PROXY_DIR) + proxyFile;
>  	if (!access(proxyPath.c_str(), X_OK))
>  		return proxyPath;

Patch

diff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp
index b409e1d..2f866cc 100644
--- a/src/libcamera/ipa_proxy.cpp
+++ b/src/libcamera/ipa_proxy.cpp
@@ -91,7 +91,28 @@  std::string IPAProxy::resolvePath(const std::string &file) const
 		}
 	}
 
-	/* Try finding the exec target from the install directory. */
+	/*
+	 * When libcamera is used before it is installed, load proxy workers
+	 * from the same build directory as the libcamera directory itself.
+	 * This requires identifying the path of the libcamera.so, and
+	 * referencing a relative path for the proxy workers from that point.
+	 */
+	if (!utils::isLibcameraInstalled()) {
+		std::string ipaProxyDir = utils::dirname(utils::libcameraPath())
+					  + "/proxy/worker";
+
+		LOG(IPAProxy, Info)
+			<< "libcamera is not installed. Loading proxy workers from'"
+			<< ipaProxyDir << "'";
+
+		std::string proxyPath = ipaProxyDir + proxyFile;
+		if (!access(proxyPath.c_str(), X_OK))
+			return proxyPath;
+
+		return std::string();
+	}
+
+	/* Else try finding the exec target from the install directory. */
 	std::string proxyPath = std::string(IPA_PROXY_DIR) + proxyFile;
 	if (!access(proxyPath.c_str(), X_OK))
 		return proxyPath;