[libcamera-devel] [PATCH] libcamera: utils: Identify the 'real' build path

Kieran Bingham kieran.bingham at ideasonboard.com
Wed Apr 29 17:19:19 CEST 2020


Call realpath() to strip out any levels of indirection required in
referencing the root build directory.

This simplifies the debug output when reporting and parsing paths.

Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
---
 src/libcamera/utils.cpp | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp
index a96ca7f40cbd..fbadf350908a 100644
--- a/src/libcamera/utils.cpp
+++ b/src/libcamera/utils.cpp
@@ -386,7 +386,16 @@ std::string libcameraBuildPath()
 	if (ret == 0)
 		return std::string();
 
-	return dirname(info.dli_fname) + "/../../";
+	std::string path = dirname(info.dli_fname) + "/../../";
+
+	char *real = realpath(path.c_str(), nullptr);
+	if (!real)
+		return std::string();
+
+	path = real;
+	free(real);
+
+	return path + "/";
 }
 
 /**
-- 
2.25.1



More information about the libcamera-devel mailing list