-
Notifications
You must be signed in to change notification settings - Fork 32
Implement GetIncludePaths
#311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement GetIncludePaths
#311
Conversation
Probably we should go for a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #311 +/- ##
==========================================
+ Coverage 72.54% 73.38% +0.83%
==========================================
Files 8 8
Lines 2972 2979 +7
==========================================
+ Hits 2156 2186 +30
+ Misses 816 793 -23
... and 1 file with indirect coverage changes
|
Looking at the failing test, cling has That raises a question; How should I handle the I don't completely know/understand some of the options there.
Not sure if we can return a reference, because we are not storing it as a vector in the class. We could return |
That's probably the easiest.
I meant having a signature like: |
@vgvassilev, please have a look at the recent changes. I have adapted the code directly from cling. The behavior matches cling's behavior. With the following changes in cppyy diff --git a/python/cppyy/__init__.py b/python/cppyy/__init__.py
index 53b7e92..d75f048 100644
--- a/python/cppyy/__init__.py
+++ b/python/cppyy/__init__.py
@@ -260,6 +260,12 @@ def add_include_path(path):
raise OSError('No such directory: %s' % path)
gbl.Cpp.AddIncludePath(path)
+def get_include_path():
+ """Get include paths available to Cling."""
+ paths = gbl.std.vector[gbl.std.string]()
+ gbl.Cpp.GetIncludePaths(paths)
+ return list(map(str, paths))
+
def add_library_path(path):
"""Add a path to the library search paths available to Cling."""
if not os.path.isdir(path): You can use it in Python >>> import cppyy
>>> cppyy.get_include_path()
['',
'/home/vipul/Workspace/c/llvm-project/build/lib/clang/17/../../../../cling-src/tools/cling/include',
'/home/vipul/Workspace/c/llvm-project/build/lib/clang/17/../../../../cling-src/include',
'/home/vipul/Workspace/c/llvm-project/build/lib/clang/17/../../..//include',
'/home/vipul/Workspace/c/cppyy-backend-compiler-research/python/cppyy_backend/include',
'/home/vipul/micromamba/envs/compiler-research/include/python3.12',
'/home/vipul/micromamba/envs/compiler-research/lib/python3.12/site-packages/../../../include/python3.12',
'/home/vipul/micromamba/envs/compiler-research/include'] |
This looks reasonable. We should add a unit test. |
clang-tidy review says "All clean, LGTM! 👍" |
1 similar comment
clang-tidy review says "All clean, LGTM! 👍" |
@@ -113,6 +113,12 @@ TEST(InterpreterTest, DetectSystemCompilerIncludePaths) { | |||
EXPECT_FALSE(includes.empty()); | |||
} | |||
|
|||
TEST(InterpreterTest, GetIncludePaths) { | |||
std::vector<std::string> includes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also test the separate flags and make sure the output is expected.
|
||
llvm::SmallVector<std::string> includes(1); | ||
|
||
I->GetIncludePaths(includes, /*withSystem=*/false, /*withFlags=*/false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note the difference in the signature of GetIncludePaths
in include/clang/Interpreter/CppInterOp.h
: void GetIncludePaths(std::vector<std::string>& IncludePaths)
and void Interpreter::GetIncludePaths(llvm::SmallVectorImpl<std::string>& incpaths, bool withSystem, bool withFlags)
in lib/Interpreter/CppInterOpInterpreter.h
.
Should both of these functions have the same signature?
While retrieving include path from Python using cppyy. The user may also want to get the system path and flags, but cannot with the current implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Interpreter::GetIncludePaths
should be hidden for the user. So I'd not worry about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
||
llvm::SmallVector<std::string> includes(1); | ||
|
||
I->GetIncludePaths(includes, /*withSystem=*/false, /*withFlags=*/false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Interpreter::GetIncludePaths
should be hidden for the user. So I'd not worry about that.
clang-tidy review says "All clean, LGTM! 👍" |
@Vipul-Cariappa, looks like the failures are due to some mismatch between the cling and clang-repl implementation. Maybe that's what you were trying to say in your previous comments. Can you look at failures? |
@Vipul-Cariappa can you rebase this PR, so you can see if any changes are needed to be compatible with llvm 19? |
Co-authored-by: Vassil Vassilev <[email protected]>
584b80f
to
5062b94
Compare
clang-tidy review says "All clean, LGTM! 👍" |
@vgvassilev, I believe the latest commit should fix the failing CI related to cling. |
I wouldn't worry about that, It's probably valgrind complaining about clang19 on the cppyy tests(failing on master too) Has been an issue for a while now that I will update with a fix soon |
clang-tidy review says "All clean, LGTM! 👍" |
@Vipul-Cariappa A fix has been patched. I have rerun the failing job, can you rebase into a single commit once they are green |
Fixes #69
I was unsure if to return
std::vector<std::string>
or a singlestd::string
with delimiter. I have gone with a singlestd::string
with:
as the delimiter, but it can be changed.With the following changes in the cppyy library.
We can get the include paths in Python