# The filesystem + dialog seam for bank packages. package_io / package_rollback are
# REAPER-free (standard filesystem only), so the pure-library/test helpers fit and
# their tests run without a DAW. Both verbs live here too: export_bank whole, and the
# import's REAPER-free half (import_landing) — the import's REAPER-facing half
# (import_bank.cpp) compiles into the extension module instead.

reasampler_pure_library(package_io SOURCES package_io.cpp)
reasampler_test(package_io LINK package_io)

reasampler_pure_library(package_rollback SOURCES package_rollback.cpp LINK PUBLIC package_io)
reasampler_test(package_rollback LINK package_rollback)

# export_bank reads the live session through ReaSamplerSession's INLINE accessors only,
# so it pulls in no REAPER-facing TU and its tests link (and run) without a DAW.
# bank_book / tail_control / origin_ledger / tracking_authority / prune_reconcile /
# app_version / view_mode_model are session.h's own transitive includes (BankBook::bank()
# in particular is out-of-line, in bank_book.cpp) — declared here, on the library that
# actually needs them, rather than left for every consumer to enumerate.
reasampler_pure_library(export_bank
    SOURCES export_bank.cpp
    LINK PUBLIC export_plan bank_package package_io
         PRIVATE capture_paths wav_codec bank_book tail_control origin_ledger
                 tracking_authority prune_reconcile app_version view_mode_model)
reasampler_test(export_bank
    LINK export_bank bank_book slot_map view_mode_model tail_control origin_ledger
         tracking_authority prune_reconcile app_version capture_paths)

# The import's decisions and its file half, both REAPER-free, so all-or-nothing,
# integrity and birth-record behaviour are assertable without a DAW. The REAPER-facing
# verb over them (import_bank.cpp) compiles into the extension module instead.
reasampler_pure_library(import_landing
    SOURCES import_landing.cpp
    LINK PUBLIC import_plan package_rollback bank_book PRIVATE bank_package wav_codec)
reasampler_test(import_landing LINK import_landing bank_package app_version wav_codec origin_ledger)

# The frozen compatibility corpus driven through both verbs in one process — the round
# trip is export -> import -> export, so its link set is export_bank's plus the import
# half. Fixture path: see tests/package_fixtures.h.
reasampler_test(package_round_trip
    LINK import_landing export_bank bank_package bank_book slot_map view_mode_model
         tail_control origin_ledger tracking_authority prune_reconcile app_version
         capture_paths wav_codec)
target_compile_definitions(package_round_trip_tests PRIVATE
    REASAMPLER_PACKAGE_FIXTURE_DIR="${REASAMPLER_PACKAGE_FIXTURE_DIR}")

# The pickers call the REAPER API, so no test target can exercise them; declared as a
# library so the TU stays compiled. reaper_plugin.h pulls SWELL in on non-Windows.
add_library(package_pickers STATIC package_pickers.cpp)
target_include_directories(package_pickers PUBLIC ${REASAMPLER_SRC_DIR})
target_include_directories(package_pickers PRIVATE ${SDK_INC} ${WDL_INC})
if(NOT WIN32)
    # Match the loadable modules: SWELL is provided by the host REAPER at runtime.
    target_compile_definitions(package_pickers PRIVATE SWELL_PROVIDED_BY_APP)
endif()
