Skip to content
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

Add NO_RUNTIME_EXCEPTION option to hide errors and warnings backtraces. #768

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ option(OCCA_ENABLE_DPCPP "Build with SYCL/DPCPP if available" ON)
option(OCCA_ENABLE_TESTS "Build tests" OFF)
option(OCCA_ENABLE_EXAMPLES "Build simple examples" OFF)
option(OCCA_ENABLE_FORTRAN "Enable Fortran interface" OFF)
option(NO_RUNTIME_EXCEPTION "Hide warnings and errors in runtime" OFF)

if(OCCA_ENABLE_FORTRAN)
enable_language(Fortran)
Expand Down Expand Up @@ -282,6 +283,9 @@ set(OCCA_SRC
${OCCA_SRC_metal})

target_sources(libocca PRIVATE ${OCCA_SRC})
if (NO_RUNTIME_EXCEPTION)
target_compile_definitions(libocca PRIVATE NO_RUNTIME_EXCEPTION)
endif()

install(TARGETS libocca EXPORT occaExport DESTINATION lib)
install(DIRECTORY include/ DESTINATION include)
Expand Down
2 changes: 2 additions & 0 deletions src/utils/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace occa {
std::string exception::toString(const int stackTraceStart) const {
std::stringstream ss;

#ifndef NO_RUNTIME_EXCEPTION
// Pad message lines
strVector lines = split(message, '\n');
const int lineCount = (int) lines.size();
Expand All @@ -47,6 +48,7 @@ namespace occa {
<< " Stack\n"
<< sys::stacktrace(stackTraceStart, " ")
<< std::string(80, '=') << '\n';
#endif // NO_RUNTIME_EXCEPTION

return ss.str();
}
Expand Down
2 changes: 2 additions & 0 deletions src/utils/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ namespace occa {
if (exitInFailure) {
throw exp;
}
#ifndef NO_RUNTIME_EXCEPTION
io::stderr << exp;
#endif // NO_RUNTIME_EXCEPTION
}

void warn(const std::string &filename,
Expand Down
Loading