-
Notifications
You must be signed in to change notification settings - Fork 28
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
Enhance Dynamic Include Path Management in xeus-cpp with XEUS_SEARCH_PATH Support #187
base: main
Are you sure you want to change the base?
Changes from 4 commits
2a6dacc
3050471
71cd1ec
5c40221
bdb66eb
944c962
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,10 @@ | |
#include "xeus-cpp/xinterpreter.hpp" | ||
#include "xeus-cpp/xmagics.hpp" | ||
|
||
#include <cstring> // for std::strlen | ||
#include <sstream> // for std::istringstream | ||
#include <string> // for std::getline | ||
|
||
#include "xinput.hpp" | ||
#include "xinspect.hpp" | ||
#ifndef EMSCRIPTEN | ||
|
@@ -357,7 +361,28 @@ __get_cxx_version () | |
|
||
void interpreter::init_includes() | ||
{ | ||
// Add the standard include path | ||
Cpp::AddIncludePath((xeus::prefix_path() + "/include/").c_str()); | ||
|
||
// Get include paths from environment variable | ||
const char* non_standard_paths = std::getenv("XEUS_SEARCH_PATH"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "std::getenv" is directly included [misc-include-cleaner] src/xinterpreter.cpp:19: - #ifndef EMSCRIPTEN
+ #include <cstdlib>
+ #ifndef EMSCRIPTEN
AhmedFatthy1040 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (!non_standard_paths) { | ||
non_standard_paths = ""; | ||
} | ||
|
||
if (std::strlen(non_standard_paths) > 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "std::strlen" is directly included [misc-include-cleaner] src/xinterpreter.cpp:19: - #ifndef EMSCRIPTEN
+ #include <cstring>
+ #ifndef EMSCRIPTEN |
||
{ | ||
// Split the paths by colon ':' and add each one | ||
std::istringstream stream(non_standard_paths); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "std::istringstream" is directly included [misc-include-cleaner] src/xinterpreter.cpp:19: - #ifndef EMSCRIPTEN
+ #include <sstream>
+ #ifndef EMSCRIPTEN |
||
std::string path; | ||
while (std::getline(stream, path, ':')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "std::getline" is directly included [misc-include-cleaner] while (std::getline(stream, path, ':'))
^ |
||
{ | ||
if (!path.empty()) | ||
{ | ||
Cpp::AddIncludePath(path.c_str()); | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can simplify this by a lot, reduce the mount braces and also consider non-unix path delimiters. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
} | ||
|
||
void interpreter::init_preamble() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef TEST_HEADER_HPP | ||
#define TEST_HEADER_HPP | ||
|
||
namespace test_ns { | ||
constexpr int test_value = 42; | ||
} | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <doctest/doctest.h> | ||
#include <string> | ||
#include "test_header.hpp" | ||
|
||
TEST_CASE("Test non-standard include paths") | ||
{ | ||
CHECK(test_ns::test_value == 42); | ||
} |
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.
This block should go in the test folder.