summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGubolin <gubolin@fantasymail.de>2014-09-07 18:22:33 +0200
committerGubolin <gubolin@fantasymail.de>2014-09-07 18:22:33 +0200
commit6f09aff97549fb9d2a3687781edf5d31dd766195 (patch)
tree7149e3ba69c2c00401e86417edd20d8e956e3d01
parent468fb94a5fb17218da16033e27e86c1219c2b3ec (diff)
downloadsnap-6f09aff97549fb9d2a3687781edf5d31dd766195.tar.gz
snap-6f09aff97549fb9d2a3687781edf5d31dd766195.zip
rewrite scripts
-rwxr-xr-xbinary.sh62
-rwxr-xr-xdesktop.sh21
-rwxr-xr-xmobile.sh33
-rwxr-xr-xsnap.html6
4 files changed, 103 insertions, 19 deletions
diff --git a/binary.sh b/binary.sh
index fbeeeae..b7c02ef 100755
--- a/binary.sh
+++ b/binary.sh
@@ -1,21 +1,71 @@
#!/bin/bash
+if [[ $# < 2 ]]
+then
+ echo "Usage: binary.sh OPTION PLATFORM [FILE]"
+ echo ""
+ echo "OPTIONS:"
+ echo " -m Mobile"
+ echo " -d Desktop"
+ echo ""
+ echo "PLATFORMS:"
+ echo " Mobile amazon-fireos android blackberry10 firefoxos ios ubuntu wp8 win8 tizen"
+ echo " Desktop win osx linux32 linux64"
+ echo ""
+ echo "If FILE is given, it will be #open-ed inside Snap\! immediately"
+ exit 0
+fi
+
# Requirements:
# git
# UglifyJS2 (https://github.com/mishoo/UglifyJS2)
-git clone https://github.com/Gubolin/snap.git
+ide=true
+platform=$2
+
+if [[ "$3" != "" ]]
+then
+ ide=false
+fi
+
+if [ $ide == false ]
+then
+ if [ -f "$3" ]
+ then
+ content=$(cat "$3")
+ else
+ ide=true
+ fi
+fi
+
+git clone "https://github.com/Gubolin/snap.git"
cd "snap"
git checkout mobileapp
rm -rf .git/
-rm lang* ypr.js paint.js cloud.js gui.js
-find . -name '*.js' | xargs -I {} uglifyjs {} -o {} -c
+if [ $ide == false ]
+then
+ 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
+ sed -i '/paint\.js"/d' snap.html
+ sed -i '/cloud\.js"/d' snap.html
+ sed -i 's/gui\.js"/binary\.js"/' snap.html
+
+ sed -i "/ide\.openIn/a\
+ ide.droppedText(\'$content\'); " snap.html
+fi
+
+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
find . -type d -empty -print0 | xargs -0 rm -r
+
+cd ..
+
+if [[ $1 == "-m" ]]
+then
+ ./mobile.sh "$2" "snap"
+else
+ ./desktop.sh "$2" "snap"
+fi
diff --git a/desktop.sh b/desktop.sh
index 46a7594..a572b4f 100755
--- a/desktop.sh
+++ b/desktop.sh
@@ -1,12 +1,25 @@
#!/bin/bash
+if [[ $1 = "" ]]
+then
+ echo "Usage: desktop.sh PLATFORM [BUILDSOURCE]"
+ exit 0
+fi
+
# 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!
-git clone https://github.com/Gubolin/snap.git
-cd "snap"
-git checkout mobileapp
-nwbuild -p win,osx,linux32,linux64 .
+if [[ $2 == "" ]]
+then
+ git clone https://github.com/Gubolin/snap.git www
+ cd www/
+ git checkout mobileapp
+else
+ cp -R "$2" www
+ cd www/
+fi
+
+nwbuild -p "$1" .
diff --git a/mobile.sh b/mobile.sh
index 656b7dc..789925a 100755
--- a/mobile.sh
+++ b/mobile.sh
@@ -1,21 +1,44 @@
#!/bin/bash
+if [[ $1 = "" ]]
+then
+ echo "Usage: mobile.sh PLATFORM [BUILDSOURCE]"
+ exit 0
+fi
+
# 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")
+fi
+
cordova create Snap-Mobile edu.berkeley.snap "Snap\!"
cd Snap-Mobile
rm -rf www config.xml
-git clone https://github.com/Gubolin/snap.git www
-cd www
-git checkout mobileapp
-cordova platform add android
+
+if [[ $2 == "" ]]
+then
+ git clone https://github.com/Gubolin/snap.git www
+ cd www/
+ git checkout mobileapp
+else
+ cp -R "$copyfrom/" .
+ mv "$copyfrom" www
+ cd www
+fi
+
+sed -i '/link rel="shortcut icon"/a\
+ <script type="text/javascript" src="cordova.js"></script>' snap.html
+
+cordova platform add "$1"
cordova plugin add org.apache.cordova.plugin.softkeyboard
cordova plugin add org.apache.cordova.vibration
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 android
+cordova build "$1"
diff --git a/snap.html b/snap.html
index 8e8e919..d197b08 100755
--- a/snap.html
+++ b/snap.html
@@ -19,15 +19,13 @@
<script type="text/javascript" src="cloud.js"></script>
<script type="text/javascript" src="sha512.js"></script>
- <!-- packaged mobile app library -->
- <script type="text/javascript" src="cordova.js"></script>
-
<script type="text/javascript">
var world;
window.onload = function () {
world = new WorldMorph(document.getElementById('world'));
world.worldCanvas.focus();
- new IDE_Morph().openIn(world);
+ var ide = new IDE_Morph()
+ ide.openIn(world);
setInterval(loop, 1);
};
function loop() {