diff options
Diffstat (limited to 'build_system/make.gzip')
-rwxr-xr-x | build_system/make.gzip | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/build_system/make.gzip b/build_system/make.gzip new file mode 100755 index 0000000..a95ed04 --- /dev/null +++ b/build_system/make.gzip | |||
@@ -0,0 +1,130 @@ | |||
1 | #!/bin/bash | ||
2 | # | ||
3 | # ExxonMobil Designer Site Build Script | ||
4 | # by Mike Crute, EYEMG (mcrute@eyemg.com) | ||
5 | # | ||
6 | # This is a pretty simple build script just export a | ||
7 | # tag or the trunk from SVN and run ./make, running | ||
8 | # make (w/out the ./) will not work. You can then | ||
9 | # take the generated tarball and explode it on the | ||
10 | # production server w/out any further configuration. | ||
11 | # | ||
12 | |||
13 | cd docroot | ||
14 | |||
15 | # Create the build directory and copy over the cgi-bin | ||
16 | mkdir -p build/{docroot,cgi-bin} | ||
17 | cp -R ../cgi-bin/* build/cgi-bin/ | ||
18 | |||
19 | # Create a build date file | ||
20 | echo "Designer Site Built `date +'%Y-%m-%d %H:%M:%S'` EST" > build/docroot/build.date | ||
21 | echo "Code Version: `grep 'releaseVersion' classes/sme.namespace.js | cut -d"'" -f 2 `" >> build/docroot/build.date | ||
22 | echo "Subversion Revision: `svn info | grep 'Revision' | awk '{ print $2 }'`" >> build/docroot/build.date | ||
23 | |||
24 | # Remove stuff from the cgi-bin that does not belong in | ||
25 | # production. | ||
26 | rm build/cgi-bin/*.sql | ||
27 | |||
28 | # Also copy over any files that don't need special processing | ||
29 | cp -R images \ | ||
30 | blank.gif \ | ||
31 | favicon.ico \ | ||
32 | custom_content \ | ||
33 | build/docroot/ | ||
34 | |||
35 | # Prepare the .htaccess file for production | ||
36 | # | ||
37 | # We use a sparse layout in development where each class is | ||
38 | # in its own separate file but in production we use a solid | ||
39 | # layout that is also gzipped so we have to un-comment the | ||
40 | # gzip headers in our htaccess file. | ||
41 | |||
42 | sed ' | ||
43 | /### PRODUCTION ###/,/### END PRODUCTION ###/ { | ||
44 | /^###.*/d | ||
45 | s/#//g | ||
46 | } | ||
47 | ' .htaccess > build/docroot/.htaccess | ||
48 | |||
49 | # Minify the PNG Behavior | ||
50 | sed ' | ||
51 | /\/\*/,/\*\// { | ||
52 | /.*/d; | ||
53 | } | ||
54 | ' pngbehavior.htc > build/docroot/pngbehavior.htc | ||
55 | |||
56 | # Concatenate the Javascript files into a single library file | ||
57 | # | ||
58 | # application.js loads all the javascript files in the development | ||
59 | # environment. When we go to production we need to parse out the | ||
60 | # actual script names being loaded and cat them, in order, into | ||
61 | # the final output application.js file. | ||
62 | |||
63 | # GNU sed uses the -r flag for extended regular expressions, | ||
64 | # Darwin uses the -E flag for regular expressions. If neither | ||
65 | # of these hold true we might as well fail. | ||
66 | if [[ `uname` == 'Linux' ]]; then | ||
67 | MYFILES=`sed -r -f ../build_system/get_jsfiles.sed application.js` | ||
68 | elif [[ `uname` == 'Darwin' ]]; then | ||
69 | MYFILES=`sed -E -f ../build_system/get_jsfiles.sed application.js` | ||
70 | else | ||
71 | print 'No valid sed command could be determined.' | ||
72 | exit 1 | ||
73 | fi | ||
74 | |||
75 | for item in $MYFILES; do | ||
76 | cat $item >> build/docroot/application.js.in | ||
77 | done | ||
78 | |||
79 | # Remove development code from the application code | ||
80 | # and append it to the libraries files | ||
81 | sed '/^;;;.*/d' build/docroot/application.js.in >> build/docroot/application.js.out | ||
82 | sed '/^\/\*;;;.*/d' build/docroot/application.js.out >> build/docroot/application.js | ||
83 | rm build/docroot/application.js.in build/docroot/application.js.out | ||
84 | |||
85 | # Minify index.html by removing leading spaces on each line | ||
86 | # as well as the ID comment, blank lines, and any script tags | ||
87 | # that appear in the <head> of the document. | ||
88 | sed 's/^[[:space:]]*//; /^$/d; s/\n$//; /<!--/,/-->/ { /.*/d; }' index.html > build/docroot/index.html | ||
89 | sed 's/^[[:space:]]*//; /^$/d; s/\n$//; /<!--/,/-->/ { /.*/d; }' logged_out.html > build/docroot/logged_out.html | ||
90 | |||
91 | # Minify the application Javascript using the YUI Compressor | ||
92 | java -jar ../build_system/yui_compressor.jar -o application.o build/docroot/application.js > /dev/null 2>&1 | ||
93 | mv application.o build/docroot/application.js | ||
94 | |||
95 | # Minify the JSON data files | ||
96 | mkdir -p build/docroot/data | ||
97 | for item in `ls data/`; do | ||
98 | java -jar ../build_system/yui_compressor.jar -o build/docroot/data/$item data/$item > /dev/null 2>&1 | ||
99 | done | ||
100 | |||
101 | # Can't minimize JSON, the semicolon at the end breaks everything | ||
102 | cat data/card_tables.js > build/docroot/data/card_tables.js | ||
103 | |||
104 | # Minify the application CSS using our custom compressor | ||
105 | ../build_system/cmpcss application.css > build/docroot/application.css | ||
106 | ../build_system/cmpcss specialcases.css > build/docroot/specialcases.css | ||
107 | |||
108 | # Gzip all that should be gzipped. This really should be done server-side | ||
109 | # but for now we work around it by statically compressing them at build time | ||
110 | # and serving it with the correct headers in the .htaccess file | ||
111 | gzip build/docroot/application.js | ||
112 | gzip build/docroot/application.css | ||
113 | gzip build/docroot/index.html | ||
114 | |||
115 | mv build/docroot/application.js.gz build/docroot/application.js | ||
116 | mv build/docroot/application.css.gz build/docroot/application.css | ||
117 | mv build/docroot/index.html.gz build/docroot/index.html | ||
118 | |||
119 | # Tar it all up in a development dump | ||
120 | mv build aes_designer | ||
121 | cd aes_designer | ||
122 | |||
123 | # Removing the date since its really not needed | ||
124 | tar -cjvf ../../aes_designer.tbz2 * > /dev/null 2>&1 | ||
125 | #tar -cjvf ../../aes_designer-`date +%Y%m%d_%H%M%S`.tbz2 * > /dev/null 2>&1 | ||
126 | |||
127 | |||
128 | cd .. | ||
129 | |||
130 | rm -rf aes_designer/ | ||