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


class helloRecipe(ConanFile):
    name = "ehs"
    version = "1.3.0"

    # Optional metadata
    license = "GNU GENERAL PUBLIC LICENSE"
    author = "Event Horizon Studios"
    url = "https://gitea.eventhorizonstudio.io/EventHorizonStudio/EHS"
    description = "Much like boost.io this library is a replacement of the standard C/C++ libraries. It provides most features needed when designing applications in a cross-platform manner. The goal for this project is for it to be compiled and run on anything which means embedded hardware support."
    topics = ("cross-platform", "audio", "file", "sockets")

    # Binary configuration
    settings = "os", "compiler", "build_type", "arch"
    options = {"shared": [True, False], "fPIC": [True, False]}
    default_options = {"shared": False, "fPIC": True}

    # Sources are located in the same place as this recipe, copy them to the recipe
    exports_sources = "CMakeLists.txt", "src/*", "include/*"

    def config_options(self):
        if self.settings.os == "Windows":
            del self.options.fPIC

    def layout(self):
        cmake_layout(self)

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

    def build(self):
        cmake = CMake(self)
        cmake.configure()
        cmake.build()

    def requirements(self):
        requirements = self.conan_data.get('requirements', [])
        for requirement in requirements:
            self.requires(requirement)

    def package(self):
        cmake = CMake(self)
        cmake.install()

    def package_info(self):
        self.cpp_info.libs = ["ehs"]