acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

gen_pack.sh (5533B)

      1 #!/bin/bash
      2 # Version: 1.1
      3 # Date: 2022-01-11
      4 # This bash script generates a CMSIS Software Pack:
      5 #
      6 # Pre-requisites:
      7 # - bash shell (for Windows: install git for Windows)
      8 # - 7z in path (zip archiving utility)
      9 #   e.g. Ubuntu: sudo apt-get install p7zip-full p7zip-rar)
     10 # - PackChk in path with execute permission
     11 #   (see CMSIS-Pack: CMSIS/Utilities/<os>/PackChk)
     12 # - xmllint in path (XML schema validation)
     13 #   e.g. Ubuntu: sudo apt-get install libxml2-utils
     14 #   Windows: download from https://www.zlatkovic.com/pub/libxml/
     15 
     16 ############### EDIT BELOW ###############
     17 # Extend Path environment variable locally
     18 #
     19 if [ `uname -s` = "Linux" ]
     20   then
     21   CMSIS_PACK_PATH="/home/$USER/.arm/Packs/ARM/CMSIS/5.7.0/"
     22   PATH_TO_ADD="$CMSIS_PACK_PATH/CMSIS/Utilities/Linux64/"
     23 else
     24   CMSIS_PACK_PATH="/C/Users/gabriel/AppData/Local/Arm/Packs/ARM/CMSIS/5.7.0"
     25   PATH_TO_ADD="/C/Program Files (x86)/7-Zip/:$CMSIS_PACK_PATH/CMSIS/Utilities/Win32/:/C/xmllint/"
     26 fi
     27 [[ ":$PATH:" != *":$PATH_TO_ADD}:"* ]] && PATH="${PATH}:${PATH_TO_ADD}"
     28 echo $PATH_TO_ADD appended to PATH
     29 echo " "
     30 
     31 # Pack warehouse directory - destination
     32 PACK_WAREHOUSE=./
     33 
     34 # Temporary pack build directory
     35 PACK_BUILD=build/
     36 
     37 # Specify directories included in pack relative to base directory
     38 # All directories:
     39 # PACK_DIRS=`ls -d */`
     40 # Do not include the build directory if it is local
     41 # PACK_DIRS=${PACK_DIRS//$PACK_BUILD/}
     42 # PACK_DIRS=${PACK_DIRS//$PACK_WAREHOUSE/}
     43 
     44 # alternative: specify directory names to be added to pack base directory
     45 PACK_DIRS="
     46   ../../src
     47   ../../docs
     48   ../../demos
     49 "
     50 
     51 
     52 # Specify file names to be added to pack base directory
     53 PACK_BASE_FILES="
     54   ../../LICENCE.txt
     55   ../../README.md
     56   ../../README_zh.md
     57   ../../lvgl.h
     58   lv_conf_cmsis.h
     59   lv_cmsis_pack.txt
     60 "
     61 
     62 ############ DO NOT EDIT BELOW ###########
     63 echo Starting CMSIS-Pack Generation: `date`
     64 # Zip utility check
     65 ZIP=7z
     66 type -a $ZIP
     67 errorlevel=$?
     68 if [ $errorlevel -gt 0 ]
     69   then
     70   echo "Error: No 7zip Utility found"
     71   echo "Action: Add 7zip to your path"
     72   echo " "
     73   exit
     74 fi
     75 
     76 # Pack checking utility check
     77 PACKCHK=PackChk
     78 type -a $PACKCHK
     79 errorlevel=$?
     80 if [ $errorlevel != 0 ]
     81   then
     82   echo "Error: No PackChk Utility found"
     83   echo "Action: Add PackChk to your path"
     84   echo "Hint: Included in CMSIS Pack:"
     85   echo "<pack_root_dir>/ARM/CMSIS/<version>/CMSIS/Utilities/<os>/"
     86   echo " "
     87   exit
     88 fi
     89 echo " "
     90 
     91 # XML syntax checking utility check
     92 XMLLINT=xmllint
     93 type -a $XMLLINT
     94 errorlevel=$?
     95 if [ $errorlevel != 0 ]
     96   then
     97   echo "Error: No xmllint found"
     98   echo "Action: Add xmllint to your path"
     99   echo " "
    100   exit
    101 fi
    102 echo " "
    103 
    104 # Locate Package Description file
    105 # check whether there is more than one pdsc file
    106 NUM_PDSCS=`ls -1 *.pdsc | wc -l`
    107 PACK_DESCRIPTION_FILE=`ls *.pdsc`
    108 if [ $NUM_PDSCS -lt 1 ]
    109   then
    110   echo "Error: No *.pdsc file found in current directory"
    111   echo " "
    112 elif [ $NUM_PDSCS -gt 1 ]
    113   then
    114   echo "Error: Only one PDSC file allowed in directory structure:"
    115   echo "Found:"
    116   echo "$PACK_DESCRIPTION_FILE"
    117   echo "Action: Delete unused pdsc files"
    118   echo " "
    119   exit
    120 fi
    121 
    122 SAVEIFS=$IFS
    123 IFS=.
    124 set $PACK_DESCRIPTION_FILE
    125 # Pack Vendor
    126 PACK_VENDOR=$1
    127 # Pack Name
    128 PACK_NAME=$2
    129 echo Generating Pack Version: for $PACK_VENDOR.$PACK_NAME
    130 echo " "
    131 IFS=$SAVEIFS
    132 
    133 #if $PACK_BUILD directory does not exist, create it.
    134 if [ ! -d $PACK_BUILD ]; then
    135   mkdir -p $PACK_BUILD
    136 fi
    137 
    138 mkdir -p ${PACK_BUILD}/examples
    139 mkdir -p ${PACK_BUILD}/examples/porting
    140 
    141 # Copy files into build base directory: $PACK_BUILD
    142 # pdsc file is mandatory in base directory:
    143 cp -f  ./$PACK_VENDOR.$PACK_NAME.pdsc ${PACK_BUILD}
    144 cp -f ../../examples/porting/* ${PACK_BUILD}/examples/porting
    145 
    146 
    147 # directories
    148 echo Adding directories to pack:
    149 echo $PACK_DIRS
    150 echo " "
    151 for d in ${PACK_DIRS}
    152 do
    153   cp -r "$d" ${PACK_BUILD}
    154 done
    155 
    156 # files for base directory
    157 echo Adding files to pack:
    158 echo $PACK_BASE_FILES
    159 echo " "
    160 for f in $PACK_BASE_FILES
    161 do
    162   cp -f  "$f" $PACK_BUILD/
    163 done
    164 
    165 mv "${PACK_BUILD}/lv_cmsis_pack.txt" "${PACK_BUILD}/lv_cmsis_pack.c"
    166 
    167 # Run Schema Check (for Linux only):
    168 # sudo apt-get install libxml2-utils
    169 
    170 echo Running schema check for $PACK_VENDOR.$PACK_NAME.pdsc
    171 $XMLLINT --noout --schema ${CMSIS_PACK_PATH}/CMSIS/Utilities/PACK.xsd $PACK_BUILD/$PACK_VENDOR.$PACK_NAME.pdsc
    172 errorlevel=$?
    173 if [ $errorlevel -ne 0 ]; then
    174   echo "build aborted: Schema check of $PACK_VENDOR.$PACK_NAME.pdsc against PACK.xsd failed"
    175   echo " "
    176   exit
    177 fi
    178 
    179 # Run Pack Check and generate PackName file with version
    180 $PACKCHK $PACK_BUILD/$PACK_VENDOR.$PACK_NAME.pdsc -n PackName.txt -x M362
    181 errorlevel=$?
    182 if [ $errorlevel -ne 0 ]; then
    183   echo "build aborted: pack check failed"
    184   echo " "
    185   exit
    186 fi
    187 
    188 PACKNAME=`cat PackName.txt`
    189 rm -rf PackName.txt
    190 
    191 echo remove unrequired files and folders...
    192 rm -rf $PACK_BUILD/demos/keypad_encoder
    193 rm -rf $PACK_BUILD/demos/music
    194 rm -rf $PACK_BUILD/demos/stress
    195 rm -rf $PACK_BUILD/demos/widgets/screenshot1.gif
    196 
    197 # echo apply patches...
    198 # rm -rf $PACK_BUILD/demos/lv_demos.h
    199 # cp -f ./lv_demos.h $PACK_BUILD/demos/
    200 
    201 # Archiving
    202 # $ZIP a $PACKNAME
    203 echo creating pack file $PACKNAME
    204 #if $PACK_WAREHOUSE directory does not exist create it
    205 if [ ! -d $PACK_WAREHOUSE ]; then
    206   mkdir -p $PACK_WAREHOUSE
    207 fi
    208 pushd $PACK_WAREHOUSE
    209 PACK_WAREHOUSE=`pwd`
    210 popd
    211 pushd $PACK_BUILD
    212 "$ZIP" a $PACK_WAREHOUSE/$PACKNAME -tzip
    213 popd
    214 errorlevel=$?
    215 if [ $errorlevel -ne 0 ]; then
    216   echo "build aborted: archiving failed"
    217   exit
    218 fi
    219 
    220 # cp -f ./$PACK_VENDOR.$PACK_NAME.pdsc ${PACK_WAREHOUSE}
    221 
    222 
    223 echo "build of pack succeeded"
    224 # Clean up
    225 echo "cleaning up ..."
    226 
    227 rm -rf $PACK_BUILD
    228 
    229 echo " "
    230 
    231 echo Completed CMSIS-Pack Generation: `date`