From dd9596232c1f56d42cb2e8213638d1be262c7b9a Mon Sep 17 00:00:00 2001 From: Anutosh Bhat <87052487+anutosh491@users.noreply.github.com> Date: Tue, 5 Nov 2024 12:14:02 +0530 Subject: [PATCH 1/5] Fix logic for resource dir --- src/xinterpreter.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index cbea0e34..2e61a5bc 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -37,12 +37,14 @@ using Args = std::vector; void* createInterpreter(const Args &ExtraArgs = {}) { Args ClangArgs = {/*"-xc++"*/"-v"}; // ? {"-Xclang", "-emit-llvm-only", "-Xclang", "-diagnostic-log-file", "-Xclang", "-", "-xc++"}; - if (std::find(ExtraArgs.begin(), ExtraArgs.end(), "-resource-dir") != ExtraArgs.end()) { + if (std::find(ExtraArgs.begin(), ExtraArgs.end(), "-resource-dir") == ExtraArgs.end()) { std::string resource_dir = Cpp::DetectResourceDir(); - if (resource_dir.empty()) - std::cerr << "Failed to detect the resource-dir\n"; - ClangArgs.push_back("-resource-dir"); - ClangArgs.push_back(resource_dir.c_str()); + if (!resource_dir.empty()) { + ClangArgs.push_back("-resource-dir"); + ClangArgs.push_back(resource_dir.c_str()); + } else { + std::cerr << "Failed to detect the resource-dir\n"; + } } std::vector CxxSystemIncludes; Cpp::DetectSystemCompilerIncludePaths(CxxSystemIncludes); From bb04af6bb7dcd7ea9d10137e06f2466f68d3ae7a Mon Sep 17 00:00:00 2001 From: Anutosh Bhat <87052487+anutosh491@users.noreply.github.com> Date: Tue, 5 Nov 2024 12:21:18 +0530 Subject: [PATCH 2/5] Update xinterpreter.cpp --- src/xinterpreter.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index 2e61a5bc..0da8ad75 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -39,12 +39,11 @@ void* createInterpreter(const Args &ExtraArgs = {}) { Args ClangArgs = {/*"-xc++"*/"-v"}; // ? {"-Xclang", "-emit-llvm-only", "-Xclang", "-diagnostic-log-file", "-Xclang", "-", "-xc++"}; if (std::find(ExtraArgs.begin(), ExtraArgs.end(), "-resource-dir") == ExtraArgs.end()) { std::string resource_dir = Cpp::DetectResourceDir(); - if (!resource_dir.empty()) { - ClangArgs.push_back("-resource-dir"); - ClangArgs.push_back(resource_dir.c_str()); - } else { + if (resource_dir.empty()) { std::cerr << "Failed to detect the resource-dir\n"; } + ClangArgs.push_back("-resource-dir"); + ClangArgs.push_back(resource_dir.c_str()); } std::vector CxxSystemIncludes; Cpp::DetectSystemCompilerIncludePaths(CxxSystemIncludes); From bca51ded272c7e5ad1dd132a218eaadc94138c01 Mon Sep 17 00:00:00 2001 From: Anutosh Bhat <87052487+anutosh491@users.noreply.github.com> Date: Tue, 5 Nov 2024 12:21:49 +0530 Subject: [PATCH 3/5] Update xinterpreter.cpp --- src/xinterpreter.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index 0da8ad75..507a7bde 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -39,9 +39,8 @@ void* createInterpreter(const Args &ExtraArgs = {}) { Args ClangArgs = {/*"-xc++"*/"-v"}; // ? {"-Xclang", "-emit-llvm-only", "-Xclang", "-diagnostic-log-file", "-Xclang", "-", "-xc++"}; if (std::find(ExtraArgs.begin(), ExtraArgs.end(), "-resource-dir") == ExtraArgs.end()) { std::string resource_dir = Cpp::DetectResourceDir(); - if (resource_dir.empty()) { - std::cerr << "Failed to detect the resource-dir\n"; - } + if (resource_dir.empty()) + std::cerr << "Failed to detect the resource-dir\n"; ClangArgs.push_back("-resource-dir"); ClangArgs.push_back(resource_dir.c_str()); } From 1e97ac79cda1d457bcc8d54f8f2765edc803c9f6 Mon Sep 17 00:00:00 2001 From: Anutosh Bhat <87052487+anutosh491@users.noreply.github.com> Date: Tue, 5 Nov 2024 12:24:44 +0530 Subject: [PATCH 4/5] Update xinterpreter.cpp --- src/xinterpreter.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index 507a7bde..7cf944e5 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -37,12 +37,13 @@ using Args = std::vector; void* createInterpreter(const Args &ExtraArgs = {}) { Args ClangArgs = {/*"-xc++"*/"-v"}; // ? {"-Xclang", "-emit-llvm-only", "-Xclang", "-diagnostic-log-file", "-Xclang", "-", "-xc++"}; - if (std::find(ExtraArgs.begin(), ExtraArgs.end(), "-resource-dir") == ExtraArgs.end()) { - std::string resource_dir = Cpp::DetectResourceDir(); - if (resource_dir.empty()) - std::cerr << "Failed to detect the resource-dir\n"; - ClangArgs.push_back("-resource-dir"); - ClangArgs.push_back(resource_dir.c_str()); + if (std::find(ExtraArgs.begin(), ExtraArgs.end(), "-resource-dir") == ExtraArgs.end()) + { + std::string resource_dir = Cpp::DetectResourceDir(); + if (resource_dir.empty()) + std::cerr << "Failed to detect the resource-dir\n"; + ClangArgs.push_back("-resource-dir"); + ClangArgs.push_back(resource_dir.c_str()); } std::vector CxxSystemIncludes; Cpp::DetectSystemCompilerIncludePaths(CxxSystemIncludes); From 79945ae532706bd1f3220b9813c2d911284acea1 Mon Sep 17 00:00:00 2001 From: Anutosh Bhat <87052487+anutosh491@users.noreply.github.com> Date: Tue, 5 Nov 2024 12:28:40 +0530 Subject: [PATCH 5/5] Update xinterpreter.cpp --- src/xinterpreter.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index 7cf944e5..2f8e8aab 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -41,7 +41,9 @@ void* createInterpreter(const Args &ExtraArgs = {}) { { std::string resource_dir = Cpp::DetectResourceDir(); if (resource_dir.empty()) - std::cerr << "Failed to detect the resource-dir\n"; + { + std::cerr << "Failed to detect the resource-dir\n"; + } ClangArgs.push_back("-resource-dir"); ClangArgs.push_back(resource_dir.c_str()); }