From patchwork Thu Mar 19 11:59:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 3194 Return-Path: Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D9A9A60417 for ; Thu, 19 Mar 2020 12:59:17 +0100 (CET) Received: by mail-pg1-x52c.google.com with SMTP id h8so1144657pgs.9 for ; Thu, 19 Mar 2020 04:59:17 -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=Cj0nQQashGWYFQCNuAM9OJGr6SbMETPE0vHYU86PlYk=; b=jTR59rxk1XcTv0JWiOrnePq6hEFYzwQzIh0nmSMUEl1cKPE95fXOMkC7+Ym7sWqkyD kommy5sCok0OK3//QEjtnopwvFvm4L9qz1KxqcXPtp9ezGi6OoVxhDrsqHt4waVps0aX OmmbAVUlZxQXXo8JKnIejKnMk7i6YSuOLXN3gpd0xEClXWUruvrS3qwR4XsbvEYqmrzi 82WADpJE2ZPudTjYRW9bJ7EsK0MlHDkMsM+R482VyfuSNldCGXIUY8mXYRhXDY2/nKAy XJyzsNOjV7TIwZhdd3jspACi4mRQYFhlAj1T+Jqe3nXuRg4ElB47hh+iS8jGhhYAZwih MvmQ== 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=Cj0nQQashGWYFQCNuAM9OJGr6SbMETPE0vHYU86PlYk=; b=iK1/+2SEJyuKVIiYjvo2p3PTIyV1TG6BbZ5oNWkLoMzH9+MXH6JGRkYCjRaT6QWtNK IojMSW17N/q32Pn+X6MLDzEpzAIPayHIKWsFc3eq7SIrE1LuPdP/047PeTMheeYfX4WG fWBzY1t0rgt7W9wP6TH5acd6GGT0nPz5n/ZzfRJrwOU8uxjSzgYp/ne2PUoXU5/dPVkr MTaDGYPU3vzzW9J7sY3Q9fA9kBf6AF5TdOrV/+HEqBYC7fpDoTFTZ9M8e+BzlEpUkJpe r1ri4LJPRd3czb1xQ3n8BG3407c7F01ZbEhIq/f5TBkwDxXJtiOcJvFqlxmQAkkdlXkD Outw== X-Gm-Message-State: ANhLgQ2Di+qbgGuWWwjSp8Hkt4sh4NwtMa6eGMVVyG4dVcWnpnv5Ju3N 2gGsc0WqTAjcEAoDA3FpJAv+nQ== X-Google-Smtp-Source: ADFU+vvP0/JYeNRWOKwnqodm1yAjRRpef263I1NfvZ5S/gpRPpX6xo92YMxHqoZfyO9JMtvOHvqi5g== X-Received: by 2002:a62:64c9:: with SMTP id y192mr3694960pfb.26.1584619156159; Thu, 19 Mar 2020 04:59:16 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.153]) by smtp.gmail.com with ESMTPSA id f8sm2260943pfn.2.2020.03.19.04.59.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Mar 2020 04:59:15 -0700 (PDT) Date: Thu, 19 Mar 2020 17:29:08 +0530 From: Kaaira Gupta To: Helen Koike , Vaishali Thakkar , kieran.bingham@ideasonboard.com, libcamera-devel@lists.libcamera.org Message-ID: <20200319115908.GA30421@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 v2] libcamera: utils: merge isLibcamerainstalled with libcameraPath 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 11:59:18 -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 libcamera sources, thereby making call sites simpler. Make changes in the call sites accordingly. Signed-off-by: Kaaira Gupta --- 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 | 17 +++++++++-------- 4 files changed, 16 insertions(+), 14 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..4e294c2 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..eae682b 100644 --- a/src/libcamera/utils.cpp +++ b/src/libcamera/utils.cpp @@ -347,16 +347,17 @@ bool isLibcameraInstalled() * * \return A string stating the path */ -std::string libcameraPath() +std::string libcameraBuildPath() { - Dl_info info; - - /* Look up our own symbol. */ - int ret = dladdr(reinterpret_cast(libcameraPath), &info); - if (ret == 0) - return nullptr; + if (!isLibcameraInstalled()) { + Dl_info info; + /* 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 */