#!/usr/bin/env python3
# Copyright (c) 2020-2022 The Bitcoin developers

from pathlib import Path
import sys


def main(input_file, output_file):
    with open(input_file, 'rb') as f:
        contents = f.read()

    with open(output_file, "w", encoding="utf-8") as f:
        f.write(
            "// -- THIS FILE IS AUTO-GENERATED BY generate_asmap.py, DO NOT EDIT IT --\n"
            "#pragma once\n"
            "#include <cstdint>\n\n"
            "static const uint8_t {}_raw[] = {{\n".format(
                Path(input_file).stem))
        f.write(", ".join(map(lambda x: "0x{:02x}".format(x), contents)))
        f.write("\n};\n")


if __name__ == "__main__":
    if len(sys.argv) != 3:
        print("Invalid parameters\nUsage: {} input_file output_file".format(
            Path(sys.argv[0]).name))
        sys.exit(1)

    main(sys.argv[1], sys.argv[2])
