Skip to content

Commit 86c0f59

Browse files
authored
Merge pull request #1432 from certik/rtlib1
Fix paths to the runtime library header files
2 parents 9efd521 + 8cb088b commit 86c0f59

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/lpython/utils.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,27 @@ std::string get_runtime_library_header_dir()
7979
char *env_p = std::getenv("LFORTRAN_RUNTIME_LIBRARY_HEADER_DIR");
8080
if (env_p) return env_p;
8181

82-
return get_runtime_library_dir() + "/impure";
82+
// The header file is in src/libasr/runtime for development, but in impure
83+
// in installed version
84+
std::string path;
85+
int dirname_length;
86+
get_executable_path(path, dirname_length);
87+
std::string dirname = path.substr(0,dirname_length);
88+
if ( endswith(dirname, "src/bin")
89+
|| endswith(dirname, "src\\bin")
90+
|| endswith(dirname, "SRC\\BIN")) {
91+
// Development version
92+
return dirname + "/../libasr/runtime";
93+
} else if (endswith(dirname, "src/lpython/tests") ||
94+
endswith(to_lower(dirname), "src\\lpython\\tests")) {
95+
// CTest Tests
96+
return dirname + "/../../libasr/runtime";
97+
} else {
98+
// Installed version
99+
return dirname + "/../share/lpython/lib/impure";
100+
}
101+
102+
return path;
83103
}
84104

85105
bool is_directory(std::string path) {

0 commit comments

Comments
 (0)