-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·65 lines (51 loc) · 1.93 KB
/
build.sh
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
#!/bin/bash
ROOTDIR=$(cd $(dirname $0) && pwd)
SRCDIR="$ROOTDIR/src"
TOOLSDIR="$SRCDIR/lib/util/buildscripts"
RESOURCES=(src/manual_style.css src/help_ja.html src/help_en.html src/about_en.html src/about_ja.html src/public_imgs)
ABOUT_FILES=($SRCDIR/about_en.html $SRCDIR/about_ja.html)
PACKAGE_FILE="$SRCDIR/app/package.json"
CMD="./build.sh --profile $SRCDIR/app/picopico_sequencer.profile.js --require $SRCDIR/app/run.js --dojoConfig $SRCDIR/app/config_build.js $EXTRA_FLAGS"
if [ ! -d "$TOOLSDIR" ]; then
echo "Can't find Dojo build tools -- did you initialize submodules?(git submodule update --init --recursive)"
exit 1
fi
if [ $# -gt 1 -a "$1" = "--no-build" ]; then
EXTRA_FLAGS="--check-args"
cd $TOOLSDIR
$CMD $EXTRA_FLAGS
exit 0
fi
if [ $# -gt 1 -a "$1" = "--rewrite-version" ]; then
if [ $# -lt 2 ]; then
echo "No new version number found. Please enter some version-ish number!"
exit 1
fi
for file in ${ABOUT_FILES[@]} ; do
sed -e "s/version:[.0-9]\+$/version:$2/" $file > $SRCDIR/tmp.html
diff $SRCDIR/tmp.html $file
rm -i $file
mv $SRCDIR/tmp.html $file
done
sed -e "s/\"version\" : \"[.0-9]\+\"/\"version\" : \"$2\"/" $PACKAGE_FILE > $SRCDIR/app/tmp.json
diff $SRCDIR/app/tmp.json $PACKAGE_FILE
rm -i $PACKAGE_FILE
mv $SRCDIR/app/tmp.json $PACKAGE_FILE
exit 0
fi
echo "Cleaning old built files..."
rm -rf release
cd $TOOLSDIR
$CMD
echo "Copying html and css files..."
cd $ROOTDIR
cat src/index.html | tr '\n' ' ' | \
perl -pe "
s/<\!--.*?-->//g; #Strip comments
s/<script src=\"app\/config.js\"><\/script>/<script>dojoConfig = {async:true,baseUrl:'',tlmSiblingOfDojo:false,parseOnLoad:false,packages:[\"dojo\",\"dijit\",\"dojox\",\"treehugger\",\"app\",\"piano_roll\"]};<\/script>/g;
s/\"lib\/dojo\/dojo.js\"/\"dojo\/dojo.js\"/;
s/\s+/ /; #Collapse white-spaces" > "release/index.html"
for path in ${RESOURCES[@]} ; do
cp -R $path release
done
echo "Build completed!"