Skip to content
This repository
Browse code

Complete overhaul of Make process to be cleaner, clearer and server-f…

…riendly
  • Loading branch information...
commit a213cfa28161d67cbaadf1fe38629829ae1f26e5 1 parent 6cf19b1
Eddie Monge authored November 09, 2011
278  Makefile
... ...
@@ -1,44 +1,3 @@
1  
-# The system generated date in YYYYMMDD format
2  
-DATE = $(shell date "+%Y%m%d")
3  
-
4  
-# The version according to the source file. If this is the nightly build, use a different version
5  
-VER = $(shell cat version.txt)
6  
-
7  
-# The command to replace the @VERSION in the files with the actual version
8  
-SED_VER = sed "s/@VERSION/$(shell git log -1 --format=format:" Git > Date: %cd Info SHA1: %H")/"
9  
-deploy:  SED_VER = sed "s/@VERSION/${VER}/"
10  
-MIN_VER = "/*! jQuery Mobile v@VERSION jquerymobile.com | jquery.org/license */"
11  
-
12  
-# The version of jQuery core used
13  
-JQUERY = $(shell grep Library js/jquery.js | sed s'/ \* jQuery JavaScript Library v//')
14  
-
15  
-# The directory to create the zipped files in and also serves as the filenames
16  
-DIR = jquery.mobile-${VER}
17  
-STRUCTUREFILE = jquery.mobile.structure-${VER}
18  
-nightly: DIR = jquery.mobile
19  
-
20  
-# The output folder for the finished files
21  
-OUTPUT = compiled
22  
-
23  
-# Command to remove the latest directory from the CDN before uploading, only if using latest target
24  
-RMLATEST = echo ""
25  
-
26  
-# The output folder for the nightly files.
27  
-NIGHTLY_OUTPUT = nightlies/${DATE}
28  
-ifeq (${NIGHTLY_OUTPUT}, latest)
29  
-	RMLATEST = ssh jqadmin@code.origin.jquery.com 'rm -rf /var/www/html/code.jquery.com/mobile/latest'
30  
-endif
31  
-NIGHTLY_WEBPATH = http://code.jquery.com/mobile/${NIGHTLY_OUTPUT}
32  
-
33  
-# The filenames
34  
-JS = ${DIR}.js
35  
-MIN = ${DIR}.min.js
36  
-CSS = ${DIR}.css
37  
-CSSMIN = ${DIR}.min.css
38  
-CSSSTRUCTURE = ${STRUCTUREFILE}.css
39  
-CSSSTRUCTUREMIN = ${STRUCTUREFILE}.min.css
40  
-CSSTHEME = default
41  
-
42 1
 # The files to include when compiling the JS files
43 2
 JSFILES = 	  js/jquery.ui.widget.js \
44 3
 			  js/jquery.mobile.widget.js \
@@ -75,8 +34,8 @@ JSFILES = 	  js/jquery.ui.widget.js \
75 34
 			  js/jquery.mobile.fixHeaderFooter.native.js \
76 35
 			  js/jquery.mobile.init.js
77 36
 
78  
-CSSTHEMEFILES = css/themes/${CSSTHEME}/jquery.mobile.theme.css
79  
-CSSSTRUCTUREFILES = css/structure/jquery.mobile.core.css \
  37
+# The files to include when compiling the CSS files
  38
+CSSFILES = css/structure/jquery.mobile.core.css \
80 39
 			  css/structure/jquery.mobile.transitions.css \
81 40
 			  css/structure/jquery.mobile.grids.css \
82 41
 			  css/structure/jquery.mobile.headerfooter.css \
@@ -91,129 +50,158 @@ CSSSTRUCTUREFILES = css/structure/jquery.mobile.core.css \
91 50
 			  css/structure/jquery.mobile.forms.textinput.css \
92 51
 			  css/structure/jquery.mobile.listview.css \
93 52
 			  css/structure/jquery.mobile.forms.slider.css
  53
+CSSTHEMEFILES = css/themes/${THEME}/jquery.mobile.theme.css
94 54
 
95 55
 
96  
-# The files to include when compiling the CSS files
97  
-CSSFILES = ${CSSTHEMEFILES} ${CSSSTRUCTUREFILES}
98 56
 
99  
-# By default, this is what get runs when make is called without any arguments.
100  
-# Min and un-min CSS and JS files are the only things built
101  
-all: init js min css cssmin notify
102 57
 
103  
-# Build the normal CSS file.
104  
-css: init
105  
-	# Build the CSS file
106  
-	@@head -8 js/jquery.mobile.core.js | ${SED_VER} > ${OUTPUT}/${CSS}
107  
-	@@cat ${CSSFILES} >> ${OUTPUT}/${CSS}
108  
-	@@head -8 js/jquery.mobile.core.js | ${SED_VER} > ${OUTPUT}/${CSSSTRUCTURE}
109  
-	@@cat ${CSSSTRUCTUREFILES} >> ${OUTPUT}/${CSSSTRUCTURE}
110  
-
111  
-# Build the minified CSS file
112  
-cssmin: init css
113  
-	# Build the minified CSS file
114  
-	@@echo ${MIN_VER} | ${SED_VER} > ${OUTPUT}/${CSSMIN}
115  
-	@@echo ${MIN_VER} | ${SED_VER} > ${OUTPUT}/${CSSSTRUCTUREMIN}
116  
-	@@java -jar build/yuicompressor-2.4.6.jar --type css ${OUTPUT}/${CSS} >> ${OUTPUT}/${CSSMIN}
117  
-	@@java -jar build/yuicompressor-2.4.6.jar --type css ${OUTPUT}/${CSSSTRUCTURE} >> ${OUTPUT}/${CSSSTRUCTUREMIN}
118  
-
119  
-# Build the normal JS file
120  
-js: init
121  
-	# Build the JavaScript file
122  
-	@@head -8 js/jquery.mobile.core.js | ${SED_VER} > ${OUTPUT}/${JS}
123  
-	@@cat ${JSFILES} >> ${OUTPUT}/${JS}
124 58
 
125  
-# Create the output directory. This is in a separate step so its not dependant on other targets
126  
-init:
127  
-	# Building jQuery Mobile in the "${OUTPUT}" folder
128  
-	@@rm -rf ${OUTPUT}
129  
-	@@mkdir ${OUTPUT}
130  
-
131  
-# Build the minified JS file
132  
-min: init js
133  
-	# Build the minified JavaScript file
134  
-	@@echo ${MIN_VER} | ${SED_VER} > ${OUTPUT}/${MIN}
135  
-	@@java -jar build/google-compiler-20111003.jar --js ${OUTPUT}/${JS} --warning_level QUIET --js_output_file ${MIN}.tmp
136  
-	@@cat ${MIN}.tmp >> ${OUTPUT}/${MIN}
137  
-	@@rm -f ${MIN}.tmp
138  
-
139  
-# Let the user know the files were built and where they are
140  
-notify:
141  
-	@@echo "The files have been built and are in: " $$(pwd)/${OUTPUT}
  59
+# Helper Variables
  60
+# The command to replace the @VERSION in the files with the actual version
  61
+VER = sed "s/v@VERSION/$$(git log -1 --format=format:"Git Build: SHA1: %H <> Date: %cd")/"
  62
+VER_MIN = "/*! jQuery Mobile v${VER_OFFICIAL} jquerymobile.com | jquery.org/license */"
  63
+VER_OFFICIAL = $(shell cat version.txt)
  64
+
  65
+# The output folder for the finished files
  66
+OUTPUT = compiled
142 67
 
143  
-# Pull the latest commits. This is used for the nightly build but can be used to save some keystrokes
144  
-pull:
145  
-	@@git pull --quiet
  68
+# The name of the files
  69
+NAME = jquery.mobile
  70
+STRUCTURE = jquery.mobile.structure
  71
+deploy: NAME = jquery.mobile-${VER_OFFICIAL}
  72
+deploy: STRUCTURE = jquery.mobile.structure-${VER_OFFICIAL}
146 73
 
147  
-# Zip the 4 files and the theme images into one convenient package
148  
-zip: init js min css cssmin
149  
-	@@mkdir -p ${DIR}
150  
-	@@cp ${OUTPUT}/*.js ${DIR}/
151  
-	@@cp ${OUTPUT}/*.css ${DIR}/
152  
-	@@cp -R css/themes/${CSSTHEME}/images ${DIR}/
153  
-	@@zip -rq ${OUTPUT}/${DIR}.zip ${DIR}
154  
-	@@rm -fr ${DIR}
  74
+# The CSS theme being used
  75
+THEME = default
155 76
 
156 77
 
157  
-# Used by the jQuery team to make the nightly builds
158  
-nightly: pull zip
159  
-	# Create the folder to hold the files for the demos
160  
-	@@mkdir -p ${VER}
161 78
 
162  
-	# Copy in the base stuff for the demos
163  
-	@@cp -r index.html css experiments docs tools ${VER}/
164 79
 
165  
-	# First change all the paths from super deep to the same level for JS files
166  
-	@@find ${VER} -type f -name '*.html' -exec sed -i 's|src="../../../js|src="js|g' {} \;
167  
-	@@find ${VER} -type f -name '*.html' -exec sed -i 's|src="../../js|src="js|g' {} \;
168  
-	@@find ${VER} -type f -name '*.html' -exec sed -i 's|src="../js|src="js|g' {} \;
169 80
 
170  
-	# Then change all the paths from super deep to the same level for CSS files
171  
-	@@find ${VER} -type f -name '*.html' -exec sed -i 's|media="only all"||g' {} \;
172  
-	@@find ${VER} -type f -name '*.html' -exec sed -i 's|rel="stylesheet"  href="../../../|rel="stylesheet"  href="|g' {} \;
173  
-	@@find ${VER} -type f -name '*.html' -exec sed -i 's|rel="stylesheet"  href="../../|rel="stylesheet"  href="|g' {} \;
174  
-	@@find ${VER} -type f -name '*.html' -exec sed -i 's|rel="stylesheet"  href="../|rel="stylesheet"  href="|g' {} \;
  81
+# Build Targets
175 82
 
176  
-	# Change the empty paths to the location of this nightly file
177  
-	@@find ${VER} -type f -name '*.html' -exec sed -i 's|href="css/themes/${CSSTHEME}/"|href="${NIGHTLY_WEBPATH}/${DIR}.min.css"|g' {} \;
178  
-	@@find ${VER} -type f -name '*.html' -exec sed -i 's|src="js/jquery.js"|src="http://code.jquery.com/jquery-${JQUERY}.min.js"|' {} \;
179  
-	@@find ${VER} -type f -name '*.html' -exec sed -i 's|src="js/"|src="${NIGHTLY_WEBPATH}/${DIR}.min.js"|g' {} \;
  83
+# When no build target is specified, all gets ran
  84
+all: init css js zip notify
180 85
 
181  
-	# Move the demos into the output folder
182  
-	@@mv ${VER} ${OUTPUT}/demos
183 86
 
184  
-	# Copy the images as well
185  
-	@@cp -R css/themes/${CSSTHEME}/images ${OUTPUT}
  87
+# Build and minify the CSS files
  88
+css: init
  89
+	# Build the CSS file with the theme included
  90
+	@@cat js/jquery.mobile.intro.js | ${VER} > ${OUTPUT}/${NAME}.css
  91
+	@@cat ${CSSTHEMEFILES} ${CSSFILES} >> ${OUTPUT}/${NAME}.css
  92
+	# ..... and then minify it
  93
+	@@echo ${VER_MIN} > ${OUTPUT}/${NAME}.min.css
  94
+	@@java -jar build/yuicompressor-2.4.6.jar --type css ${OUTPUT}/${NAME}.css >> ${OUTPUT}/${NAME}.min.css
  95
+	# Build the CSS Structure-only file
  96
+	@@cat js/jquery.mobile.intro.js | ${VER} > ${OUTPUT}/${STRUCTURE}.css
  97
+	@@cat ${CSSFILES} >> ${OUTPUT}/${STRUCTURE}.css
  98
+	# ..... and then minify it
  99
+	@@echo ${VER_MIN} > ${OUTPUT}/${NAME}.structure.min.css
  100
+	@@java -jar build/yuicompressor-2.4.6.jar --type css ${OUTPUT}/${STRUCTURE}.css >> ${OUTPUT}/${STRUCTURE}.min.css
  101
+	# ..... and then copy in the images
  102
+	@@cp -R css/themes/${THEME}/images ${OUTPUT}/
  103
+	# Css portion is complete.
  104
+	# -------------------------------------------------
  105
+
  106
+
  107
+docs: init css js
  108
+	# Create the Demos/Docs/Tests/Tools
  109
+	@@mkdir -p tmp/${NAME}
  110
+	@@cp -r index.html docs experiments external js/jquery.js tests tmp/${NAME}/
  111
+	@@cp ${OUTPUT}/${NAME}.min.css ${OUTPUT}/${NAME}.min.js tmp/${NAME}/
  112
+	# ... Update the JavaScript and CSS paths
  113
+	@@find tmp/${NAME} -type f \
  114
+		\( -name '*.html' -o -name '*.php' \) \
  115
+		-exec sed -i '' 's|js/"|${NAME}.min.js"|g' {} \; \
  116
+		-exec sed -i '' 's|css/themes/default/|${NAME}.min.css|g' {} \; \
  117
+		-exec sed -i '' 's|js/jquery.js"|jquery.js"|g' {} \;	
  118
+	# ... And then move it the finished directory
  119
+	@@mv tmp/${NAME} ${OUTPUT}/demos
  120
+	# Last, zip up the the whole folder
  121
+	@@zip -rq tmp/${NAME}.zip ${OUTPUT}
  122
+	@@mv tmp/${NAME}.zip ${OUTPUT}/${NAME}.docs.zip
  123
+	# Remove the temporary files
  124
+	@@rm -rf tmp
  125
+	# -------------------------------------------------
  126
+
186 127
 
187  
-	@@${RMLATEST}
188  
-	@@scp -r ${OUTPUT} jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/mobile/${NIGHTLY_OUTPUT}
  128
+# Create the output directory. This is in a separate step so its not dependant on other targets
  129
+init:
  130
+	# -------------------------------------------------
  131
+	# Building jQuery Mobile in the "${OUTPUT}" folder
189 132
 	@@rm -rf ${OUTPUT}
  133
+	@@rm -rf tmp
  134
+	@@mkdir -p ${OUTPUT}
  135
+	# -------------------------------------------------
190 136
 
191  
-# Used by the jQuery team to deploy a build to the CDN
192  
-deploy: zip
193  
-	# Deploy to CDN
194  
-	@@mv ${OUTPUT} ${VER}
195  
-	@@scp -r ${VER} jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/mobile/
196  
-	@@mv ${VER} ${OUTPUT}
197 137
 
198  
-	# Deploy Demos to the jQueryMobile.com site
199  
-	@@mkdir -p ${VER}
200  
-	@@cp -r index.html css experiments docs tools ${VER}/
  138
+# Build and minify the JS files
  139
+js: init
  140
+	# Build the JavaScript file
  141
+	@@cat js/jquery.mobile.intro.js | ${VER} > ${OUTPUT}/${NAME}.js
  142
+	@@cat ${JSFILES} >> ${OUTPUT}/${NAME}.js
  143
+	# ..... and then minify it
  144
+	@@echo ${VER_MIN} > ${OUTPUT}/${NAME}.min.js
  145
+	@@java -jar build/google-compiler-20111003.jar --js ${OUTPUT}/${NAME}.js --warning_level QUIET >> ${OUTPUT}/${NAME}.min.js
  146
+	# -------------------------------------------------
  147
+
  148
+
  149
+# Output a message saying the process is complete
  150
+notify: init
  151
+	@@echo "The files have been built and are in: " $$(pwd)/${OUTPUT}
  152
+	# -------------------------------------------------
201 153
 
202  
-	@@find ${VER} -type f -name '*.html' -exec sed -i "" -e 's|src="../../../js|src="js|g' {} \;
203  
-	@@find ${VER} -type f -name '*.html' -exec sed -i "" -e 's|src="../../js|src="js|g' {} \;
204  
-	@@find ${VER} -type f -name '*.html' -exec sed -i "" -e 's|src="../js|src="js|g' {} \;
205 154
 
206  
-	@@find ${VER} -type f -name '*.html' -exec sed -i "" -e 's|media="only all"||g' {} \;
207  
-	@@find ${VER} -type f -name '*.html' -exec sed -i "" -e 's|rel="stylesheet"  href="../../../|rel="stylesheet"  href="|g' {} \;
208  
-	@@find ${VER} -type f -name '*.html' -exec sed -i "" -e 's|rel="stylesheet"  href="../../|rel="stylesheet"  href="|g' {} \;
209  
-	@@find ${VER} -type f -name '*.html' -exec sed -i "" -e 's|rel="stylesheet"  href="../|rel="stylesheet"  href="|g' {} \;
  155
+# Zip up the jQm files without docs
  156
+zip: init css js
  157
+	# Packaging up the files into a zip archive
  158
+	@@zip -rq ${NAME}.tmp.zip ${OUTPUT}
  159
+	@@mv ${NAME}.tmp.zip ${OUTPUT}/${NAME}.zip
  160
+	# -------------------------------------------------
  161
+	
210 162
 
211  
-	@@find ${VER} -type f -name '*.html' -exec sed -i "" -e 's|href="css/themes/${CSSTHEME}/"|href="http://code.jquery.com/mobile/${VER}/${DIR}.min.css"|g' {} \;
212  
-	@@find ${VER} -type f -name '*.html' -exec sed -i "" -e 's|src="js/jquery.js"|src="http://code.jquery.com/jquery-${JQUERY}.min.js"|' {} \;
213  
-	@@find ${VER} -type f -name '*.html' -exec sed -i "" -e 's|src="js/"|src="http://code.jquery.com/mobile/${VER}/${DIR}.min.js"|g' {} \;
214 163
 
215  
-	@@scp -r ${VER} jqadmin@jquerymobile.com:/srv/jquerymobile.com/htdocs/demos/
216 164
 
217  
-	# Clean up the local files
218  
-	@@rm -rf ${VER}
219  
-	@@echo "All Done"
  165
+# -------------------------------------------------
  166
+# -------------------------------------------------
  167
+# -------------------------------------------------
  168
+#
  169
+# For jQuery Team Use Only
  170
+#
  171
+# -------------------------------------------------
  172
+
  173
+# Push the latest git version to the CDN. This is done on a post commit hook
  174
+latest: init js css zip
  175
+	# Time to put these on the CDN
  176
+	@@scp -r ${OUTPUT}/* jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/mobile/latest/
  177
+	# Do some cleanup to wrap it up
  178
+	@@rm -rf ${OUTPUT}
  179
+	# -------------------------------------------------
  180
+
  181
+# Build the nightly backups. This is done on a server cronjob
  182
+nightlies: init js css zip docs 
  183
+	# Time to put these on the CDN
  184
+	@@mkdir -p tmp/nightlies
  185
+	@@mv ${OUTPUT} tmp/nightlies/$$(date "+%Y%m%d")
  186
+	@@scp -r nightlies/* jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/mobile/nightlies/
  187
+	# Do some cleanup to wrap it up
  188
+	@@rm -rf tmp
  189
+	# -------------------------------------------------
  190
+
  191
+
  192
+# Deploy a finished release. This is manually done.
  193
+deploy: init js css docs zip
  194
+	# Deploying all the files to the CDN
  195
+	@@mkdir tmp
  196
+	@@cp -r ${OUTPUT} tmp/${VER_OFFICIAL}
  197
+	@@scp -r tmp/* jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/mobile/
  198
+	@@rm -rf tmp/${VER_OFFICIAL}
  199
+	# Create the Demos/Docs/Tests/Tools for jQueryMobile.com
  200
+	@@mv ${OUTPUT}/demos tmp/${VER_OFFICIAL}
  201
+	# ... And copied to the CDN and the jquerymobile.com server
  202
+	@@scp -r tmp/* jqadmin@jquerymobile.com:/srv/jquerymobile.com/htdocs/demos/	
  203
+	# Do some cleanup to wrap it up
  204
+	@@rm -rf tmp
  205
+	@@rm -rf ${OUTPUT}
  206
+	# -------------------------------------------------
  207
+
9  js/jquery.mobile.intro.js
... ...
@@ -0,0 +1,9 @@
  1
+/*
  2
+* jQuery Mobile Framework v@VERSION
  3
+* http://jquerymobile.com
  4
+*
  5
+* Copyright 2011 (c) jQuery Project
  6
+* Dual licensed under the MIT or GPL Version 2 licenses.
  7
+* http://jquery.org/license
  8
+*
  9
+*/

0 notes on commit a213cfa

Please sign in to comment.
Something went wrong with that request. Please try again.