Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/ext/wasm/mkdist.sh # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / ext / wasm / mkdist.sh` 210 lines ยท 3960 bytes Raw Blame History 1 #!/usr/bin/env bash 2 ### 3 # 4 # Builds the SQLite JS/WASM distribution zip file. 5 # 6 # Usage: $0 build-name ?flags? 7 # 8 # build-name is the dir/archive name prefix for the 9 # build and defaults to sqlite-wasm. 10 # 11 # -?|--help = Show this text 12 # 13 # -0 = Use -O0 instead of ${optFlag} 14 # 15 # -1 = Use make -j1 instead of ${makeFlag} 16 # 17 # -64 = Include 64-bit builds 18 # 19 # --noclean = do not run 'make clean' first 20 # 21 # --snapshot = gives the archive name a distinctive suffix 22 # 23 ### 24 25 function die(){ 26 local rc=$1 27 shift 28 echo "Error: $@" 1>&2 29 exit $rc 30 } 31 32 dirTop=../.. 33 buildName= 34 b64=0 35 optFlag=-Oz 36 clean=1 37 makeFlag=-j4 38 snapshotSuffix= 39 for arg in $@; do 40 case $arg in 41 42 -64) b64=1 43 ;; 44 45 -0) optFlag=-O0 46 ;; 47 48 -1) makeFlag= 49 ;; 50 51 --noclean) clean=0 52 ;; 53 54 --snapshot) 55 snapshotSuffix=-snapshot-$(date +%Y%m%d) 56 ;; 57 58 -?|--help) 59 sed -n -e '2,/^###/p' $0 60 exit 61 ;; 62 63 *) if [[ x != x${buildName} ]]; then 64 die 1 "Unhandled argument: $arg" 65 fi 66 buildName=$arg 67 ;; 68 esac 69 done 70 71 make= 72 for i in gmake make; do 73 make=$(which $i 2>/dev/null) 74 [[ x != x${make} ]] && break 75 done 76 [[ x = x$make ]] && die 127 "Cannot find make" 77 78 79 [[ x = x${buildName} ]] && buildName=sqlite-wasm 80 81 buildName=${buildName}${snapshotSuffix} 82 83 echo "Creating the SQLite wasm dist bundle..." 84 85 # 86 # Generates files which, when built, will also build all of the pieces 87 # neaded for the dist bundle. 88 # 89 tgtFiles=( 90 demo-worker1-promiser.html 91 demo-worker1-promiser.js 92 demo-worker1-promiser-esm.html 93 demo-worker1-promiser.mjs 94 95 tester1.html 96 tester1-esm.html 97 tester1-worker.html 98 tester1.js 99 tester1.mjs 100 ) 101 102 if [[ 1 = $b64 ]]; then 103 tgtFiles+=( 104 tester1-64bit.html 105 tester1-esm-64bit.html 106 tester1-worker-64bit.html 107 tester1-64bit.js 108 tester1-64bit.mjs 109 ) 110 fi 111 112 [[ 1 = $clean ]] && $make clean 113 $make $makeFlag \ 114 t-version-info t-stripccomments \ 115 ${tgtFiles[@]} \ 116 "emcc_opt=${optFlag}" || die $? 117 118 dirTmp=d.dist 119 rm -fr $dirTmp 120 mkdir -p $dirTmp/jswasm || die $? 121 mkdir -p $dirTmp/common || die $? 122 123 # Static files for the top-most dir: 124 fTop=( 125 demo-123.html 126 demo-123-worker.html 127 demo-123.js 128 129 demo-worker1.html 130 demo-worker1.js 131 132 demo-jsstorage.html 133 demo-jsstorage.js 134 135 module-symbols.html 136 ) 137 138 # Files for the jswasm subdir sans jswasm prefix: 139 # 140 # fJ1 = JS files to stripccomments -k on 141 # fJ2 = JS files to stripccomments -k -k on 142 fJ1=( 143 sqlite3-opfs-async-proxy.js 144 sqlite3-worker1.js 145 sqlite3-worker1.mjs 146 sqlite3-worker1-bundler-friendly.mjs 147 sqlite3-worker1-promiser.js 148 sqlite3-worker1-promiser.mjs 149 sqlite3-worker1-promiser-bundler-friendly.mjs 150 ) 151 fJ2=( 152 sqlite3.js 153 sqlite3.mjs 154 ) 155 156 # fW = list of wasm files to copy from jswasm/. 157 fW=(sqlite3.wasm) 158 if [[ 1 = $b64 ]]; then 159 fW+=(sqlite3-64bit.wasm) 160 fi 161 162 function fcp() { 163 cp -p $@ || die $? 164 chmod +w ${@: -1} 165 } 166 167 function scc(){ 168 ${dirTop}/tool/stripccomments $@ || die $? 169 } 170 171 jw=jswasm 172 fcp ${tgtFiles[@]} $dirTmp/. 173 fcp README-dist.txt $dirTmp/README.txt 174 fcp index-dist.html $dirTmp/index.html 175 fcp common/*.css common/SqliteTestUtil.js $dirTmp/common/. 176 177 for i in ${fTop[@]}; do 178 fcp $i $dirTmp/. 179 done 180 181 for i in ${fW[@]}; do 182 fcp $jw/$i $dirTmp/$jw/. 183 done 184 185 for i in ${fJ1[@]}; do 186 scc -k < $jw/$i > $dirTmp/$jw/$i || die $? 187 done 188 189 for i in ${fJ2[@]}; do 190 scc -k -k < $jw/$i > $dirTmp/$jw/$i || die $? 191 done 192 193 # 194 # Done copying files. Now zip it up... 195 # 196 svi=./version-info 197 vnum=$($svi --download-version) 198 [ "" = "$vnum" ] && die "version number is empty!" 199 vdir=${buildName}-${vnum} 200 fzip=${vdir}.zip 201 rm -fr ${vdir} ${fzip} 202 mv $dirTmp $vdir || die $? 203 zip -rq9 $fzip $(find $vdir -type f | sort) || die $? 204 ls -la $fzip 205 unzip -lv $fzip || die $? 206 cat <