Skip to content
Merged
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
1 change: 1 addition & 0 deletions .github/workflows/website-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
-DBLAZE_DOCUMENTATION:BOOL=OFF
-DBLAZE_EDITOR:BOOL=OFF
-DBLAZE_FOUNDATION:BOOL=OFF
-DBLAZE_BUNDLE:BOOL=OFF
-DBLAZE_TESTS:BOOL=OFF
-DBLAZE_DOCS:BOOL=ON
- run: cmake --build ./build --config Release --target doxygen
1 change: 1 addition & 0 deletions .github/workflows/website-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
-DBLAZE_DOCUMENTATION:BOOL=OFF
-DBLAZE_EDITOR:BOOL=OFF
-DBLAZE_FOUNDATION:BOOL=OFF
-DBLAZE_BUNDLE:BOOL=OFF
-DBLAZE_TESTS:BOOL=OFF
-DBLAZE_DOCS:BOOL=ON
- run: cmake --build ./build --config Release --target doxygen
Expand Down
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ option(BLAZE_CODEGEN "Build the Blaze codegen library" ON)
option(BLAZE_DOCUMENTATION "Build the Blaze documentation generator library" ON)
option(BLAZE_EDITOR "Build the Blaze editor schema compatibility library" ON)
option(BLAZE_FOUNDATION "Build the Blaze foundation JSON Schema library" ON)
option(BLAZE_BUNDLE "Build the Blaze bundle library" ON)
option(BLAZE_TESTS "Build the Blaze tests" OFF)
Copy link
Copy Markdown

@augmentcode augmentcode Bot May 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BLAZE_BUNDLE is configurable, but several enabled-by-default targets now link against sourcemeta::blaze::bundle unconditionally, so -DBLAZE_BUNDLE=OFF with those still ON will fail at configure/link time. Consider enforcing the option dependency (or gating those components/tests) so the build remains consistent when BLAZE_BUNDLE is disabled.

Other locations where this applies: src/codegen/CMakeLists.txt:20, src/compiler/CMakeLists.txt:30, src/configuration/CMakeLists.txt:14, test/editor/CMakeLists.txt:10, test/evaluator/CMakeLists.txt:20

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

option(BLAZE_BENCHMARK "Build the Blaze benchmarks" OFF)
option(BLAZE_CONTRIB "Build the Blaze contrib programs" OFF)
Expand Down Expand Up @@ -51,6 +52,10 @@ if(BLAZE_FOUNDATION)
add_subdirectory(src/foundation)
endif()

if(BLAZE_BUNDLE)
add_subdirectory(src/bundle)
endif()

if(BLAZE_COMPILER)
add_subdirectory(src/compiler)
endif()
Expand Down Expand Up @@ -137,6 +142,10 @@ if(BLAZE_TESTS)
add_subdirectory(test/foundation)
endif()

if(BLAZE_BUNDLE)
add_subdirectory(test/bundle)
endif()

if(BLAZE_COMPILER)
add_subdirectory(test/compiler)
endif()
Expand Down
6 changes: 5 additions & 1 deletion benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(BENCHMARK_SOURCES)

if(BLAZE_FOUNDATION)
if(BLAZE_FOUNDATION AND BLAZE_BUNDLE)
list(APPEND BENCHMARK_SOURCES foundation.cc)
endif()

Expand Down Expand Up @@ -53,6 +53,10 @@ if(BENCHMARK_SOURCES)
target_link_libraries(sourcemeta_blaze_benchmark
PRIVATE sourcemeta::blaze::foundation)
endif()
if(BLAZE_BUNDLE)
target_link_libraries(sourcemeta_blaze_benchmark
PRIVATE sourcemeta::blaze::bundle)
endif()

add_custom_target(benchmark_all
COMMAND sourcemeta_blaze_benchmark
Expand Down
2 changes: 2 additions & 0 deletions benchmark/foundation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#include <filesystem> // std::filesystem
#include <vector> // std::vector

#include <sourcemeta/blaze/bundle.h>
#include <sourcemeta/blaze/foundation.h>

#include <sourcemeta/core/json.h>
#include <sourcemeta/core/uri.h>

Expand Down
8 changes: 8 additions & 0 deletions config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ if(NOT BLAZE_COMPONENTS)
list(APPEND BLAZE_COMPONENTS codegen)
list(APPEND BLAZE_COMPONENTS documentation)
list(APPEND BLAZE_COMPONENTS editor)
list(APPEND BLAZE_COMPONENTS bundle)
endif()

include(CMakeFindDependencyMacro)
Expand All @@ -24,13 +25,15 @@ foreach(component ${BLAZE_COMPONENTS})
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_foundation.cmake")
elseif(component STREQUAL "compiler")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_foundation.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_bundle.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_evaluator.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_compiler.cmake")
elseif(component STREQUAL "evaluator")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_foundation.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_evaluator.cmake")
elseif(component STREQUAL "test")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_foundation.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_bundle.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_evaluator.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_compiler.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_test.cmake")
Expand All @@ -40,6 +43,7 @@ foreach(component ${BLAZE_COMPONENTS})
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_output.cmake")
elseif(component STREQUAL "configuration")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_foundation.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_bundle.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_configuration.cmake")
elseif(component STREQUAL "alterschema")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_foundation.cmake")
Expand All @@ -49,6 +53,7 @@ foreach(component ${BLAZE_COMPONENTS})
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_alterschema.cmake")
elseif(component STREQUAL "codegen")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_foundation.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_bundle.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_evaluator.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_compiler.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_output.cmake")
Expand All @@ -60,6 +65,9 @@ foreach(component ${BLAZE_COMPONENTS})
elseif(component STREQUAL "editor")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_foundation.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_editor.cmake")
elseif(component STREQUAL "bundle")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_foundation.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_blaze_bundle.cmake")
else()
message(FATAL_ERROR "Unknown Blaze component: ${component}")
endif()
Expand Down
1 change: 1 addition & 0 deletions doxygen/index.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ CMake
| `BLAZE_DOCUMENTATION` | Boolean | `ON` | Build the Blaze documentation library |
| `BLAZE_EDITOR` | Boolean | `ON` | Build the Blaze editor library |
| `BLAZE_FOUNDATION` | Boolean | `ON` | Build the Blaze foundation library |
| `BLAZE_BUNDLE` | Boolean | `ON` | Build the Blaze bundle library |
| `BLAZE_TESTS` | Boolean | `OFF` | Build the Blaze tests |
| `BLAZE_BENCHMARK` | Boolean | `OFF` | Build the Blaze benchmarks |
| `BLAZE_CONTRIB` | Boolean | `OFF` | Build the Blaze contrib programs |
Expand Down
16 changes: 16 additions & 0 deletions src/bundle/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
sourcemeta_library(NAMESPACE sourcemeta PROJECT blaze NAME bundle
FOLDER "Blaze/Bundle"
SOURCES bundle.cc helpers.h)

if(BLAZE_INSTALL)
sourcemeta_library_install(NAMESPACE sourcemeta PROJECT blaze NAME bundle)
endif()

target_link_libraries(sourcemeta_blaze_bundle PUBLIC
sourcemeta::core::json)
target_link_libraries(sourcemeta_blaze_bundle PUBLIC
sourcemeta::core::jsonpointer)
target_link_libraries(sourcemeta_blaze_bundle PUBLIC
sourcemeta::blaze::foundation)
target_link_libraries(sourcemeta_blaze_bundle PRIVATE
sourcemeta::core::uri)
2 changes: 2 additions & 0 deletions src/foundation/bundle.cc → src/bundle/bundle.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <sourcemeta/blaze/bundle.h>

#include <sourcemeta/blaze/foundation.h>

#include "helpers.h"
Expand Down
89 changes: 89 additions & 0 deletions src/bundle/helpers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#ifndef SOURCEMETA_BLAZE_BUNDLE_HELPERS_H
#define SOURCEMETA_BLAZE_BUNDLE_HELPERS_H

#include <sourcemeta/blaze/foundation.h>

#include <cassert> // assert
#include <string_view> // std::string_view

namespace sourcemeta::blaze {

inline auto id_keyword(const SchemaBaseDialect base_dialect)
-> std::string_view {
switch (base_dialect) {
case SchemaBaseDialect::JSON_Schema_2020_12:
case SchemaBaseDialect::JSON_Schema_2020_12_Hyper:
case SchemaBaseDialect::JSON_Schema_2019_09:
case SchemaBaseDialect::JSON_Schema_2019_09_Hyper:
case SchemaBaseDialect::JSON_Schema_Draft_7:
case SchemaBaseDialect::JSON_Schema_Draft_7_Hyper:
case SchemaBaseDialect::JSON_Schema_Draft_6:
case SchemaBaseDialect::JSON_Schema_Draft_6_Hyper:
return "$id";
case SchemaBaseDialect::JSON_Schema_Draft_4:
case SchemaBaseDialect::JSON_Schema_Draft_4_Hyper:
case SchemaBaseDialect::JSON_Schema_Draft_3:
case SchemaBaseDialect::JSON_Schema_Draft_3_Hyper:
case SchemaBaseDialect::JSON_Schema_Draft_2_Hyper:
case SchemaBaseDialect::JSON_Schema_Draft_1_Hyper:
case SchemaBaseDialect::JSON_Schema_Draft_0_Hyper:
return "id";
}

assert(false);
return "$id";
}

inline auto definitions_keyword(const SchemaBaseDialect base_dialect)
-> std::string_view {
switch (base_dialect) {
case SchemaBaseDialect::JSON_Schema_2020_12:
case SchemaBaseDialect::JSON_Schema_2020_12_Hyper:
case SchemaBaseDialect::JSON_Schema_2019_09:
case SchemaBaseDialect::JSON_Schema_2019_09_Hyper:
return "$defs";
case SchemaBaseDialect::JSON_Schema_Draft_7:
case SchemaBaseDialect::JSON_Schema_Draft_7_Hyper:
case SchemaBaseDialect::JSON_Schema_Draft_6:
case SchemaBaseDialect::JSON_Schema_Draft_6_Hyper:
case SchemaBaseDialect::JSON_Schema_Draft_4:
case SchemaBaseDialect::JSON_Schema_Draft_4_Hyper:
case SchemaBaseDialect::JSON_Schema_Draft_3:
case SchemaBaseDialect::JSON_Schema_Draft_3_Hyper:
return "definitions";
case SchemaBaseDialect::JSON_Schema_Draft_2_Hyper:
case SchemaBaseDialect::JSON_Schema_Draft_1_Hyper:
case SchemaBaseDialect::JSON_Schema_Draft_0_Hyper:
return "";
}

assert(false);
return "$defs";
}

// In older drafts, the presence of `$ref` would override any sibling keywords
// See
// https://json-schema.org/draft-07/draft-handrews-json-schema-01#rfc.section.8.3
inline auto
ref_overrides_adjacent_keywords(const SchemaBaseDialect base_dialect) -> bool {
switch (base_dialect) {
case SchemaBaseDialect::JSON_Schema_Draft_7:
case SchemaBaseDialect::JSON_Schema_Draft_7_Hyper:
case SchemaBaseDialect::JSON_Schema_Draft_6:
case SchemaBaseDialect::JSON_Schema_Draft_6_Hyper:
case SchemaBaseDialect::JSON_Schema_Draft_4:
case SchemaBaseDialect::JSON_Schema_Draft_4_Hyper:
case SchemaBaseDialect::JSON_Schema_Draft_3:
case SchemaBaseDialect::JSON_Schema_Draft_3_Hyper:
case SchemaBaseDialect::JSON_Schema_Draft_2_Hyper:
case SchemaBaseDialect::JSON_Schema_Draft_1_Hyper:
case SchemaBaseDialect::JSON_Schema_Draft_0_Hyper:
return true;
default:
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
return false;
}
}

} // namespace sourcemeta::blaze

#endif
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
#ifndef SOURCEMETA_BLAZE_FOUNDATION_BUNDLE_H
#define SOURCEMETA_BLAZE_FOUNDATION_BUNDLE_H
#ifndef SOURCEMETA_BLAZE_BUNDLE_H_
#define SOURCEMETA_BLAZE_BUNDLE_H_

#ifndef SOURCEMETA_BLAZE_FOUNDATION_EXPORT
#include <sourcemeta/blaze/foundation_export.h>
/// @defgroup bundle Bundle
/// @brief Bundle JSON Schemas by inlining their external references.
///
/// This functionality is included as follows:
///
/// ```cpp
/// #include <sourcemeta/blaze/bundle.h>
/// ```

#ifndef SOURCEMETA_BLAZE_BUNDLE_EXPORT
#include <sourcemeta/blaze/bundle_export.h>
#endif

#include <sourcemeta/core/json.h>
#include <sourcemeta/core/jsonpointer.h>

// NOLINTBEGIN(misc-include-cleaner)
#include <sourcemeta/blaze/foundation_frame.h>
#include <sourcemeta/blaze/foundation_types.h>
// NOLINTEND(misc-include-cleaner)
#include <sourcemeta/blaze/foundation.h>

#include <functional> // std::function
#include <optional> // std::optional, std::nullopt
#include <string_view> // std::string_view

namespace sourcemeta::blaze {

/// @ingroup foundation
/// @ingroup bundle
/// A callback to get dependency information
/// - Origin URI (empty if none)
/// - Pointer (reference keyword from the origin)
Expand All @@ -28,13 +35,14 @@ using DependencyCallback =
std::function<void(std::string_view, const sourcemeta::core::WeakPointer &,
std::string_view, const sourcemeta::core::JSON &)>;

/// @ingroup foundation
/// @ingroup bundle
///
/// This function recursively traverses and reports the external references in a
/// schema. For example:
///
/// ```cpp
/// #include <sourcemeta/core/json.h>
/// #include <sourcemeta/blaze/bundle.h>
/// #include <sourcemeta/blaze/foundation.h>
///
/// // A custom resolver that knows about an additional schema
Expand Down Expand Up @@ -66,7 +74,7 @@ using DependencyCallback =
/// // Do something with the information
/// });
/// ```
SOURCEMETA_BLAZE_FOUNDATION_EXPORT
SOURCEMETA_BLAZE_BUNDLE_EXPORT
auto dependencies(const sourcemeta::core::JSON &schema,
const SchemaWalker &walker, const SchemaResolver &resolver,
const DependencyCallback &callback,
Expand All @@ -75,14 +83,15 @@ auto dependencies(const sourcemeta::core::JSON &schema,
const SchemaFrame::Paths &paths = {
sourcemeta::core::empty_weak_pointer}) -> void;

/// @ingroup foundation
/// @ingroup bundle
///
/// This function bundles a JSON Schema (starting from Draft 4) by embedding
/// every remote reference into the top level schema resource, handling circular
/// dependencies and more. This overload mutates the input schema. For example:
///
/// ```cpp
/// #include <sourcemeta/core/json.h>
/// #include <sourcemeta/blaze/bundle.h>
/// #include <sourcemeta/blaze/foundation.h>
/// #include <cassert>
///
Expand Down Expand Up @@ -124,7 +133,7 @@ auto dependencies(const sourcemeta::core::JSON &schema,
///
/// assert(document == expected);
/// ```
SOURCEMETA_BLAZE_FOUNDATION_EXPORT
SOURCEMETA_BLAZE_BUNDLE_EXPORT
auto bundle(sourcemeta::core::JSON &schema, const SchemaWalker &walker,
const SchemaResolver &resolver,
std::string_view default_dialect = "",
Expand All @@ -134,7 +143,7 @@ auto bundle(sourcemeta::core::JSON &schema, const SchemaWalker &walker,
const SchemaFrame::Paths &paths = {
sourcemeta::core::empty_weak_pointer}) -> void;

/// @ingroup foundation
/// @ingroup bundle
///
/// This function bundles a JSON Schema (starting from Draft 4) by embedding
/// every remote reference into the top level schema resource, handling circular
Expand All @@ -143,6 +152,7 @@ auto bundle(sourcemeta::core::JSON &schema, const SchemaWalker &walker,
///
/// ```cpp
/// #include <sourcemeta/core/json.h>
/// #include <sourcemeta/blaze/bundle.h>
/// #include <sourcemeta/blaze/foundation.h>
/// #include <cassert>
///
Expand Down Expand Up @@ -185,7 +195,7 @@ auto bundle(sourcemeta::core::JSON &schema, const SchemaWalker &walker,
///
/// assert(result == expected);
/// ```
SOURCEMETA_BLAZE_FOUNDATION_EXPORT
SOURCEMETA_BLAZE_BUNDLE_EXPORT
auto bundle(
const sourcemeta::core::JSON &schema, const SchemaWalker &walker,
const SchemaResolver &resolver, std::string_view default_dialect = "",
Expand Down
2 changes: 2 additions & 0 deletions src/codegen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ target_link_libraries(sourcemeta_blaze_codegen PUBLIC
sourcemeta::core::json)
target_link_libraries(sourcemeta_blaze_codegen PUBLIC
sourcemeta::blaze::foundation)
target_link_libraries(sourcemeta_blaze_codegen PRIVATE
sourcemeta::blaze::bundle)
target_link_libraries(sourcemeta_blaze_codegen PRIVATE
sourcemeta::blaze::alterschema)
1 change: 1 addition & 0 deletions src/codegen/codegen.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <sourcemeta/blaze/alterschema.h>
#include <sourcemeta/blaze/bundle.h>
#include <sourcemeta/blaze/codegen.h>

#include <algorithm> // std::ranges::sort
Expand Down
2 changes: 2 additions & 0 deletions src/compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ target_link_libraries(sourcemeta_blaze_compiler PRIVATE
sourcemeta::core::uri)
target_link_libraries(sourcemeta_blaze_compiler PUBLIC
sourcemeta::blaze::foundation)
target_link_libraries(sourcemeta_blaze_compiler PRIVATE
sourcemeta::blaze::bundle)
target_link_libraries(sourcemeta_blaze_compiler PUBLIC
sourcemeta::blaze::evaluator)
2 changes: 1 addition & 1 deletion src/compiler/compile.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <sourcemeta/blaze/bundle.h>
#include <sourcemeta/blaze/compiler.h>
#include <sourcemeta/blaze/evaluator.h>

#include <sourcemeta/blaze/foundation.h>

#include <algorithm> // std::move, std::sort, std::unique
Expand Down
1 change: 1 addition & 0 deletions src/configuration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ target_link_libraries(sourcemeta_blaze_configuration PRIVATE sourcemeta::core::u
target_link_libraries(sourcemeta_blaze_configuration PRIVATE sourcemeta::core::io)
target_link_libraries(sourcemeta_blaze_configuration PRIVATE sourcemeta::core::crypto)
target_link_libraries(sourcemeta_blaze_configuration PRIVATE sourcemeta::blaze::foundation)
target_link_libraries(sourcemeta_blaze_configuration PRIVATE sourcemeta::blaze::bundle)
Loading
Loading