Show a patch.

GET /api/1.1/patches/3567/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 3567,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/3567/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3567/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20200427121834.15930-1-laurent.pinchart@ideasonboard.com>",
    "date": "2020-04-27T12:18:34",
    "name": "[libcamera-devel,v1.1,02/11] libcamera: utils: Add a function to retrieve the libcamera source tree",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "c66b4c1d9834aff7c33b141733d3d2a2ae725a89",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/3567/mbox/",
    "series": [
        {
            "id": 835,
            "url": "https://patchwork.libcamera.org/api/1.1/series/835/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=835",
            "date": "2020-04-27T12:18:34",
            "name": null,
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/835/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3567/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3567/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EEDE1603F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Apr 2020 14:18:52 +0200 (CEST)",
            "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5ACD572C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Apr 2020 14:18:52 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"N8DLQM4q\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1587989932;\n\tbh=GHMBE45760CiUMLJq0HZwj6/Wos+ZEReX2gJe2KaI7A=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=N8DLQM4q+WAniHowmczheZKOPmEkCvpj4c+l0tsNAxS4f9Phy7s2qJwzD2AEwZUaG\n\tEtc7FzGQMij9zwnjFtI8DKiJemljoAitGABq26XTZjLhe7AidzJWXRHvjIViwFY/Ma\n\t04JwpZ9VA+dxVJbi6JZTihDVJc6iYa5MqHMtS120=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 27 Apr 2020 15:18:34 +0300",
        "Message-Id": "<20200427121834.15930-1-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.25.3",
        "In-Reply-To": "<20200427031713.14013-3-laurent.pinchart@ideasonboard.com>",
        "References": "<20200427031713.14013-3-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v1.1 02/11] libcamera: utils: Add a\n\tfunction to retrieve the libcamera source tree",
        "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": "Mon, 27 Apr 2020 12:18:53 -0000"
    },
    "content": "Similarly to libcameraBuildPath(), there's a need to locate resources\nwithin the source tree when running libcamera without installing it.\nSupport this use case with a new utils::libcameraSourcePath() function.\n\nThe implementation uses a symlink from the build root to the source root\nin order to avoid hardcoding the path to the source root in the\nlibcamera.so binary.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nChanges since v1:\n\n- Use a symlink to the source tree to avoid hardcoding the path in the\n  libcamera.so binary\n---\n meson.build                   |  6 +++++\n src/libcamera/include/utils.h |  1 +\n src/libcamera/utils.cpp       | 49 ++++++++++++++++++++++++++++++++---\n 3 files changed, 53 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/meson.build b/meson.build\nindex c6e6a934e54e..ec5bc970f5b6 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -93,6 +93,12 @@ if get_option('test')\n     subdir('test')\n endif\n \n+# Create a symlink from the build root to the source root. This is used when\n+# running libcamera from the build directory to locate resources in the source\n+# directory (such as IPA configuration files).\n+run_command('ln', '-fs', meson.source_root(),\n+            join_paths(meson.build_root(), 'source'))\n+\n configure_file(output : 'config.h', configuration : config_h)\n \n pkg_mod = import('pkgconfig')\ndiff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h\nindex 242eeded9d50..3334ff16613d 100644\n--- a/src/libcamera/include/utils.h\n+++ b/src/libcamera/include/utils.h\n@@ -188,6 +188,7 @@ private:\n details::StringSplitter split(const std::string &str, const std::string &delim);\n \n std::string libcameraBuildPath();\n+std::string libcameraSourcePath();\n \n } /* namespace utils */\n \ndiff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\nindex 97f9b632e45b..a96ca7f40cbd 100644\n--- a/src/libcamera/utils.cpp\n+++ b/src/libcamera/utils.cpp\n@@ -10,10 +10,13 @@\n #include <dlfcn.h>\n #include <elf.h>\n #include <iomanip>\n+#include <limits.h>\n #include <link.h>\n #include <sstream>\n #include <stdlib.h>\n #include <string.h>\n+#include <sys/stat.h>\n+#include <sys/types.h>\n #include <unistd.h>\n \n /**\n@@ -360,9 +363,10 @@ bool isLibcameraInstalled()\n  *\n  * During development, it is useful to run libcamera binaries directly from the\n  * build directory without installing them. This function helps components that\n- * need to locate resources, such as IPA modules or IPA proxy workers, by\n- * providing them with the path to the root of the build directory. Callers can\n- * then use it to complement or override searches in system-wide directories.\n+ * need to locate resources in the build tree, such as IPA modules or IPA proxy\n+ * workers, by providing them with the path to the root of the build directory.\n+ * Callers can then use it to complement or override searches in system-wide\n+ * directories.\n  *\n  * If libcamera has been installed, the build directory path is not available\n  * and this function returns an empty string.\n@@ -385,6 +389,45 @@ std::string libcameraBuildPath()\n \treturn dirname(info.dli_fname) + \"/../../\";\n }\n \n+/**\n+ * \\brief Retrieve the path to the source directory\n+ *\n+ * During development, it is useful to run libcamera binaries directly from the\n+ * build directory without installing them. This function helps components that\n+ * need to locate resources in the source tree, such as IPA configuration\n+ * files, by providing them with the path to the root of the source directory.\n+ * Callers can then use it to complement or override searches in system-wide\n+ * directories.\n+ *\n+ * If libcamera has been installed, the source directory path is not available\n+ * and this function returns an empty string.\n+ *\n+ * \\return The path to the source directory if running from a build directory,\n+ * or an empty string otherwise\n+ */\n+std::string libcameraSourcePath()\n+{\n+\tstd::string path = libcameraBuildPath();\n+\tif (path.empty())\n+\t\treturn std::string();\n+\n+\tpath += \"source\";\n+\n+\tchar *real = realpath(path.c_str(), nullptr);\n+\tif (!real)\n+\t\treturn std::string();\n+\n+\tpath = real;\n+\tfree(real);\n+\n+\tstruct stat statbuf;\n+\tint ret = stat(path.c_str(), &statbuf);\n+\tif (ret < 0 || (statbuf.st_mode & S_IFMT) != S_IFDIR)\n+\t\treturn std::string();\n+\n+\treturn path + \"/\";\n+}\n+\n } /* namespace utils */\n \n } /* namespace libcamera */\n",
    "prefixes": [
        "libcamera-devel",
        "v1.1",
        "02/11"
    ]
}