Skip to content

Commit

Permalink
Improve compilation speed for android build
Browse files Browse the repository at this point in the history
Avoid hardcoding and reuse flash_cmd_generator.py to
get flashfiles content and generate installer.cmd &
flash.json

Tracked-On: OAM-112083
Signed-off-by: sgnanase <[email protected]>
  • Loading branch information
sgnanase authored and swaroopbalan committed Oct 25, 2023
1 parent 2b3c8db commit 227ff85
Showing 1 changed file with 57 additions and 20 deletions.
77 changes: 57 additions & 20 deletions releasetools/flashfiles_from_target_files.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,74 @@
#!/bin/bash

echo "========================"
echo "Preparing flashfiles - New Method"
echo "No more Zip. We use tar + pigz"

echo "========================"
echo "Images / Files to be packed"
echo "========================"
echo "acpio.img"
echo "boot.img"
echo "bootloader.img"
echo "config.img"
echo "flash.json"
echo "gpt.bin"
echo "installer.cmd"
echo "installer.efi "
echo "odm.img "
echo "startup.nsh "
echo "super_empty.img "
echo "super.img "
echo "vbmeta.img "
echo "vendor_boot.img "
echo "========================"


#tar
## PRE-REQUISITE
flashfile=`basename $1`
flashfile_dir=`echo $flashfile | sed 's/\.tar\.gz//g'`
PRODUCT_OUT=`dirname $1`
VARIANT=`grep -i "ro.system.build.type=" $PRODUCT_OUT/system/build.prop | cut -d '=' -f2`
TARGET=`grep -i "ro.build.product=" $PRODUCT_OUT/system/build.prop | cut -d '=' -f2`

echo "========================"
echo "Images / Files to be packed"
echo "========================"
IMAGES_TUPLE=`./device/intel/build/releasetools/flash_cmd_generator.py device/intel/project-celadon/$TARGET/flashfiles.ini $TARGET $VARIANT | tail -1`
c=-2
for i in $IMAGES_TUPLE
do
if [[ $c -gt 0 && `expr $c % 2` == 1 ]]; then
i=`echo ${i::-3} | sed "s/'//g"`
echo $i
j="$j $i"
fi
c=$((c+1))
done

IMAGES=`echo $j | xargs -n1 | sort -u`
echo "========================"
echo "Generating Tar ..."
echo "========================"
cd $PRODUCT_OUT
rm -rf $flashfile_dir
mkdir $flashfile_dir
cp acpio.img boot.img bootloader.img config.img gpt.bin installer.cmd efi/installer.efi odm.img efi/startup.nsh super_empty.img ./obj/PACKAGING/super.img_intermediates/super.img vbmeta.img vendor_boot.img $flashfile_dir/.

for i in $IMAGES
do
echo "Adding $i"
if [[ $i == "super.img" ]]; then
SUPER_IMG=true
cp ./obj/PACKAGING/super.img_intermediates/super.img $flashfile_dir/.
else
if [[ $i == "installer.efi" ]]; then
cp efi/installer.efi $flashfile_dir/.
else
if [[ $i == "startup.nsh" ]]; then
cp efi/startup.nsh $flashfile_dir/.
else
cp $i $flashfile_dir/.
fi
fi
fi
done

echo "========================"
echo "Generate installer.cmd"
echo "========================"
./device/intel/build/releasetools/flash_cmd_generator.py device/intel/project-celadon/$TARGET/flashfiles.ini $TARGET $VARIANT | sed '$d' | sed '$d' | sed -n '/installer.cmd/,$p' | sed '1d' > $flashfile_dir/installer.cmd

echo "========================"
echo "Generate flash.json"
echo "========================"
./device/intel/build/releasetools/flash_cmd_generator.py device/intel/project-celadon/$TARGET/flashfiles.ini $TARGET $VARIANT | sed -n '/installer.cmd/q;p' | sed '1d' > $flashfile_dir/flash.json

if [[ $SUPER_IMG == "true" ]]; then
rm -f $flashfile_dir/system.img $flashfile_dir/vendor.img $flashfile_dir/product.img
fi

tar -cvf - $flashfile_dir/ | /usr/bin/pigz > $flashfile

echo "========================"
Expand Down

0 comments on commit 227ff85

Please sign in to comment.