From patchwork Wed Mar 18 11:58:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 3163 Return-Path: Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0C20D60419 for ; Wed, 18 Mar 2020 12:59:12 +0100 (CET) Received: by mail-pl1-x643.google.com with SMTP id h11so1580649plr.11 for ; Wed, 18 Mar 2020 04:59:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=agsiwyHzfZJIIoAsTPb14yEuXD72N4ZhO6DvJhFu2dY=; b=t7iWuFgJ/CdAQPrS7GtGEY1Qaow9FN18Jt8LwE1rKWep30XNX11ess7aQxTvdc7ndM IlWHocS6GKYbTBIxxoInMdfaDtZeEQw7LxpQVDi6mmZ6K8l0q+398Gqa3c7FUVIXFekc jniLxRfZha/m5K8EsBB4b3yXWUtsZy3gAkVutZgXw6F4SAkFvVDxEPmecbCIAvxJYnBi IMYHoXcobjyMKn0+7pHMpyyq4DirBwCgFccTS8rP5iwCrkTx9pgy9nk8DPL8WmhEDwWm ACc83CCTkpi/R0CJihoS0NH/nEPJLdFnNSqzbs5b0u/Lhw4WU4FXKonfuOMuBquAK1oM AQRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=agsiwyHzfZJIIoAsTPb14yEuXD72N4ZhO6DvJhFu2dY=; b=hOo2SyE2FKSip6kuRRchqvmSIA3pnFymR7q23w4W3BgLJSFojZ/kJvNoBjR3x+dLUc bNlwJh2lFm7A57efIQcuZrvdXTOlmepE8fDBH529SDoodfGeyq967Qr7UrRQerbwN9WI UJGhOfS2bR/Lptdh7XgVddvrYDxBq0ujSu3XmMwcTHrf0RVBKtbBH7bR0f6lqTU5hh7m mMeadvh4R321ai+45gY8nyD/yfFha2VbnK2uj6cskQmyWI9d0pgxTbFqwEmCQj5/kzeq ZXbtB+kXUTiewpvgXaK0wDt2F7WamdmjQRHFL4FqWIbi0dIUYIbHtF97rp14w5uEaBRh 5Z6A== X-Gm-Message-State: ANhLgQ19AYeWKTS+l9SxCxJgEWsY+1F/tB+bO8cq5AsbwDStmrv7FrQM vzpvvjbG9g1FxligudDP8zuvVQ== X-Google-Smtp-Source: ADFU+vuwTWVey58q002cNJpgZljei5oaZDirhMs8nG30CdG12S8OUD+HwoCRPa9PeoMEz/oW+crlJQ== X-Received: by 2002:a17:902:528:: with SMTP id 37mr3641534plf.322.1584532750286; Wed, 18 Mar 2020 04:59:10 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.153]) by smtp.gmail.com with ESMTPSA id k3sm6542539pfp.142.2020.03.18.04.59.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2020 04:59:09 -0700 (PDT) From: Kaaira Gupta To: Helen Koike , Vaishali Thakkar , kieran.bingham@ideasonboard.com, libcamera-devel@lists.libcamera.org Cc: Kaaira Gupta Date: Wed, 18 Mar 2020 17:28:41 +0530 Message-Id: <20200318115846.7975-2-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200318115846.7975-1-kgupta@es.iitr.ac.in> References: <20200318115846.7975-1-kgupta@es.iitr.ac.in> Subject: [libcamera-devel] [PATCH LIBCAMERA v3 1/6] libcamera: ipa_proxy: use utils::split() 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: Wed, 18 Mar 2020 11:59:12 -0000 Replace the manual string splitting with utils::split() Signed-off-by: Kaaira Gupta Reviewed-by: Kieran Bingham --- src/libcamera/ipa_proxy.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp index 5a3d2f1..c7347c8 100644 --- a/src/libcamera/ipa_proxy.cpp +++ b/src/libcamera/ipa_proxy.cpp @@ -83,21 +83,16 @@ std::string IPAProxy::resolvePath(const std::string &file) const /* No exec target in install directory; check env variable. */ const char *execPaths = utils::secure_getenv("LIBCAMERA_IPA_PROXY_PATH"); - while (execPaths) { - const char *delim = strchrnul(execPaths, ':'); - size_t count = delim - execPaths; + if (execPaths) { + for (const auto &dir : utils::split(execPaths, ":")) { + if (dir.empty()) + continue; - if (count) { - std::string proxyPath(execPaths, count); + std::string proxyPath = dir; proxyPath += proxyFile; if (!access(proxyPath.c_str(), X_OK)) return proxyPath; } - - if (*delim == '\0') - break; - - execPaths += count + 1; } return std::string(); From patchwork Wed Mar 18 11:58:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 3164 Return-Path: Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B23DA60419 for ; Wed, 18 Mar 2020 12:59:18 +0100 (CET) Received: by mail-pg1-x541.google.com with SMTP id 7so13573798pgr.2 for ; Wed, 18 Mar 2020 04:59:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rdfoQjGn5hqOOYCxvBAN9ITJhTDA0Hwl1+8XEz2sZtE=; b=U4mgLJKKTss/QeKt+ZeZQNKSqkOq1Bo+q4ARsafwKOmEIBgv1xscvEmunYWmAsEXJC 32IUnj/pQ6pgD2S6QmdarbwWp7bCKZbNOXviyjLdi0jLSAoPv3LHcP1LMqGSaagZAm40 uPlwxdvBd1hppYgAF/GnT99eatuJW2kgsEREfDsE5jByUsVprgZ8ceUWM6gk3mGbTqFb TM92rlxRe8UcplkEKlpYHCS/NMvWa0SM4IptzMX4OgTOcwM6FPkCEwXJs96skKPy/Rvm TLsr8RNSfkjwQxUR3sdWrhsA1POZt9V0aw6j5fvF/aU2Gqcai3iELxgQBfoacP7BoOFt nXpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rdfoQjGn5hqOOYCxvBAN9ITJhTDA0Hwl1+8XEz2sZtE=; b=LaivrbllxBG30DqnRuG5zisyDszY9pmaRNzuMquuz8Xm4G2JgW/+Jdu0SHc4Ftlsu6 8gIgyF1UDSPnEKbqaIvU5JM5P0uFz8cJP0XUR4euLcx4cBu2ix+fcOheUIgCgxkYv3hD wTToj1AiURn8xg3VTWl1LdADFWTJrrfxLi51A0QPOgECD4hQ//sOPdJ/hlsep0X8FqyX KqIM8haVRefjd3dlESGOfSSe3BsYBuMLuecI82irZbwAh7qZbzLjrLwZZRs3dPE5hOjF B9E0pBKjhX51hF05v7tqDtn9cFvAs6Ta546l8t7Mxu24OY7uMijH6McOaA05luFcISa9 /rDQ== X-Gm-Message-State: ANhLgQ1ILhFASZzMaTrbhkBOAXfFa4I8KtT06lcUJ8iCKN7tcgaS27mv NNMBSNUZn6UkKyf0V7encoKLiA== X-Google-Smtp-Source: ADFU+vsM8m9D1kccTl9URjP4XBkRY4fifT7+vai8XGdZbW58ArRroxp+dYQR9/+sTubk5zSx7eHrQQ== X-Received: by 2002:aa7:8f22:: with SMTP id y2mr4072001pfr.300.1584532757300; Wed, 18 Mar 2020 04:59:17 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.153]) by smtp.gmail.com with ESMTPSA id i11sm2378519pje.30.2020.03.18.04.59.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2020 04:59:16 -0700 (PDT) From: Kaaira Gupta To: Helen Koike , Vaishali Thakkar , kieran.bingham@ideasonboard.com, libcamera-devel@lists.libcamera.org Cc: Kaaira Gupta Date: Wed, 18 Mar 2020 17:28:42 +0530 Message-Id: <20200318115846.7975-3-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200318115846.7975-1-kgupta@es.iitr.ac.in> References: <20200318115846.7975-1-kgupta@es.iitr.ac.in> Subject: [libcamera-devel] [PATCH LIBCAMERA v3 2/6] libcamera: ipa_proxy: rearrange proxies 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: Wed, 18 Mar 2020 11:59:18 -0000 User environment path in LIBCAMERA_IPA_PROXY_PATH should take precedence over system loading locations. Change precedence accordingly Signed-off-by: Kaaira Gupta Reviewed-by: Kieran Bingham --- src/libcamera/ipa_proxy.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp index c7347c8..b409e1d 100644 --- a/src/libcamera/ipa_proxy.cpp +++ b/src/libcamera/ipa_proxy.cpp @@ -75,13 +75,9 @@ IPAProxy::~IPAProxy() */ std::string IPAProxy::resolvePath(const std::string &file) const { - /* Try finding the exec target from the install directory first */ std::string proxyFile = "/" + file; - std::string proxyPath = std::string(IPA_PROXY_DIR) + proxyFile; - if (!access(proxyPath.c_str(), X_OK)) - return proxyPath; - /* No exec target in install directory; check env variable. */ + /* Check env variable first. */ const char *execPaths = utils::secure_getenv("LIBCAMERA_IPA_PROXY_PATH"); if (execPaths) { for (const auto &dir : utils::split(execPaths, ":")) { @@ -95,6 +91,11 @@ std::string IPAProxy::resolvePath(const std::string &file) const } } + /* 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; + return std::string(); } From patchwork Wed Mar 18 11:58:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 3165 Return-Path: Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4E3A860419 for ; Wed, 18 Mar 2020 12:59:24 +0100 (CET) Received: by mail-pf1-x435.google.com with SMTP id 2so13766006pfg.12 for ; Wed, 18 Mar 2020 04:59:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mKogFjsmRN3byaPv0b/6ZZyVMnNZ8tddAXwdndhLKH0=; b=u14CwDODjdreSOhe+S5/2Iw7Bmqq2rKc5MIYmg9FelM4Fu9ILp6bjecor/qEKS8vAR Ob1KJA9vQcYf1np6Wx/SJldcGqfW4isTpKQSX/p+whyHmW7Gc73xzbY0UGSx1w9gcljo WBGNhyIWjbHE5+nuntatv8o7gzETDZ+P0rgY2xumuXiwn0oA9LdMlaTHDM1SrSFASDVs XFxalksr4KpORQCG84/6S+pJnNyRKHnbMS67hpirVmUxacVLdOH9ZEmAinFUBja3fdsm 2COrutuQyUI5MWEodUCB7A8aYKEXdMQF5KnfzgiCoTX0UAIrEZ/IqLL7T5nlQt5vsNgE CFQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mKogFjsmRN3byaPv0b/6ZZyVMnNZ8tddAXwdndhLKH0=; b=jqDOiJbhfQ8sPnIOoWKG1hkIzNmxIg8QQ3BIUVlvtc4W9h9zeNPbQOC3bmyvStIFHc 263hmGt2t5jgDTHlf542CHWDF8xb/GbQPek7NPJJuhqZrcYd++JMR8PdNbXAcuLbG2xd EJ4mH4RCojR0UZ13YmGeZMsEZqBgLWhrzIaqOKsRV8QLlY1P0ctzsZvijuUHwqaMswEd SDpAdJAhB/bukwjNqApDmV0bRulrsVKFv8Aa8JQHsJcFyCXKcoj9QlXtYkbyEPPgcYLt +9fPS1drFPZUY7WV0qqQasJI7Jd1SbHRz5iAehJ7cC1qH7L0XvtjSx1CzRBgMARmWww5 50fw== X-Gm-Message-State: ANhLgQ0Nx0wK9CpS2paDA6M3WAgujfrC6SCt0fop3NUd2TC68z41I94a OpPMZu1aYAM6GXS0QP5Or+EHuQ== X-Google-Smtp-Source: ADFU+vuC/5vEGkQqxzRm7VlMppCyPeDQR+8AmrOh7WcL3kRqbA/0+VtT6yHbgX+wa/f62TvAczpcxQ== X-Received: by 2002:a62:1cf:: with SMTP id 198mr4062245pfb.246.1584532762859; Wed, 18 Mar 2020 04:59:22 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.153]) by smtp.gmail.com with ESMTPSA id i11sm2378818pje.30.2020.03.18.04.59.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2020 04:59:22 -0700 (PDT) From: Kaaira Gupta To: Helen Koike , Vaishali Thakkar , kieran.bingham@ideasonboard.com, libcamera-devel@lists.libcamera.org Cc: Kaaira Gupta Date: Wed, 18 Mar 2020 17:28:43 +0530 Message-Id: <20200318115846.7975-4-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200318115846.7975-1-kgupta@es.iitr.ac.in> References: <20200318115846.7975-1-kgupta@es.iitr.ac.in> Subject: [libcamera-devel] [PATCH LIBCAMERA v3 3/6] libcamera: utils: add Libcamera installed & path 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: Wed, 18 Mar 2020 11:59:24 -0000 Add a global functions 'isLibcameraInstalled' to check if libcamera is installed or not, and another global function 'libcameraPath' to return the path of libcamera.so in utils. Signed-off-by: Kaaira Gupta --- src/libcamera/include/utils.h | 4 +++ src/libcamera/utils.cpp | 48 +++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h index 9405977..bc96e79 100644 --- a/src/libcamera/include/utils.h +++ b/src/libcamera/include/utils.h @@ -143,6 +143,10 @@ private: details::StringSplitter split(const std::string &str, const std::string &delim); +bool isLibcameraInstalled(); + +std::string libcameraPath(); + } /* namespace utils */ } /* namespace libcamera */ diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp index f566e88..aeaf163 100644 --- a/src/libcamera/utils.cpp +++ b/src/libcamera/utils.cpp @@ -12,12 +12,18 @@ #include #include #include +#include +#include +#include /** * \file utils.h * \brief Miscellaneous utility functions */ +/* musl doesn't declare _DYNAMIC in link.h, declare it manually. */ +extern ElfW(Dyn) _DYNAMIC[]; + namespace libcamera { namespace utils { @@ -310,6 +316,48 @@ details::StringSplitter split(const std::string &str, const std::string &delim) return details::StringSplitter(str, delim); } +/** + * \brief Checks if Libcamera is installed or not + * + * Utilises 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. + * + * \return A bool stating if libcamera is installed or not + */ +bool isLibcameraInstalled() +{ + /* + * DT_RUNPATH (DT_RPATH when the linker uses old dtags) 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; +} + +/** + * \brief Identifies libcamera path + * + * Identifies the location by finding the path of the active libcamera.so itself. + * + * \return A string stating the path. + */ +std::string libcameraPath() +{ + Dl_info info; + + /* Look up our own symbol. */ + int ret = dladdr(reinterpret_cast(libcameraPath), &info); + if (ret == 0) + return nullptr; + + return info.dli_fname; +} + } /* namespace utils */ } /* namespace libcamera */ From patchwork Wed Mar 18 11:58:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 3166 Return-Path: Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 89DDA60419 for ; Wed, 18 Mar 2020 12:59:29 +0100 (CET) Received: by mail-pg1-x544.google.com with SMTP id m5so13571828pgg.0 for ; Wed, 18 Mar 2020 04:59:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=S9PynKcuJpQuOHFN0kYzs6do1Q7f5BCY5H/KXRXtOSw=; b=0fH4m7JPOKML1jbO5sadrOwmzYctIEJNi0shwkBi1nJWytq0MsPF99JWvozUZapOK+ 4ceanhci/SwPr8GWIC9QlZMddwPZa4qoCaVSIeQWHP163X7vfuzfF6VZrGTSRLC6+LW7 cb93j+CIgqws15DtWm/spu0TR2+qz6rDiFk7Onn+XIFEQ3b+1X6vqTlkfM6M/qTxIWCF 42obaQNvVB747wV1XXukyUfRxB2C2OXOj2kyot1HPkNH3tAcRhQ6kWBlc+6ZumbkQhlV WEk1z7aeGU4SwZI+L8V0CKU3ZB5OKL2GXtERtZG7sQpVpVMh/ilL3n8mhOYaK0v3okPi Aryw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=S9PynKcuJpQuOHFN0kYzs6do1Q7f5BCY5H/KXRXtOSw=; b=TUA5PUYjr30Y1Kwc9eO4AJwXRqAcf9ZGj6+Bkbn/jvMMG+PuVQUPjl4FISudmo1P8V BV0HgolpOw7qpXiDcQu+LzblmKs08y79WXrwaKVKTa9H7ktHnZOc4nguPalOOXniSIwa EsnU/uOtvTGWn1jwJS626lnP/a6lrjrEtjV+rcRwEkJNYn9+76BZ06yPqbmtpMZKWf/Z yAXdv2SYIhQGMmp4u+8WpZ6ltXXzER9q/p+7kaWWR7dwr6jMXHwefYEu3ugAwSbgsyRU FwKmOFzlNmzvn92FN+x6Bp2e6t/cQxNBPom0w/LgIBRSNYc8G9xnEF4r0FnnCeIHmQ6j T7GA== X-Gm-Message-State: ANhLgQ0kvkTBS5btJ+6sPNUwUuF5Hfub61Gn3hrEWrsvt9F5rSHvxrIh vSr7dwlBrj8cpdz7Icck+M83aJiobiU= X-Google-Smtp-Source: ADFU+vvouxoXglSf1HSkQuIcmGFk+yvofKmvOvPRdpjXMeMX5Odc0iQv3sIvAstb3Q2I7XPmCwZaow== X-Received: by 2002:a63:8b42:: with SMTP id j63mr4038255pge.27.1584532768129; Wed, 18 Mar 2020 04:59:28 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.153]) by smtp.gmail.com with ESMTPSA id g6sm2288456pjv.13.2020.03.18.04.59.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2020 04:59:27 -0700 (PDT) From: Kaaira Gupta To: Helen Koike , Vaishali Thakkar , kieran.bingham@ideasonboard.com, libcamera-devel@lists.libcamera.org Cc: Kaaira Gupta Date: Wed, 18 Mar 2020 17:28:44 +0530 Message-Id: <20200318115846.7975-5-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200318115846.7975-1-kgupta@es.iitr.ac.in> References: <20200318115846.7975-1-kgupta@es.iitr.ac.in> Subject: [libcamera-devel] [PATCH LIBCAMERA v3 4/6] libcamera: ipa_proxy: search for proxy 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: Wed, 18 Mar 2020 11:59:29 -0000 When libcamera is built and tested before installing, it will be unable to locate the path to proxy files, or previously installed files in the system path may be incorrect to load. Hence, when libcamera is not installed and running from a build tree, identify the location of that tree by using libcameraPath(), and from that point add relative path to the proxy file. Signed-off-by: Kaaira Gupta --- src/libcamera/ipa_proxy.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp index b409e1d..1014e79 100644 --- a/src/libcamera/ipa_proxy.cpp +++ b/src/libcamera/ipa_proxy.cpp @@ -91,10 +91,23 @@ std::string IPAProxy::resolvePath(const std::string &file) const } } - /* 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; + /* + * When libcamera is used before it is installed, load proxies 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 proxies from that point. + */ + if (!utils::isLibcameraInstalled()) { + std::string ipaProxyDir = utils::dirname(utils::libcameraPath()) + "/../../proxy"; + + LOG(IPAProxy, Info) + << "libcamera is not installed. Adding '" + << ipaProxyDir << "' to the Proxy search path"; + + std::string proxyPath = ipaProxyDir + proxyFile; + if (!access(proxyPath.c_str(), X_OK)) + return proxyPath; + } return std::string(); } From patchwork Wed Mar 18 11:58:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 3167 Return-Path: Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9F70F60418 for ; Wed, 18 Mar 2020 12:59:34 +0100 (CET) Received: by mail-pl1-x62f.google.com with SMTP id h11so11089025plk.7 for ; Wed, 18 Mar 2020 04:59:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9ua74D+pawbGOHEp2jkPTCrGO8MCR0QT8xKXKQ8HvG0=; b=SUp8S9ZOG/9Yq5OGbQIKPS2i3I38RV4wnQeqtwUyoNGhuvxiyaCFyJT6k2YofeI20T piWUVI32G49w20k8ukdzCqQAUSoJ1lgra6ceLxs2yjuLbA+aq+ql8mJFtCt+iBP1eP7s o2ECOfCcnCEzCbZju9WcqdkwWCC3mSwxs+bHTXSQbHYI51dklhIwOpn7M57xS4ghCecr QyoLggcRP1MDEdFtAsMAyp4Tpf96hB6Z6bqK8emLkQpVEssIzugIFV2k5CwYI0jLvN7c 53wp/uuqK2/u5oWTHD0PdAiDlBtl4NeThZ2OLH+QJDPIMaaqUgSauGV8xwmwQWsJSSyt jUhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9ua74D+pawbGOHEp2jkPTCrGO8MCR0QT8xKXKQ8HvG0=; b=kgIliijTd2KVuTPpMaKLeFAlhsn217+MpBFZ9/MTVDBT1LfrKnCFdt7lwdk2243Q1q xD+UEO46N89HXYUxTKIBm/hx8zwA6Eu1WmaOm9LbZjYLrp7Gs4YldaAOiAFY9wD8oInQ RHois0fuLzEpEv8NuO31q4+xHTkWnKz2C/6+Ihsdbup8jc05NxhacGMSsXCQWRc8efba LuW5UqLXowQhpue+21ot9b6NfnFZMsGGU6IwoSGhEzKfo4VPGr43TOmWiqabSXrLjjPZ g2q2SZL9CrPPTt/tij6yRc3zdb9Orqjzto9GHqnkCLFceu85QQT9YuUWJUH8FekYrdz6 p89g== X-Gm-Message-State: ANhLgQ0sKSa3nI3xghhcPK3AZzWCivrU8mRl7QUSd5wFkH/1nRNS8tK9 xODkzs2j13auJ8Q1/5wa68VmVA== X-Google-Smtp-Source: ADFU+vsZqqhy6NBdWaVB/hHnvbRBVURdD7miE7eUgwek5N6FmXWnPP4jrEV3hYopqyK3AJX7VhYJYQ== X-Received: by 2002:a17:90a:3328:: with SMTP id m37mr4296506pjb.158.1584532773127; Wed, 18 Mar 2020 04:59:33 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.153]) by smtp.gmail.com with ESMTPSA id y131sm6613014pfg.25.2020.03.18.04.59.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2020 04:59:32 -0700 (PDT) From: Kaaira Gupta To: Helen Koike , Vaishali Thakkar , kieran.bingham@ideasonboard.com, libcamera-devel@lists.libcamera.org Cc: Kaaira Gupta Date: Wed, 18 Mar 2020 17:28:45 +0530 Message-Id: <20200318115846.7975-6-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200318115846.7975-1-kgupta@es.iitr.ac.in> References: <20200318115846.7975-1-kgupta@es.iitr.ac.in> Subject: [libcamera-devel] [PATCH LIBCAMERA v3 5/6] libcamera: ipa_manager: replace by utils functions 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: Wed, 18 Mar 2020 11:59:34 -0000 Now that functions isLibcameraInstalled() and libcameraPath() are defined in utils, they don't need to be defined here again. Hence remove them and replace them with utils' functions. Signed-off-by: Kaaira Gupta --- src/libcamera/ipa_manager.cpp | 36 ++--------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index 238433d..0bd280c 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -9,9 +9,6 @@ #include #include -#include -#include -#include #include #include @@ -27,35 +24,6 @@ * \brief Image Processing Algorithm module manager */ -static bool isLibcameraInstalled() -{ - /* musl doesn't declare _DYNAMIC in link.h, declare it manually. */ - extern ElfW(Dyn) _DYNAMIC[]; - - /* - * DT_RUNPATH (DT_RPATH when the linker uses old dtags) 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 std::string libcameraPath() -{ - Dl_info info; - - /* Look up our own symbol. */ - int ret = dladdr(reinterpret_cast(libcameraPath), &info); - if (ret == 0) - return nullptr; - - return info.dli_fname; -} - namespace libcamera { LOG_DEFINE_CATEGORY(IPAManager) @@ -151,8 +119,8 @@ IPAManager::IPAManager() * path for the IPA from that point. We need to recurse one level of * sub-directories to match the build tree. */ - if (!isLibcameraInstalled()) { - std::string ipaBuildPath = utils::dirname(libcameraPath()) + "/../ipa"; + if (!utils::isLibcameraInstalled()) { + std::string ipaBuildPath = utils::dirname(utils::libcameraPath()) + "/../ipa"; constexpr int maxDepth = 1; LOG(IPAManager, Info) From patchwork Wed Mar 18 11:58:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 3168 Return-Path: Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 884AD60418 for ; Wed, 18 Mar 2020 12:59:39 +0100 (CET) Received: by mail-pl1-x642.google.com with SMTP id g2so8585619plo.3 for ; Wed, 18 Mar 2020 04:59:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tsazxHH1+SOiGiAm5erMhZ+1DNE5amuFMkfAMcCKrrw=; b=wmg7t80qiT3hfOo1m7iVTjydFkh+/PfPp5CGHjaiT10hs993GQ3f1V13s9aZ+BEJIi U+l/5JvGcqI/wBcF4BQsz6S5zs9/r9FEdloHx15yqk+g+3DJkcohIiJbRBG4++e11DC7 ShCT94+ErSnCPxvHeKMnAufzRgZq+Z8VssJ4yiHLfiV9zHdBovaC65EJFh/NV6PJWA08 Uo7htoVNH0Ft9wMe3zYLaDq/vYfw2pUk+Op95FtK4EOmtyv7OFDPTAwERZPhtEfGeQDK vnr8G6AIZnd0pE0rCfwxv/S3Pcpj98jW55cEZH4krlahShg3xXeZSILa7lcDY6czogHn +jUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tsazxHH1+SOiGiAm5erMhZ+1DNE5amuFMkfAMcCKrrw=; b=DQyS3WXrvbby3SnLvwgBPfUe/fOkcnXwk/hNZT/Ghw47rvoVA14atva4wAMffZEIUN ReUUD4B1ZKxfkjmcRAAB3saq6MCabUn5yOZVeqHBpfiuwh9pbsTMN47Xai2CWjf36iW1 11SEA56SOexw7PpQA50Xc2V/ujp7JS5ivetTmbczHnxXU7kbNAXImcn8M/iLI//y8UVs LnHROBIHP/tfEKYaY8TNku3DZXu4GAu64B/SLfw2ZfKd3WpdxLgqkOLkR0/oCy1osTnc NrT6mJQlX+jYOvZN9rmQxYnmICdjaUt60QWFWXUQxcqy4F3LrcYVMvndV+9Cs2FAKpzS 6niQ== X-Gm-Message-State: ANhLgQ2BVvy4Q37yD25APXvpE61Y9CUiuE7ZxwNhAm6VUZlZ4FIO4WiG AMOnyHms8MrFIRDRn1dyE0AS7w== X-Google-Smtp-Source: ADFU+vscHbD7d5daoSVcc9awgTcbwNO2nRprxxq+smCOsyWAbReENp8iJm0C22K+Ywl69EKWMnK9Ig== X-Received: by 2002:a17:90b:355:: with SMTP id fh21mr4155079pjb.147.1584532778017; Wed, 18 Mar 2020 04:59:38 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.153]) by smtp.gmail.com with ESMTPSA id q6sm2344750pja.34.2020.03.18.04.59.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2020 04:59:37 -0700 (PDT) From: Kaaira Gupta To: Helen Koike , Vaishali Thakkar , kieran.bingham@ideasonboard.com, libcamera-devel@lists.libcamera.org Cc: Kaaira Gupta Date: Wed, 18 Mar 2020 17:28:46 +0530 Message-Id: <20200318115846.7975-7-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200318115846.7975-1-kgupta@es.iitr.ac.in> References: <20200318115846.7975-1-kgupta@es.iitr.ac.in> Subject: [libcamera-devel] [PATCH LIBCAMERA v3 6/6] tests: remove IPA_PROXY_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: Wed, 18 Mar 2020 11:59:39 -0000 The tests declare a hard-coded LIBCAMERA_IPA_PROXY_PATH to allow tests to run from tests-suite. Now that the proxy path is determined at runtime, we can remove the redundant setting of LIBCAMERA_IPA_PROXY_PATH for tests. Signed-off-by: Kaaira Gupta Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- test/libtest/test.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/libtest/test.cpp b/test/libtest/test.cpp index 6cd3fbe..fd9f3d7 100644 --- a/test/libtest/test.cpp +++ b/test/libtest/test.cpp @@ -21,10 +21,6 @@ int Test::execute() { int ret; - ret = setenv("LIBCAMERA_IPA_PROXY_PATH", "src/libcamera/proxy/worker", 1); - if (ret) - return errno; - ret = init(); if (ret) return ret;