mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-11 12:33:25 -08:00
Add a TagDatabase loader that understands Scryfall's Oracle Tags bulk data and user-supplied tag files (tag objects, flat oracle-id or name maps, optional manifest, JSON or JSONL, gzip/xz/zip). The importer joins the slugs on identifiers.scryfallOracleId while the identifiers are still available, falls back to the card name, and unions them with any tags the source already provides. Split-card faces merge through the existing tag union path. This replaces oracle/scripts/inject_scryfall_tags.py, which patched AllPrintings.json before import. Loading during import keeps tags on by default for every source and lets users pair Oracle with any tag database.
84 lines
2.8 KiB
CMake
84 lines
2.8 KiB
CMake
# Optional compression libs, mirrored from oracle/CMakeLists.txt, so the tag database
|
|
# loader can decompress whatever format the tag source serves, and the benchmark can
|
|
# download and decompress whatever AllPrintings format the default URL selects.
|
|
# add_definitions() is directory-scoped and order-independent, so HAS_ZLIB/HAS_LZMA
|
|
# reach every test target below regardless of where they are declared.
|
|
set(_ORACLE_COMPRESSION_SOURCES)
|
|
set(_ORACLE_COMPRESSION_LIBRARIES)
|
|
|
|
find_package(ZLIB)
|
|
if(ZLIB_FOUND)
|
|
add_definitions("-DHAS_ZLIB")
|
|
list(APPEND _ORACLE_COMPRESSION_SOURCES ../../oracle/src/zip/unzip.cpp ../../oracle/src/zip/zipglobal.cpp)
|
|
cockatrice_disable_sanitizers_for(${_ORACLE_COMPRESSION_SOURCES})
|
|
cockatrice_disable_coverage_for(${_ORACLE_COMPRESSION_SOURCES})
|
|
list(APPEND _ORACLE_COMPRESSION_LIBRARIES ${ZLIB_LIBRARIES})
|
|
include_directories(${ZLIB_INCLUDE_DIRS})
|
|
else()
|
|
message(STATUS "Oracle tests: zlib not found; gzip/zip tag databases and the zip download benchmark disabled")
|
|
endif()
|
|
|
|
find_package(LibLZMA)
|
|
if(LIBLZMA_FOUND)
|
|
add_definitions("-DHAS_LZMA")
|
|
list(APPEND _ORACLE_COMPRESSION_SOURCES ../../oracle/src/lzma/decompress.cpp)
|
|
cockatrice_disable_sanitizers_for(../../oracle/src/lzma/decompress.cpp)
|
|
cockatrice_disable_coverage_for(../../oracle/src/lzma/decompress.cpp)
|
|
list(APPEND _ORACLE_COMPRESSION_LIBRARIES ${LIBLZMA_LIBRARIES})
|
|
include_directories(${LIBLZMA_INCLUDE_DIRS})
|
|
else()
|
|
message(STATUS "Oracle tests: LibLZMA not found; xz tag databases and the xz download benchmark disabled")
|
|
endif()
|
|
|
|
cockatrice_add_test(NAME parse_cipt_test SOURCES ../../oracle/src/parsehelpers.cpp parse_cipt_test.cpp)
|
|
|
|
# Oracle importer unit tests
|
|
cockatrice_add_test(
|
|
NAME
|
|
oracle_importer_test
|
|
SOURCES
|
|
${VERSION_STRING_CPP}
|
|
../../oracle/src/oracleimporter.cpp
|
|
../../oracle/src/parsehelpers.cpp
|
|
../../oracle/src/raw_json_scanner.cpp
|
|
../../oracle/src/tag_database.cpp
|
|
oracle_importer_test.cpp
|
|
${_ORACLE_COMPRESSION_SOURCES}
|
|
LIBS
|
|
libcockatrice_card
|
|
libcockatrice_interfaces
|
|
EXTRA_LIBS
|
|
${_ORACLE_COMPRESSION_LIBRARIES}
|
|
)
|
|
|
|
# Tag database format detection, parsing and parent expansion
|
|
cockatrice_add_test(
|
|
NAME
|
|
tag_database_test
|
|
SOURCES
|
|
../../oracle/src/tag_database.cpp
|
|
tag_database_test.cpp
|
|
${_ORACLE_COMPRESSION_SOURCES}
|
|
EXTRA_LIBS
|
|
${_ORACLE_COMPRESSION_LIBRARIES}
|
|
)
|
|
|
|
# Oracle importer benchmark tests (manual, not run in CI, incl. RAM benchmark)
|
|
cockatrice_add_manual_test(
|
|
NAME
|
|
oracle_importer_benchmark_test
|
|
SOURCES
|
|
${VERSION_STRING_CPP}
|
|
../../oracle/src/oracleimporter.cpp
|
|
../../oracle/src/parsehelpers.cpp
|
|
../../oracle/src/raw_json_scanner.cpp
|
|
../../oracle/src/tag_database.cpp
|
|
oracle_importer_benchmark_test.cpp
|
|
${_ORACLE_COMPRESSION_SOURCES}
|
|
LIBS
|
|
libcockatrice_card
|
|
libcockatrice_interfaces
|
|
EXTRA_LIBS
|
|
${_ORACLE_COMPRESSION_LIBRARIES}
|
|
MANUAL
|
|
)
|