# Copyright (c) 2023, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

copyright_notice = """


/*
 * NOTE: this file is generated by 00_generate.py
 *
 * Make changes there and run in this directory:
 *
 * > python 00_generate.py
 *
 */

"""

ext_headers = [
    "cuvs/neighbors/brute_force-ext.cuh",
    "cuvs/distance/distance-ext.cuh",
    "cuvs/distance/detail/pairwise_matrix/dispatch-ext.cuh",
    "raft/matrix/detail/select_k-ext.cuh",
    "cuvs/neighbors/ball_cover-ext.cuh",
    "cuvs/spatial/knn/detail/fused_l2_knn-ext.cuh",
    "cuvs/distance/fused_l2_nn-ext.cuh",
    "cuvs/neighbors/ivf_pq-ext.cuh",
    "raft/util/memory_pool-ext.hpp",
    "cuvs/neighbors/ivf_flat-ext.cuh",
    "raft/core/logger-ext.hpp",
    "cuvs/neighbors/refine-ext.cuh",
    "cuvs/neighbors/detail/ivf_flat_search-ext.cuh",
    "cuvs/neighbors/detail/selection_faiss-ext.cuh",
    "raft/linalg/detail/coalesced_reduction-ext.cuh",
    "cuvs/spatial/knn/detail/ball_cover/registers-ext.cuh",
    "cuvs/neighbors/detail/ivf_flat_interleaved_scan-ext.cuh",
    "cuvs/neighbors/detail/ivf_pq_compute_similarity-ext.cuh",
]

for ext_header in ext_headers:
    header = ext_header.replace("-ext", "")

    path = (
        header
        .replace("/", "_")
        .replace(".cuh", ".cu")
        .replace(".hpp", ".cpp")
    )

    with open(path, "w") as f:
        f.write(copyright_notice)
        f.write(f"#include <{header}>\n")

    # For in CMakeLists.txt
    print(f"test/ext_headers/{path}")
