# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit lomiri

if [[ ${PV} == 9999 ]]; then
    KEYWORDS=""
    EGIT_REPO_URI="https://gitlab.com/ubports/development/core/${PN}.git"
    inherit git-r3
else
    KEYWORDS="~amd64"
    SRC_URI="https://gitlab.com/ubports/development/core/${PN}/-/archive/${PV}/${P}.tar.gz"
fi

DESCRIPTION="Library to detect and configure devices"
HOMEPAGE="https://gitlab.com/ubports/development/core/${PN}"
LICENSE="GPL-3"
SLOT="0"
RESTRICT="test mirror"

DEPEND="
    dev-cpp/yaml-cpp
"

RDEPEND="${DEPEND}"

BDEPEND="
    dev-build/cmake
    dev-build/cmake-extras
    virtual/pkgconfig
"

src_prepare() {
    # remove hard coded coverage report
    sed -i "/find_package(CoverageReport)/d" CMakeLists.txt  || die

    # remove search for libandroid-properties
    sed -i "/pkg_search_module(ANDROIDPROPS libandroid-properties)/,/endif()/d" CMakeLists.txt  || die

    lomiri_src_prepare
}

src_configure() {
    local mycmakeargs=(
        -DDISABLE_TESTS="ON"
        -DWITH_EXTRAS="OFF"
        -DCONFIG_PATH=/etc/lomiri-deviceinfo
    )

    lomiri_src_configure
}