From aefe5be54c31070422d333fc195d171bdfaa7d7c Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Wed, 13 Nov 2024 15:36:49 -0400 Subject: [PATCH] Implement an enterprise-edition extension hook for `index` (#34) Signed-off-by: Juan Cruz Viotti --- src/enterprise/enterprise_index.h | 19 +++++++++++++++++++ src/enterprise/index.cmake | 4 ++++ src/index/index.cc | 16 +++++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/enterprise/enterprise_index.h diff --git a/src/enterprise/enterprise_index.h b/src/enterprise/enterprise_index.h new file mode 100644 index 0000000..651ffe2 --- /dev/null +++ b/src/enterprise/enterprise_index.h @@ -0,0 +1,19 @@ +#ifndef SOURCEMETA_REGISTRY_ENTERPRISE_INDEX_H_ +#define SOURCEMETA_REGISTRY_ENTERPRISE_INDEX_H_ + +#include + +#include // EXIT_SUCCESS +#include // std::filesystem + +namespace sourcemeta::registry::enterprise { + +auto attach(const sourcemeta::jsontoolkit::JSON &, + const std::filesystem::path &, const std::filesystem::path &) + -> int { + return EXIT_SUCCESS; +} + +} // namespace sourcemeta::registry::enterprise + +#endif diff --git a/src/enterprise/index.cmake b/src/enterprise/index.cmake index a5f3e81..d45809c 100644 --- a/src/enterprise/index.cmake +++ b/src/enterprise/index.cmake @@ -1 +1,5 @@ target_compile_definitions(schema_registry_index PRIVATE SOURCEMETA_REGISTRY_ENTERPRISE) + +cmake_path(GET CMAKE_CURRENT_LIST_FILE PARENT_PATH ENTERPRISE_SOURCE_DIR) +target_sources(schema_registry_index PRIVATE "${ENTERPRISE_SOURCE_DIR}/enterprise_index.h") +target_include_directories(schema_registry_index PRIVATE "${ENTERPRISE_SOURCE_DIR}") diff --git a/src/index/index.cc b/src/index/index.cc index 9e1730d..0c251ce 100644 --- a/src/index/index.cc +++ b/src/index/index.cc @@ -19,6 +19,10 @@ #include // std::string_view #include // std::vector +#ifdef SOURCEMETA_REGISTRY_ENTERPRISE +#include "enterprise_index.h" +#endif + static auto index(const sourcemeta::jsontoolkit::JSON &configuration, const std::filesystem::path &base, const std::filesystem::path &output) -> int { @@ -148,7 +152,17 @@ static auto index_main(const std::string_view &program, sourcemeta::jsontoolkit::prettify(configuration_copy, stream); stream << "\n"; - return index(configuration, configuration_path.parent_path(), output); + const auto code{ + index(configuration, configuration_path.parent_path(), output)}; + +#ifdef SOURCEMETA_REGISTRY_ENTERPRISE + if (code == EXIT_SUCCESS) { + return sourcemeta::registry::enterprise::attach( + configuration, configuration_path.parent_path(), output); + } +#endif + + return code; } auto main(int argc, char *argv[]) noexcept -> int {