#include <cstdio>

#include <inspirecv/version.h>

namespace inspirecv {
namespace {

const LibraryInfo kLibraryInfo = {
    1,
    0,
    2,
    "InspireCV v1.0.2@General - Build Time: 2026-09-20",
    "2026-09-20",
    "OKCV",
    "Linux",
    "armv7",
    "GNU",
    "8.3.0",
    "Release",
    14,
    (0 != 0),
    (0 != 0),
    (0 != 0),
    (1 != 0),
    (0 == 0),
    256,
    "-flax-vector-conversions -std=c++14 -O3 -O3 -DNDEBUG",
};

}  // namespace

const char* GetVersion() {
    return kLibraryInfo.version_string;
}

const char* GetCVBackend() {
    return kLibraryInfo.cv_backend;
}

const LibraryInfo& GetLibraryInfo() {
    return kLibraryInfo;
}

void PrintLibraryInfo() {
    const LibraryInfo& info = GetLibraryInfo();
    std::printf("%s\n", info.version_string);
    std::printf("  Backend    : %s\n", info.cv_backend);
    std::printf("  System     : %s (%s)\n", info.system_name,
                info.system_processor);
    std::printf("  Compiler   : %s %s (C++%d)\n", info.compiler_name,
                info.compiler_version, info.cxx_standard);
    std::printf("  BuildType  : %s\n", info.build_type);
    std::printf("  LTO        : %s\n", info.lto_enabled ? "ON" : "OFF");
    std::printf("  SSE        : %s\n", info.sse_enabled ? "ON" : "OFF");
    std::printf("  AVX2       : %s\n", info.avx2_enabled ? "ON" : "OFF");
    std::printf("  NEON       : %s\n", info.neon_enabled ? "ON" : "OFF");
    std::printf("  TaskTiling : %s\n",
                info.task_tiling_enabled ? "ON" : "OFF");
    std::printf("  TaskTile   : %d\n", info.task_tile_width);
    if (info.cxx_flags && info.cxx_flags[0]) {
        std::printf("  CXXFlags   : %s\n", info.cxx_flags);
    }
}

}  // namespace inspirecv
