|  | 
| 21 | 21 | 
 | 
| 22 | 22 | source venv/bin/activate | 
| 23 | 23 | 
 | 
| 24 |  | -rm -rf build | 
|  | 24 | +ZEPHYR_BASE=$(west topdir)/zephyr | 
|  | 25 | + | 
|  | 26 | +# Get the variant name (NORMALIZED_BOARD_TARGET in Zephyr) | 
|  | 27 | +tmpdir=$(mktemp -d) | 
|  | 28 | +variant=$(cmake -DBOARD=$board -S loader -DMODULES=boards -B${tmpdir} -P ${ZEPHYR_BASE}/cmake/package_helper.cmake -R $(pwd)/extra/get_variant_name.cmake | grep 'VARIANT=' | cut -d '=' -f 2) | 
|  | 29 | +rm -rf ${tmpdir} | 
|  | 30 | + | 
|  | 31 | +if [ -z "${variant}" ] ; then | 
|  | 32 | +	echo "Failed to get variant name from '$board'" | 
|  | 33 | +	exit 1 | 
|  | 34 | +fi | 
| 25 | 35 | 
 | 
| 26 | 36 | echo && echo && echo | 
|  | 37 | +echo ${variant} | 
|  | 38 | +echo ${variant} | sed -e 's/./=/g' | 
|  | 39 | +echo | 
| 27 | 40 | 
 | 
| 28 |  | -west build loader -b $board -t llext-edk $* | 
| 29 |  | -tar xfp build/zephyr/llext-edk.tar.Z | 
| 30 |  | -variant=$(cat llext-edk/Makefile.cflags | grep BOARD_TARGET | cut -d'=' -f2 | tr -d '" ') | 
|  | 41 | +# Build the loader | 
|  | 42 | +BUILD_DIR=build/${variant} | 
|  | 43 | +VARIANT_DIR=variants/${variant} | 
|  | 44 | +rm -rf ${BUILD_DIR} | 
|  | 45 | +west build -d ${BUILD_DIR} -b ${board} loader -t llext-edk $* | 
|  | 46 | + | 
|  | 47 | +# Extract the generated EDK tarball and copy it to the variant directory | 
|  | 48 | +mkdir -p ${VARIANT_DIR} firmwares | 
|  | 49 | +(set -e ; cd ${BUILD_DIR} && rm -rf llext-edk && tar xf zephyr/llext-edk.tar.Z) | 
|  | 50 | +rsync -a --delete ${BUILD_DIR}/llext-edk ${VARIANT_DIR}/ | 
| 31 | 51 | 
 | 
| 32 | 52 | # remove all inline comments in macro definitions | 
| 33 | 53 | # (especially from devicetree_generated.h and sys/util_internal.h) | 
| 34 | 54 | line_preproc_ok='^\s*#\s*(if|else|elif|endif)' # match conditional preproc lines | 
| 35 | 55 | line_comment_only='^\s*\/\*' # match lines starting with comment | 
| 36 | 56 | line_continuation='\\$' # match lines ending with '\' | 
| 37 | 57 | c_comment='\s*\/\*.*?\*\/' # match C-style comments and any preceding space | 
| 38 |  | -perl -i -pe "s/${c_comment}//gs unless /${line_preproc_ok}/ || (/${line_comment_only}/ && !/${line_continuation}/)" $(find llext-edk/include/ -type f) | 
| 39 |  | - | 
| 40 |  | -mkdir -p firmwares variants/$variant | 
| 41 |  | -rm -rf variants/$variant/llext-edk | 
| 42 |  | -mv llext-edk variants/$variant/ | 
|  | 58 | +perl -i -pe "s/${c_comment}//gs unless /${line_preproc_ok}/ || (/${line_comment_only}/ && !/${line_continuation}/)" $(find ${VARIANT_DIR}/llext-edk/include/ -type f) | 
| 43 | 59 | for ext in elf bin hex; do | 
| 44 |  | -    rm -f build/zephyr/zephyr-$variant.$ext | 
| 45 |  | -    if [ -f build/zephyr/zephyr.$ext ]; then | 
| 46 |  | -        cp build/zephyr/zephyr.$ext firmwares/zephyr-$variant.$ext | 
|  | 60 | +    rm -f firmwares/zephyr-$variant.$ext | 
|  | 61 | +    if [ -f ${BUILD_DIR}/zephyr/zephyr.$ext ]; then | 
|  | 62 | +        cp ${BUILD_DIR}/zephyr/zephyr.$ext firmwares/zephyr-$variant.$ext | 
| 47 | 63 |     fi | 
| 48 | 64 | done | 
| 49 | 65 | 
 | 
|  | 
0 commit comments