-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbinary.sh
More file actions
executable file
·93 lines (80 loc) · 2.58 KB
/
binary.sh
File metadata and controls
executable file
·93 lines (80 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/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 "If URL starts with a hash ('#'), it will be used as initial base url suffix"
echo " (for example '#present:UserName=foo\&ProjectName=bar', escape the '&')."
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
if [[ $url == \#* ]]
then
# load custom project from cloud or string
sed -i "s/snap.html/snap.html${url}/g" config.xml package.json
else
# load custom project from url
sed -i "/ide\.openIn/a\
setTimeout(function () {\
ide.droppedText(ide.getURL('$url'));\
}, 2000);" snap.html
sed -i "/this.toggleAppMode(false)/d" gui.js
sed -i "s/snap.html/snap.html#run:/g" config.xml package.json
fi
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