From 8cb088bac64c6a0f40e6b2f761d01495bdb84e37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Tue, 17 Jan 2023 18:20:52 -0700 Subject: [PATCH] Fix paths to the runtime library header files --- src/lpython/utils.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/lpython/utils.cpp b/src/lpython/utils.cpp index efa4d5e3bd..d3c07855de 100644 --- a/src/lpython/utils.cpp +++ b/src/lpython/utils.cpp @@ -79,7 +79,27 @@ std::string get_runtime_library_header_dir() char *env_p = std::getenv("LFORTRAN_RUNTIME_LIBRARY_HEADER_DIR"); if (env_p) return env_p; - return get_runtime_library_dir() + "/impure"; + // The header file is in src/libasr/runtime for development, but in impure + // in installed version + std::string path; + int dirname_length; + get_executable_path(path, dirname_length); + std::string dirname = path.substr(0,dirname_length); + if ( endswith(dirname, "src/bin") + || endswith(dirname, "src\\bin") + || endswith(dirname, "SRC\\BIN")) { + // Development version + return dirname + "/../libasr/runtime"; + } else if (endswith(dirname, "src/lpython/tests") || + endswith(to_lower(dirname), "src\\lpython\\tests")) { + // CTest Tests + return dirname + "/../../libasr/runtime"; + } else { + // Installed version + return dirname + "/../share/lpython/lib/impure"; + } + + return path; } bool is_directory(std::string path) {