Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <[email protected]>
  • Loading branch information
jviotti committed Oct 15, 2024
0 parents commit cc8419d
Show file tree
Hide file tree
Showing 721 changed files with 156,299 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .ackrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--ignore-dir=build
--ignore-dir=vendor
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[Makefile]
indent_style = tab

[*.mk]
indent_style = tab
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor/** linguist-generated=true
182 changes: 182 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
name: Blaze

on:
schedule:
# Once per day, Monday to Friday
- cron: '0 19 * * 1-5'
push:
branches:
- main
pull_request:

jobs:
test:
strategy:
fail-fast: false
matrix:
platform:
- os: macos-latest
cc: clang
cxx: clang++
type: static
shell: sh
benchmark: macos/llvm
- os: macos-latest
cc: clang
cxx: clang++
type: shared
shell: sh
- os: macos-latest
cc: gcc-13
cxx: g++-13
type: static
shell: sh
benchmark: macos/gcc
- os: ubuntu-latest
cc: clang
cxx: clang++
type: static
shell: sh
benchmark: linux/llvm
- os: ubuntu-latest
cc: gcc
cxx: g++
type: static
shell: sh
benchmark: linux/gcc
- os: ubuntu-latest
cc: clang
cxx: clang++
type: shared
shell: sh
- os: ubuntu-latest
cc: gcc
cxx: g++
type: shared
shell: sh
- os: windows-latest
type: static
shell: pwsh
benchmark: windows/msvc
- os: windows-latest
type: shared
shell: pwsh

# Sanitizers
- os: ubuntu-latest
cc: clang
cxx: clang++
type: static
shell: sh
options: -DBLAZE_ADDRESS_SANITIZER:BOOL=ON
- os: ubuntu-latest
cc: clang
cxx: clang++
type: static
shell: sh
options: -DBLAZE_UNDEFINED_SANITIZER:BOOL=ON

defaults:
run:
shell: ${{ matrix.platform.shell }}

runs-on: ${{ matrix.platform.os }}
env:
CC: ${{ matrix.platform.cc }}
CXX: ${{ matrix.platform.cxx }}
steps:
- name: Install ClangFormat
run: pipx install clang-format==19.1.0

- uses: actions/checkout@v4
- name: Install dependencies (macOS)
if: runner.os == 'macos'
run: brew bundle
env:
HOMEBREW_NO_ANALYTICS: 1
HOMEBREW_NO_AUTO_UPDATE: 1
- run: cmake --version
- name: Configure Blaze (static)
if: matrix.platform.type == 'static'
run: >
cmake -S . -B ./build
-DCMAKE_BUILD_TYPE:STRING=Release
-DBLAZE_TESTS:BOOL=ON
-DBLAZE_BENCHMARK:BOOL=ON
-DBLAZE_DOCS:BOOL=OFF
-DBUILD_SHARED_LIBS:BOOL=OFF
-DCMAKE_COMPILE_WARNING_AS_ERROR:BOOL=ON
${{ matrix.platform.options }}
- name: Configure Blaze (shared)
if: matrix.platform.type == 'shared'
run: >
cmake -S . -B ./build
-DCMAKE_BUILD_TYPE:STRING=Release
-DBLAZE_TESTS:BOOL=ON
-DBLAZE_BENCHMARK:BOOL=ON
-DBLAZE_DOCS:BOOL=OFF
-DBUILD_SHARED_LIBS:BOOL=ON
-DCMAKE_COMPILE_WARNING_AS_ERROR:BOOL=ON
${{ matrix.platform.options }}
- run: cmake --build ./build --config Release --target clang_format_test
- run: cmake --build ./build --config Release --parallel 4
- run: >
cmake --install ./build --prefix ./build/dist --config Release --verbose
--component sourcemeta_jsontoolkit
- run: >
cmake --install ./build --prefix ./build/dist --config Release --verbose
--component sourcemeta_jsontoolkit_dev
- run: >
cmake --install ./build --prefix ./build/dist --config Release --verbose
--component sourcemeta_blaze
- run: >
cmake --install ./build --prefix ./build/dist --config Release --verbose
--component sourcemeta_blaze_dev
# Not every CTest version supports the --test-dir option. If such option
# is not recognized, `ctest` will successfully exit finding no tests.
# Better to be sure and `cd` all the time here.
- run: cd ./build && ctest --build-config Release --output-on-failure --parallel
env:
# See https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
UBSAN_OPTIONS: print_stacktrace=1

- run: cmake --build ./build --config Release --verbose --target benchmark_all
if: matrix.platform.benchmark
- run: cmake --build ./build --config Release --verbose --target benchmark_json
if: matrix.platform.benchmark

- uses: benchmark-action/github-action-benchmark@v1
if: matrix.platform.benchmark
with:
name: Benchmark (${{ matrix.platform.benchmark }})
tool: googlecpp
output-file-path: build/benchmark.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: ${{ github.event_name != 'pull_request' }}
benchmark-data-dir-path: benchmark/${{ matrix.platform.benchmark }}
alert-threshold: '5%'
comment-always: true
fail-on-alert: false

# TODO: Re-enable
# bindings:
# strategy:
# fail-fast: false
# matrix:
# binding:
# - name: nodejs
# env:
# EMSDK_VERSION: 3.1.58
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - run: |
# git clone --depth 1 https://github.com/emscripten-core/emsdk.git
# ./emsdk/emsdk install ${{ env.EMSDK_VERSION }}
# ./emsdk/emsdk activate ${{ env.EMSDK_VERSION }}
# rm -rf emsdk/upstream/emscripten/cmake
# echo "$(pwd)/emsdk/upstream/emscripten" >> $GITHUB_PATH
# if: matrix.binding.name == 'nodejs'
# - run: make -C bindings/${{ matrix.binding.name }} compile
# - run: make -C bindings/${{ matrix.binding.name }} test
23 changes: 23 additions & 0 deletions .github/workflows/website-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: website
on:
pull_request:

concurrency:
group: website-build-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt update
- run: sudo apt install -y doxygen
- run: >
cmake -S . -B ./build
-DCMAKE_BUILD_TYPE:STRING=Release
-DBLAZE_COMPILER:BOOL=OFF
-DBLAZE_EVALUATOR:BOOL=OFF
-DBLAZE_TESTS:BOOL=OFF
-DBLAZE_DOCS:BOOL=ON
- run: cmake --build ./build --config Release --target doxygen
43 changes: 43 additions & 0 deletions .github/workflows/website-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: website
on:
push:
branches: [ "main" ]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: website-deploy-${{ github.ref }}
cancel-in-progress: true

jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: sudo apt update
- run: sudo apt install -y doxygen
- run: >
cmake -S . -B ./build
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_BUILD_TYPE:STRING=Release
-DBLAZE_COMPILER:BOOL=OFF
-DBLAZE_EVALUATOR:BOOL=OFF
-DBLAZE_TESTS:BOOL=OFF
-DBLAZE_DOCS:BOOL=ON
- run: cmake --build ./build --config Release --target doxygen
- name: Setup Pages
uses: actions/configure-pages@v1
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./build/website
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
/build
Brewfile.lock.json
.DS_Store
.cache
/bindings/*/build
3 changes: 3 additions & 0 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
brew "cmake"
brew "doxygen"
brew "gcc@13"
93 changes: 93 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
cmake_minimum_required(VERSION 3.16)
project(blaze VERSION 0.0.1 LANGUAGES CXX
DESCRIPTION "The ultra high-performance JSON Schema evaluator"
HOMEPAGE_URL "https://github.com/sourcemeta/blaze")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(vendor/noa/cmake/noa.cmake)

# Options
option(BLAZE_COMPILER "Build the Blaze compiler library" ON)
option(BLAZE_EVALUATOR "Build the Blaze evaluator library" ON)
option(BLAZE_TESTS "Build the Blaze tests" OFF)
option(BLAZE_BENCHMARK "Build the Blaze benchmarks" OFF)
option(BLAZE_DOCS "Build the Blaze docs" OFF)
option(BLAZE_INSTALL "Install the Blaze library" ON)
option(BLAZE_ADDRESS_SANITIZER "Build Blaze with an address sanitizer" OFF)
option(BLAZE_UNDEFINED_SANITIZER "Build Blaze with an undefined behavior sanitizer" OFF)

if(BLAZE_INSTALL)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
configure_package_config_file(
config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
COMPATIBILITY SameMajorVersion)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
COMPONENT sourcemeta_blaze_dev)
endif()

if(BLAZE_COMPILER OR BLAZE_EVALUATOR)
find_package(JSONToolkit REQUIRED)
endif()

if(BLAZE_COMPILER)
add_subdirectory(src/compiler)
endif()

if(BLAZE_EVALUATOR)
add_subdirectory(src/evaluator)
endif()

if(BLAZE_ADDRESS_SANITIZER)
noa_sanitizer(TYPE address)
elseif(BLAZE_UNDEFINED_SANITIZER)
noa_sanitizer(TYPE undefined)
endif()

if(BLAZE_DOCS)
noa_target_doxygen(CONFIG "${PROJECT_SOURCE_DIR}/doxygen/Doxyfile.in"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/website")
endif()

if(PROJECT_IS_TOP_LEVEL)
noa_target_clang_format(SOURCES
bindings/*.cc
src/*.h src/*.cc
benchmark/*.h benchmark/*.cc
test/*.h test/*.cc)
noa_target_clang_tidy(SOURCES
src/*.h src/*.cc)
endif()

# Testing
if(BLAZE_TESTS)
find_package(GoogleTest REQUIRED)
enable_testing()

if(BLAZE_COMPILER)
add_subdirectory(test/compiler)
endif()

if(BLAZE_EVALUATOR)
add_subdirectory(test/evaluator)
endif()

if(PROJECT_IS_TOP_LEVEL)
# Otherwise we need the child project to link
# against the sanitizers too.
if(NOT BLAZE_ADDRESS_SANITIZER AND NOT BLAZE_UNDEFINED_SANITIZER)
add_subdirectory(test/packaging)
endif()
endif()

if(BLAZE_BENCHMARK)
find_package(GoogleBenchmark REQUIRED)
add_subdirectory(benchmark)
endif()
endif()
6 changes: 6 additions & 0 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
vendorpull https://github.com/sourcemeta/vendorpull dea311b5bfb53b6926a4140267959ae334d3ecf4
noa https://github.com/sourcemeta/noa 837e1ff981f8df45d9e2977a50f5da61d8affed4
jsontoolkit https://github.com/sourcemeta/jsontoolkit b19c02084362aff20b2517b1b2cd0fe80acc2382
googletest https://github.com/google/googletest a7f443b80b105f940225332ed3c31f2790092f47
googlebenchmark https://github.com/google/benchmark 378fe693a1ef51500db21b11ff05a8018c5f0e55
jsonschema-test-suite https://github.com/json-schema-org/JSON-Schema-Test-Suite c2badb1298a8698f86dadf1aea7b44b3a894e5ac
Loading

0 comments on commit cc8419d

Please sign in to comment.