Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of Noa in this project #1489

Merged
merged 1 commit into from
Jan 28, 2025
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
6 changes: 0 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,6 @@ jobs:
${{ 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_noa
- run: >
cmake --install ./build --prefix ./build/dist --config Release --verbose
--component sourcemeta_noa_dev
- run: >
cmake --install ./build --prefix ./build/dist --config Release --verbose
--component sourcemeta_core
Expand Down
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ option(SOURCEMETA_CORE_INSTALL "Install the Sourcemeta Core library" ON)
option(SOURCEMETA_CORE_ADDRESS_SANITIZER "Build Sourcemeta Core with an address sanitizer" OFF)
option(SOURCEMETA_CORE_UNDEFINED_SANITIZER "Build Sourcemeta Core with an undefined behavior sanitizer" OFF)

include(./vendor/noa/cmake/noa.cmake)
include(Sourcemeta)

# TODO: Turn this into a re-usable utility CMake function
if(SOURCEMETA_CORE_INSTALL)
Expand Down Expand Up @@ -74,22 +74,22 @@ if(SOURCEMETA_CORE_EXTENSION_ALTERSCHEMA)
endif()

if(SOURCEMETA_CORE_ADDRESS_SANITIZER)
noa_sanitizer(TYPE address)
sourcemeta_sanitizer(TYPE address)
elseif(SOURCEMETA_CORE_UNDEFINED_SANITIZER)
noa_sanitizer(TYPE undefined)
sourcemeta_sanitizer(TYPE undefined)
endif()

if(SOURCEMETA_CORE_DOCS)
noa_target_doxygen(CONFIG "${PROJECT_SOURCE_DIR}/doxygen/Doxyfile.in"
sourcemeta_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
sourcemeta_target_clang_format(SOURCES
src/*.h src/*.cc
benchmark/*.h benchmark/*.cc
test/*.h test/*.cc)
noa_target_clang_tidy(SOURCES
sourcemeta_target_clang_tidy(SOURCES
src/*.h src/*.cc)
endif()

Expand Down
1 change: 0 additions & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
vendorpull https://github.com/sourcemeta/vendorpull 70342aaf458e6cb80baeb5b718901075fc42ede6
noa https://github.com/sourcemeta/noa b2c8e362a5c4c138eb708603a351df2b2d79a1c9
jsontestsuite https://github.com/nst/JSONTestSuite d64aefb55228d9584d3e5b2433f720ea8fd00c82
jsonschema-2020-12 https://github.com/json-schema-org/json-schema-spec 769daad75a9553562333a8937a187741cb708c72
jsonschema-2019-09 https://github.com/json-schema-org/json-schema-spec 41014ea723120ce70b314d72f863c6929d9f3cfd
Expand Down
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ configure: .always
compile: .always
$(CMAKE) --build ./build --config $(PRESET) --target clang_format
$(CMAKE) --build ./build --config $(PRESET) --parallel 4
$(CMAKE) --install ./build --prefix ./build/dist --config $(PRESET) --verbose \
--component sourcemeta_noa
$(CMAKE) --install ./build --prefix ./build/dist --config $(PRESET) --verbose \
--component sourcemeta_noa_dev
$(CMAKE) --install ./build --prefix ./build/dist --config $(PRESET) --verbose \
--component sourcemeta_core
$(CMAKE) --install ./build --prefix ./build/dist --config $(PRESET) --verbose \
Expand Down
Binary file removed assets/logo.png
Binary file not shown.
15 changes: 0 additions & 15 deletions assets/logo.svg

This file was deleted.

2 changes: 1 addition & 1 deletion benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if(SOURCEMETA_CORE_JSONPOINTER)
endif()

if(BENCHMARK_SOURCES)
noa_googlebenchmark(NAMESPACE sourcemeta PROJECT core
sourcemeta_googlebenchmark(NAMESPACE sourcemeta PROJECT core
FOLDER "Core" SOURCES ${BENCHMARK_SOURCES})

target_compile_definitions(sourcemeta_core_benchmark
Expand Down
2 changes: 1 addition & 1 deletion cmake/FindBoostRegex.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ if(NOT BoostRegex_FOUND)

target_compile_definitions(boost_regex INTERFACE BOOST_REGEX_STANDALONE)

if(SOURCEMETA_CORE_UNDEFINED_SANITIZER AND NOA_COMPILER_LLVM)
if(SOURCEMETA_CORE_UNDEFINED_SANITIZER AND SOURCEMETA_COMPILER_LLVM)
# Boost Regex doesn't pass the LLVM Undefined Behavior sanitizer otherwise
# vendor/boost-regex/include/boost/regex/v5/cpp_regex_traits.hpp:1022:60:
# runtime error: implicit conversion from type 'unsigned char' of value 128
Expand Down
2 changes: 1 addition & 1 deletion cmake/Findyaml.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if(NOT Yaml_FOUND)

add_library(yaml ${YAML_SOURCES})

if(NOA_COMPILER_LLVM OR NOA_COMPILER_GCC)
if(SOURCEMETA_COMPILER_LLVM OR SOURCEMETA_COMPILER_GCC)
target_compile_options(yaml PRIVATE -Wno-implicit-function-declaration)
target_compile_options(yaml PRIVATE -Wno-int-to-pointer-cast)
endif()
Expand Down
16 changes: 16 additions & 0 deletions cmake/Sourcemeta.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
set(SOURCEMETA_UTILITIES_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/common")
include("${SOURCEMETA_UTILITIES_DIRECTORY}/shim.cmake")
include("${SOURCEMETA_UTILITIES_DIRECTORY}/variables.cmake")
include("${SOURCEMETA_UTILITIES_DIRECTORY}/defaults.cmake")
include("${SOURCEMETA_UTILITIES_DIRECTORY}/compiler/sanitizer.cmake")
include("${SOURCEMETA_UTILITIES_DIRECTORY}/compiler/options.cmake")
include("${SOURCEMETA_UTILITIES_DIRECTORY}/options/enum.cmake")
include("${SOURCEMETA_UTILITIES_DIRECTORY}/commands/copy-file.cmake")
include("${SOURCEMETA_UTILITIES_DIRECTORY}/targets/library.cmake")
include("${SOURCEMETA_UTILITIES_DIRECTORY}/targets/executable.cmake")
include("${SOURCEMETA_UTILITIES_DIRECTORY}/targets/clang-format.cmake")
include("${SOURCEMETA_UTILITIES_DIRECTORY}/targets/clang-tidy.cmake")
include("${SOURCEMETA_UTILITIES_DIRECTORY}/targets/shellcheck.cmake")
include("${SOURCEMETA_UTILITIES_DIRECTORY}/targets/doxygen.cmake")
include("${SOURCEMETA_UTILITIES_DIRECTORY}/targets/googletest.cmake")
include("${SOURCEMETA_UTILITIES_DIRECTORY}/targets/googlebenchmark.cmake")
17 changes: 17 additions & 0 deletions cmake/common/commands/copy-file.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function(sourcemeta_command_copy_file)
cmake_parse_arguments(SOURCEMETA_COMMAND_COPY_FILE "" "FROM;TO" "" ${ARGN})

if(NOT SOURCEMETA_COMMAND_COPY_FILE_FROM)
message(FATAL_ERROR "You must pass the file to copy using the FROM option")
endif()
if(NOT SOURCEMETA_COMMAND_COPY_FILE_TO)
message(FATAL_ERROR "You must pass the destination to copy to using the TO option")
endif()

add_custom_command(
OUTPUT "${SOURCEMETA_COMMAND_COPY_FILE_TO}"
COMMAND "${CMAKE_COMMAND}" -E copy "${SOURCEMETA_COMMAND_COPY_FILE_FROM}" "${SOURCEMETA_COMMAND_COPY_FILE_TO}"
MAIN_DEPENDENCY "${SOURCEMETA_COMMAND_COPY_FILE_FROM}"
DEPENDS "${SOURCEMETA_COMMAND_COPY_FILE_FROM}"
COMMENT "Copying ${SOURCEMETA_COMMAND_COPY_FILE_FROM} ot ${SOURCEMETA_COMMAND_COPY_FILE_TO}")
endfunction()
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function(noa_add_default_options visibility target)
if(NOA_COMPILER_MSVC)
function(sourcemeta_add_default_options visibility target)
if(SOURCEMETA_COMPILER_MSVC)
# See https://learn.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-by-category
target_compile_options("${target}" ${visibility}
/options:strict
Expand All @@ -8,7 +8,7 @@ function(noa_add_default_options visibility target)
/WL
/MP
/sdl)
elseif(NOA_COMPILER_LLVM OR NOA_COMPILER_GCC)
elseif(SOURCEMETA_COMPILER_LLVM OR SOURCEMETA_COMPILER_GCC)
target_compile_options("${target}" ${visibility}
-Wall
-Wextra
Expand Down Expand Up @@ -54,7 +54,7 @@ function(noa_add_default_options visibility target)
-fwrapv)
endif()

if(NOA_COMPILER_LLVM)
if(SOURCEMETA_COMPILER_LLVM)
target_compile_options("${target}" ${visibility}
-Wbool-conversion
-Wint-conversion
Expand All @@ -80,7 +80,7 @@ function(noa_add_default_options visibility target)
-fvectorize
# Enable vectorization of straight-line code for performance
-fslp-vectorize)
elseif(NOA_COMPILER_GCC)
elseif(SOURCEMETA_COMPILER_GCC)
target_compile_options("${target}" ${visibility}
-fno-trapping-math
# Newer versions of GCC (i.e. 14) seem to print a lot of false-positives here
Expand All @@ -95,13 +95,13 @@ endfunction()
# For studying failed vectorization results
# - On Clang , seems to only take effect on release shared builds
# - On GCC, seems to only take effect on release shared builds
function(noa_add_vectorization_diagnostics target)
if(NOA_COMPILER_LLVM)
function(sourcemeta_add_vectorization_diagnostics target)
if(SOURCEMETA_COMPILER_LLVM)
# See https://llvm.org/docs/Vectorizers.html#id6
target_compile_options("${target}" PRIVATE
-Rpass-analysis=loop-vectorize
-Rpass-missed=loop-vectorize)
elseif(NOA_COMPILER_GCC)
elseif(SOURCEMETA_COMPILER_GCC)
target_compile_options("${target}" PRIVATE
-fopt-info-vec-missed
-fopt-info-loop-missed)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
function(noa_sanitizer)
cmake_parse_arguments(NOA_SANITIZER "" "TYPE" "" ${ARGN})
function(sourcemeta_sanitizer)
cmake_parse_arguments(SOURCEMETA_SANITIZER "" "TYPE" "" ${ARGN})

if(NOT NOA_SANITIZER_TYPE)
if(NOT SOURCEMETA_SANITIZER_TYPE)
message(FATAL_ERROR "You must pass the intended sanitizer")
endif()

if(NOA_COMPILER_LLVM AND "${NOA_SANITIZER_TYPE}" STREQUAL "address")
if(SOURCEMETA_COMPILER_LLVM AND "${SOURCEMETA_SANITIZER_TYPE}" STREQUAL "address")
# See https://clang.llvm.org/docs/AddressSanitizer.html
message(STATUS "Enabling sanitizer: Clang AddressSanitizer")
add_compile_options(-fsanitize=address -fsanitize-address-use-after-scope)
add_link_options(-fsanitize=address)
# Get nicer stack traces with the Address sanitizer
add_compile_options(-fno-omit-frame-pointer -fno-optimize-sibling-calls)
add_compile_options(-O1)
elseif(NOA_COMPILER_LLVM AND "${NOA_SANITIZER_TYPE}" STREQUAL "memory")
elseif(SOURCEMETA_COMPILER_LLVM AND "${SOURCEMETA_SANITIZER_TYPE}" STREQUAL "memory")
if(APPLE)
message(FATAL_ERROR "Clang MemorySanitizer is not available on Apple platforms")
endif()
Expand All @@ -25,7 +25,7 @@ function(noa_sanitizer)
# Get nicer stack traces with the Memory sanitizer
add_compile_options(-fno-omit-frame-pointer -fno-optimize-sibling-calls)
add_compile_options(-O1)
elseif(NOA_COMPILER_LLVM AND "${NOA_SANITIZER_TYPE}" STREQUAL "undefined")
elseif(SOURCEMETA_COMPILER_LLVM AND "${SOURCEMETA_SANITIZER_TYPE}" STREQUAL "undefined")
# See https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
message(STATUS "Enabling sanitizer: Clang UndefinedBehaviorSanitizer")
add_compile_options(-fsanitize=undefined,nullability,integer,implicit-conversion,local-bounds
Expand Down
22 changes: 11 additions & 11 deletions vendor/noa/cmake/noa/defaults.cmake → cmake/common/defaults.cmake
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
# Standards (sane modern defaults)
if("CXX" IN_LIST NOA_LANGUAGES)
if("CXX" IN_LIST SOURCEMETA_LANGUAGES)
set(CMAKE_CXX_STANDARD 20)
endif()
if("C" IN_LIST NOA_LANGUAGES)
if("C" IN_LIST SOURCEMETA_LANGUAGES)
set(CMAKE_C_STANDARD 11)
endif()
if("OBJCXX" IN_LIST NOA_LANGUAGES)
if("OBJCXX" IN_LIST SOURCEMETA_LANGUAGES)
set(CMAKE_OBJCXX_STANDARD "${CMAKE_CXX_STANDARD}")
endif()

# Hide symbols from shared libraries by default
# In certain compilers, like GCC and Clang,
# symbols are visible by default.
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)
if("CXX" IN_LIST NOA_LANGUAGES)
if("CXX" IN_LIST SOURCEMETA_LANGUAGES)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
endif()
if("C" IN_LIST NOA_LANGUAGES)
if("C" IN_LIST SOURCEMETA_LANGUAGES)
set(CMAKE_C_VISIBILITY_PRESET hidden)
endif()
if("OBJCXX" IN_LIST NOA_LANGUAGES)
if("OBJCXX" IN_LIST SOURCEMETA_LANGUAGES)
set(CMAKE_OBJCXX_VISIBILITY_PRESET hidden)
endif()

# By default, stay within ISO C++
if("CXX" IN_LIST NOA_LANGUAGES)
if("CXX" IN_LIST SOURCEMETA_LANGUAGES)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
if("C" IN_LIST NOA_LANGUAGES)
if("C" IN_LIST SOURCEMETA_LANGUAGES)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
endif()
if("OBJCXX" IN_LIST NOA_LANGUAGES)
if("OBJCXX" IN_LIST SOURCEMETA_LANGUAGES)
set(CMAKE_OBJCXX_STANDARD_REQUIRED ON)
set(CMAKE_OBJCXX_EXTENSIONS OFF)
endif()
Expand Down Expand Up @@ -79,15 +79,15 @@ endif()
# - https://gcc.gnu.org/onlinedocs/gccint/LTO-Overview.html
# - https://llvm.org/docs/FatLTO.html

if(NOA_COMPILER_GCC AND CMAKE_BUILD_TYPE STREQUAL "Release" AND NOT BUILD_SHARED_LIBS)
if(SOURCEMETA_COMPILER_GCC AND CMAKE_BUILD_TYPE STREQUAL "Release" AND NOT BUILD_SHARED_LIBS)
message(STATUS "Enabling Fat LTO")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -ffat-lto-objects")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto")
endif()

# TODO: Make this work on Linux on LLVM
if(NOA_COMPILER_LLVM AND CMAKE_BUILD_TYPE STREQUAL "Release" AND NOT BUILD_SHARED_LIBS AND APPLE)
if(SOURCEMETA_COMPILER_LLVM AND CMAKE_BUILD_TYPE STREQUAL "Release" AND NOT BUILD_SHARED_LIBS AND APPLE)
message(STATUS "Enabling Fat LTO")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto=full")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto=full")
Expand Down
32 changes: 32 additions & 0 deletions cmake/common/options/enum.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
function(sourcemeta_option_enum)
cmake_parse_arguments(SOURCEMETA_OPTION_ENUM "" "NAME;DEFAULT;DESCRIPTION" "CHOICES" ${ARGN})

if(NOT SOURCEMETA_OPTION_ENUM_NAME)
message(FATAL_ERROR "You must pass the option name as NAME")
endif()
if(NOT SOURCEMETA_OPTION_ENUM_DEFAULT)
message(FATAL_ERROR "You must pass the option default value as DEFAULT")
endif()
if(NOT "${SOURCEMETA_OPTION_ENUM_DEFAULT}" IN_LIST SOURCEMETA_OPTION_ENUM_CHOICES)
message(FATAL_ERROR "Default value of ${SOURCEMETA_OPTION_ENUM_NAME} must be one of these: ${SOURCEMETA_OPTION_ENUM_CHOICES}")
endif()
if(NOT SOURCEMETA_OPTION_ENUM_DESCRIPTION)
message(FATAL_ERROR "You must pass the option description as DESCRIPTION")
endif()
if(NOT SOURCEMETA_OPTION_ENUM_CHOICES)
message(FATAL_ERROR "You must pass the option enum choices as CHOICES")
endif()

# Declare the option
set("${SOURCEMETA_OPTION_ENUM_NAME}" "${SOURCEMETA_OPTION_ENUM_DEFAULT}"
CACHE STRING "${SOURCEMETA_OPTION_ENUM_DESCRIPTION}")

# Display a nice set of options in `cmake-gui`
set_property(CACHE "${SOURCEMETA_OPTION_ENUM_NAME}"
PROPERTY STRINGS ${SOURCEMETA_OPTION_ENUM_CHOICES})

# Perform validation
if(NOT "${${SOURCEMETA_OPTION_ENUM_NAME}}" IN_LIST SOURCEMETA_OPTION_ENUM_CHOICES)
message(FATAL_ERROR "Value of ${SOURCEMETA_OPTION_ENUM_NAME} must be one of these: ${SOURCEMETA_OPTION_ENUM_CHOICES}")
endif()
endfunction()
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
function(noa_target_clang_format)
cmake_parse_arguments(NOA_TARGET_CLANG_FORMAT "REQUIRED" "" "SOURCES" ${ARGN})
function(sourcemeta_target_clang_format)
cmake_parse_arguments(SOURCEMETA_TARGET_CLANG_FORMAT "REQUIRED" "" "SOURCES" ${ARGN})

if(NOA_TARGET_CLANG_FORMAT_REQUIRED)
if(SOURCEMETA_TARGET_CLANG_FORMAT_REQUIRED)
find_program(CLANG_FORMAT_BIN NAMES clang-format REQUIRED)
else()
find_program(CLANG_FORMAT_BIN NAMES clang-format)
endif()

# This covers the empty list too
if(NOT NOA_TARGET_CLANG_FORMAT_SOURCES)
if(NOT SOURCEMETA_TARGET_CLANG_FORMAT_SOURCES)
message(FATAL_ERROR "You must pass file globs to format in the SOURCES option")
endif()
file(GLOB_RECURSE NOA_TARGET_CLANG_FORMAT_FILES
${NOA_TARGET_CLANG_FORMAT_SOURCES})
file(GLOB_RECURSE SOURCEMETA_TARGET_CLANG_FORMAT_FILES
${SOURCEMETA_TARGET_CLANG_FORMAT_SOURCES})

set(CLANG_FORMAT_CONFIG "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/clang-format.config")
if(CLANG_FORMAT_BIN)
add_custom_target(clang_format
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
VERBATIM
COMMAND "${CLANG_FORMAT_BIN}" "--style=file:${CLANG_FORMAT_CONFIG}"
-i ${NOA_TARGET_CLANG_FORMAT_FILES}
-i ${SOURCEMETA_TARGET_CLANG_FORMAT_FILES}
COMMENT "Formatting sources using ClangFormat")
add_custom_target(clang_format_test
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
VERBATIM
COMMAND "${CLANG_FORMAT_BIN}" "--style=file:${CLANG_FORMAT_CONFIG}"
--dry-run -Werror
-i ${NOA_TARGET_CLANG_FORMAT_FILES}
-i ${SOURCEMETA_TARGET_CLANG_FORMAT_FILES}
COMMENT "Checking for ClangFormat compliance")
else()
add_custom_target(clang_format
Expand Down
Loading