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