Revert "Export"
[framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.1.0 / Makefile
1 # Helper Variables
2 # The command to replace the @VERSION in the files with the actual version
3 HEAD_SHA = $(shell git log -1 --format=format:"%H")
4 VER = sed "s/v@VERSION/$$(git log -1 --format=format:"Git Build: SHA1: %H <> Date: %cd")/"
5 VER_MIN = "/*! jQuery Mobile v$$(git log -1 --format=format:"Git Build: SHA1: %H <> Date: %cd") jquerymobile.com | jquery.org/license */"
6 VER_OFFICIAL = $(shell cat version.txt)
7 SED_VER_REPLACE = 's/__version__/"${VER_OFFICIAL}"/g'
8 SED_VER_API = sed ${SED_VER_REPLACE}
9 SED_INPLACE_EXT = "whyunowork"
10 deploy: VER = sed "s/v@VERSION/${VER_OFFICIAL} ${HEAD_SHA}/"
11 deploy: VER_MIN = "/*! jQuery Mobile v${VER_OFFICIAL} ${HEAD_SHA} jquerymobile.com | jquery.org/license */"
12
13 # The output folder for the finished files
14 OUTPUT = compiled
15
16 # The name of the files
17 NAME = jquery.mobile
18 BASE_NAME = jquery.mobile
19 THEME_FILENAME = jquery.mobile.theme
20 STRUCTURE = jquery.mobile.structure
21 deploy: NAME = jquery.mobile-${VER_OFFICIAL}
22 deploy: THEME_FILENAME = jquery.mobile.theme-${VER_OFFICIAL}
23 deploy: STRUCTURE = jquery.mobile.structure-${VER_OFFICIAL}
24
25 # The CSS theme being used
26 THEME = default
27
28 # If node is available then use node to run r.js
29 # otherwise use good old rhino/java
30 NODE ?= /usr/local/bin/node
31 HAS_NODE = $(shell if test -x ${NODE} ;then echo true; fi)
32
33 ifeq ($(HAS_NODE), true)
34         RUN_JS = @@${NODE}
35 else
36         RUN_JS = @@java -XX:ReservedCodeCacheSize=64m -classpath build/js.jar:build/google-compiler-20111003.jar org.mozilla.javascript.tools.shell.Main
37 endif
38
39 # Build Targets
40
41 # When no build target is specified, all gets ran
42 all: css js zip notify
43
44 clean:
45         # -------------------------------------------------
46         # Cleaning build output
47         @@rm -rf ${OUTPUT}
48         @@rm -rf tmp
49
50 # Create the output directory.
51 init:
52         @@mkdir -p ${OUTPUT}
53
54 # Build and minify the CSS files
55 css: init
56         # Build the CSS file with the theme included
57         ${RUN_JS} \
58                 external/r.js/dist/r.js \
59                 -o cssIn=css/themes/default/jquery.mobile.css \
60                 optimizeCss=standard.keepComments.keepLines \
61                 out=${OUTPUT}/${NAME}.compiled.css
62         @@cat LICENSE-INFO.txt | ${VER} > ${OUTPUT}/${NAME}.css
63         @@cat ${OUTPUT}/${NAME}.compiled.css >> ${OUTPUT}/${NAME}.css
64         @@echo ${VER_MIN} > ${OUTPUT}/${NAME}.min.css
65         @@java -XX:ReservedCodeCacheSize=64m \
66                 -jar build/yuicompressor-2.4.6.jar \
67                 --type css ${OUTPUT}/${NAME}.compiled.css >> ${OUTPUT}/${NAME}.min.css
68         @@rm ${OUTPUT}/${NAME}.compiled.css
69         # Build the CSS Structure-only file
70         ${RUN_JS} \
71                 external/r.js/dist/r.js \
72                 -o cssIn=css/structure/jquery.mobile.structure.css \
73                 out=${OUTPUT}/${STRUCTURE}.compiled.css
74         @@cat LICENSE-INFO.txt | ${VER} > ${OUTPUT}/${STRUCTURE}.css
75         @@cat ${OUTPUT}/${STRUCTURE}.compiled.css >> ${OUTPUT}/${STRUCTURE}.css
76         # ..... and then minify it
77         @@echo ${VER_MIN} > ${OUTPUT}/${STRUCTURE}.min.css
78         @@java -XX:ReservedCodeCacheSize=64m \
79                 -jar build/yuicompressor-2.4.6.jar \
80                 --type css ${OUTPUT}/${STRUCTURE}.compiled.css >> ${OUTPUT}/${STRUCTURE}.min.css
81         @@rm ${OUTPUT}/${STRUCTURE}.compiled.css
82         # Build the theme only file
83         @@cat LICENSE-INFO.txt | ${VER} > ${OUTPUT}/${THEME_FILENAME}.css
84         @@cat css/themes/default/jquery.mobile.theme.css >> ${OUTPUT}/${THEME_FILENAME}.css
85         # ..... and then minify it
86         @@echo ${VER_MIN} > ${OUTPUT}/${THEME_FILENAME}.min.css
87         @@java -XX:ReservedCodeCacheSize=64m \
88                 -jar build/yuicompressor-2.4.6.jar \
89                 --type css ${OUTPUT}/${THEME_FILENAME}.css >> ${OUTPUT}/${THEME_FILENAME}.min.css
90         # Copy in the images
91         @@cp -R css/themes/${THEME}/images ${OUTPUT}/
92         # Css portion is complete.
93         # -------------------------------------------------
94
95
96 docs: init js css
97         # Create the Demos/Docs/Tests/Tools
98         # ... Create staging directories
99         @@mkdir -p tmp/demos/js
100         @@mkdir -p tmp/demos/css/themes/${THEME}
101         # ... Copy script files
102         @@cp compiled/*.js tmp/demos/js
103         @@cp js/jquery.js tmp/demos/js
104         # ... Copy html files
105         @@cp index.html tmp/demos
106         @@cp -r docs tmp/demos
107         # ... Copy css and images
108         @@cp compiled/*.css tmp/demos/css/themes/${THEME}
109         @@cp -r compiled/images tmp/demos/css/themes/${THEME}
110         # ... replace "js/" with "js/jquery.mobile.js"
111         @@ # NOTE the deletion here is required by gnu/bsd sed differences
112         @@find tmp/demos -name "*.html" -exec sed -i${SED_INPLACE_EXT} -e 's@js/"@js/jquery.mobile.js"@' {} \;
113         @@find tmp/demos -name "*${SED_INPLACE_EXT}" -exec rm {} \;
114         # ... Move and zip up the the whole folder
115         @@rm -f ${OUTPUT}/${BASE_NAME}.docs.zip
116         @@cd tmp/demos && zip -rq ../../${OUTPUT}/${NAME}.docs.zip *
117         @@rm -rf ${OUTPUT}/demos && mv -f tmp/demos ${OUTPUT}
118         # Finish by removing the temporary files
119         @@rm -rf tmp
120         # -------------------------------------------------
121
122 # Build and minify the JS files
123 js: init
124         # Build the JavaScript file
125         ${RUN_JS} \
126                 external/r.js/dist/r.js \
127                 -o baseUrl="js" \
128                 name=jquery.mobile \
129                 exclude=jquery,../external/requirejs/order,../external/requirejs/depend,../external/requirejs/text,../external/requirejs/text!../version.txt \
130                 out=${OUTPUT}/${NAME}.compiled.js \
131                 pragmasOnSave.jqmBuildExclude=true \
132                 wrap.startFile=build/wrap.start \
133                 wrap.endFile=build/wrap.end \
134                 findNestedDependencies=true \
135                 skipModuleInsertion=true \
136                 optimize=none
137         @@cat LICENSE-INFO.txt | ${VER} > ${OUTPUT}/${NAME}.js
138         @@cat ${OUTPUT}/${NAME}.compiled.js | ${SED_VER_API} >> ${OUTPUT}/${NAME}.js
139         @@rm ${OUTPUT}/${NAME}.compiled.js
140         ## ..... and then minify it
141         ##@@echo ${VER_MIN} > ${OUTPUT}/${NAME}.min.js
142         ##@@java -XX:ReservedCodeCacheSize=64m \
143         ##      -jar build/google-compiler-20111003.jar \
144         ##      --js ${OUTPUT}/${NAME}.js \
145         ##      --js_output_file ${OUTPUT}/${NAME}.compiled.js
146         ##@@cat ${OUTPUT}/${NAME}.compiled.js >> ${OUTPUT}/${NAME}.min.js
147         ##@@rm ${OUTPUT}/${NAME}.compiled.js
148         # -------------------------------------------------
149
150
151 # Output a message saying the process is complete
152 notify: init
153         @@echo "The files have been built and are in: " $$(pwd)/${OUTPUT}
154         # -------------------------------------------------
155
156
157 # Zip up the jQm files without docs
158 zip: init css js
159         # Packaging up the files into a zip archive
160         @@mkdir tmp
161         @@cp -R ${OUTPUT} tmp/${NAME}
162         # ... And remove the Zipped docs so they aren't included twice (for deploy scripts)
163         @@rm -rf tmp/${NAME}/*.zip
164         @@cd tmp; zip -rq ../${OUTPUT}/${NAME}.zip ${NAME}
165         @@rm -rf tmp
166         # -------------------------------------------------
167
168 # -------------------------------------------------
169 # -------------------------------------------------
170 # -------------------------------------------------
171 #
172 # For jQuery Team Use Only
173 #
174 # -------------------------------------------------
175 # NOTE the clean (which removes previous build output) has been removed to prevent a gap in service
176 build_latest: css docs js zip
177         # ... Copy over the lib js, avoid the compiled stuff, to get the defines for tests/unit/*
178         @@ # TODO centralize list of built files
179         @@find js -name "*.js" -not -name "*.docs.js" -not -name "*.mobile.js"  | xargs -L1 -I FILENAME cp FILENAME ${OUTPUT}/demos/js/
180
181 # Push the latest git version to the CDN. This is done on a post commit hook
182 deploy_latest:
183         # Time to put these on the CDN
184         @@scp -qr ${OUTPUT}/* jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/mobile/latest/
185         # -------------------------------------------------
186
187 # TODO target name preserved to avoid issues during refactor, latest -> deploy_latest
188 latest: build_latest deploy_latest
189
190 # Push the nightly backups. This is done on a server cronjob
191 deploy_nightlies:
192         # Time to put these on the CDN
193         @@scp -qr ${OUTPUT} jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/mobile/nightlies/$$(date "+%Y%m%d")
194         # -------------------------------------------------
195
196 # Deploy a finished release. This is manually done.
197 deploy: init css js docs zip
198         # Deploying all the files to the CDN
199         @@mkdir tmp
200         @@cp -R ${OUTPUT} tmp/${VER_OFFICIAL}
201         @@scp -qr tmp/* jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/mobile/
202         @@rm -rf tmp/${VER_OFFICIAL}
203         @@mv ${OUTPUT}/demos tmp/${VER_OFFICIAL}
204         # Create the Demos/Docs/Tests/Tools for jQueryMobile.com
205         # ... By first replacing the paths
206         @@ # TODO update jQuery Version replacement on deploy
207         @@find tmp/${VER_OFFICIAL} -type f \
208                 \( -name '*.html' -o -name '*.php' \) \
209                 -exec perl -pi -e \
210                 's|src="(.*)${BASE_NAME}.js"|src="//code.jquery.com/mobile/${VER_OFFICIAL}/${NAME}.min.js"|g;s|href="(.*)${BASE_NAME}.css"|href="//code.jquery.com/mobile/${VER_OFFICIAL}/${NAME}.min.css"|g;s|src="(.*)jquery.js"|src="//code.jquery.com/jquery-1.7.1.min.js"|g' {} \;
211         # ... So they can be copied to jquerymobile.com
212         @@scp -qr tmp/* jqadmin@jquerymobile.com:/srv/jquerymobile.com/htdocs/demos/
213         # Do some cleanup to wrap it up
214         @@rm -rf tmp
215         @@rm -rf ${OUTPUT}
216         # -------------------------------------------------
217
218