# We have a conf and classes directory, add to BBPATH
BBPATH .= ":${LAYERDIR}"

# We have a packages directory, add to BBFILES
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb"
BBFILES += "${LAYERDIR}/recipes-*/*/*.bbappend"

BBFILE_COLLECTIONS += "xilinx"
BBFILE_PATTERN_xilinx = "^${LAYERDIR}/"
BBFILE_PRIORITY_xilinx = "5"

BBFILES_DYNAMIC += " \
openembedded-layer:${LAYERDIR}/dynamic-layers/openembedded-layer/recipes-*/*/*.bb \
openembedded-layer:${LAYERDIR}/dynamic-layers/openembedded-layer/recipes-*/*/*.bbappend \
meta-python:${LAYERDIR}/dynamic-layers/meta-python/recipes-*/*/*.bb \
meta-python:${LAYERDIR}/dynamic-layers/meta-python/recipes-*/*/*.bbappend \
openamp-layer:${LAYERDIR}/dynamic-layers/openamp-layer/recipes-*/*/*.bb \
openamp-layer:${LAYERDIR}/dynamic-layers/openamp-layer/recipes-*/*/*.bbappend \
virtualization-layer:${LAYERDIR}/dynamic-layers/virtualization-layer/recipes-*/*/*.bb \
virtualization-layer:${LAYERDIR}/dynamic-layers/virtualization-layer/recipes-*/*/*.bbappend \
xilinx-tools:${LAYERDIR}/dynamic-layers/meta-xilinx-tools/recipes-*/*/*.bb \
xilinx-tools:${LAYERDIR}/dynamic-layers/meta-xilinx-tools/recipes-*/*/*.bbappend \
"

LAYERDEPENDS_xilinx = "core"
LAYERRECOMMENDS_xilinx = "openembedded-layer"

LAYERSERIES_COMPAT_xilinx = "langdale"

SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS += " \
  *->xrt \
  *->zocl \
  *->cairo \
  *->libepoxy \
  *->gstreamer1.0-plugins-base \
  *->gtk+ \
  *->gtk+3 \
  *->libglu \
  *->libsdl \
  *->libsdl2 \
  *->qemu \
  *->xserver-xorg \
"

XILINX_RELEASE_VERSION ??= "v2024.1"

BUILDCFG_VARS:append = " SOC_VARIANT XILINX_RELEASE_VERSION"

# Workaround for a bbappend bug in meta-virtualization (fixed in scarthgap)
BBMASK += "/meta-virtualization/recipes-devtools/qemu/"

XILINX_QEMU_VERSION[v2023.1] = "v7.1.0-xilinx-v2023.1%"
XILINX_QEMU_VERSION[v2023.2] = "v7.1.0-xilinx-v2023.2%"
XILINX_QEMU_VERSION[v2024.1] = "v8.1.0-xilinx-v2024.1%"
PREFERRED_VERSION_qemu ?= "${@ '7.1%' if not (d.getVar('XILINX_RELEASE_VERSION') or 'undefined').startswith('v2024') else '8.1%'}"
PREFERRED_VERSION_qemu-xilinx ?= "${@d.getVarFlag('XILINX_QEMU_VERSION', d.getVar('XILINX_RELEASE_VERSION')) or 'undefined'}"
PREFERRED_VERSION_qemu-xilinx-native ?= "${@d.getVarFlag('XILINX_QEMU_VERSION', d.getVar('XILINX_RELEASE_VERSION')) or 'undefined'}"
PREFERRED_VERSION_qemu-xilinx-system-native ?= "${@d.getVarFlag('XILINX_QEMU_VERSION', d.getVar('XILINX_RELEASE_VERSION')) or 'undefined'}"
PREFERRED_VERSION_qemu-devicetrees ?= "xilinx-${XILINX_RELEASE_VERSION}%"

XILINX_ATF_VERSION[v2023.1] = "2.8-xilinx-v2023.1%"
XILINX_ATF_VERSION[v2023.2] = "2.8-xilinx-v2023.2%"
XILINX_ATF_VERSION[v2024.1] = "2.10-xilinx-v2024.1%"
PREFERRED_VERSION_arm-trusted-firmware ?= "${@d.getVarFlag('XILINX_ATF_VERSION', d.getVar('XILINX_RELEASE_VERSION')) or 'undefined'}"

XILINX_UBOOT_VERSION[v2023.1] = "v2023.01-xilinx-v2023.1%"
XILINX_UBOOT_VERSION[v2023.2] = "v2023.01-xilinx-v2023.2%"
XILINX_UBOOT_VERSION[v2024.1] = "v2023.01-xilinx-v2024.1%"

PREFERRED_VERSION_u-boot-xlnx ?= "${@d.getVarFlag('XILINX_UBOOT_VERSION', d.getVar('XILINX_RELEASE_VERSION')) or 'undefined'}"
PREFERRED_VERSION_u-boot-tools-xlnx ?= "${@d.getVarFlag('XILINX_UBOOT_VERSION', d.getVar('XILINX_RELEASE_VERSION')) or 'undefined'}"

XILINX_LINUX_VERSION[v2023.1] = "6.1.5-xilinx-v2023.1%"
XILINX_LINUX_VERSION[v2023.2] = "6.1.60-xilinx-v2023.2%"
XILINX_LINUX_VERSION[v2024.1] = "6.6.10-xilinx-v2024.1%"
PREFERRED_VERSION_linux-xlnx ?= "${@d.getVarFlag('XILINX_LINUX_VERSION', d.getVar('XILINX_RELEASE_VERSION')) or 'undefined'}"

# Add support to eSDK for gen-machine-conf if it exists
PLNX_SCRIPTS_PATH = "${LAYERDIR}/gen-machine-conf/gen-machine-scripts"
BB_HASHEXCLUDE_COMMON:append = " PLNX_SCRIPTS_PATH"

IMAGE_CLASSES += "gen-machine-conf"
