#
# DO NOT EDIT THIS FILE!
# This file is generated by `scargo update`.
#

from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout

{% if config.project.target.family == "stm32" %}
from conans import tools
{% endif %}

class {{ config.project.name|capitalize|replace("-", "") }}Conan(ConanFile):  # type: ignore[misc, no-any-unimported]
    name = "{{ config.project.name }}"
    version = "{{ config.project.version }}"
    license = "MIT"
    description = "{{ config.project.description }}"
    settings = "os", "compiler", "build_type", "arch"
    url = "{{ config.project.homepage_url }}"
    generators = "CMakeDeps"
    exports_sources = ["{{ config.source_dir_path.relative_to(config.project_root) }}/*", "CMakeLists.txt", "include/*", "config/*"]

    {% if config.dependencies.build or config.dependencies.tool %}
    def build_requirements(self) -> None:
        {% for dep in config.dependencies.build %}
        self.requires("{{ dep }}")
        {% endfor %}
        {% for tool_dep in config.dependencies.tool %}
        self.tool_requires("{{ tool_dep }}")
        {% endfor %}

    {% endif %}
    {% if config.dependencies.general %}
    def requirements(self) -> None:
        {% for dep in config.dependencies.general %}
        self.requires("{{ dep }}")
        {% endfor %}
    {% endif %}

    {% if config.project.target.family == "stm32" %}
    def source(self) -> None:
        git = tools.Git(folder="third-party/stm32-cmake")
        git.clone("https://github.com/ObKo/stm32-cmake.git", "master")
    {% endif %}

    def layout(self):
        cmake_layout(self)

    def generate(self):
        tc = CMakeToolchain(self)
        tc.generate()

    def build(self) -> None:
        cmake = CMake(self)
        cmake.configure()
        cmake.build()

    def package(self) -> None:
        {% if config.project.lib_name %}
        cmake = CMake(self)
        cmake.install()
        {% endif %}
        {% if config.project.bin_name %}
        self.copy("*.bin")
        self.copy("*.elf")
        {% endif %}

    {% if config.project.lib_name %}
    def package_info(self) -> None:
        self.cpp_info.libs = ["{{ config.project.name }}"]
    {% endif %}

  


