|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# helper script for automatic releases. |
| 4 | +# |
| 5 | +# Prints one platform entry for the given file to be added to the |
| 6 | +# package_*.json file. |
| 7 | + |
| 8 | + |
| 9 | +if [ $# -ne 4 ]; then |
| 10 | + echo |
| 11 | + echo "helper script for automatic releases." |
| 12 | + echo |
| 13 | + echo "Prints one platform entry for the given file to be added to the" |
| 14 | + echo "package_*_index.json file." |
| 15 | + echo |
| 16 | + echo "usage: $0 corefile coreversion sdccversion toolsversion" |
| 17 | + exit 1 |
| 18 | +fi |
| 19 | + |
| 20 | +COREFILE=$1 |
| 21 | +COREVERSION=$2 |
| 22 | +SDCCVERSION=$3 |
| 23 | +TOOLSVERSION=$4 |
| 24 | +PACKAGER=CH55xDuino |
| 25 | + |
| 26 | +BASEURL=https://github.com/DeqingSun/ch55xduino/releases/download/${COREVERSION} |
| 27 | + |
| 28 | +### helper functions ##################################################### |
| 29 | + |
| 30 | +# format ID information for a file |
| 31 | +print_filedata() |
| 32 | +{ |
| 33 | + FILENAME=$(basename "$1") |
| 34 | + URL=${BASEURL}/${FILENAME} |
| 35 | + SIZE=$(stat -f%z $1) |
| 36 | + CHKSUM=$(shasum -a 256 $1|cut "-d " -f1) |
| 37 | +cat << EOF |
| 38 | + "url": "$URL", |
| 39 | + "archiveFileName": "$FILENAME", |
| 40 | + "checksum": "SHA-256:$CHKSUM", |
| 41 | + "size": "$SIZE" |
| 42 | +EOF |
| 43 | +} |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | +# list of supported boards in current boards.txt |
| 48 | +list_boards() |
| 49 | +{ |
| 50 | + echo -n " \"boards\": [" |
| 51 | + n=0 |
| 52 | + sed -n "s/.*\.name=//p" ../ch55x/boards.txt |\ |
| 53 | + while read line; do |
| 54 | + if [ $n -ne 0 ]; then echo -n ","; fi |
| 55 | + echo |
| 56 | + echo -n " {\"name\": \"$line\"}" |
| 57 | + n=$((n+1)) |
| 58 | + done |
| 59 | + echo |
| 60 | + echo " ]," |
| 61 | +} |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | +### print a platform entry for the given file ############################ |
| 66 | + |
| 67 | +cat << EOF |
| 68 | +{ |
| 69 | + "name": "CH55xDuino MCS51 plain C core (non-C++)", |
| 70 | + "architecture": "mcs51", |
| 71 | + "version": "$COREVERSION", |
| 72 | + "category": "Contributed", |
| 73 | +EOF |
| 74 | +list_boards |
| 75 | +cat << EOF |
| 76 | + "toolsDependencies": [ |
| 77 | + { |
| 78 | + "name": "MCS51Tools", |
| 79 | + "version": "$TOOLSVERSION", |
| 80 | + "packager": "$PACKAGER" |
| 81 | + }, |
| 82 | + { |
| 83 | + "name": "sdcc", |
| 84 | + "version": "build.$SDCCVERSION", |
| 85 | + "packager": "$PACKAGER" |
| 86 | + } |
| 87 | + ], |
| 88 | +EOF |
| 89 | +print_filedata "$COREFILE" |
| 90 | +echo "}," |
0 commit comments