[{"id":4104,"web_url":"https://patchwork.libcamera.org/comment/4104/","msgid":"<CADFBUUL3-6B3hsovraB7VuNbREy47PjKH-OrBb=tv6evv38B-Q@mail.gmail.com>","date":"2020-03-19T15:22:29","subject":"Re: [libcamera-devel] [PATCH LIBCAMERA v4] libcamera: utils: adapt\n\tlibcameraPath to match use cases","submitter":{"id":39,"url":"https://patchwork.libcamera.org/api/people/39/","name":"Kaaira Gupta","email":"kgupta@es.iitr.ac.in"},"content":"Please ignore.\nSent wrong version.\n\nOn Thu, 19 Mar, 2020, 20:49 Kaaira Gupta, <kgupta@es.iitr.ac.in> wrote:\n\n> The two callers of functions libcameraPath() and isLibcameraInstalled()\n> end up using the same process and finally use the path with\n> libcamera.so. Hence write a function libcameraBuildPath() which\n> combines their functions and returns the root of the build sources\n> when the library has not been installed, but is running, thereby making\n> call sites simpler.\n>\n> When the library is installed, libcameraBuildPath() will return an empty\n> string.\n>\n> Make changes in the call sites accordingly.\n>\n> Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>\n> ---\n> Changes since v3:\n>         - removed isLibcameraInstalled() from utils.h\n>         - reformatted the code to reduce indentation of the code that\n>           implements actual logic, also, to catch the errors\n>           immediately.\n>         - changes in spellings and whitespaces in commit messages.\n>\n> Changes since v2:\n>         - rename subject line and add necessary details in commit\n>           message.\n>         - Solve whitespace issues.\n>         - specify the final 'slash' for directory path in return\n>           statement itself.\n>\n> Changes since v1:\n>         - rename function to libcameraBuildPath() instead, and return\n>           the root of libcamera source, and not the source directory\n>           root.\n>         - Return empty string instead of nullptr when ret==0\n>\n>  src/libcamera/include/utils.h |  2 +-\n>  src/libcamera/ipa_manager.cpp |  5 +++--\n>  src/libcamera/ipa_proxy.cpp   |  6 +++---\n>  src/libcamera/utils.cpp       | 16 +++++++++-------\n>  4 files changed, 16 insertions(+), 13 deletions(-)\n>\n> diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h\n> index bc96e79..5dea8d2 100644\n> --- a/src/libcamera/include/utils.h\n> +++ b/src/libcamera/include/utils.h\n> @@ -145,7 +145,7 @@ details::StringSplitter split(const std::string &str,\n> const std::string &delim);\n>\n>  bool isLibcameraInstalled();\n>\n> -std::string libcameraPath();\n> +std::string libcameraBuildPath();\n>\n>  } /* namespace utils */\n>\n> diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp\n> index 0bd280c..bcaae35 100644\n> --- a/src/libcamera/ipa_manager.cpp\n> +++ b/src/libcamera/ipa_manager.cpp\n> @@ -119,8 +119,9 @@ IPAManager::IPAManager()\n>          * path for the IPA from that point. We need to recurse one level\n> of\n>          * sub-directories to match the build tree.\n>          */\n> -       if (!utils::isLibcameraInstalled()) {\n> -               std::string ipaBuildPath =\n> utils::dirname(utils::libcameraPath()) + \"/../ipa\";\n> +       std::string root = utils::libcameraBuildPath();\n> +       if (!root.empty()) {\n> +               std::string ipaBuildPath = root + \"src/ipa\";\n>                 constexpr int maxDepth = 1;\n>\n>                 LOG(IPAManager, Info)\n> diff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp\n> index 2f866cc..5fd88a4 100644\n> --- a/src/libcamera/ipa_proxy.cpp\n> +++ b/src/libcamera/ipa_proxy.cpp\n> @@ -97,9 +97,9 @@ std::string IPAProxy::resolvePath(const std::string\n> &file) const\n>          * This requires identifying the path of the libcamera.so, and\n>          * referencing a relative path for the proxy workers from that\n> point.\n>          */\n> -       if (!utils::isLibcameraInstalled()) {\n> -               std::string ipaProxyDir =\n> utils::dirname(utils::libcameraPath())\n> -                                         + \"/proxy/worker\";\n> +       std::string root = utils::libcameraBuildPath();\n> +       if (!root.empty()) {\n> +               std::string ipaProxyDir = root +\n> \"src/libcamera/proxy/worker\";\n>\n>                 LOG(IPAProxy, Info)\n>                         << \"libcamera is not installed. Loading proxy\n> workers from'\"\n> diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\n> index 7e118fa..42c5c76 100644\n> --- a/src/libcamera/utils.cpp\n> +++ b/src/libcamera/utils.cpp\n> @@ -347,16 +347,18 @@ bool isLibcameraInstalled()\n>   *\n>   * \\return A string stating the path\n>   */\n> -std::string libcameraPath()\n> +std::string libcameraBuildPath()\n>  {\n> -       Dl_info info;\n> +       if (!isLibcameraInstalled()) {\n> +               Dl_info info;\n>\n> -       /* Look up our own symbol. */\n> -       int ret = dladdr(reinterpret_cast<void *>(libcameraPath), &info);\n> -       if (ret == 0)\n> -               return nullptr;\n> +               /* Look up our own symbol. */\n> +               int ret = dladdr(reinterpret_cast<void\n> *>(libcameraBuildPath), &info);\n> +               if (ret)\n> +                       return dirname(info.dli_fname) + \"/../../\";\n> +       }\n>\n> -       return info.dli_fname;\n> +       return std::string();\n>  }\n>\n>  } /* namespace utils */\n> --\n> 2.17.1\n>\n>","headers":{"Return-Path":"<kgupta@es.iitr.ac.in>","Received":["from mail-pg1-x535.google.com (mail-pg1-x535.google.com\n\t[IPv6:2607:f8b0:4864:20::535])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4FF41629AC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 Mar 2020 16:22:43 +0100 (CET)","by mail-pg1-x535.google.com with SMTP id x7so1452346pgh.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 Mar 2020 08:22:43 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to;\n\tbh=aBSEqe5Jc4639+zHWoiptgTLxafMuSKwLM19sXg3Acs=;\n\tb=XXU/LFUrW59uKJfwpzTcBorc3LpI6Fqszpru7rolQ3nPJwkAeni8RJ4FVJOdG9W06n\n\t/XrU+aC5NdUEwTW9DFC/NUY2qYuXzs504pjmgVh6cHucCVIoI0HkBvrppKdpXvrNkeRo\n\tFnhSDN00/xAPccmLcAYFNmQWgVRK1OpGGslM6zRmUlkAla5+6CqDodjFk/vh2jt+RhT8\n\tyFYUiboOxoB/A3GhrO3khDtGYsCOzo8e5qB6jQeM/RjsZGbAI12wNWMVOg5eG0MBN9ca\n\tk4ZeipiHOTwLWKBaoEXK25jba4bL2X73/+iZF/r5Iix0VI3m8rIUerZhuyTElHfT2n4h\n\tGgIQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to;\n\tbh=aBSEqe5Jc4639+zHWoiptgTLxafMuSKwLM19sXg3Acs=;\n\tb=MDhjHRMSH/m5F2iRYilJ4ExvKwE7LdFYg3g+vMXTkASbATjOaF5kHmEmnn0+VoUNy1\n\tJbZx0a4Z1eSIUFTZe1P26rS38hUEg0aOZwUhQyjnAgAo3G/PtBQ8Wyj1Rc0BtAb8glWI\n\tHjItOzKro/8oXJOcFR361WC+FQfaNgkXc79s4YOKymWSG8Z05gBW6qo1k7N6U8krqWwg\n\tGwUGeAN433irEcGEnKTR7su0JCkl9r/FrK+HK/U7t9u5XJ0IMT2qrxwsuOTMmyweqXUz\n\tnSfjkZqFj5qxLIf9lwEUIw/KohoXFYT29XBjcqqcpHga8wwgcZIPCWcBu3r48D1xQ+Bg\n\tW1Ww==","X-Gm-Message-State":"ANhLgQ1ZZoRxOQVrR7hlVM19k/kNpDWUJ2fN4OfxU9rcMqb4qnS2jyw5\n\tHlLKCh5A8ZX0DCwyzka64cEhPphF0uFvukmApwaeHw==","X-Google-Smtp-Source":"ADFU+vuwmSooKMcp4TsD3DNLZ1w51463l19b2TYoAJpCtznrcWjBbfy05LRiuITVUvuhOgdoyotqevGamqDDtdoWc+M=","X-Received":"by 2002:a63:fe58:: with SMTP id\n\tx24mr3776252pgj.170.1584631361748; \n\tThu, 19 Mar 2020 08:22:41 -0700 (PDT)","MIME-Version":"1.0","References":"<20200319151919.GA4693@kaaira-HP-Pavilion-Notebook>","In-Reply-To":"<20200319151919.GA4693@kaaira-HP-Pavilion-Notebook>","From":"KAAIRA GUPTA <kgupta@es.iitr.ac.in>","Date":"Thu, 19 Mar 2020 20:52:29 +0530","Message-ID":"<CADFBUUL3-6B3hsovraB7VuNbREy47PjKH-OrBb=tv6evv38B-Q@mail.gmail.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Content-Type":"multipart/alternative; boundary=\"0000000000006af17f05a136bd03\"","Subject":"Re: [libcamera-devel] [PATCH LIBCAMERA v4] libcamera: utils: adapt\n\tlibcameraPath to match use cases","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Thu, 19 Mar 2020 15:22:43 -0000"}}]