summaryrefslogtreecommitdiff
path: root/binary.sh
diff options
context:
space:
mode:
authorCode WvS <code-wvs@quantentunnel.de>2015-03-04 17:25:47 +0100
committerCode WvS <code-wvs@quantentunnel.de>2015-03-04 17:25:47 +0100
commitc82cf0fa106ef9ea589962f59c784cda7a7a17f8 (patch)
treeddf8283dffca49e25f81dcc53aed1c67a37d605e /binary.sh
parentf7dcf37f972c1b7ed6d63e350b3bc5ba118b0fd4 (diff)
downloadsnap-yow-c82cf0fa106ef9ea589962f59c784cda7a7a17f8.tar.gz
snap-yow-c82cf0fa106ef9ea589962f59c784cda7a7a17f8.zip
add mobile version
Diffstat (limited to 'binary.sh')
-rwxr-xr-xbinary.sh83
1 files changed, 83 insertions, 0 deletions
diff --git a/binary.sh b/binary.sh
new file mode 100755
index 0000000..1d23507
--- /dev/null
+++ b/binary.sh
@@ -0,0 +1,83 @@
+#!/bin/bash
+
+if [[ "$snapsource" == "" ]]
+then
+ export snapsource="https://github.com/Gubolin/snap.git"
+fi
+
+if [[ $# < 2 ]]
+then
+ echo "Usage: binary.sh OPTION PLATFORM [FILE/URL]"
+ 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 win32 win64 osx linux32 linux64"
+ echo ""
+ echo "If FILE/URL is given, it will be #open-ed inside Snap! immediately. URL will be loaded at runtime."
+ echo ""
+ echo ""
+ echo "The following environment variables will be used, if available:"
+ echo " snapsource Path or URL to the Snap! git repository. This repository must contain the branch"
+ echo " mobileapp with the configuration files! Default: https://github.com/Gubolin/snap.git"
+ echo " crosswalk Path to a crosswalk-cordova directory. Download \"Cordova Android\" here:"
+ echo " https://crosswalk-project.org/documentation/downloads.html"
+ echo " If omitted, standard cordova will be used."
+ exit 0
+fi
+
+scriptdir=$(readlink -e ".")
+
+# Requirements:
+# git
+# UglifyJS2 (https://github.com/mishoo/UglifyJS2)
+
+ide=true
+platform=$2
+
+# presentation mode
+if [[ "$3" != "" ]]
+then
+ ide=false
+fi
+
+buildsource=$(mktemp -d)
+git clone $snapsource $buildsource
+cd "$buildsource"
+
+if [ $ide == false ]
+then
+ # if a file was given, move it to "project.xml"
+ # it will be loaded like an URL then
+ if [ -f "$3" ]
+ then
+ cp "$3" "project.xml"
+ url="project.xml"
+ else
+ url=$3
+ fi
+
+ # load custom project from url
+ sed -i "/ide\.openIn/a\
+ ide.droppedText(ide.getURL('$url'));" snap.html
+ # ... in presentation mode
+ sed -i "s/this.isAppMode = false/this.isAppMode = true/g" gui.js
+fi
+
+# compress all js files
+find . -name '*.js' | xargs -I {} uglifyjs {} -o {} -c 2> /dev/null
+
+# return to the directory where the script was called from
+cd "$scriptdir"
+
+# run helper scripts for building
+
+if [[ $1 == "-m" ]]
+then
+ ./mobile.sh "$2" "$buildsource"
+else
+ ./desktop.sh "$2" "$buildsource"
+fi