From patchwork Thu Mar 19 12:42:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 3195 Return-Path: Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5A15B629AC for ; Thu, 19 Mar 2020 13:43:01 +0100 (CET) Received: by mail-pj1-x1031.google.com with SMTP id v13so986634pjb.0 for ; Thu, 19 Mar 2020 05:43:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=8RpfOHzKGZeAw4fCqiifLDLNZT3TryQA2olsuLZqbfc=; b=qCTPegBbzKmNG615eE/JnxpCNSp7KNMRDaEwYx5aJc+iary5LEgTTS9GD9TjRRcxEy T/ZCBbinyX7iXkc9RQOV6XU2AuObcor6lS1FbxaWN4ZwplS8c55twpGQsOQvbSnnM17x n2MKNtjJ+2pei+JopaW7JC/UF9DJfpaucI/2lKbT2QlUPDItRf8zc6dTdM0xQrD5RcLw B63dXeocJGbY9Tcjt3H7LXaYWbT64p96iebAM5ThdL2+2MS1t5UI57hz9bwrP1LekHc9 g5aXdyUNhjtL6gF+3LLr6vS92pY/paZEYACOUeUKjG/AqAe0KFuha6qdmkGNk12tP/xb 7jWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=8RpfOHzKGZeAw4fCqiifLDLNZT3TryQA2olsuLZqbfc=; b=ZfK82BABz++b54/mwKNY/LfLo829pulM1O38VT8QeLDx8soAbl7e/SiymxD3mihDXy vaIOcJWfiReGPA87e4YHaAIJKWOfaApxC1axNrPpaviRElcw51e5HQMHql4Ucw+etsrG Ne70BAAWsKPHV5Lr19cmcFYfx7Ay3G3dmAAhSPzzVeIyqdZwNT5ndQdj0TP+qCDUSKAa IVLpXWV+VqrJ+UPb990octuXnvRyBAyTVVCdTx6Q4V1oQx4htRStQoPlkKL+6ZgFjom9 +DBPeQnJlTGBEeQzduZ+r5M/C+kNm2cLpnnU5Z8NFiBGpz1xtb9v8kgcG+pYPuF/fauj JQTw== X-Gm-Message-State: ANhLgQ3rLzosV7LS8pnzq3x+fhdj2QKD7KSkijE3CKBnDoRb/cueLdNP kcD3KOEJTkrunI6mi0QlK9fEXc8f/dI= X-Google-Smtp-Source: ADFU+vv+MRZ8oniiASNfVSOHThNeLT5r67v2ngwIvBaYqj0VYMpJGDeGF3+GcWoD4qWCl0GcpJiooA== X-Received: by 2002:a17:90a:c695:: with SMTP id n21mr3610486pjt.133.1584621779089; Thu, 19 Mar 2020 05:42:59 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.153]) by smtp.gmail.com with ESMTPSA id a19sm2466745pfk.110.2020.03.19.05.42.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Mar 2020 05:42:58 -0700 (PDT) Date: Thu, 19 Mar 2020 18:12:52 +0530 From: Kaaira Gupta To: Helen Koike , Vaishali Thakkar , kieran.bingham@ideasonboard.com, libcamera-devel@lists.libcamera.org Message-ID: <20200319124252.GA31289@kaaira-HP-Pavilion-Notebook> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Subject: [libcamera-devel] [PATCH LIBCAMERA v3] libcamera: utils: adapt libcameraPath to match use cases 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, 19 Mar 2020 12:43:01 -0000 The two callers of functions libcameraPath() and isLibcameraInstalled() end up using the same process and finally use the path with libcamera.so. Hence write a function libcameraBuildPath() which combines their functions and returns the root of the build sources when the library has not been installed, but is running,thereby making call sites simpler. When the library is imstalled, libcameraBuildPath() will return an empty string. Make changes in the call sites accordingly. Signed-off-by: Kaaira Gupta Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- Changes since v2: - rename subject line and add necessary details in commit message. - Solve whitespace issues. - specify the final 'slash' for directory path in return statement itself. Changes since v1: - rename function to libcameraBuildPath() instead, and return the root of libcamera source, and not the source directory root. - Return empty string instead of nullptr when ret==0 src/libcamera/include/utils.h | 2 +- src/libcamera/ipa_manager.cpp | 5 +++-- src/libcamera/ipa_proxy.cpp | 6 +++--- src/libcamera/utils.cpp | 16 +++++++++------- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h index bc96e79..5dea8d2 100644 --- a/src/libcamera/include/utils.h +++ b/src/libcamera/include/utils.h @@ -145,7 +145,7 @@ details::StringSplitter split(const std::string &str, const std::string &delim); bool isLibcameraInstalled(); -std::string libcameraPath(); +std::string libcameraBuildPath(); } /* namespace utils */ diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index 0bd280c..bcaae35 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -119,8 +119,9 @@ IPAManager::IPAManager() * path for the IPA from that point. We need to recurse one level of * sub-directories to match the build tree. */ - if (!utils::isLibcameraInstalled()) { - std::string ipaBuildPath = utils::dirname(utils::libcameraPath()) + "/../ipa"; + std::string root = utils::libcameraBuildPath(); + if (!root.empty()) { + std::string ipaBuildPath = root + "src/ipa"; constexpr int maxDepth = 1; LOG(IPAManager, Info) diff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp index 2f866cc..5fd88a4 100644 --- a/src/libcamera/ipa_proxy.cpp +++ b/src/libcamera/ipa_proxy.cpp @@ -97,9 +97,9 @@ std::string IPAProxy::resolvePath(const std::string &file) const * 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"; + std::string root = utils::libcameraBuildPath(); + if (!root.empty()) { + std::string ipaProxyDir = root + "src/libcamera/proxy/worker"; LOG(IPAProxy, Info) << "libcamera is not installed. Loading proxy workers from'" diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp index 7e118fa..42c5c76 100644 --- a/src/libcamera/utils.cpp +++ b/src/libcamera/utils.cpp @@ -347,16 +347,18 @@ bool isLibcameraInstalled() * * \return A string stating the path */ -std::string libcameraPath() +std::string libcameraBuildPath() { - Dl_info info; + if (!isLibcameraInstalled()) { + Dl_info info; - /* Look up our own symbol. */ - int ret = dladdr(reinterpret_cast(libcameraPath), &info); - if (ret == 0) - return nullptr; + /* Look up our own symbol. */ + int ret = dladdr(reinterpret_cast(libcameraBuildPath), &info); + if (ret) + return dirname(info.dli_fname) + "/../../"; + } - return info.dli_fname; + return std::string(); } } /* namespace utils */