Newer
Older
SUMMARY = "Install MAPT files for each variants"
SECTION = "opt"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
# Adding MAPT files to SRC_URI and FILES for each variant
python () {
import os, glob
from pathlib import Path
src_dir = d.getVar('PL_VARIANTS_DIR')
dest_path = os.path.join('/opt', 'fofb', 'map')
for var_name in d.getVar('PL_VARIANTS').split():
mapt_path = next(Path(src_dir).rglob(f"{var_name}*ch8.mapt")).absolute()
dest_file = os.path.join(dest_path, f"app_{var_name}.mapt")
d.appendVar("SRC_URI", f" file://{mapt_path}")
d.appendVar("PL_MAPT_PATH", f" {mapt_path}")
d.appendVar("FILES_"+d.getVar("PN"), " "+dest_file)
}
# Changing BAR of mapt files to 0 (field #5 receive 0)
# Replace each line of MATRIX coeff by a global entry
do_compile () {
for MAPT in ${PL_MAPT_PATH}
do
awk 'FNR>1 {$5=0} {if ($1 ~ /MATRIXCOEF\.[^0]/ ) next} {if ($1 ~ /MATRIXCOEF\.0/) {$1="APP.corr_matrix_0.MATRIXCOEF" ; $2="12800" ; $4="51200"}} {print}' ${WORKDIR}/${MAPT} > ${WORKDIR}/${MAPT}.bar0
done
}
# Adding MAPT files to install dir
python do_install () {
import shutil, os
dest_path = os.path.join(d.getVar('D'), 'opt', 'fofb', 'map')
os.makedirs(dest_path, exist_ok=True)
for var_name, mapt_path in zip(
d.getVar('PL_VARIANTS').split(),
d.getVar('PL_MAPT_PATH').split(),
):
orig_file = d.getVar("WORKDIR")+mapt_path+".bar0"
dest_file = os.path.join(dest_path, f"app_{var_name}.mapt")
print(f"Install {orig_file} in {dest_file}")
shutil.copy(orig_file, dest_file)
}