mirror of
https://github.com/allankoechke/jwt-cpp.git
synced 2026-11-30 10:18:40 +00:00
* quick poc at using cmake to generate the defaults.h traits files * add test preset to dev * self review * poc moving logic to actions * Remove stale defaults.h generation configuration * Fix file path in lint workflow configuration * chmod +x * linter * linter * clean up action and lint workflow * rm source_dir cli arg from cmake script now just assume the current directory is correct * linter * fix order * add workflow preset for running unit test sadly then is less reusable than i wanted
39 lines
1.5 KiB
Bash
Executable File
39 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Trait metadata configuration for generating defaults.h files
|
|
# Maps trait names to their library information
|
|
|
|
set -e # Exit on error
|
|
|
|
# Define traits metadata as pipe-delimited strings
|
|
# Format: TRAITS_NAME|LIBRARY_NAME|LIBRARY_URL|DISABLE_DEFAULT_TRAITS
|
|
JWT_TRAITS_METADATA=(
|
|
"kazuho_picojson|picojson|https://github.com/kazuho/picojson|false"
|
|
"nlohmann_json|JSON for Modern C++|https://github.com/nlohmann/json|true"
|
|
"boost_json|Boost.JSON|https://github.com/boostorg/json|true"
|
|
"danielaparker_jsoncons|jsoncons|https://github.com/danielaparker/jsoncons|true"
|
|
"open_source_parsers_jsoncpp|jsoncpp|https://github.com/open-source-parsers/jsoncpp|true"
|
|
"glaze_json|Glaze|https://github.com/stephenberry/glaze|true"
|
|
"reflectcpp_json|ReflectCpp|https://github.com/getml/reflect-cpp|true"
|
|
)
|
|
|
|
# Function to configure traits defaults
|
|
configure_traits_defaults() {
|
|
for trait_meta in "${JWT_TRAITS_METADATA[@]}"; do
|
|
# Split the metadata by pipe delimiter
|
|
IFS='|' read -r TRAITS_NAME LIBRARY_NAME LIBRARY_URL DISABLE_DEFAULT_TRAITS <<< "$trait_meta"
|
|
|
|
# Call the CMake script to generate defaults.h for this trait
|
|
if ! cmake \
|
|
-DTRAITS_NAME="$TRAITS_NAME" \
|
|
-DLIBRARY_NAME="$LIBRARY_NAME" \
|
|
-DLIBRARY_URL="$LIBRARY_URL" \
|
|
-DDISABLE_DEFAULT_TRAITS="$DISABLE_DEFAULT_TRAITS" \
|
|
-P "cmake/generate-defaults-h.cmake"; then
|
|
echo "::error::Failed to configure defaults.h for $TRAITS_NAME"
|
|
fi
|
|
done
|
|
}
|
|
|
|
# Execute the configuration
|
|
configure_traits_defaults
|