aboutsummaryrefslogtreecommitdiff
path: root/backend/lib
diff options
context:
space:
mode:
Diffstat (limited to 'backend/lib')
-rw-r--r--backend/lib/CMakeLists.txt3
-rw-r--r--backend/lib/Support/CMakeLists.txt40
-rw-r--r--backend/lib/Support/Error.cpp28
3 files changed, 71 insertions, 0 deletions
diff --git a/backend/lib/CMakeLists.txt b/backend/lib/CMakeLists.txt
new file mode 100644
index 0000000..13f7c7b
--- /dev/null
+++ b/backend/lib/CMakeLists.txt
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+add_subdirectory(Support)
diff --git a/backend/lib/Support/CMakeLists.txt b/backend/lib/Support/CMakeLists.txt
new file mode 100644
index 0000000..88c959d
--- /dev/null
+++ b/backend/lib/Support/CMakeLists.txt
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+set(RCCBackendSupportSources Error.cpp)
+set(
+ RCCBackendSupportHeaders
+ "${RCC_BACKEND_SOURCE_DIR}/include/rcc/Support/Error.h"
+)
+
+add_library(RCCBackendSupport ${RCCBackendSupportSources})
+add_library(RCCBackend::Support ALIAS RCCBackendSupport)
+
+rcc_backend_configure_target(RCCBackendSupport)
+
+target_include_directories(
+ RCCBackendSupport
+ PUBLIC
+ "$<BUILD_INTERFACE:${RCC_BACKEND_SOURCE_DIR}/include>"
+ "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
+)
+
+set_target_properties(
+ RCCBackendSupport
+ PROPERTIES
+ EXPORT_NAME Support
+ OUTPUT_NAME RCCBackendSupport
+)
+
+install(
+ TARGETS RCCBackendSupport
+ EXPORT RCCBackendTargets
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+)
+
+rcc_backend_register_format_files(
+ "${CMAKE_CURRENT_SOURCE_DIR}/Error.cpp"
+ ${RCCBackendSupportHeaders}
+)
+rcc_backend_register_tidy_files("${CMAKE_CURRENT_SOURCE_DIR}/Error.cpp")
diff --git a/backend/lib/Support/Error.cpp b/backend/lib/Support/Error.cpp
new file mode 100644
index 0000000..dc7d590
--- /dev/null
+++ b/backend/lib/Support/Error.cpp
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#include "rcc/Support/Error.h"
+
+namespace rcc {
+
+std::string_view getErrorCodeName(ErrorCode Code) noexcept {
+ switch (Code) {
+ case ErrorCode::InvalidArgument:
+ return "invalid argument";
+ case ErrorCode::ParseError:
+ return "parse error";
+ case ErrorCode::VerificationError:
+ return "verification error";
+ case ErrorCode::Unsupported:
+ return "unsupported";
+ case ErrorCode::IoError:
+ return "I/O error";
+ case ErrorCode::InternalError:
+ return "internal error";
+ }
+
+ return "unknown error";
+}
+
+Error::Error(ErrorCode Code, std::string Message) : Code(Code), Message(std::move(Message)) {}
+
+} // namespace rcc