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


class OpenalSoftRecipe(ConanFile):
    name = "openal-soft"
    package_type = "library"
    user = "aurora"

    license = "LGPL"
    author = "Vladislav Larionov <vladislav.larionov@fruct.org>"
    url = "https://gitverse.ru/auroraos/mirror_openal-soft"
    description = "OpenAL Soft is a software implementation of the OpenAL 3D audio API"
    topics = ("openal", "audio")

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

    def layout(self):
        cmake_layout(self)

    def source(self):
        get(self, **self.conan_data["sources"][self.version], strip_root=True)

    def generate(self):
        deps = CMakeDeps(self)
        deps.generate()
        tc = CMakeToolchain(self)
        tc.cache_variables["ALSOFT_EXAMPLES"] = False
        tc.generate()

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

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

    def package_info(self):
        self.cpp_info.libs = ["openal"]
        self.cpp_info.includedirs.append(os.path.join("include", "AL"))

