Skip to content

Commit

Permalink
Implement an enterprise-edition extension hook for index (#34)
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <[email protected]>
  • Loading branch information
jviotti authored Nov 13, 2024
1 parent df39807 commit aefe5be
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/enterprise/enterprise_index.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef SOURCEMETA_REGISTRY_ENTERPRISE_INDEX_H_
#define SOURCEMETA_REGISTRY_ENTERPRISE_INDEX_H_

#include <sourcemeta/jsontoolkit/json.h>

#include <cstdlib> // EXIT_SUCCESS
#include <filesystem> // 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
4 changes: 4 additions & 0 deletions src/enterprise/index.cmake
Original file line number Diff line number Diff line change
@@ -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}")
16 changes: 15 additions & 1 deletion src/index/index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#include <string_view> // std::string_view
#include <vector> // 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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit aefe5be

Please sign in to comment.