This repository has been archived by the owner on Nov 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 116
/
version.compile.sh
executable file
·124 lines (106 loc) · 3.28 KB
/
version.compile.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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
source ./version.compile.variables.sh
./version.compile.pack.sh
CAAT_DST="/tmp/caat"
echo "\n\nCompilation process\n\n"
#
# define CAAT products files.
#
DST_FILE_NAME="${CAAT_DST}";
FILE_CAAT="${DST_FILE_NAME}-min.js"
FILE_CAAT_CSS="${DST_FILE_NAME}-css-min.js"
FILE_CAAT_BOX2D="${DST_FILE_NAME}-box2d-min.js"
#
# DST_FILE is a file name.
# This script will produce different target files as follow:
# + DST_FILE.js
# + DST_FILE-css.js
# + DST_FILE-box2d.js
#
echo "" > "${FILE_CAAT}"
echo "" > "${FILE_CAAT_CSS}"
echo "" > "${FILE_CAAT_BOX2D}"
SOURCE_DIR=${CAAT_SOURCE_DIR}
#
# set compilation level
#
COMPILATION_LEVEL=$1
if [ "${COMPILATION_LEVEL}" ]; then
if [[ "${COMPILATION_LEVEL}" == "simple" ]]; then
echo "Compilation level set to simple"
COMPILATION_LEVEL="SIMPLE_OPTIMIZATIONS"
elif [[ "${COMPILATION_LEVEL}" == "advanced" ]]; then
echo "Compilation level set to advanced"
COMPILATION_LECEL="ADVANCED_OPTIMIZATIONS"
elif [[ "${COMPILATION_LEVEL}" == "spaces" ]]; then
echo "Compilation level set to white spaces"
COMPILATION_LEVEL="WHITESPACE_ONLY"
else
echo "Compilation level unknown: '${COMPILATION_LEVEL}'. Change to SIMPLE_OPTIMIZATIONS"
COMPILATION_LEVEL="SIMPLE_OPTIMIZATIONS"
fi
else
echo "Compilation level defaults to simple optimizations."
COMPILATION_LEVEL="SIMPLE_OPTIMIZATIONS"
fi
#
# execute version procedure.
# version.nfo contains new version value.
#
./version.sh
VERSION=`cat version.nfo`
echo "New generated version: ${VERSION}"
echo "Generated at: ${DST_FILE_NAME}"
echo "From files at: ${SOURCE_DIR}"
#
# create stub files for all CAAT products.
#
echo "/*" >> "${FILE_CAAT}"
cat LICENSE >> "${FILE_CAAT}"
echo "\nVersion: ${VERSION}\n" >> "${FILE_CAAT}"
echo "Created on:" >> "${FILE_CAAT}"
date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" >> "${FILE_CAAT}"
echo "*/\n\n" >> "${FILE_CAAT}"
echo "/*" >> "${FILE_CAAT_CSS}"
cat LICENSE >> "${FILE_CAAT_CSS}"
echo "\nVersion: ${VERSION}\n" >> "${FILE_CAAT_CSS}"
echo "Created on:" >> "${FILE_CAAT_CSS}"
date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" >> "${FILE_CAAT_CSS}"
echo "*/\n\n" >> "${FILE_CAAT_CSS}"
echo "/*" >> "${FILE_CAAT_BOX2D}"
cat LICENSE >> "${FILE_CAAT_BOX2D}"
echo "\nVersion: ${VERSION}\n" >> "${FILE_CAAT_BOX2D}"
echo "Created on:" >> "${FILE_CAAT_BOX2D}"
date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" >> "${FILE_CAAT_BOX2D}"
echo "*/\n\n" >> "${FILE_CAAT_BOX2D}"
#
# Compile canvas/GL
#
echo "\nCreating CAAT canvas/webGL"
/usr/bin/java -jar ${CAAT_CLOSURE_PATH}/compiler.jar --compilation_level "${COMPILATION_LEVEL}" \
--js ${CAAT_BUILD_DIR}/caat.js \
>> "${FILE_CAAT}"
#
# Compile box2d
#
echo "Creating CAAT Box2d"
/usr/bin/java -jar ${CAAT_CLOSURE_PATH}/compiler.jar --compilation_level "${COMPILATION_LEVEL}" --js ${CAAT_BUILD_DIR}/caat-box2d.js >> "${FILE_CAAT_BOX2D}"
#
# Compile css
#
echo "Creating CAAT CSS"
echo "CAAT.__CSS__=1;" >> /tmp/__css.js
java -jar ${CAAT_CLOSURE_PATH}/compiler.jar --compilation_level "${COMPILATION_LEVEL}" \
--js ${CAAT_BUILD_DIR}/caat-css.js >> "${FILE_CAAT_CSS}"
#
# Distribute resulting compiled files
#
echo "\nCopying:"
echo "\tCopying results to ${CAAT_BUILD_DIR}"
cp ${FILE_CAAT} ${CAAT_BUILD_DIR}
cp ${FILE_CAAT_CSS} ${CAAT_BUILD_DIR}
cp ${FILE_CAAT_BOX2D} ${CAAT_BUILD_DIR}
#
# Generating JSDoc.
#
echo "\nGenerating JSDoc"
./version.compile.doc.sh