{"id":3149,"url":"https://patchwork.libcamera.org/api/patches/3149/?format=json","web_url":"https://patchwork.libcamera.org/patch/3149/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200318001009.32512-4-kgupta@es.iitr.ac.in>","date":"2020-03-18T00:10:06","name":"[libcamera-devel,v2,3/6] libcamera: utils: add Libcamera installed & path","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"5a79e60455e07092f6f51899959bd2c08611d3f0","submitter":{"id":39,"url":"https://patchwork.libcamera.org/api/people/39/?format=json","name":"Kaaira Gupta","email":"kgupta@es.iitr.ac.in"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/3149/mbox/","series":[{"id":729,"url":"https://patchwork.libcamera.org/api/series/729/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=729","date":"2020-03-18T00:10:03","name":"libcamera: determine IPA_PROXY_PATH at runtime","version":2,"mbox":"https://patchwork.libcamera.org/series/729/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3149/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3149/checks/","tags":{},"headers":{"Return-Path":"<kgupta@es.iitr.ac.in>","Received":["from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com\n\t[IPv6:2607:f8b0:4864:20::52f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0B59A60422\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 Mar 2020 01:10:41 +0100 (CET)","by mail-pg1-x52f.google.com with SMTP id t24so12632084pgj.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 17 Mar 2020 17:10:40 -0700 (PDT)","from kaaira-HP-Pavilion-Notebook ([103.113.213.153])\n\tby smtp.gmail.com with ESMTPSA id\n\tgv7sm460563pjb.16.2020.03.17.17.10.38\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 17 Mar 2020 17:10:39 -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=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=BjxbadyKnvQeZHEaUc82NkDXvLsV4Hay+RsBUzZq6Qo=;\n\tb=Z2BKoqP7R5XWm/i3L+ikIAFHAnNKM5NcRt60DNewG+oMBwXwXvhLuXpP7EgSTcZXdf\n\tuEnNKR91yytAhpwyOlNWJacOeVd6jhjXRla/npdWtgvb/6azS+HRvHBjhaVzzP1/hc77\n\tDU1ko9uTdPKv4CV/2Wpz8VKPniGaI5M+P/lV2ufAAjq7qJ5/ONqpOqAE4D0uhY7cRTmD\n\t8Zcn1lhXPzqeClDvRFN8S1dj+ZcgOu3ED9PK8mvI+QC1MV+4Ga0MCxfaxB2ZEG56rbce\n\tlVqdXWijBKIWB/XjiONU8DcyyID/wVz69nb0f2cDx48F8BxWfa6Vs21k4ifddj6jYIZo\n\tV0xg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=BjxbadyKnvQeZHEaUc82NkDXvLsV4Hay+RsBUzZq6Qo=;\n\tb=AumD6RHRh4GWfzbEdDPEqhOruQNscdg0k/AV/fjxKwkG7r8876SSY9ti0rHD4wReVq\n\tyNJhDV7hBXT5+1AFEn1/g7Mz+L4AnazUGyZQUDGj5EV5Pj+Jp3P56ce00N5QBRndgMM0\n\twsOS8A0vUvdE6AdqGFgcrrLSxs6NdsjelS+PfzvVDr9cy2yMjHb2jZG8ZBCtQBryvQvF\n\txvbYBG9sGaixMcqNDymTbOVhm9jTg+Evwud/N0YFaQSf+RZaFrSKQJkH4TSg5oRkmPgH\n\tOxolOHhO/zL+E03Mzz6WIhCnb+d/R1/SCiLaSlZOUXuUm/E4kmHxCtu+ld2MEV72qYWk\n\tVr8g==","X-Gm-Message-State":"ANhLgQ2hJvqHAtoLiA3D6AVajnZ1mNdxCZ4QQkDLWNW8/AjbiFn53oAK\n\t7fuXje0iUL1tb84OAeiPjc07vQ==","X-Google-Smtp-Source":"ADFU+vttXeM+ZtwCSD6dQ7vfRvGDEd9XYh54QG2uriSW4DnliprzfwW14hExWHh6BfNoILBfHjlevw==","X-Received":"by 2002:a62:1c08:: with SMTP id c8mr1483363pfc.80.1584490239623; \n\tTue, 17 Mar 2020 17:10:39 -0700 (PDT)","From":"Kaaira Gupta <kgupta@es.iitr.ac.in>","To":"kieran.bingham@ideasonboard.com, libcamera-devel@lists.libcamera.org,\n\tHelen Koike <helen.koike@collabora.com>,\n\tVaishali Thakkar <vthakkar@vaishalithakkar.in>","Cc":"Kaaira Gupta <kgupta@es.iitr.ac.in>","Date":"Wed, 18 Mar 2020 05:40:06 +0530","Message-Id":"<20200318001009.32512-4-kgupta@es.iitr.ac.in>","X-Mailer":"git-send-email 2.17.1","In-Reply-To":"<20200318001009.32512-1-kgupta@es.iitr.ac.in>","References":"<20200318001009.32512-1-kgupta@es.iitr.ac.in>","Subject":"[libcamera-devel] [PATCH LIBCAMERA v2 3/6] libcamera: utils: add\n\tLibcamera installed & path","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":"Wed, 18 Mar 2020 00:10:41 -0000"},"content":"Add a global functions 'isLibcameraInstalled' to check if libcamera is\ninstalled or not, and another global function 'libcameraPath' to return\nthe path of libcamera.so in utils.\n\nSigned-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>\n---\n src/libcamera/utils.cpp | 48 +++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 48 insertions(+)","diff":"diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\nindex f566e88..1f6ec60 100644\n--- a/src/libcamera/utils.cpp\n+++ b/src/libcamera/utils.cpp\n@@ -12,6 +12,9 @@\n #include <stdlib.h>\n #include <string.h>\n #include <unistd.h>\n+#include <dlfcn.h>\n+#include <elf.h>\n+#include <link.h>\n \n /**\n  * \\file utils.h\n@@ -310,6 +313,51 @@ details::StringSplitter split(const std::string &str, const std::string &delim)\n \treturn details::StringSplitter(str, delim);\n }\n \n+/**\n+ * \\brief Checks if Libcamera is installed or not\n+ *\n+ * Utilises the build_rpath dynamic tag which is stripped out by meson at\n+ * install time to determine at runtime if the library currently executing\n+ * has been installed or not.\n+ *\n+ * \\return A bool stating if libcamera is installed or not\n+ */\n+bool isLibcameraInstalled()\n+{\n+\t/* musl doesn't declare _DYNAMIC in link.h, declare it manually. */\n+\textern ElfW(Dyn) _DYNAMIC[];\n+\n+\t/*\n+\t * DT_RUNPATH (DT_RPATH when the linker uses old dtags) is removed on\n+\t * install.\n+\t */\n+\tfor (const ElfW(Dyn) *dyn = _DYNAMIC; dyn->d_tag != DT_NULL; ++dyn) {\n+\t\tif (dyn->d_tag == DT_RUNPATH || dyn->d_tag == DT_RPATH)\n+\t\t\treturn false;\n+\t}\n+\n+\treturn true;\n+}\n+\n+/**\n+ * \\brief Identifies libcamera path\n+ *\n+ * Identifies the location by finding the path of the active libcamera.so itself.\n+ *\n+ * \\return A string stating the path.\n+ */\n+std::string libcameraPath()\n+{\n+\tDl_info info;\n+\n+\t/* Look up our own symbol. */\n+\tint ret = dladdr(reinterpret_cast<void *>(libcameraPath), &info);\n+\tif (ret == 0)\n+\t\treturn nullptr;\n+\n+\treturn info.dli_fname;\n+}\n+\n } /* namespace utils */\n \n } /* namespace libcamera */\n","prefixes":["libcamera-devel","v2","3/6"]}