<commit_before>DESCRIPTION = "Compile AT91 board device tree overlays and pack them in a FIT image"
LICENSE = "(GPLv2+ & MIT)"
LIC_FILES_CHKSUM = "file://COPYING;md5=775626b7bc958bdcc525161f725ece0f \
		    file://LICENSES/GPL-2.0;md5=e6a75371ba4d16749254a51215d13f97 \
		    file://LICENSES/MIT;md5=e8f57dd048e186199433be2c41bd3d6d"

inherit deploy

COMPATIBLE_MACHINE = '(sama5d3xek|sama5d3-xplained|sama5d3-xplained-sd|at91sam9x5ek|at91sam9rlek|at91sam9m10g45ek|sama5d4ek|sama5d4-xplained|sama5d4-xplained-sd|sama5d2-xplained|sama5d2-xplained-sd|sama5d2-xplained-emmc|sama5d2-ptc-ek|sama5d2-ptc-ek-sd|sama5d27-som1-ek|sama5d27-som1-ek-sd)'

SRC_URI = "git://github.com/linux4sam/dt-overlay-at91.git;protocol=https"

PV = "1.0+git${SRCPV}"
SRCREV = "${AUTOREV}"

DEPENDS = "virtual/kernel u-boot-mkimage-native dtc-native"

S = "${WORKDIR}/git"

do_compile[depends] += "virtual/kernel:do_deploy"

do_compile () {
	echo "Compiling DTBOs"
	oe_runmake DTC=dtc KERNEL_DIR=${STAGING_KERNEL_DIR} KERNEL_BUILD_DIR=${KERNEL_PATH} ${AT91BOOTSTRAP_MACHINE}_dtbos

	echo "****************"
	ls -l ${DEPLOY_DIR_IMAGE}
	echo "****************"
	# Over-ride itb target in Makefile
	echo "Creating the FIT image"
	DTC_OPTIONS="-Wno-unit_address_vs_reg -Wno-graph_child_address -Wno-pwms_property"
	mkimage -D "-i${DEPLOY_DIR_IMAGE} -p 1000 ${DTC_OPTIONS}" -f ${AT91BOOTSTRAP_MACHINE}.its ${AT91BOOTSTRAP_MACHINE}.itb
}

FILES_${PN} = "/boot/*.*"

addtask install after do_compile

do_install () {
	# Copy files to /boot
	if [ -e ${AT91BOOTSTRAP_MACHINE}/${AT91BOOTSTRAP_MACHINE}*.dtbo ]; then
		install -d ${D}/boot
		install ${AT91BOOTSTRAP_MACHINE}/${AT91BOOTSTRAP_MACHINE}*.dtbo ${D}/boot
	fi;

	if [ -e ${AT91BOOTSTRAP_MACHINE}.itb ]; then
		install -d ${D}/boot
		fit_image_basename="fitImage-${MACHINE}"
		install ${AT91BOOTSTRAP_MACHINE}.itb ${D}/boot/${fit_image_basename}.itb
		install ${AT91BOOTSTRAP_MACHINE}.its ${D}/boot/${fit_image_basename}.its
	fi;
}

addtask deploy after do_install

do_deploy () {
	fit_image_basename="fitImage-${MACHINE}"<commit_msg>dt-overlay-at91: compile only if dtso/its files exist<commit_after>DESCRIPTION = "Compile AT91 board device tree overlays and pack them in a FIT image"
LICENSE = "(GPLv2+ & MIT)"
LIC_FILES_CHKSUM = "file://COPYING;md5=775626b7bc958bdcc525161f725ece0f \
		    file://LICENSES/GPL-2.0;md5=e6a75371ba4d16749254a51215d13f97 \
		    file://LICENSES/MIT;md5=e8f57dd048e186199433be2c41bd3d6d"

inherit deploy

COMPATIBLE_MACHINE = '(sama5d3xek|sama5d3-xplained|sama5d3-xplained-sd|at91sam9x5ek|at91sam9rlek|at91sam9m10g45ek|sama5d4ek|sama5d4-xplained|sama5d4-xplained-sd|sama5d2-xplained|sama5d2-xplained-sd|sama5d2-xplained-emmc|sama5d2-ptc-ek|sama5d2-ptc-ek-sd|sama5d27-som1-ek|sama5d27-som1-ek-sd)'

SRC_URI = "git://github.com/linux4sam/dt-overlay-at91.git;protocol=https"

PV = "1.0+git${SRCPV}"
SRCREV = "${AUTOREV}"

DEPENDS = "virtual/kernel u-boot-mkimage-native dtc-native"

S = "${WORKDIR}/git"

do_compile[depends] += "virtual/kernel:do_deploy"

do_compile () {
	if [ -e ${AT91BOOTSTRAP_MACHINE}/${AT91BOOTSTRAP_MACHINE}*.dtso ]; then
		echo "Compiling DTBOs"
		oe_runmake DTC=dtc KERNEL_DIR=${STAGING_KERNEL_DIR} KERNEL_BUILD_DIR=${KERNEL_PATH} ${AT91BOOTSTRAP_MACHINE}_dtbos
	else
		echo "No DTBOs to compile"
	fi

	echo "****************"
	ls -l ${DEPLOY_DIR_IMAGE}
	echo "****************"
	# Over-ride itb target in Makefile
	if [ -e ${AT91BOOTSTRAP_MACHINE}.its ]; then
		echo "Creating the FIT image"
		DTC_OPTIONS="-Wno-unit_address_vs_reg -Wno-graph_child_address -Wno-pwms_property"
		mkimage -D "-i${DEPLOY_DIR_IMAGE} -p 1000 ${DTC_OPTIONS}" -f ${AT91BOOTSTRAP_MACHINE}.its ${AT91BOOTSTRAP_MACHINE}.itb
	else
		echo "No its file to create FIT images"
	fi
}

FILES_${PN} = "/boot/*.*"

addtask install after do_compile

do_install () {
	# Copy files to /boot
	if [ -e ${AT91BOOTSTRAP_MACHINE}/${AT91BOOTSTRAP_MACHINE}*.dtbo ]; then
		install -d ${D}/boot
		install ${AT91BOOTSTRAP_MACHINE}/${AT91BOOTSTRAP_MACHINE}*.dtbo ${D}/boot
	fi;

	if [ -e ${AT91BOOTSTRAP_MACHINE}.itb ]; then
		install -d ${D}/boot
		fit_image_basename="fitImage-${MACHINE}"
		install ${AT91BOOTSTRAP_MACHINE}.itb ${D}/boot/${fit_image_basename}.itb
		install ${AT91BOOTSTRAP_MACHINE}.its ${D}/boot/${fit_image_basename}.its
	fi;
}

addtask deploy after do_install

do_deploy () {
	fit_image_basename="fitImage-${MACHINE}"
{'fraction_non_alphanumeric': 0.1559422944813373, 'fraction_numerical': 0.06823906572017403, 'mean_word_length': 5.835680751173709, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6031688', 'n_tokens_mistral': 2096, 'n_tokens_neox': 1934, 'n_words': 266}