diff options
| author | Gubolin <gubolin@fantasymail.de> | 2014-09-08 11:34:23 +0200 |
|---|---|---|
| committer | Gubolin <gubolin@fantasymail.de> | 2014-09-08 11:34:23 +0200 |
| commit | 8c4dbc73a29ad4f2b22ee9bc1129b19d9742a5f7 (patch) | |
| tree | 740c8bea00343904fade43592137928c1c600b25 | |
| parent | 6f09aff97549fb9d2a3687781edf5d31dd766195 (diff) | |
| download | snap-8c4dbc73a29ad4f2b22ee9bc1129b19d9742a5f7.tar.gz snap-8c4dbc73a29ad4f2b22ee9bc1129b19d9742a5f7.zip | |
rewrite scripts
| -rwxr-xr-x | binary.sh | 34 | ||||
| -rwxr-xr-x | desktop.sh | 17 | ||||
| -rwxr-xr-x | mobile.sh | 24 |
3 files changed, 55 insertions, 20 deletions
@@ -16,6 +16,8 @@ then exit 0 fi +scriptdir=$(readlink -e ".") + # Requirements: # git # UglifyJS2 (https://github.com/mishoo/UglifyJS2) @@ -23,6 +25,7 @@ fi ide=true platform=$2 +# presentation mode if [[ "$3" != "" ]] then ide=false @@ -32,40 +35,55 @@ if [ $ide == false ] then if [ -f "$3" ] then - content=$(cat "$3") + content=$(cat $3) else ide=true fi fi -git clone "https://github.com/Gubolin/snap.git" -cd "snap" +buildsource=$(mktemp -d) +git clone "https://github.com/Gubolin/snap.git" $buildsource +cd "$buildsource" git checkout mobileapp rm -rf .git/ if [ $ide == false ] then + # minimize everything rm lang* ypr.js paint.js cloud.js gui.js sed -i '/paint\.js"/d' snap.html sed -i '/cloud\.js"/d' snap.html sed -i 's/gui\.js"/binary\.js"/' snap.html + # load custom project from file + sed -i '/sha512\.js"/a\ + <script type="text/javascript" src="code.js"></script> ' snap.html + + echo "var code =" > code.js + echo "'$content'" >> code.js + echo ";" >> code.js + sed -i "/ide\.openIn/a\ - ide.droppedText(\'$content\'); " snap.html + ide.droppedText(code); " snap.html fi +# compress all js files find . -name '*.js' | xargs -I {} uglifyjs {} -o {} -c -find . \( \! -name '*.js' \! -name 'snap.html' \! -name 'mobile.sh' \! -name 'desktop.sh' \! -name 'snap_logo_sm.png' \! -name 'config.xml' \! -name 'package.json' -type f \) -print0 | xargs -0 rm +# delete everything that is not html/js/logo/config +find . \( \! -name '*.js' \! -name 'snap.html' \! -name 'snap_logo_sm.png' \! -name 'config.xml' \! -name 'package.json' -type f \) -print0 | xargs -0 rm find . -type d -empty -print0 | xargs -0 rm -r -cd .. +# return to the directory where the script was called from +cd "$scriptdir" + +# run helper scripts for building if [[ $1 == "-m" ]] then - ./mobile.sh "$2" "snap" + ./mobile.sh "$2" "$buildsource" else - ./desktop.sh "$2" "snap" + ./desktop.sh "$2" "$buildsource" fi @@ -6,20 +6,27 @@ then exit 0 fi +scriptdir=$(readlink -e ".") + # Requirements: # git, zip, nodejs # node-webkit (https://github.com/rogerwang/node-webkit), node-webkit-builder (https://github.com/mllrsohn/node-webkit-builder) -# binaries are in snap/build/Snap! +builddir=$(mktemp -d) if [[ $2 == "" ]] then - git clone https://github.com/Gubolin/snap.git www - cd www/ + git clone https://github.com/Gubolin/snap.git $builddir + cd $builddir/ git checkout mobileapp else - cp -R "$2" www - cd www/ + mv "$2" $builddir + cd $builddir/ fi +# remove mobile config +rm config.xml + nwbuild -p "$1" . + +mv build/* $scriptdir/ @@ -6,19 +6,21 @@ then exit 0 fi +scriptdir=$(readlink -e ".") + # Requirements: # git, nodejs, android SDK / other platform(s) # cordova (https://cordova.apache.org/) -# binaries are in platform/android/ant-build/Snap-debug.apk - if [[ $2 != "" ]] then - copyfrom=$(readlink -e "$2") + buildsource=$(readlink -e "$2") fi -cordova create Snap-Mobile edu.berkeley.snap "Snap\!" -cd Snap-Mobile +builddir=$(mktemp -d) + +cordova create $builddir edu.berkeley.snap "Snap\!" +cd $builddir rm -rf www config.xml if [[ $2 == "" ]] @@ -27,14 +29,18 @@ then cd www/ git checkout mobileapp else - cp -R "$copyfrom/" . - mv "$copyfrom" www + mv "$buildsource" www cd www fi +# remove configs for desktop, it is not needed +rm package.json + +# add mobile-specific library; it's made available at runtime sed -i '/link rel="shortcut icon"/a\ <script type="text/javascript" src="cordova.js"></script>' snap.html +# add everything needed and build for $device cordova platform add "$1" cordova plugin add org.apache.cordova.plugin.softkeyboard cordova plugin add org.apache.cordova.vibration @@ -42,3 +48,7 @@ cordova plugin add org.apache.cordova.device-motion cordova plugin add org.apache.cordova.device-orientation cordova plugin add org.apache.cordova.geolocation cordova build "$1" + +cd $builddir +# TODO other platforms +find -name '*.apk' | xargs -I {} mv {} $scriptdir |
