From patchwork Wed Mar 18 00:10:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 3147 Return-Path: Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 701F360422 for ; Wed, 18 Mar 2020 01:10:31 +0100 (CET) Received: by mail-pl1-x644.google.com with SMTP id g6so10359298plt.2 for ; Tue, 17 Mar 2020 17:10:31 -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=0k3SXu/OVTTm4R1dMrdzhoOHXiYgb3hcUSCJiQW9Z7L+fLrNycL8/vCFgViU1EA7wf XEmQPYHdkM4dHV/yKpmIFJ5fN7lnvdTGtX6hed6DUxRxKepTvWLHWIWNrVNgsizec06M SVnISYlllA9o+v+gc67ii6sEaW+eFtDMxmHdn2BPO15o31mbTZRKbQ/E8+OF6y6tYXBB SBrcbzzAdFH3gJSFkV2LMvF5LspItINSWV399ye2lxGAC5kKVnhjTZsxz1riGzo17A7A 9w7jjwxCHfLGDzumfFEyAZmYi1H/0yF2YGhU1NliopDOksNc8jIhRfAv9WduRNk5hFWL lB1Q== 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=G1i7bkw9hJjap3mHgA/IzBEVP7+sZtTbrhksoYxHSr2Xphb8U6aZdyFfDazd37vQ0X uREMKpustnD0YL3p1nOSQglEL4DWToYL7Tu2fFZKHGqqa92NCuwhEgqV6Y6fZc3DzHoL vZh4Oe9Lh7hgkEEbn+ryyOf6cCsOTREoBATg/vU1cOuodYvDzuF74QPvY08/v3TwpQM6 L2Zx4mFFbx9k3J48zHi6PCZMLuJ0OGfg1eqG6ZeTgAdjsOxrFhXP1fYwZboQuG+2D6xG kLRjzUs/CTWP22iCYDZC5sOMY1/MrUwMHboxHnS/5MlcOm9qofP0Axiv8xVavLRoi9Sx /bTw== X-Gm-Message-State: ANhLgQ0CYV6CcoRCNpzDFKTKRdrjXSXT7tbqC9+GUnnpGimdcJlh395p PLaOgUrKBG5fghDgkzr4dOG2YA== X-Google-Smtp-Source: ADFU+vs9GtrhwFTQ0UgvorHmnVGbxk6XZLxL4eTutZmSLSQGUWqf+vFeWmjoL3LxUu1vPUKDQX2RsQ== X-Received: by 2002:a17:902:9b95:: with SMTP id y21mr1201488plp.101.1584490230005; Tue, 17 Mar 2020 17:10:30 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.153]) by smtp.gmail.com with ESMTPSA id e9sm4294006pfl.179.2020.03.17.17.10.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 17:10:29 -0700 (PDT) From: Kaaira Gupta To: kieran.bingham@ideasonboard.com, libcamera-devel@lists.libcamera.org, Helen Koike , Vaishali Thakkar Cc: Kaaira Gupta Date: Wed, 18 Mar 2020 05:40:04 +0530 Message-Id: <20200318001009.32512-2-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 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 00:10:31 -0000 Replace the manual string splitting with utils::split() Signed-off-by: Kaaira Gupta --- 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 00:10:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 3148 Return-Path: Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3B5CC60422 for ; Wed, 18 Mar 2020 01:10:36 +0100 (CET) Received: by mail-pj1-x1043.google.com with SMTP id ck23so454892pjb.4 for ; Tue, 17 Mar 2020 17:10:36 -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=Ey2kh95b46jwmxxTfJZizM8cxetL4I0jD1fjKedlJp+xgS6vfMbMBOeuXp6k7LGkc4 16ugtd/9kCPdclTd6ePY9QScHH2J1hoG9c3bla7XxojeKcwNGZcVNg9UmqWitEf/q8Ga UhxTOep+D6JxxtKBuNyCnWBm0xaB66FFuGUkjHGisosDIP1UVoWgdp7xikz85fgdIEmj 3AKLuD/j03WILygNt2UUkn7HCPzEJ+kZGjpyCxwMDSoMxslJRET3lrCcSe+NY4lkWWu3 shpJBsJbfhEc/UgvlV55A0iRzoNVtZVmQWRL0utuVUSb5G5dMkXlW0ecmuJwcgtPd/iv zowg== 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=VKopbuKlJ8SM6H5j8VWKvWSp35fUL8M9o5OzYMRRcQXFq8N5nOMb7J3t8FDhTacZ0Z 4yF8v+E93arm6AS8z4wj5d2yIGwQKSDw2lbslQXY6QS8lPz5ZDR1lbQjIdJyjmuoIN7V qbtscJV+wVzsz+CoB3pO3ak58zcIzXD/BIVSLJpoggbDYjiYXzWIus2cVySnpjB+vJ3n rB0+KmsQ8KgbTBfc/cR8nv4zlfMpZz36NWMU3J4Q+Q/y9+MbZxa0YnyA60SQR76mFi0a P8JKF7/UrjG1bI2r7mRUPK4BMPHRA/GoXmxtwQLYdm3XKH+EvsqfOKQ3FMmTmVX3FTZI SwnQ== X-Gm-Message-State: ANhLgQ0RwkDOAI99JuJn1iNtmaZZFl6DurWgHowvTjmy/eu2poKHdk12 5BqSb5eYBZNnusxqvT8ciIr0j0gMr+U= X-Google-Smtp-Source: ADFU+vvCYlslo98xu0DXPf+BzJMjban9kMLVaZf5DYdUd/TaSRm03T8hmFWSjTys2IH/FL9umDjxAg== X-Received: by 2002:a17:90a:fa96:: with SMTP id cu22mr1690974pjb.187.1584490234650; Tue, 17 Mar 2020 17:10:34 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.153]) by smtp.gmail.com with ESMTPSA id w11sm4102523pfn.4.2020.03.17.17.10.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 17:10:34 -0700 (PDT) From: Kaaira Gupta To: kieran.bingham@ideasonboard.com, libcamera-devel@lists.libcamera.org, Helen Koike , Vaishali Thakkar Cc: Kaaira Gupta Date: Wed, 18 Mar 2020 05:40:05 +0530 Message-Id: <20200318001009.32512-3-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 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 00:10:36 -0000 User environment path in LIBCAMERA_IPA_PROXY_PATH should take precedence over system loading locations. Change precedence accordingly Signed-off-by: Kaaira Gupta --- 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 00:10:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 3149 Return-Path: Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0B59A60422 for ; Wed, 18 Mar 2020 01:10:41 +0100 (CET) Received: by mail-pg1-x52f.google.com with SMTP id t24so12632084pgj.7 for ; Tue, 17 Mar 2020 17:10:40 -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=BjxbadyKnvQeZHEaUc82NkDXvLsV4Hay+RsBUzZq6Qo=; b=Z2BKoqP7R5XWm/i3L+ikIAFHAnNKM5NcRt60DNewG+oMBwXwXvhLuXpP7EgSTcZXdf uEnNKR91yytAhpwyOlNWJacOeVd6jhjXRla/npdWtgvb/6azS+HRvHBjhaVzzP1/hc77 DU1ko9uTdPKv4CV/2Wpz8VKPniGaI5M+P/lV2ufAAjq7qJ5/ONqpOqAE4D0uhY7cRTmD 8Zcn1lhXPzqeClDvRFN8S1dj+ZcgOu3ED9PK8mvI+QC1MV+4Ga0MCxfaxB2ZEG56rbce lVqdXWijBKIWB/XjiONU8DcyyID/wVz69nb0f2cDx48F8BxWfa6Vs21k4ifddj6jYIZo V0xg== 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=BjxbadyKnvQeZHEaUc82NkDXvLsV4Hay+RsBUzZq6Qo=; b=AumD6RHRh4GWfzbEdDPEqhOruQNscdg0k/AV/fjxKwkG7r8876SSY9ti0rHD4wReVq yNJhDV7hBXT5+1AFEn1/g7Mz+L4AnazUGyZQUDGj5EV5Pj+Jp3P56ce00N5QBRndgMM0 wsOS8A0vUvdE6AdqGFgcrrLSxs6NdsjelS+PfzvVDr9cy2yMjHb2jZG8ZBCtQBryvQvF xvbYBG9sGaixMcqNDymTbOVhm9jTg+Evwud/N0YFaQSf+RZaFrSKQJkH4TSg5oRkmPgH OxolOHhO/zL+E03Mzz6WIhCnb+d/R1/SCiLaSlZOUXuUm/E4kmHxCtu+ld2MEV72qYWk Vr8g== X-Gm-Message-State: ANhLgQ2hJvqHAtoLiA3D6AVajnZ1mNdxCZ4QQkDLWNW8/AjbiFn53oAK 7fuXje0iUL1tb84OAeiPjc07vQ== X-Google-Smtp-Source: ADFU+vttXeM+ZtwCSD6dQ7vfRvGDEd9XYh54QG2uriSW4DnliprzfwW14hExWHh6BfNoILBfHjlevw== X-Received: by 2002:a62:1c08:: with SMTP id c8mr1483363pfc.80.1584490239623; Tue, 17 Mar 2020 17:10:39 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.153]) by smtp.gmail.com with ESMTPSA id gv7sm460563pjb.16.2020.03.17.17.10.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 17:10:39 -0700 (PDT) From: Kaaira Gupta To: kieran.bingham@ideasonboard.com, libcamera-devel@lists.libcamera.org, Helen Koike , Vaishali Thakkar Cc: Kaaira Gupta 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 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 00:10:41 -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/utils.cpp | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp index f566e88..1f6ec60 100644 --- a/src/libcamera/utils.cpp +++ b/src/libcamera/utils.cpp @@ -12,6 +12,9 @@ #include #include #include +#include +#include +#include /** * \file utils.h @@ -310,6 +313,51 @@ 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() +{ + /* 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; +} + +/** + * \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 00:10:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 3150 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 DF45F60422 for ; Wed, 18 Mar 2020 01:10:45 +0100 (CET) Received: by mail-pg1-x541.google.com with SMTP id 37so12619434pgm.11 for ; Tue, 17 Mar 2020 17:10:45 -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=AZN6TEGOKuDqe3KiH69oLtXcUjXsNId/klKpnB4hwS6AwKMWDEesqtrgJI9w0YoCpy 7TzrP6JloMp07brEoVLvz/+FT+OxDf/IpcqWz5uXZR4zZk4enU++24qcflgy+sCm/4Pz vvlVH+OzsbaERgYslhdNUhuwrn+Nx/M+u1zrs86SAiAtU/9ndq5gFQTWOxnxQMF+B7ou VcoaEc0bYxA6U2W+BhUULawNlCKWpM/4NKduEKkzKwKJNhI2rLtRXGEBl2mVU61BdaDz s5n5CEokgGoLPp3ZXxbN6zENvkpbuwOQ5PbRjgS7Yhn8Sp3Hp2bPXztExOJMpG5Xre3E bTfw== 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=qE8DW7P/98ZaMZo3ulraAYysUu+G0eVR7rQ4RuhQbH4O8spZeA8zxQ97v7hx5pgI/H VFIGz2+Kh0/jgtIWQDzCGkZSm5+4edOL778OuTXu0OVn27U0ofPxmq9NQ32DpS//D8jy 4ed/S8kjy7NMc1wXFhhvrfNzLFkTtlDL69tHc0SAsLBCRiIcg2c7Rj0NJBhozSjZRJTq mPBdBbt+ehIzbz35dBlFxfge+OTX4euw19gkhEJAWbU/2/DBJh2HoM2vuC5XTHlmhsGu wAeN6NFl37YJdF9DFF+X/94InKomtkxt1lGrJoKZnbCdk2x9NFauRDVvlnEuJszuPvBV DUMA== X-Gm-Message-State: ANhLgQ15MLPnfMtAc7PTTpCkTBv0WzWpgKcqJdQONwnXtZ2Q2FUR+6Ld MYBxjW02vP3rQtvRk+46Rjp4iw== X-Google-Smtp-Source: ADFU+vvZ7KGjTM3tbG5lzs031TnpxX8XZWvxj1e64i8FxtbLNyEIPGxSjKG92EZ3PtdBWPoS3AyZwA== X-Received: by 2002:aa7:9838:: with SMTP id q24mr1413578pfl.135.1584490244487; Tue, 17 Mar 2020 17:10:44 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.153]) by smtp.gmail.com with ESMTPSA id f127sm4178266pfa.112.2020.03.17.17.10.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 17:10:44 -0700 (PDT) From: Kaaira Gupta To: kieran.bingham@ideasonboard.com, libcamera-devel@lists.libcamera.org, Helen Koike , Vaishali Thakkar Cc: Kaaira Gupta Date: Wed, 18 Mar 2020 05:40:07 +0530 Message-Id: <20200318001009.32512-5-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 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 00:10:46 -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 00:10: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: 3151 Return-Path: Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 946D760422 for ; Wed, 18 Mar 2020 01:10:50 +0100 (CET) Received: by mail-pj1-x102e.google.com with SMTP id nu11so461857pjb.1 for ; Tue, 17 Mar 2020 17:10:50 -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=LYLnbya1xX1x1ggDavhU4Gu2iookTyUdcQMMKnU3CvCNF0ymrCzGOfouQLAUgNX85G 32V/Zoa6RhIrwWXx3F39CbQVFkQTni5MRWkvzbArq9wiI2uZG9CTVjjz4A1Y8bQCwPMl tbwcf01W80Sm38a2f8NzGcRE7HRYs7fieKHqYfjx3vN646Q/8uD/mkDglc42GkR/Zrzb pCY97qRpW5Ha9Cbng5U6nwa6qC5oUR2KExRCJIPSgZp5iiBEotoAUTQwOtFWEz5x9hZW +iAqj36PXtiHal4sM1Hy+YEdq/YMZf7H+sIY9P/Wb554DdRP4NDiFpc16N7oBvXGWyau hpeA== 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=lfZx046UbP0gkPOXnjjjJLpr3kTAOE5V0dLFNTpm45OI/cSuOE++GCy0QiUTsuG3J3 Xx/zlefkKeHeIPTOhxP8wfOZ2ubJDabzuRN5MZCTflpoP1fRWajneEEL6zGq9sGUgl2w tbAOqHyenBfWB7qvRM2YmeUznIO8VLOksVLpcNDzurHHVfDYsCCsSe4UE9KKD6XMhML1 jVg0/G6np9P07eojv+mffCavvWeDOTLWsQe7Yw/f3PMxb0cJ+BrQM4PtUN2DSAkeGy7g WUKENOSk6si1J3XhWOWrRk/29tlmRH82xu0f72lrvfRj1vUBoZ4nXLKW/jfNCMmgk9Tq uU2g== X-Gm-Message-State: ANhLgQ2Oy/LIG61s7jHYwT3MIFlbgUP9Y5a6qWINvUgBJyLkxX3HPDWZ 8aBqqDpKFcZGWceOAWLNfmlefQ== X-Google-Smtp-Source: ADFU+vv9rRehpEy71JAeilQhuqyGQUhA5QD7G0Jgo1hQzBO1KEJyYbWrhY0/lQItFH2eJYAKas8/6w== X-Received: by 2002:a17:902:7d8f:: with SMTP id a15mr1188851plm.175.1584490249109; Tue, 17 Mar 2020 17:10:49 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.153]) by smtp.gmail.com with ESMTPSA id w205sm4318658pfc.75.2020.03.17.17.10.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 17:10:48 -0700 (PDT) From: Kaaira Gupta To: kieran.bingham@ideasonboard.com, libcamera-devel@lists.libcamera.org, Helen Koike , Vaishali Thakkar Cc: Kaaira Gupta Date: Wed, 18 Mar 2020 05:40:08 +0530 Message-Id: <20200318001009.32512-6-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 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 00:10:50 -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 00:10:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 3152 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 5B49060422 for ; Wed, 18 Mar 2020 01:10:55 +0100 (CET) Received: by mail-pg1-x544.google.com with SMTP id t3so12635747pgn.1 for ; Tue, 17 Mar 2020 17:10:55 -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=hWSA3CKQtfc5Cjh9NULyoS94jU3LbbuWTH872Bg4l7eT4jN3vOB5wUV0WGU7n8Gm9w it4hzIWnqVVNcakb7eU1USiTTA0oSounCC10t8zXArjJwr+EAhIkt2SGzkPbF31BSo7T 3vav3/vfZZxdnsZaC9CfsuP8wM1YtzH3Zc0jZBeMmGLPaXRHGLklzw79ABcXdBAGr1CL u/RPDssyO8YWGaJJLJdx0WGmsfiZ0hMG0nIuz9ZwZbri2oSg0kzsCiJWrJxWrBHczOiy cqtGjgRoxLAsyiVaOWrY7oV19tLEd/LvqzhlwFP8AxEYWznXo/uQrFn3NY3EXt7Rrz2Y RqGw== 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=ikyegrS5NaLeTJH6CFTAJcoowkkQS8ngazxTIXVYojb2/Eluq8UY79B2YEF7f8t3KS hl0g5K6XBpNTQwdKsRkrhgeAjAXtutV8G+BovH+ng8z6xaSJxcWM/dDfd3VarDRqVQhU PBmI1dCkmZw29YSvw5jUvLBTQj2KTGBdThcQcYYeSSq9tANKwvfc3x0sTyneX3aJOWJF q2+irtwZdIOOmbXhKnnkn0IVdfkDPx4/BiL8pBzNu5H3UJcR68yZexw8P3MEu+FKq29m b5qp1rqaIZEDXjfxyLLx2Dqb8XqjTYtnpc869mg2l/M6SQ8stI8MhN3qygE2TeMJ4k4R LRdA== X-Gm-Message-State: ANhLgQ1m1HFbGtqxqfil9su50FOLHMUZXSnMwlMO0yzZ+Jhg4M3P/6s8 pRptBFTN0h0gGxhv99tFkVgpJQ== X-Google-Smtp-Source: ADFU+vsqX3c0XRrEXTeG9w1g1vUbtggVFj77AssG+afvOA6OQeZV/8aGRRHq6Cz796mXE8zUN2apqg== X-Received: by 2002:aa7:84cd:: with SMTP id x13mr1433015pfn.310.1584490253962; Tue, 17 Mar 2020 17:10:53 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.153]) by smtp.gmail.com with ESMTPSA id 127sm4223652pfb.130.2020.03.17.17.10.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 17:10:53 -0700 (PDT) From: Kaaira Gupta To: kieran.bingham@ideasonboard.com, libcamera-devel@lists.libcamera.org, Helen Koike , Vaishali Thakkar Cc: Kaaira Gupta Date: Wed, 18 Mar 2020 05:40:09 +0530 Message-Id: <20200318001009.32512-7-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 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 00:10:55 -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 --- 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;